     1                                  ; ****************************************************************************
     2                                  ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.0
     3                                  ; ----------------------------------------------------------------------------
     4                                  ; Last Update: 30/07/2016
     5                                  ; ----------------------------------------------------------------------------
     6                                  ; Beginning: 04/01/2016
     7                                  ; ----------------------------------------------------------------------------
     8                                  ; Assembler: NASM version 2.11 (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                                  
    22                                  KLOAD	equ 10000h ; Kernel loading address
    23                                  	; NOTE: Retro UNIX 8086 v1 /boot code loads kernel at 1000h:0000h 
    24                                  KCODE	equ 08h	; Code segment descriptor (ring 0)
    25                                  KDATA	equ 10h	; Data segment descriptor (ring 0)
    26                                  ; 19/03/2015
    27                                  UCODE	equ 1Bh ; 18h + 3h  (ring 3)
    28                                  UDATA	equ 23h ; 20h + 3h  (ring 3)
    29                                  ; 24/03/2015
    30                                  TSS	equ 28h	; Task state segment descriptor (ring 0)
    31                                  ; 19/03/2015
    32                                  CORE	equ 400000h  ; Start of USER's virtual/linear address space 
    33                                  		     ; (at the end of the 1st 4MB)
    34                                  ECORE	equ 0FFC00000h ; End of USER's virtual address space (4GB - 4MB)
    35                                  		     ; ULIMIT = (ECORE/4096) - 1 = 0FFBFFh (in GDT)
    36                                  
    37                                  ;; 27/12/2013
    38                                  ;KEND    equ KLOAD + 65536 ; (28/12/2013) (end of kernel space)
    39                                  ; 04/07/2016
    40                                  KEND    equ KERNELFSIZE + KLOAD
    41                                  
    42                                  
    43                                  
    44                                  ; IBM PC/AT BIOS ----- 10/06/85 (postequ.inc)
    45                                  ;--------- CMOS TABLE LOCATION ADDRESS'S -------------------------------------
    46                                  CMOS_SECONDS	EQU	00H		; SECONDS (BCD)
    47                                  CMOS_SEC_ALARM	EQU	01H		; SECONDS ALARM (BCD)
    48                                  CMOS_MINUTES	EQU	02H		; MINUTES (BCD)
    49                                  CMOS_MIN_ALARM	EQU	03H		; MINUTES ALARM (BCD) 	
    50                                  CMOS_HOURS	EQU	04H		; HOURS (BCD
    51                                  CMOS_HR_ALARM	EQU	005H		; HOURS ALARM   (BCD)
    52                                  CMOS_DAY_WEEK	EQU	06H		; DAY OF THE WEEK  (BCD)
    53                                  CMOS_DAY_MONTH	EQU	07H		; DAY OF THE MONTH (BCD) 
    54                                  CMOS_MONTH	EQU	08H		; MONTH (BCD)
    55                                  CMOS_YEAR	EQU	09H		; YEAR (TWO DIGITS) (BCD)
    56                                  CMOS_CENTURY	EQU	32H		; DATE CENTURY BYTE (BCD)
    57                                  CMOS_REG_A	EQU	0AH		; STATUS REGISTER A
    58                                  CMOS_REG_B	EQU	00BH		; STATUS REGISTER B  ALARM
    59                                  CMOS_REG_C	EQU	00CH		; STATUS REGISTER C  FLAGS
    60                                  CMOS_REG_D	EQU	0DH		; STATUS REGISTER D  BATTERY
    61                                  CMOS_SHUT_DOWN	EQU	0FH		; SHUTDOWN STATUS COMMAND BYTE
    62                                  ;----------------------------------------
    63                                  ;	CMOS EQUATES FOR THIS SYSTEM	;
    64                                  ;-----------------------------------------------------------------------------
    65                                  CMOS_PORT	EQU	070H		; I/O ADDRESS OF CMOS ADDRESS PORT
    66                                  CMOS_DATA	EQU	071H		; I/O ADDRESS OF CMOS DATA PORT
    67                                  NMI		EQU	10000000B	; DISABLE NMI INTERRUPTS MASK -
    68                                  					; HIGH BIT OF CMOS LOCATION ADDRESS
    69                                  
    70                                  ; Memory Allocation Table Address
    71                                  ; 05/11/2014
    72                                  ; 31/10/2014
    73                                  MEM_ALLOC_TBL	equ	100000h		; Memory Allocation Table at the end of
    74                                  					; the 1st 1 MB memory space.
    75                                  					; (This address must be aligned
    76                                  					;  on 128 KB boundary, if it will be
    77                                  					;  changed later.)
    78                                  					; ((lower 17 bits of 32 bit M.A.T.
    79                                  					;   address must be ZERO)).
    80                                  					; ((((Reason: 32 bit allocation 
    81                                  					;     instructions, dword steps)))
    82                                  					; (((byte >> 12 --> page >> 5)))  
    83                                  ;04/11/2014	
    84                                  PDE_A_PRESENT	equ	1		; Present flag for PDE
    85                                  PDE_A_WRITE	equ 	2		; Writable (write permission) flag
    86                                  PDE_A_USER	equ	4		; User (non-system/kernel) page flag
    87                                  ;
    88                                  PTE_A_PRESENT	equ	1		; Present flag for PTE (bit 0)
    89                                  PTE_A_WRITE	equ 	2		; Writable (write permission) flag (bit 1)
    90                                  PTE_A_USER	equ	4		; User (non-system/kernel) page flag (bit 2)
    91                                  PTE_A_ACCESS    equ	32		; Accessed flag (bit 5) ; 09/03/2015
    92                                  
    93                                  ; 17/02/2015 (unix386.s)
    94                                  ; 10/12/2014 - 30/12/2014 (0B000h -> 9000h) (dsectrm2.s)
    95                                  DPT_SEGM equ 09000h  ; FDPT segment (EDD v1.1, EDD v3)
    96                                  ;
    97                                  HD0_DPT	 equ 0	    ; Disk parameter table address for hd0
    98                                  HD1_DPT	 equ 32	    ; Disk parameter table address for hd1
    99                                  HD2_DPT	 equ 64	    ; Disk parameter table address for hd2
   100                                  HD3_DPT	 equ 96	    ; Disk parameter table address for hd3
   101                                  
   102                                  
   103                                  ; FDPT (Phoenix, Enhanced Disk Drive Specification v1.1, v3.0)
   104                                  ;      (HDPT: Programmer's Guide to the AMIBIOS, 1993)
   105                                  ;
   106                                  FDPT_CYLS	equ 0 ; 1 word, number of cylinders
   107                                  FDPT_HDS	equ 2 ; 1 byte, number of heads
   108                                  FDPT_TT		equ 3 ; 1 byte, A0h = translated FDPT with logical values
   109                                  		      ; otherwise it is standard FDPT with physical values 	
   110                                  FDPT_PCMP	equ 5 ; 1 word, starting write precompensation cylinder
   111                                  		      ; (obsolete for IDE/ATA drives)
   112                                  FDPT_CB		equ 8 ; 1 byte, drive control byte
   113                                  			; Bits 7-6 : Enable or disable retries (00h = enable)
   114                                  			; Bit 5	: 1 = Defect map is located at last cyl. + 1
   115                                  			; Bit 4 : Reserved. Always 0
   116                                  			; Bit 3 : Set to 1 if more than 8 heads
   117                                  			; Bit 2-0 : Reserved. Alsways 0
   118                                  FDPT_LZ		equ 12 ; 1 word, landing zone (obsolete for IDE/ATA drives)
   119                                  FDPT_SPT	equ 14 ; 1 byte, sectors per track
   120                                  
   121                                  ; Floppy Drive Parameters Table (Programmer's Guide to the AMIBIOS, 1993)
   122                                  ; (11 bytes long) will be used by diskette handler/bios
   123                                  ; which is derived from IBM PC-AT BIOS (DISKETTE.ASM, 21/04/1986).
   124                                  
   125                                  ; 01/02/2016
   126                                  Logical_DOSDisks equ 90000h + 100h ; 26*256 = 6656 bytes
   127                                  Directory_Buffer equ 80000h ; max = 64K Bytes
   128                                  FAT_Buffer	 equ 91C00h ; 1536 bytes (3 sectors)
   129                                  ; 15/02/2016
   130                                  Cluster_Buffer	 equ 70000h ; max = 64K Bytes ; buffer for file read & write
   131                                  ; 11/04/2016
   132                                  Env_Page:	 equ 93000h ; 512 bytes (4096 bytes)
   133                                  Env_Page_Size	 equ 512    ; (4096 bytes)
   134                                  ; 30/07/2016
   135                                  Video_Pg_Backup	 equ 98000h ; Mode 3h, video page backup (32K, 8 pages)				 	  		 	  
   136                                  
   137                                  [BITS 16]       ; We need 16-bit intructions for Real mode
   138                                  
   139                                  [ORG 0] 
   140                                  	; 12/11/2014
   141                                  	; Save boot drive number (that is default root drive)
   142 00000000 8816[F4EC]              	mov	[boot_drv], dl ; physical drv number
   143                                  
   144                                  	; Determine installed memory
   145                                  	; 31/10/2014
   146                                  	;
   147 00000004 B801E8                  	mov	ax, 0E801h ; Get memory size 
   148 00000007 CD15                    	int	15h	   ; for large configurations
   149 00000009 7308                    	jnc	short chk_ms
   150 0000000B B488                    	mov	ah, 88h    ; Get extended memory size 
   151 0000000D CD15                    	int	15h
   152                                  	;	   
   153                                  	;mov	al, 17h	; Extended memory (1K blocks) low byte
   154                                  	;out	70h, al ; select CMOS register
   155                                  	;in	al, 71h ; read data (1 byte)
   156                                  	;mov	cl, al
   157                                  	;mov	al, 18h ; Extended memory (1K blocks) high byte
   158                                  	;out	70h, al ; select CMOS register
   159                                  	;in	al, 71h ; read data (1 byte)
   160                                  	;mov	ch, al
   161                                   	;      
   162 0000000F 89C1                    	mov	cx, ax
   163 00000011 31D2                    	xor	dx, dx
   164                                  chk_ms:
   165 00000013 890E[CEEE]              	mov	[mem_1m_1k], cx
   166 00000017 8916[D0EE]              	mov	[mem_16m_64k], dx
   167                                  	; 05/11/2014
   168                                  	;and	dx, dx
   169                                  	;jz	short L2
   170 0000001B 81F90004                        cmp     cx, 1024
   171 0000001F 7315                    	jnb	short L0
   172                                  		 ; insufficient memory_error	
   173                                  		 ; Minimum 2 MB memory is needed... 
   174                                  	; 05/11/2014
   175                                  	; (real mode error printing)
   176 00000021 FB                      	sti
   177 00000022 BE[97ED]                	mov	si, msg_out_of_memory
   178 00000025 BB0700                  	mov	bx, 7
   179 00000028 B40E                    	mov	ah, 0Eh	; write tty
   180                                  oom_1:
   181 0000002A AC                      	lodsb
   182 0000002B 08C0                    	or	al, al
   183 0000002D 7404                    	jz	short oom_2
   184 0000002F CD10                    	int	10h
   185 00000031 EBF7                    	jmp	short oom_1
   186                                  oom_2:
   187 00000033 F4                              hlt
   188 00000034 EBFD                    	jmp	short oom_2
   189                                  
   190                                  L0:
   191                                  %include 'diskinit.s' ; 07/03/2015
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.0 - diskinit.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 09/07/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> ; 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> 	; 10/12/2014 - 02/02/2015 - dsectrm2.s
    27                              <1> ;L0:
    28                              <1> 	; 12/11/2014 (Retro UNIX 386 v1 - beginning)
    29                              <1> 	; Detecting disk drives... (by help of ROM-BIOS)
    30 00000036 BA7F00              <1> 	mov	dx, 7Fh
    31                              <1> L1:	
    32 00000039 FEC2                <1> 	inc	dl
    33 0000003B B441                <1> 	mov	ah, 41h ; Check extensions present
    34                              <1> 			; Phoenix EDD v1.1 - EDD v3
    35 0000003D BBAA55              <1> 	mov	bx, 55AAh
    36 00000040 CD13                <1> 	int 	13h
    37 00000042 721A                <1> 	jc	short L2
    38                              <1> 
    39 00000044 81FB55AA            <1> 	cmp	bx, 0AA55h
    40 00000048 7514                <1> 	jne	short L2
    41 0000004A FE06[F7EC]          <1> 	inc	byte [hdc]	; count of hard disks (EDD present)
    42 0000004E 8816[F6EC]          <1>         mov     [last_drv], dl  ; last hard disk number
    43 00000052 BB[7AEC]            <1> 	mov	bx, hd0_type - 80h
    44 00000055 01D3                <1> 	add	bx, dx	 
    45 00000057 880F                <1> 	mov	[bx], cl ; Interface support bit map in CX
    46                              <1> 			 ; Bit 0 - 1, Fixed disk access subset ready
    47                              <1> 			 ; Bit 1 - 1, Drv locking and ejecting ready
    48                              <1> 			 ; Bit 2 - 1, Enhanced Disk Drive Support
    49                              <1>                          ;            (EDD) ready (DPTE ready)
    50                              <1> 			 ; Bit 3 - 1, 64bit extensions are present
    51                              <1>                          ;            (EDD-3)
    52                              <1> 			 ; Bit 4 to 15 - 0, Reserved
    53 00000059 80FA83              <1> 	cmp	dl, 83h	 ; drive number < 83h
    54 0000005C 72DB                <1> 	jb	short L1
    55                              <1> L2:
    56                              <1> 	; 23/11/2014
    57                              <1> 	; 19/11/2014
    58 0000005E 30D2                <1> 	xor	dl, dl  ; 0
    59                              <1> 	; 04/02/2016 (esi -> si)
    60 00000060 BE[F8EC]            <1> 	mov	si, fd0_type
    61                              <1> L3:
    62                              <1> 	; 14/01/2015
    63 00000063 8816[F5EC]          <1> 	mov	[drv], dl
    64                              <1> 	;
    65 00000067 B408                <1> 	mov 	ah, 08h ; Return drive parameters
    66 00000069 CD13                <1> 	int	13h	
    67 0000006B 7210                <1> 	jc	short L4
    68                              <1> 		; BL = drive type (for floppy drives)
    69                              <1> 		; DL = number of floppy drives
    70                              <1> 		;		
    71                              <1> 		; ES:DI = Address of DPT from BIOS
    72                              <1> 		;
    73 0000006D 881C                <1> 	mov	[si], bl ;  Drive type
    74                              <1> 			; 4 = 1.44 MB, 80 track, 3 1/2"
    75                              <1> 	; 14/01/2015
    76 0000006F E8BC01              <1> 	call	set_disk_parms
    77                              <1> 	; 10/12/2014
    78 00000072 81FE[F8EC]          <1> 	cmp	si, fd0_type
    79 00000076 7705                <1> 	ja	short L4
    80 00000078 46                  <1> 	inc	si ; fd1_type
    81 00000079 B201                <1> 	mov	dl, 1
    82 0000007B EBE6                <1> 	jmp	short L3
    83                              <1> L4:
    84                              <1> 	; Older BIOS (INT 13h, AH = 48h is not available)
    85 0000007D B27F                <1> 	mov	dl, 7Fh
    86                              <1> 	; 24/12/2014 (Temporary)
    87 0000007F 803E[F7EC]00        <1> 	cmp	byte [hdc], 0 ; EDD present or not ?	
    88 00000084 0F879000            <1>         ja      L10       ; yes, all fixed disk operations
    89                              <1> 			  ; will be performed according to
    90                              <1> 			  ; present EDD specification
    91                              <1> L6:
    92 00000088 FEC2                <1> 	inc 	dl
    93 0000008A 8816[F5EC]          <1>         mov     [drv], dl
    94 0000008E 8816[F6EC]          <1>         mov     [last_drv], dl ; 14/01/2015
    95 00000092 B408                <1> 	mov 	ah, 08h ; Return drive parameters
    96 00000094 CD13                <1> 	int	13h	; (conventional function)
    97 00000096 0F828601            <1>         jc      L13	; fixed disk drive not ready
    98 0000009A 8816[F7EC]          <1>         mov     [hdc], dl ; number of drives
    99                              <1> 	;; 14/01/2013
   100                              <1> 	;;push	cx
   101 0000009E E88D01              <1> 	call	set_disk_parms
   102                              <1> 	;;pop	cx
   103                              <1> 	;
   104                              <1> 	;;and	cl, 3Fh	 ; sectors per track (bits 0-6)
   105 000000A1 8A16[F5EC]          <1>         mov     dl, [drv]
   106 000000A5 BB0401              <1> 	mov	bx, 65*4 ; hd0 parameters table (INT 41h)	
   107 000000A8 80FA80              <1> 	cmp	dl, 80h
   108 000000AB 7603                <1> 	jna	short L7
   109 000000AD 83C314              <1> 	add	bx, 5*4	 ; hd1 parameters table (INT 46h)
   110                              <1> L7:	
   111 000000B0 31C0                <1> 	xor	ax, ax
   112 000000B2 8ED8                <1> 	mov	ds, ax
   113 000000B4 8B37                <1>         mov     si, [bx]
   114 000000B6 8B4702              <1>         mov     ax, [bx+2] 
   115 000000B9 8ED8                <1> 	mov	ds, ax
   116 000000BB 3A4C0E              <1>         cmp     cl, [si+FDPT_SPT] ; sectors per track 
   117 000000BE 0F855A01            <1>         jne     L12 ; invalid FDPT
   118 000000C2 BF0000              <1> 	mov	di, HD0_DPT
   119 000000C5 80FA80              <1> 	cmp	dl, 80h
   120 000000C8 7603                <1> 	jna	short L8
   121 000000CA BF2000              <1> 	mov	di, HD1_DPT 
   122                              <1> L8:
   123                              <1> 	; 30/12/2014
   124 000000CD B80090              <1> 	mov	ax, DPT_SEGM
   125 000000D0 8EC0                <1> 	mov	es, ax
   126                              <1> 	; 24/12/2014
   127 000000D2 B90800              <1> 	mov	cx, 8
   128 000000D5 F3A5                <1> 	rep	movsw  ; copy 16 bytes to the kernel's DPT location
   129 000000D7 8CC8                <1> 	mov	ax, cs
   130 000000D9 8ED8                <1> 	mov	ds, ax
   131                              <1> 	; 02/02/2015
   132 000000DB 8A0E[F5EC]          <1>         mov     cl, [drv]
   133 000000DF 88CB                <1> 	mov	bl, cl
   134 000000E1 B8F001              <1> 	mov	ax, 1F0h
   135 000000E4 80E301              <1> 	and	bl, 1
   136 000000E7 7406                <1> 	jz	short L9
   137 000000E9 C0E304              <1> 	shl	bl, 4
   138 000000EC 2D8000              <1> 	sub	ax, 1F0h-170h
   139                              <1> L9:
   140 000000EF AB                  <1> 	stosw	; I/O PORT Base Address (1F0h, 170h)
   141 000000F0 050602              <1> 	add	ax, 206h
   142 000000F3 AB                  <1> 	stosw	; CONTROL PORT Address (3F6h, 376h)	
   143 000000F4 88D8                <1> 	mov	al, bl
   144 000000F6 04A0                <1> 	add	al, 0A0h
   145 000000F8 AA                  <1> 	stosb	; Device/Head Register upper nibble
   146                              <1> 	;
   147 000000F9 FE06[F5EC]          <1> 	inc	byte [drv]
   148 000000FD BB[7AEC]            <1> 	mov	bx, hd0_type - 80h
   149 00000100 01CB                <1> 	add	bx, cx
   150 00000102 800F80              <1>         or      byte [bx], 80h  ; present sign (when lower nibble is 0)
   151 00000105 A0[F7EC]            <1> 	mov	al, [hdc]
   152 00000108 FEC8                <1> 	dec	al
   153 0000010A 0F841201            <1>         jz      L13
   154 0000010E 80FA80              <1> 	cmp	dl, 80h
   155 00000111 0F8673FF            <1>         jna     L6
   156 00000115 E90801              <1>         jmp     L13
   157                              <1> L10:
   158 00000118 FEC2                <1> 	inc 	dl
   159                              <1> 	; 25/12/2014
   160 0000011A 8816[F5EC]          <1> 	mov	[drv], dl
   161 0000011E B408                <1> 	mov 	ah, 08h ; Return drive parameters
   162 00000120 CD13                <1> 	int	13h	; (conventional function)
   163 00000122 0F82FA00            <1>         jc      L13
   164                              <1> 	; 14/01/2015
   165 00000126 8A16[F5EC]          <1> 	mov	dl, [drv]
   166 0000012A 52                  <1> 	push	dx
   167 0000012B 51                  <1> 	push	cx
   168 0000012C E8FF00              <1> 	call	set_disk_parms
   169 0000012F 59                  <1> 	pop	cx
   170 00000130 5A                  <1> 	pop	dx
   171                              <1> 	; 06/07/2016 (BugFix for >64K kernel files)
   172                              <1> 	; 04/02/2016 (esi -> si)
   173                              <1> 	;mov	si, _end ; 30 byte temporary buffer address 	
   174                              <1> 	;		 ; at the '_end' of kernel.
   175                              <1> 	;mov	word [si], 30
   176                              <1> 	; 06/07/2016
   177 00000131 BE[B1ED]            <1> 	mov	si, _int13h_48h_buffer
   178                              <1> 	; 09/07/2016
   179 00000134 B81E00              <1> 	mov	ax, 001Eh
   180 00000137 8824                <1> 	mov	[si], ah ; 0
   181 00000139 46                  <1> 	inc	si
   182 0000013A 8904                <1> 	mov	word [si], ax
   183                              <1>  	; word [si] = 30
   184                              <1> 	;
   185 0000013C B448                <1> 	mov	ah, 48h	 ; Get drive parameters (EDD function)
   186 0000013E CD13                <1> 	int	13h
   187 00000140 0F82DC00            <1>         jc      L13
   188                              <1> 	; 04/02/2016 (ebx -> bx)
   189                              <1> 	; 14/01/2015
   190 00000144 28FF                <1> 	sub	bh, bh
   191 00000146 88D3                <1> 	mov	bl, dl
   192 00000148 80EB80              <1> 	sub	bl, 80h
   193 0000014B 81C3[FAEC]          <1> 	add	bx, hd0_type
   194 0000014F 8A07                <1> 	mov 	al, [bx]
   195 00000151 0C80                <1> 	or	al, 80h
   196 00000153 8807                <1> 	mov 	[bx], al	
   197 00000155 81EB[F8EC]          <1> 	sub	bx, hd0_type - 2 ; 15/01/2015
   198 00000159 81C3[44ED]          <1> 	add	bx, drv.status
   199 0000015D 8807                <1> 	mov	[bx], al
   200                              <1> 	; 04/02/2016 (eax -> ax)
   201 0000015F 8B4410              <1> 	mov	ax, [si+16]
   202 00000162 854412              <1> 	test	ax, [si+18]
   203 00000165 7412                <1> 	jz	short L10_A0h 
   204                              <1> 			; 'CHS only' disks on EDD system 
   205                              <1> 			;  are reported with ZERO disk size
   206 00000167 81EB[44ED]          <1> 	sub	bx, drv.status
   207 0000016B C1E302              <1> 	shl	bx, 2
   208 0000016E 81C3[28ED]          <1> 	add	bx, drv.size ; disk size (in sectors)
   209 00000172 8907                <1> 	mov	[bx], ax
   210 00000174 8B4412              <1> 	mov	ax, [si+18]
   211 00000177 8907                <1> 	mov	[bx], ax
   212                              <1> 
   213                              <1> L10_A0h: ; Jump here to fix a ZERO (LBA) disk size problem 
   214                              <1> 	 ; for CHS disks (28/02/2015)
   215                              <1> 	; 30/12/2014
   216 00000179 BF0000              <1> 	mov	di, HD0_DPT
   217 0000017C 88D0                <1> 	mov	al, dl
   218 0000017E 83E003              <1> 	and 	ax, 3
   219 00000181 C0E005              <1> 	shl	al, 5 ; *32
   220 00000184 01C7                <1> 	add 	di, ax
   221 00000186 B80090              <1> 	mov	ax, DPT_SEGM
   222 00000189 8EC0                <1> 	mov	es, ax
   223                              <1> 	;
   224 0000018B 88E8                <1> 	mov	al, ch	; max. cylinder number (bits 0-7)
   225 0000018D 88CC                <1> 	mov	ah, cl	
   226 0000018F C0EC06              <1> 	shr	ah, 6	; max. cylinder number (bits 8-9)
   227 00000192 40                  <1>  	inc	ax	; logical cylinders (limit 1024)
   228 00000193 AB                  <1> 	stosw		
   229 00000194 88F0                <1> 	mov	al, dh	; max. head number
   230 00000196 FEC0                <1> 	inc	al
   231 00000198 AA                  <1> 	stosb		; logical heads (limits 256)
   232 00000199 B0A0                <1> 	mov	al, 0A0h ; Indicates translated table
   233 0000019B AA                  <1> 	stosb
   234 0000019C 8A440C              <1> 	mov	al, [si+12]
   235 0000019F AA                  <1> 	stosb		 ; physical sectors per track
   236 000001A0 31C0                <1>  	xor	ax, ax
   237                              <1> 	;dec	ax	 ; 02/01/2015 
   238 000001A2 AB                  <1> 	stosw		 ; precompensation (obsolete)
   239                              <1> 	;xor	al, al	 ; 02/01/2015	
   240 000001A3 AA                  <1> 	stosb		 ; reserved
   241 000001A4 B008                <1> 	mov	al, 8	 ; drive control byte
   242                              <1> 		         ; (do not disable retries, 
   243                              <1> 			 ; more than 8 heads)
   244 000001A6 AA                  <1> 	stosb
   245 000001A7 8B4404              <1> 	mov	ax, [si+4]
   246 000001AA AB                  <1> 	stosw		 ; physical number of cylinders	
   247                              <1> 	;push	ax	 ; 02/01/2015
   248 000001AB 8A4408              <1> 	mov	al, [si+8]
   249 000001AE AA                  <1> 	stosb		 ; physical num. of heads (limit 16)
   250 000001AF 29C0                <1> 	sub 	ax, ax
   251                              <1> 	;pop	ax	 ; 02/01/2015	
   252 000001B1 AB                  <1> 	stosw		 ; landing zone (obsolete)
   253 000001B2 88C8                <1> 	mov	al, cl	 ; logical sectors per track (limit 63)
   254 000001B4 243F                <1> 	and 	al, 3Fh	
   255 000001B6 AA                  <1> 	stosb
   256                              <1> 	;sub	al, al	 ; checksum
   257                              <1> 	;stosb
   258                              <1> 	;
   259 000001B7 83C61A              <1> 	add	si, 26   ; (BIOS) DPTE address pointer
   260 000001BA AD                  <1> 	lodsw
   261 000001BB 50                  <1> 	push	ax	 ; (BIOS) DPTE offset
   262 000001BC AD                  <1> 	lodsw
   263 000001BD 50                  <1> 	push	ax	 ; (BIOS) DPTE segment
   264                              <1> 	;
   265                              <1> 	; checksum calculation
   266 000001BE 89FE                <1> 	mov	si, di
   267 000001C0 06                  <1> 	push	es
   268 000001C1 1F                  <1> 	pop	ds
   269                              <1> 	;mov	cx, 16
   270 000001C2 B90F00              <1> 	mov 	cx, 15
   271 000001C5 29CE                <1> 	sub	si, cx
   272 000001C7 30E4                <1> 	xor	ah, ah
   273                              <1> 	;del	cl
   274                              <1> L11:		
   275 000001C9 AC                  <1> 	lodsb
   276 000001CA 00C4                <1> 	add	ah, al
   277 000001CC E2FB                <1> 	loop	L11
   278                              <1> 	;
   279 000001CE 88E0                <1> 	mov	al, ah
   280 000001D0 F6D8                <1> 	neg	al	; -x+x = 0
   281 000001D2 AA                  <1> 	stosb		; put checksum in byte 15 of the tbl
   282                              <1> 	;
   283 000001D3 1F                  <1> 	pop	ds	; (BIOS) DPTE segment
   284 000001D4 5E                  <1> 	pop	si	; (BIOS) DPTE offset	
   285                              <1> 	;
   286                              <1> 	; 23/02/2015
   287 000001D5 57                  <1> 	push	di
   288                              <1> 	; ES:DI points to DPTE (FDPTE) location
   289                              <1> 	;mov	cx, 8
   290 000001D6 B108                <1> 	mov	cl, 8
   291 000001D8 F3A5                <1> 	rep	movsw	
   292                              <1> 	;
   293                              <1> 	; 23/02/2015
   294                              <1> 	; (P)ATA drive and LBA validation
   295                              <1> 	; (invalidating SATA drives and setting
   296                              <1> 	; CHS type I/O for old type fixed disks)
   297 000001DA 5B                  <1> 	pop	bx
   298 000001DB 8CC8                <1> 	mov	ax, cs
   299 000001DD 8ED8                <1> 	mov	ds, ax
   300 000001DF 268B07              <1> 	mov	ax, [es:bx]
   301 000001E2 3DF001              <1> 	cmp	ax, 1F0h
   302 000001E5 7418                <1> 	je	short L11a
   303 000001E7 3D7001              <1> 	cmp	ax, 170h
   304 000001EA 7413                <1> 	je	short L11a
   305                              <1> 	; invalidation 
   306                              <1> 	; (because base port address is not 1F0h or 170h)
   307 000001EC 30FF                <1> 	xor	bh, bh
   308 000001EE 88D3                <1> 	mov	bl, dl
   309 000001F0 80EB80              <1> 	sub	bl, 80h
   310 000001F3 C687[FAEC]00        <1> 	mov	byte [bx+hd0_type], 0 ; not a valid disk drive !		
   311 000001F8 808F[46ED]F0        <1>         or      byte [bx+drv.status+2], 0F0h ; (failure sign)
   312 000001FD EB14                <1> 	jmp	short L11b
   313                              <1> L11a:	
   314                              <1> 	; LBA validation
   315 000001FF 268A4704            <1> 	mov	al, [es:bx+4] ; Head register upper nibble
   316 00000203 A840                <1> 	test	al, 40h ; LBA bit (bit 6)
   317 00000205 750C                <1> 	jnz	short L11b ; LBA type I/O is OK! (E0h or F0h)
   318                              <1> 	; force CHS type I/O for this drive (A0h or B0h)
   319 00000207 28FF                <1> 	sub	bh, bh
   320 00000209 88D3                <1> 	mov	bl, dl
   321 0000020B 80EB80              <1> 	sub	bl, 80h ; 26/02/2015
   322 0000020E 80A7[46ED]FE        <1>         and     byte [bx+drv.status+2], 0FEh ; clear bit 0
   323                              <1> 				; bit 0 = LBA ready bit
   324                              <1> 	; 'diskio' procedure will check this bit !
   325                              <1> L11b:
   326 00000213 3A16[F6EC]          <1> 	cmp	dl, [last_drv] ; 25/12/2014
   327 00000217 7307                <1>         jnb     short L13
   328 00000219 E9FCFE              <1>         jmp     L10
   329                              <1> L12:
   330                              <1> 	; Restore data registers
   331 0000021C 8CC8                <1> 	mov	ax, cs
   332 0000021E 8ED8                <1> 	mov	ds, ax	
   333                              <1> L13:
   334                              <1> 	; 13/12/2014
   335 00000220 0E                  <1> 	push	cs
   336 00000221 07                  <1> 	pop	es
   337                              <1> L14:
   338 00000222 B411                <1> 	mov 	ah, 11h
   339 00000224 CD16                <1> 	int 	16h
   340 00000226 7466                <1> 	jz 	short L16 ; no keys in keyboard buffer
   341 00000228 B010                <1> 	mov	al, 10h
   342 0000022A CD16                <1> 	int 	16h
   343 0000022C EBF4                <1> 	jmp 	short L14
   344                              <1> 
   345                              <1> set_disk_parms:
   346                              <1> 	; 04/02/2016 (ebx -> bx)
   347                              <1> 	; 10/07/2015
   348                              <1> 	; 14/01/2015
   349                              <1> 	;push	bx
   350 0000022E 28FF                <1> 	sub	bh, bh
   351 00000230 8A1E[F5EC]          <1> 	mov	bl, [drv]
   352 00000234 80FB80              <1> 	cmp	bl, 80h
   353 00000237 7203                <1> 	jb	short sdp0
   354 00000239 80EB7E              <1> 	sub	bl, 7Eh
   355                              <1> sdp0:	
   356 0000023C 81C3[44ED]          <1> 	add	bx, drv.status
   357 00000240 C60780              <1>   	mov	byte [bx], 80h ; 'Present' flag
   358                              <1> 	;
   359 00000243 88E8                <1> 	mov	al, ch ; last cylinder (bits 0-7)
   360 00000245 88CC                <1> 	mov	ah, cl ; 
   361 00000247 C0EC06              <1> 	shr	ah, 6  ; last cylinder (bits 8-9)
   362 0000024A 81EB[44ED]          <1> 	sub	bx, drv.status
   363 0000024E D0E3                <1> 	shl	bl, 1
   364 00000250 81C3[FEEC]          <1> 	add	bx, drv.cylinders
   365 00000254 40                  <1> 	inc	ax  ; convert max. cyl number to cyl count		
   366 00000255 8907                <1> 	mov	[bx], ax
   367 00000257 50                  <1> 	push	ax ; ** cylinders
   368 00000258 81EB[FEEC]          <1> 	sub	bx, drv.cylinders
   369 0000025C 81C3[0CED]          <1> 	add	bx, drv.heads
   370 00000260 30E4                <1> 	xor	ah, ah
   371 00000262 88F0                <1> 	mov	al, dh ; heads
   372 00000264 40                  <1> 	inc	ax
   373 00000265 8907                <1> 	mov	[bx], ax
   374 00000267 81EB[0CED]          <1>         sub     bx, drv.heads
   375 0000026B 81C3[1AED]          <1>         add     bx, drv.spt
   376 0000026F 30ED                <1> 	xor	ch, ch
   377 00000271 80E13F              <1> 	and	cl, 3Fh	; sectors (bits 0-6)
   378 00000274 890F                <1> 	mov	[bx], cx
   379 00000276 81EB[1AED]          <1>         sub     bx, drv.spt
   380 0000027A D1E3                <1> 	shl	bx, 1
   381 0000027C 81C3[28ED]          <1> 	add	bx, drv.size ; disk size (in sectors)
   382                              <1> 	; LBA size = cylinders * heads * secpertrack
   383 00000280 F7E1                <1> 	mul	cx 
   384 00000282 89C2                <1> 	mov	dx, ax	; heads*spt					
   385 00000284 58                  <1> 	pop	ax ; ** cylinders
   386 00000285 48                  <1> 	dec	ax ; 1 cylinder reserved (!?)
   387 00000286 F7E2                <1> 	mul	dx ; cylinders * (heads*spt)		
   388 00000288 8907                <1> 	mov	[bx], ax
   389 0000028A 895702              <1> 	mov	[bx+2], dx
   390                              <1> 	;
   391                              <1> 	;pop	bx
   392 0000028D C3                  <1> 	retn
   393                              <1> 
   394                              <1> L16:	; 28/05/2016
   192                                  
   193                                  	; 10/11/2014
   194 0000028E FA                           	cli	; Disable interrupts (clear interrupt flag)
   195                                  		; Reset Interrupt MASK Registers (Master&Slave)
   196                                  	;mov	al, 0FFh	; mask off all interrupts
   197                                  	;out	21h, al		; on master PIC (8259)
   198                                  	;jmp 	$+2  ; (delay)
   199                                  	;out	0A1h, al	; on slave PIC (8259)
   200                                  	;
   201                                  	; Disable NMI 
   202 0000028F B080                    	mov   	al, 80h 
   203 00000291 E670                    	out   	70h, al		; set bit 7 to 1 for disabling NMI
   204                                  	;23/02/2015
   205                                  	;nop			;
   206                                  	;in	al, 71h		; read in 71h just after writing out to 70h
   207                                  				; for preventing unknown state (!?)
   208                                  	;
   209                                   	; 20/08/2014
   210                                  	; Moving the kernel 64 KB back (to physical address 0)
   211                                  	; DS = CS = 1000h
   212                                  	; 05/11/2014
   213 00000293 31C0                    	xor	ax, ax
   214 00000295 8EC0                    	mov	es, ax ; ES = 0
   215                                  	;
   216                                  	; 04/07/2016 -  TRDOS 386 (64K - 128K kernel)
   217 00000297 31F6                          	xor	si, si
   218 00000299 31FF                    	xor	di, di
   219 0000029B B90040                  	mov	cx, 16384
   220 0000029E F366A5                  	rep	movsd
   221                                  	;
   222 000002A1 06                      	push	es ; 0
   223 000002A2 68[A602]                	push	L17
   224 000002A5 CB                      	retf
   225                                  L17:
   226 000002A6 B90010                  	mov	cx, 1000h
   227 000002A9 8EC1                    	mov	es, cx  ; 1000h 
   228 000002AB 01C9                    	add	cx, cx
   229 000002AD 8ED9                    	mov	ds, cx  ; 2000h
   230 000002AF 29F6                    	sub	si, si
   231 000002B1 29FF                    	sub	di, di
   232 000002B3 B90040                  	mov	cx, 16384
   233 000002B6 F366A5                  	rep	movsd
   234                                  	
   235                                  	; Turn off the floppy drive motor
   236 000002B9 BAF203                          mov     dx, 3F2h
   237 000002BC EE                              out     dx, al ; 0 ; 31/12/2013
   238                                  
   239                                  	; Enable access to memory above one megabyte
   240                                  L18:
   241 000002BD E464                    	in	al, 64h
   242 000002BF A802                    	test	al, 2
   243 000002C1 75FA                            jnz     short L18
   244 000002C3 B0D1                    	mov	al, 0D1h	; Write output port
   245 000002C5 E664                    	out	64h, al
   246                                  L19:
   247 000002C7 E464                    	in	al, 64h
   248 000002C9 A802                    	test	al, 2
   249 000002CB 75FA                            jnz     short L19
   250 000002CD B0DF                    	mov	al, 0DFh	; Enable A20 line
   251 000002CF E660                    	out	60h, al
   252                                  ;L20:
   253                                  	;
   254                                  	; Load global descriptor table register
   255                                  
   256                                          ;mov     ax, cs
   257                                          ;mov     ds, ax
   258                                  
   259 000002D1 2E0F0116[60E6]                  lgdt    [cs:gdtd]
   260                                  
   261 000002D7 0F20C0                          mov     eax, cr0
   262                                  	; or 	eax, 1
   263 000002DA 40                      	inc     ax
   264 000002DB 0F22C0                  	mov     cr0, eax
   265                                  
   266                                  	; Jump to 32 bit code
   267                                  	
   268 000002DE 66                      	db 66h 			; Prefix for 32-bit
   269 000002DF EA                      	db 0EAh 		; Opcode for far jump
   270 000002E0 [E6020000]              	dd StartPM 		; Offset to start, 32-bit
   271                                  				; (1000h:StartPM = StartPM + 10000h)
   272 000002E4 0800                    	dw KCODE		; This is the selector for CODE32_DESCRIPTOR,
   273                                  				; assuming that StartPM resides in code32
   274                                  
   275                                  [BITS 32] 
   276                                  
   277                                  StartPM:
   278                                  	; Kernel Base Address = 0 ; 30/12/2013
   279 000002E6 66B81000                	mov ax, KDATA           ; Save data segment identifier
   280 000002EA 8ED8                            mov ds, ax              ; Move a valid data segment into DS register
   281 000002EC 8EC0                           	mov es, ax              ; Move data segment into ES register
   282 000002EE 8EE0                           	mov fs, ax              ; Move data segment into FS register
   283 000002F0 8EE8                          	mov gs, ax              ; Move data segment into GS register
   284 000002F2 8ED0                            mov ss, ax              ; Move data segment into SS register
   285 000002F4 BC00000900                      mov esp, 90000h         ; Move the stack pointer to 090000h
   286                                  
   287                                  clear_bss: ; Clear uninitialized data area
   288                                  	; 11/03/2015
   289 000002F9 31C0                    	xor  eax, eax ; 0
   290 000002FB B96C080000              	mov  ecx, (bss_end - bss_start)/4
   291                                  	;shr  ecx, 2 ; bss section is already aligned for double words
   292 00000300 BF[C01C0100]            	mov  edi, bss_start	
   293 00000305 F3AB                    	rep  stosd  		
   294                                  
   295                                  memory_init:
   296                                  	; Initialize memory allocation table and page tables
   297                                  	; 16/11/2014
   298                                  	; 15/11/2014
   299                                  	; 07/11/2014
   300                                  	; 06/11/2014
   301                                  	; 05/11/2014
   302                                  	; 04/11/2014
   303                                  	; 31/10/2014 (Retro UNIX 386 v1 - Beginning) 
   304                                  	;
   305                                  ;	xor	eax, eax
   306                                  ;	xor 	ecx, ecx
   307 00000307 B108                    	mov	cl, 8
   308 00000309 BF00001000              	mov	edi, MEM_ALLOC_TBL	
   309 0000030E F3AB                    	rep	stosd		   ; clear Memory Allocation Table
   310                                  				   ; for the first 1 MB memory
   311                                  	;
   312 00000310 668B0D[CEEE0000]        	mov	cx, [mem_1m_1k]	   ; Number of contiguous KB between
   313                                  				   ; 1 and 16 MB, max. 3C00h = 15 MB.
   314 00000317 66C1E902                	shr	cx, 2		   ; convert 1 KB count to 4 KB count
   315 0000031B 890D[B01F0100]          	mov	[free_pages], ecx
   316 00000321 668B15[D0EE0000]        	mov	dx, [mem_16m_64k]  ; Number of contiguous 64 KB blocks
   317                                  				   ; between 16 MB and 4 GB.	
   318 00000328 6609D2                  	or	dx, dx
   319 0000032B 7413                    	jz	short mi_0
   320                                  	;
   321 0000032D 6689D0                  	mov	ax, dx
   322 00000330 C1E004                  	shl	eax, 4		   ; 64 KB -> 4 KB (page count)
   323 00000333 0105[B01F0100]          	add	[free_pages], eax
   324 00000339 0500100000              	add	eax, 4096	   ; 16 MB = 4096 pages
   325 0000033E EB07                    	jmp	short mi_1
   326                                  mi_0:
   327 00000340 6689C8                  	mov	ax, cx
   328 00000343 66050001                	add	ax, 256		   ; add 256 pages for the first 1 MB		 
   329                                  mi_1:
   330 00000347 A3[AC1F0100]            	mov	[memory_size], eax ; Total available memory in pages
   331                                  				   ; 1 alloc. tbl. bit = 1 memory page
   332                                  				   ; 32 allocation bits = 32 mem. pages   
   333                                  	;
   334 0000034C 05FF7F0000              	add	eax, 32767	   ; 32768 memory pages per 1 M.A.T. page 	
   335 00000351 C1E80F                  	shr	eax, 15		   ; ((32768 * x) + y) pages (y < 32768)
   336                                  				   ;  --> x + 1 M.A.T. pages, if y > 0
   337                                  				   ;  --> x M.A.T. pages, if y = 0
   338 00000354 66A3[C01F0100]          	mov	[mat_size], ax	   ; Memory Alloc. Table Size in pages		
   339 0000035A C1E00C                  	shl	eax, 12		   ; 1 M.A.T. page = 4096 bytes
   340                                  	;			   ; Max. 32 M.A.T. pages (4 GB memory)
   341 0000035D 89C3                    	mov	ebx, eax	   ; M.A.T. size in bytes
   342                                  	; Set/Calculate Kernel's Page Directory Address
   343 0000035F 81C300001000            	add	ebx, MEM_ALLOC_TBL
   344 00000365 891D[A81F0100]          	mov	[k_page_dir], ebx  ; Kernel's Page Directory address
   345                                  				   ; just after the last M.A.T. page
   346                                  	;
   347 0000036B 83E804                  	sub	eax, 4		   ; convert M.A.T. size to offset value
   348 0000036E A3[B81F0100]            	mov	[last_page], eax   ; last page ofset in the M.A.T.
   349                                  	;			   ; (allocation status search must be 
   350                                  				   ; stopped after here)	
   351 00000373 31C0                    	xor	eax, eax
   352 00000375 48                      	dec	eax		   ; FFFFFFFFh (set all bits to 1)	
   353 00000376 6651                    	push	cx
   354 00000378 C1E905                  	shr	ecx, 5		   ; convert 1 - 16 MB page count to 
   355                                  				   ; count of 32 allocation bits
   356 0000037B F3AB                    	rep	stosd
   357 0000037D 6659                    	pop	cx
   358 0000037F 40                      	inc	eax		   ; 0	
   359 00000380 80E11F                  	and	cl, 31		   ; remain bits
   360 00000383 7412                    	jz	short mi_4
   361 00000385 8907                    	mov	[edi], eax	   ; reset	
   362                                  mi_2:
   363 00000387 0FAB07                  	bts	[edi], eax	   ; 06/11/2014		
   364 0000038A FEC9                    	dec	cl
   365 0000038C 7404                    	jz	short mi_3
   366 0000038E FEC0                    	inc	al
   367 00000390 EBF5                    	jmp	short mi_2
   368                                  mi_3:
   369 00000392 28C0                    	sub	al, al	   	   ; 0
   370 00000394 83C704                  	add	edi, 4		   ; 15/11/2014
   371                                  mi_4:
   372 00000397 6609D2                  	or	dx, dx		  ; check 16M to 4G memory space	
   373 0000039A 7421                    	jz	short mi_6	  ; max. 16 MB memory, no more...
   374                                  	;	
   375 0000039C B900021000              	mov	ecx, MEM_ALLOC_TBL + 512 ; End of first 16 MB memory
   376                                  	;	
   377 000003A1 29F9                    	sub	ecx, edi	  ; displacement (to end of 16 MB)
   378 000003A3 7406                    	jz	short mi_5	  ; jump if EDI points to 
   379                                  				  ;         end of first 16 MB	
   380 000003A5 D1E9                    	shr	ecx, 1		  ; convert to dword count
   381 000003A7 D1E9                    	shr	ecx, 1		  ; (shift 2 bits right) 
   382 000003A9 F3AB                    	rep 	stosd		  ; reset all bits for reserved pages
   383                                  				  ; (memory hole under 16 MB)
   384                                  mi_5:
   385 000003AB 6689D1                  	mov	cx, dx		  ; count of 64 KB memory blocks
   386 000003AE D1E9                    	shr	ecx, 1		  ; 1 alloc. dword per 128 KB memory
   387 000003B0 9C                      	pushf			  ; 16/11/2014		
   388 000003B1 48                      	dec	eax		  ; FFFFFFFFh (set all bits to 1)
   389 000003B2 F3AB                    	rep	stosd
   390 000003B4 40                      	inc	eax		  ; 0
   391 000003B5 9D                      	popf			  ; 16/11/2014
   392 000003B6 7305                    	jnc	short mi_6
   393 000003B8 6648                    	dec	ax		  ; eax = 0000FFFFh
   394 000003BA AB                      	stosd
   395 000003BB 6640                    	inc	ax		  ; 0		
   396                                  mi_6:
   397 000003BD 39DF                    	cmp	edi, ebx	  ; check if EDI points to 	
   398 000003BF 730A                    	jnb	short mi_7	  ; end of memory allocation table
   399                                  	;			  ; (>= MEM_ALLOC_TBL + 4906) 
   400 000003C1 89D9                    	mov	ecx, ebx	  ; end of memory allocation table
   401 000003C3 29F9                    	sub	ecx, edi	  ; convert displacement/offset
   402 000003C5 D1E9                    	shr	ecx, 1		  ; to dword count 	 		
   403 000003C7 D1E9                    	shr	ecx, 1		  ; (shift 2 bits right) 
   404 000003C9 F3AB                    	rep 	stosd		  ; reset all remain M.A.T. bits
   405                                  mi_7:
   406                                  	; Reset M.A.T. bits in M.A.T. (allocate M.A.T. pages)
   407 000003CB BA00001000              	mov	edx, MEM_ALLOC_TBL
   408                                  	;sub	ebx, edx	  ; Mem. Alloc. Tbl. size in bytes
   409                                  	;shr	ebx, 12		  ; Mem. Alloc. Tbl. size in pages	
   410 000003D0 668B0D[C01F0100]        	mov	cx, [mat_size]	  ; Mem. Alloc. Tbl. size in pages
   411 000003D7 89D7                    	mov	edi, edx
   412 000003D9 C1EF0F                  	shr	edi, 15		  ; convert M.A.T. address to
   413                                  				  ; byte offset in M.A.T.
   414                                  				  ; (1 M.A.T. byte points to 
   415                                  				  ;	      32768 bytes)
   416                                  				  ; Note: MEM_ALLOC_TBL address 
   417                                  				  ; must be aligned on 128 KB 
   418                                  				  ; boundary!
   419 000003DC 01D7                    	add	edi, edx	  ; points to M.A.T.'s itself	
   420                                  	; eax = 0
   421 000003DE 290D[B01F0100]          	sub	[free_pages], ecx ; 07/11/2014
   422                                  mi_8:
   423 000003E4 0FB307                  	btr	[edi], eax	  ; clear bit 0 to bit x (1 to 31)
   424                                  	;dec	bl
   425 000003E7 FEC9                    	dec	cl
   426 000003E9 7404                    	jz	short mi_9
   427 000003EB FEC0                    	inc	al
   428 000003ED EBF5                    	jmp	short mi_8
   429                                  mi_9:
   430                                  	;
   431                                  	; Reset Kernel's Page Dir. and Page Table bits in M.A.T.
   432                                  	;		(allocate pages for system page tables)
   433                                  
   434                                  	; edx = MEM_ALLOC_TBL
   435 000003EF 8B0D[AC1F0100]          	mov	ecx, [memory_size] ; memory size in pages (PTEs)
   436 000003F5 81C1FF030000            	add	ecx, 1023	 ; round up (1024 PTEs per table)	 	
   437 000003FB C1E90A                  	shr	ecx, 10		 ; convert memory page count to 
   438                                  				 ; page table count (PDE count)
   439                                  	;
   440 000003FE 51                      	push	ecx		 ; (**) PDE count (<= 1024)
   441                                  	;
   442 000003FF 41                      	inc	ecx		 ; +1 for kernel page directory	
   443                                  	;
   444 00000400 290D[B01F0100]          	sub	[free_pages], ecx ; 07/11/2014
   445                                  	;
   446 00000406 8B35[A81F0100]          	mov	esi, [k_page_dir] ; Kernel's Page Directory address
   447 0000040C C1EE0C                  	shr	esi, 12		 ; convert to page number
   448                                  mi_10:
   449 0000040F 89F0                    	mov	eax, esi	 ; allocation bit offset		 
   450 00000411 89C3                    	mov	ebx, eax
   451 00000413 C1EB03                  	shr	ebx, 3		 ; convert to alloc. byte offset
   452 00000416 80E3FC                  	and	bl,  0FCh	 ; clear bit 0 and bit 1
   453                                  				 ;   to align on dword boundary
   454 00000419 83E01F                  	and	eax, 31		 ; set allocation bit position 
   455                                  				 ;  (bit 0 to bit 31)
   456                                  	;
   457 0000041C 01D3                    	add	ebx, edx	 ; offset in M.A.T. + M.A.T. address 
   458                                  	;
   459 0000041E 0FB303                  	btr 	[ebx], eax	 ; reset relevant bit (0 to 31)
   460                                  	;
   461 00000421 46                      	inc	esi		 ; next page table
   462 00000422 E2EB                    	loop	mi_10		 ; allocate next kernel page table 
   463                                  				 ; (ecx = page table count + 1)		
   464                                  	;
   465 00000424 59                      	pop	ecx		 ; (**) PDE count (= pg. tbl. count)
   466                                  	;
   467                                  	; Initialize Kernel Page Directory and Kernel Page Tables
   468                                  	;
   469                                  	; Initialize Kernel's Page Directory
   470 00000425 8B3D[A81F0100]          	mov	edi, [k_page_dir]
   471 0000042B 89F8                    	mov	eax, edi
   472 0000042D 0C03                    	or	al, PDE_A_PRESENT + PDE_A_WRITE
   473                                  		     	      ; supervisor + read&write + present
   474 0000042F 89CA                    	mov	edx, ecx 	; (**) PDE count (= pg. tbl. count)	
   475                                  mi_11:
   476 00000431 0500100000              	add	eax, 4096	; Add page size (PGSZ)
   477                                  			        ; EAX points to next page table
   478 00000436 AB                      	stosd
   479 00000437 E2F8                    	loop	mi_11
   480 00000439 29C0                    	sub	eax, eax	; Empty PDE
   481 0000043B 66B90004                	mov	cx, 1024	; Entry count (PGSZ/4)
   482 0000043F 29D1                    	sub	ecx, edx
   483 00000441 7402                    	jz	short mi_12
   484 00000443 F3AB                    	rep	stosd 		; clear remain (empty) PDEs
   485                                  	;
   486                                  	; Initialization of Kernel's Page Directory is OK, here.
   487                                  mi_12:
   488                                  	; Initialize Kernel's Page Tables
   489                                  	;
   490                                  	; (EDI points to address of page table 0)
   491                                  	; eax = 0
   492 00000445 8B0D[AC1F0100]          	mov	ecx, [memory_size] ; memory size in pages
   493 0000044B 89CA                    	mov	edx, ecx	; (***)
   494 0000044D B003                    	mov	al, PTE_A_PRESENT + PTE_A_WRITE
   495                                  			     ; supervisor + read&write + present 	
   496                                  mi_13:
   497 0000044F AB                      	stosd
   498 00000450 0500100000              	add	eax, 4096	
   499 00000455 E2F8                    	loop	mi_13	
   500 00000457 6681E2FF03              	and	dx, 1023	; (***)
   501 0000045C 740B                    	jz	short mi_14
   502 0000045E 66B90004                	mov	cx, 1024	
   503 00000462 6629D1                  	sub	cx, dx		; from dx (<= 1023) to 1024
   504 00000465 31C0                    	xor	eax, eax
   505 00000467 F3AB                    	rep	stosd		; clear remain (empty) PTEs 
   506                                  				; of the last page table
   507                                  mi_14:
   508                                  	;  Initialization of Kernel's Page Tables is OK, here.
   509                                  	;
   510 00000469 89F8                    	mov	eax, edi	; end of the last page table page
   511                                  			        ; (beginging of user space pages)
   512 0000046B C1E80F                  	shr	eax, 15		; convert to M.A.T. byte offset
   513 0000046E 24FC                    	and	al, 0FCh	; clear bit 0 and bit 1 for
   514                                  				; aligning on dword boundary	
   515                                  	 
   516 00000470 A3[BC1F0100]            	mov	[first_page], eax
   517 00000475 A3[B41F0100]            	mov	[next_page], eax ; The first free page pointer
   518                                  				 ; for user programs
   519                                  				 ; (Offset in Mem. Alloc. Tbl.)	
   520                                  	;
   521                                  	; Linear/FLAT (1 to 1) memory paging for the kernel is OK, here.
   522                                  	;
   523                                  	
   524                                  	; Enable paging
   525                                  	;
   526 0000047A A1[A81F0100]                    mov     eax, [k_page_dir]
   527 0000047F 0F22D8                  	mov	cr3, eax
   528 00000482 0F20C0                  	mov	eax, cr0
   529 00000485 0D00000080              	or	eax, 80000000h	; set paging bit (bit 31)
   530 0000048A 0F22C0                  	mov	cr0, eax
   531                                          ;jmp    KCODE:StartPMP
   532                                  
   533 0000048D EA                      	db 0EAh 		; Opcode for far jump
   534 0000048E [94040000]                      dd StartPMP		; 32 bit offset
   535 00000492 0800                    	dw KCODE		; kernel code segment descriptor
   536                                  
   537                                  
   538                                  StartPMP:
   539                                  	; 06/11//2014
   540                                  	; Clear video page 0
   541                                  	;
   542                                  	; Temporary Code
   543                                  	;
   544 00000494 B9E8030000              	mov	ecx, 80*25/2
   545 00000499 BF00800B00              	mov	edi, 0B8000h
   546                                  	; 30/01/2016
   547                                  	;xor	eax, eax	; black background, black fore color
   548 0000049E B800070007              	mov	eax, 07000700h  ; black background, light gray fore color
   549 000004A3 F3AB                    	rep	stosd
   550                                  	
   551                                  	; 19/08/2014
   552                                  	; Kernel Base Address = 0
   553                                  	; It is mapped to (physically) 0 in the page table.
   554                                  	; So, here is exactly 'StartPMP' address.
   555                                  
   556                                   	; 29/01/2016 (TRDOS 386 = TRDOS v2.0)
   557 000004A5 BE[D2EE0000]            	mov	esi, starting_msg
   558                                  	;; 14/08/2015 (kernel version message will appear
   559                                  	;;	       when protected mode and paging is enabled)
   560 000004AA BF00800B00              	mov	edi, 0B8000h ; 27/08/2014
   561 000004AF B40A                    	mov	ah, 0Ah ; Black background, light green forecolor
   562                                  	; 20/08/2014
   563 000004B1 E880010000              	call	printk
   564                                  
   565                                  	; 'UNIX v7/x86' source code by Robert Nordier (1999)
   566                                  	; // Set IRQ offsets
   567                                  	;
   568                                  	;  Linux (v0.12) source code by Linus Torvalds (1991)
   569                                  	;
   570                                  					;; ICW1
   571 000004B6 B011                    	mov	al, 11h			; Initialization sequence
   572 000004B8 E620                    	out	20h, al			; 	8259A-1
   573                                  	; jmp 	$+2
   574 000004BA E6A0                    	out	0A0h, al		; 	8259A-2
   575                                  					;; ICW2
   576 000004BC B020                    	mov	al, 20h			; Start of hardware ints (20h)
   577 000004BE E621                    	out	21h, al			;	for 8259A-1
   578                                  	; jmp 	$+2
   579 000004C0 B028                    	mov	al, 28h			; Start of hardware ints (28h)
   580 000004C2 E6A1                    	out	0A1h, al		; 	for 8259A-2
   581                                  					;
   582 000004C4 B004                    	mov	al, 04h			;; ICW3
   583 000004C6 E621                    	out	21h, al			; 	IRQ2 of 8259A-1 (master)
   584                                  	; jmp 	$+2
   585 000004C8 B002                    	mov	al, 02h			; 	is 8259A-2 (slave)
   586 000004CA E6A1                    	out	0A1h, al		;
   587                                  					;; ICW4
   588 000004CC B001                    	mov	al, 01h	 		;
   589 000004CE E621                    	out	21h, al			; 	8086 mode, normal EOI	
   590                                  	; jmp 	$+2
   591 000004D0 E6A1                    	out	0A1h, al		;	for both chips.
   592                                  
   593                                  	;mov	al, 0FFh	; mask off all interrupts for now
   594                                  	;out	21h, al
   595                                  	;; jmp 	$+2
   596                                  	;out	0A1h, al
   597                                  
   598                                  	; 02/04/2015
   599                                  	; 26/03/2015 System call (INT 30h) modification
   600                                  	;  DPL = 3 (Interrupt service routine can be called from user mode)			
   601                                  	;
   602                                  	;; Linux (v0.12) source code by Linus Torvalds (1991)
   603                                  	;  setup_idt:
   604                                  	;
   605                                          ;; 16/02/2015
   606                                  	;;mov     dword [DISKETTE_INT], fdc_int ; IRQ 6 handler
   607                                  	; 21/08/2014 (timer_int)
   608 000004D2 BE[6CE60000]            	mov	esi, ilist
   609 000004D7 8D3D[C01C0100]          	lea	edi, [idt]
   610                                  	; 26/03/2015
   611 000004DD B930000000              	mov	ecx, 48		; 48 hardware interrupts (INT 0 to INT 2Fh)
   612                                  	; 02/04/2015
   613 000004E2 BB00000800              	mov	ebx,  80000h
   614                                  rp_sidt1:
   615 000004E7 AD                      	lodsd
   616 000004E8 89C2                    	mov	edx, eax
   617 000004EA 66BA008E                	mov	dx, 8E00h
   618 000004EE 6689C3                  	mov	bx, ax
   619 000004F1 89D8                    	mov	eax, ebx	; /* selector = 0x0008 = cs */
   620                                         			        ; /* interrupt gate - dpl=0, present */
   621 000004F3 AB                      	stosd	; selector & offset bits 0-15 	
   622 000004F4 89D0                    	mov	eax, edx
   623 000004F6 AB                      	stosd	; attributes & offset bits 16-23
   624 000004F7 E2EE                    	loop	rp_sidt1
   625                                  	; 15/04/2016
   626                                  	; TRDOS 386 (TRDOS v2.0) /// 32 sofware interrupts ///
   627                                  	;mov	cl, 16        ; 16 software interrupts (INT 30h to INT 3Fh)
   628 000004F9 B120                    	mov	cl, 32	      ;  16 software interrupts (INT 30h to INT 4Fh)	
   629                                  rp_sidt2:
   630 000004FB AD                      	lodsd
   631 000004FC 21C0                    	and	eax, eax
   632 000004FE 7413                    	jz	short rp_sidt3
   633 00000500 89C2                    	mov	edx, eax
   634 00000502 66BA00EE                	mov	dx, 0EE00h	; P=1b/DPL=11b/01110b
   635 00000506 6689C3                  	mov	bx, ax
   636 00000509 89D8                    	mov	eax, ebx	; selector & offset bits 0-15 	
   637 0000050B AB                      	stosd
   638 0000050C 89D0                    	mov	eax, edx
   639 0000050E AB                      	stosd
   640 0000050F E2EA                    	loop	rp_sidt2
   641 00000511 EB16                    	jmp	short sidt_OK
   642                                  rp_sidt3:
   643 00000513 B8[A1090000]            	mov	eax, ignore_int
   644 00000518 89C2                    	mov	edx, eax
   645 0000051A 66BA00EE                	mov	dx, 0EE00h	; P=1b/DPL=11b/01110b
   646 0000051E 6689C3                  	mov	bx, ax
   647 00000521 89D8                    	mov	eax, ebx	; selector & offset bits 0-15 	
   648                                  rp_sidt4:
   649 00000523 AB                      	stosd
   650 00000524 92                      	xchg	eax, edx
   651 00000525 AB                      	stosd
   652 00000526 92                      	xchg	edx, eax
   653 00000527 E2FA                    	loop	rp_sidt4
   654                                  sidt_OK: 
   655 00000529 0F011D[66E60000]        	lidt 	[idtd]
   656                                  	;
   657                                  	; TSS descriptor setup ; 24/03/2015
   658 00000530 B8[401F0100]            	mov	eax, task_state_segment
   659 00000535 66A3[5AE60000]          	mov	[gdt_tss0], ax
   660 0000053B C1C010                  	rol	eax, 16
   661 0000053E A2[5CE60000]            	mov	[gdt_tss1], al
   662 00000543 8825[5FE60000]          	mov	[gdt_tss2], ah
   663 00000549 66C705[A61F0100]68-     	mov	word [tss.IOPB], tss_end - task_state_segment
   663 00000551 00                 
   664                                  		; 
   665                                  		; IO Map Base address (When this address points
   666                                  		; to end of the TSS, CPU does not use IO port 
   667                                  		; permission bit map for RING 3 IO permissions, 
   668                                  		; access to any IO ports in ring 3 will be forbidden.)
   669                                   		;
   670                                  	;mov	[tss.esp0], esp ; TSS offset 4
   671                                  	;mov	word [tss.ss0], KDATA ; TSS offset 8 (SS)
   672 00000552 66B82800                   	mov	ax, TSS  ; It is needed when an interrupt 
   673                                  			 ; occurs (or a system call -software INT- is requested)
   674                                  			 ; while cpu running in ring 3 (in user mode).				
   675                                  			 ; (Kernel stack pointer and segment will be loaded
   676                                  			 ; from offset 4 and 8 of the TSS, by the CPU.)	 
   677 00000556 0F00D8                  	ltr	ax  ; Load task register
   678                                  	;
   679                                  esp0_set0:
   680                                  	; 30/07/2015
   681 00000559 8B0D[AC1F0100]          	mov 	ecx, [memory_size] ; memory size in pages
   682 0000055F C1E10C                  	shl 	ecx, 12 ; convert page count to byte count
   683 00000562 81F900004000            	cmp	ecx, CORE ; beginning of user's memory space (400000h)
   684                                  			  ; (kernel mode virtual address)
   685 00000568 7605                    	jna	short esp0_set1
   686                                  	;
   687                                  	; If available memory > CORE (end of the 1st 4 MB)
   688                                  	; set stack pointer to CORE
   689                                  	;(Because, PDE 0 is reserved for kernel space in user's page directory)
   690                                  	;(PDE 0 points to page table of the 1st 4 MB virtual address space)
   691 0000056A B900004000              	mov	ecx, CORE
   692                                  esp0_set1:
   693 0000056F 89CC                    	mov	esp, ecx ; top of kernel stack (**tss.esp0**)
   694                                  esp0_set_ok:
   695                                  	; 30/07/2015 (**tss.esp0**) 
   696 00000571 8925[441F0100]          	mov	[tss.esp0], esp
   697 00000577 66C705[481F0100]10-             mov     word [tss.ss0], KDATA
   697 0000057F 00                 
   698                                  	; 14/08/2015
   699                                  	; 10/11/2014 (Retro UNIX 386 v1 - Erdogan Tan)
   700                                  	;
   701                                  	;cli	; Disable interrupts (for CPU)
   702                                  	;    (CPU will not handle hardware interrupts, except NMI!)
   703                                  	;
   704 00000580 30C0                    	xor	al, al		; Enable all hardware interrupts!
   705 00000582 E621                    	out	21h, al		; (IBM PC-AT compatibility)
   706 00000584 EB00                    	jmp 	$+2		; (All conventional PC-AT hardware
   707 00000586 E6A1                    	out	0A1h, al	;  interrupts will be in use.)	
   708                                  				; (Even if related hardware component
   709                                  				;  does not exist!)
   710                                  	; Enable NMI 
   711 00000588 B07F                    	mov	al, 7Fh		; Clear bit 7 to enable NMI (again)
   712 0000058A E670                    	out  	70h, al
   713                                  	; 23/02/2015
   714 0000058C 90                      	nop
   715 0000058D E471                    	in	al, 71h		; read in 71h just after writing out to 70h
   716                                  				; for preventing unknown state (!?)
   717                                  	;
   718                                  	; Only a NMI can occur here... (Before a 'STI' instruction)
   719                                  	;
   720                                  	; 02/09/2014
   721 0000058F 6631DB                  	xor	bx, bx
   722 00000592 66BA0002                	mov	dx, 0200h	; Row 2, column 0  ; 07/03/2015
   723 00000596 E817160000              	call	_set_cpos	; 24/01/2016
   724                                  	;
   725                                  	; 06/11/2014
   726 0000059B E8FF260000              	call	memory_info
   727                                  	; 14/08/2015
   728                                  	;call getch ; 28/02/2015
   729                                  drv_init:
   730 000005A0 FB                      	sti	; Enable Interrupts 
   731                                  	; 06/02/2015
   732 000005A1 8B15[FAEC0000]          	mov	edx, [hd0_type] ; hd0, hd1, hd2, hd3
   733 000005A7 668B1D[F8EC0000]        	mov	bx, [fd0_type] ; fd0, fd1
   734                                  	; 22/02/2015
   735 000005AE 6621DB                  	and	bx, bx
   736 000005B1 751C                    	jnz	short di1
   737                                  	;
   738 000005B3 09D2                    	or 	edx, edx
   739 000005B5 752A                    	jnz	short di2
   740                                  	;
   741                                  setup_error:
   742 000005B7 BE[D3ED0000]            	mov 	esi, setup_error_msg
   743                                  psem:	
   744 000005BC AC                      	lodsb
   745 000005BD 08C0                    	or	al, al
   746                                  	;jz	short haltx ; 22/02/2015
   747 000005BF 7427                    	jz	short di3
   748 000005C1 56                      	push	esi
   749                                  	; 13/05/2016
   750 000005C2 BB07000000              	mov	ebx, 7	; Black background, 
   751                                  			; light gray forecolor
   752                                  			; Video page 0 (BH=0)
   753 000005C7 E850150000              	call	_write_tty
   754 000005CC 5E                      	pop	esi
   755 000005CD EBED                    	jmp	short psem
   756                                  
   757                                  di1:
   758                                  	; supress 'jmp short T6'
   759                                  	;  (activate fdc motor control code)
   760 000005CF 66C705[B7060000]90-     	mov	word [T5], 9090h ; nop
   760 000005D7 90                 
   761                                  	;
   762                                  	;mov	ax, int_0Eh	; IRQ 6 handler
   763                                  	;mov	di, 0Eh*4	; IRQ 6 vector
   764                                  	;stosw
   765                                  	;mov 	ax, cs
   766                                  	;stosw
   767                                  	;; 16/02/2015
   768                                          ;;mov     dword [DISKETTE_INT], fdc_int ; IRQ 6 handler
   769                                  	;
   770 000005D8 E836360000              	CALL	DSKETTE_SETUP	; Initialize Floppy Disks
   771                                  	;
   772 000005DD 09D2                    	or	edx, edx
   773 000005DF 7407                            jz      short di3
   774                                  di2:
   775 000005E1 E874360000              	call   	DISK_SETUP	; Initialize Fixed Disks
   776 000005E6 72CF                            jc      short setup_error
   777                                  di3:
   778 000005E8 E886260000              	call	setup_rtc_int	; 22/05/2015 (dsectrpm.s)
   779                                  	;
   780 000005ED E890DF0000              	call	display_disks ; 07/03/2015  (Temporary)
   781                                  ;haltx:
   782                                  	; 14/08/2015
   783                                  	;call	getch ; 22/02/2015
   784                                  	;sti	; Enable interrupts (for CPU)
   785                                  ;	; 29/01/2016
   786                                  ;	sub	ah, ah ;  read time count
   787                                  ;	call	int1Ah
   788                                  ;	mov	edx, ecx ; 18.2 * seconds
   789                                  ;md_info_msg_wait1:
   790                                  ;	; 29/01/2016
   791                                  ;	mov	ah, 1
   792                                  ;	call	int16h
   793                                  ;	jz	short md_info_msg_wait2
   794                                  ;	xor	ah, ah ; 0
   795                                  ;       call    int16h
   796                                  ;	jmp 	short md_info_msg_ok
   797                                  ;md_info_msg_wait2:
   798                                  ;	sub	ah, ah  ; read time count
   799                                  ;	call	int1Ah
   800                                  ;	cmp	edx, ecx ; ; 18.2 * seconds
   801                                  ;	jna	short md_info_msg_wait3
   802                                  ;	xchg 	edx, ecx	
   803                                  ;md_info_msg_wait3:
   804                                  ;	sub	ecx, edx
   805                                  ;	cmp	ecx, 127 ; 7 seconds (18.2 * 7)
   806                                  ;	jb	short md_info_msg_wait1		
   807                                  ;md_info_msg_ok:
   808                                  	; 30/06/2015
   809 000005F2 E8344E0000              	call	sys_init
   810                                  	;
   811                                  	;jmp 	cpu_reset ; 22/02/2015
   812                                  hang:  
   813                                  	; 23/02/2015
   814                                  	;sti			; Enable interrupts
   815 000005F7 F4                      	hlt
   816                                  	;
   817                                  	;nop
   818                                  	;; 03/12/2014
   819                                  	;; 28/08/2014
   820                                  	;mov	ah, 11h
   821                                  	;call	getc
   822                                  	;jz      _c8
   823                                  	;
   824                                  	; 23/02/2015
   825                                  	; 06/02/2015
   826                                  	; 07/09/2014
   827 000005F8 31DB                    	xor	ebx, ebx
   828 000005FA 8A1D[D61F0100]          	mov	bl, [ptty]	; active_page
   829 00000600 89DE                    	mov	esi, ebx
   830 00000602 66D1E6                  	shl 	si, 1
   831 00000605 81C6[D81F0100]          	add	esi, ttychr
   832 0000060B 668B06                  	mov	ax, [esi]
   833 0000060E 6621C0                  	and	ax, ax
   834                                  	;jz	short _c8
   835 00000611 74E4                    	jz	short hang
   836 00000613 66C7060000              	mov	word [esi], 0
   837 00000618 80FB03                  	cmp	bl, 3		; Video page 3
   838                                  	;jb	short _c8
   839 0000061B 72DA                    	jb	short hang
   840                                  	;	
   841                                  	; 13/05/2016
   842                                  	; 07/09/2014
   843                                  nxtl:
   844 0000061D 6653                    	push	bx
   845 0000061F 66BB0E00                	mov	bx, 0Eh 	; Yellow character 
   846                                  				; on black background
   847                                  				; bh = 0 (video page 0)
   848                                  				; Retro UNIX 386 v1 - Video Mode 0
   849                                  				; (PC/AT Video Mode 3 - 80x25 Alpha.)
   850 00000623 6650                    	push	ax
   851 00000625 E8F2140000              	call 	_write_tty
   852 0000062A 6658                    	pop	ax
   853 0000062C 665B                    	pop	bx
   854 0000062E 3C0D                    	cmp	al, 0Dh		; carriage return (enter)
   855                                  	;jne	short _c8
   856 00000630 75C5                    	jne	short hang
   857 00000632 B00A                    	mov	al, 0Ah		; next line
   858 00000634 EBE7                    	jmp	short nxtl
   859                                  	
   860                                  ;_c8:
   861                                  ;	; 25/08/2014
   862                                  ;	cli				; Disable interrupts
   863                                  ;	mov	al, [scounter + 1]
   864                                  ;	and	al, al
   865                                  ;	jnz	hang
   866                                  ;	call	rtc_p
   867                                  ;	jmp     hang
   868                                  
   869                                  
   870                                  	; 27/08/2014
   871                                  	; 20/08/2014
   872                                  printk:
   873                                          ;mov    edi, [scr_row]
   874                                  pkl:
   875 00000636 AC                      	lodsb
   876 00000637 08C0                    	or 	al, al
   877 00000639 7404                    	jz	short pkr
   878 0000063B 66AB                    	stosw
   879 0000063D EBF7                    	jmp	short pkl
   880                                  pkr:
   881 0000063F C3                      	retn
   882                                  
   883                                  ; 06/06/2016
   884                                  ; 23/05/2016
   885                                  ; 22/05/2016 - TRDOS 386 (TRDOS v2.0) Timer Event Modifications
   886                                  ; 25/07/2015
   887                                  ; 14/05/2015 (multi tasking -time sharing- 'clock', x_timer)
   888                                  ; 17/02/2015
   889                                  ; 06/02/2015 (unix386.s)
   890                                  ; 11/12/2014 - 22/12/2014 (dsectrm2.s) 
   891                                  ;
   892                                  ; IBM PC-XT Model 286 Source Code - BIOS2.ASM (06/10/85)
   893                                  ;
   894                                  ;-- HARDWARE INT  08 H - ( IRQ LEVEL 0 ) ---------------------------------------
   895                                  ;	THIS ROUTINE HANDLES THE TIMER INTERRUPT FROM FROM CHANNEL 0 OF        :
   896                                  ;	THE 8254 TIMER.  INPUT FREQUENCY IS 1.19318 MHZ AND THE DIVISOR        :
   897                                  ;	IS 65536, RESULTING IN APPROXIMATELY 18.2 INTERRUPTS EVERY SECOND.     :
   898                                  ;									       :
   899                                  ;	THE INTERRUPT HANDLER MAINTAINS A COUNT (40:6C) OF INTERRUPTS SINCE    :
   900                                  ;	POWER ON TIME, WHICH MAY BE USED TO ESTABLISH TIME OF DAY.	       :
   901                                  ;	THE INTERRUPT HANDLER ALSO DECREMENTS THE MOTOR CONTROL COUNT (40:40)  :
   902                                  ;	OF THE DISKETTE, AND WHEN IT EXPIRES, WILL TURN OFF THE 	       :
   903                                  ;	DISKETTE MOTOR(s), AND RESET THE MOTOR RUNNING FLAGS.		       :
   904                                  ;	THE INTERRUPT HANDLER WILL ALSO INVOKE A USER ROUTINE THROUGH	       :
   905                                  ;	INTERRUPT 1CH AT EVERY TIME TICK.  THE USER MUST CODE A 	       :
   906                                  ;	ROUTINE AND PLACE THE CORRECT ADDRESS IN THE VECTOR TABLE.	       :
   907                                  ;-------------------------------------------------------------------------------
   908                                  ;
   909                                  
   910                                  timer_int:	; IRQ 0
   911                                  ;int_08h:	; Timer
   912                                  	; 14/10/2015
   913                                  	; Here, we are simulating system call entry (for task switch)
   914                                  	; (If multitasking is enabled, 
   915                                  	; 'clock' procedure may jump to 'sysrelease')
   916 00000640 1E                      	push	ds
   917 00000641 06                      	push	es
   918 00000642 0FA0                    	push	fs
   919 00000644 0FA8                    	push	gs
   920 00000646 60                      	pushad  ; eax, ecx, edx, ebx, esp -before pushad-, ebp, esi, edi
   921 00000647 66B91000                	mov     cx, KDATA
   922 0000064B 8ED9                            mov     ds, cx
   923 0000064D 8EC1                            mov     es, cx
   924 0000064F 8EE1                            mov     fs, cx
   925 00000651 8EE9                            mov     gs, cx
   926                                  	;
   927 00000653 0F20D9                  	mov	ecx, cr3
   928 00000656 890D[483D0100]          	mov	[cr3reg], ecx ; save current cr3 register value/content
   929                                  	;
   930 0000065C 3B0D[A81F0100]          	cmp 	ecx, [k_page_dir]
   931 00000662 7420                    	je	short T3
   932                                  	;
   933                                  	; timer interrupt has been occurred while OS is in user mode
   934 00000664 FC                      	cld	; 06/06/2016
   935 00000665 A3[88300100]            	mov 	[u.r0], eax
   936 0000066A 89E1                    	mov	ecx, esp
   937 0000066C 83C130                  	add	ecx, ESPACE ; 4 * 12 (stack frame)	
   938 0000066F 890D[80300100]          	mov	[u.sp], ecx ; kernel stack pointer at the start of interrupt
   939 00000675 8925[84300100]          	mov	[u.usp], esp ; kernel stack points to user's registers   
   940                                  	;
   941 0000067B 8B0D[A81F0100]          	mov	ecx, [k_page_dir]
   942 00000681 0F22D9                  	mov	cr3, ecx
   943                                  T3:
   944                                  	;sti				; INTERRUPTS BACK ON
   945 00000684 66FF05[28200100]        	INC	word [TIMER_LOW]	; INCREMENT TIME
   946 0000068B 7507                    	JNZ	short T4		; GO TO TEST_DAY
   947 0000068D 66FF05[2A200100]        	INC	word [TIMER_HIGH]	; INCREMENT HIGH WORD OF TIME
   948                                  T4:					; TEST_DAY
   949 00000694 66833D[2A200100]18      	CMP	word [TIMER_HIGH],018H	; TEST FOR COUNT EQUALING 24 HOURS
   950 0000069C 7519                    	JNZ	short T5		; GO TO DISKETTE_CTL
   951 0000069E 66813D[28200100]B0-     	CMP	word [TIMER_LOW],0B0H
   951 000006A6 00                 
   952 000006A7 750E                    	JNZ	short T5		; GO TO DISKETTE_CTL
   953                                  
   954                                  ;-----	TIMER HAS GONE 24 HOURS
   955                                  	;;SUB	AX,AX
   956                                  	;MOV	[TIMER_HIGH],AX
   957                                  	;MOV	[TIMER_LOW],AX
   958 000006A9 29C0                    	sub	eax, eax
   959 000006AB A3[28200100]            	mov	[TIMER_LH], eax
   960                                  	;	
   961 000006B0 C605[2C200100]01        	MOV	byte [TIMER_OFL],1
   962                                  
   963                                  ;-----	TEST FOR DISKETTE TIME OUT
   964                                  
   965                                  T5:
   966                                  	; 23/12/2014
   967 000006B7 EB1D                    	jmp	short T6		; will be replaced with nop, nop
   968                                  					; (9090h) if a floppy disk
   969                                  					; is detected.
   970                                  	;mov	al,[CS:MOTOR_COUNT]
   971 000006B9 A0[2F200100]            	mov	al, [MOTOR_COUNT]
   972 000006BE FEC8                    	dec	al
   973                                  	;mov	[CS:MOTOR_COUNT], al	; DECREMENT DISKETTE MOTOR CONTROL
   974 000006C0 A2[2F200100]            	mov	[MOTOR_COUNT], al
   975                                  	;mov	[ORG_MOTOR_COUNT], al
   976 000006C5 750F                    	JNZ	short T6		; RETURN IF COUNT NOT OUT
   977 000006C7 B0F0                    	mov 	al,0F0h
   978                                  	;AND	[CS:MOTOR_STATUS],al 	; TURN OFF MOTOR RUNNING BITS
   979 000006C9 2005[2E200100]          	and	[MOTOR_STATUS], al
   980                                  	;and	[ORG_MOTOR_STATUS], al
   981 000006CF B00C                    	MOV	AL,0CH			; bit 3 = enable IRQ & DMA, 
   982                                  					; bit 2 = enable controller
   983                                  					;	1 = normal operation
   984                                  					;	0 = reset	
   985                                  					; bit 0, 1 = drive select
   986                                  					; bit 4-7 = motor running bits 
   987 000006D1 66BAF203                	MOV	DX,03F2H		; FDC CTL PORT
   988 000006D5 EE                      	OUT	DX,AL			; TURN OFF THE MOTOR
   989                                  T6:	
   990                                  	;inc	word [CS:wait_count]	; 22/12/2014 (byte -> word)
   991                                  					; TIMER TICK INTERRUPT
   992                                  	;;inc	word [wait_count] ;;27/02/2015
   993                                  	;INT	1CH			; TRANSFER CONTROL TO A USER ROUTINE
   994                                  	;cli
   995 000006D6 E87E030000              	call 	u_timer			; TRANSFER CONTROL TO A USER ROUTINE
   996                                  	; 23/05/2016
   997 000006DB E888D40000              	call	clock			; Multi Tasking control procedure
   998                                  T7:
   999                                  	; 14/10/2015
  1000 000006E0 B020                    	MOV	AL,EOI			; GET END OF INTERRUPT MASK
  1001                                  	;CLI				; DISABLE INTERRUPTS TILL STACK CLEARED
  1002 000006E2 E620                    	OUT	INTA00,AL		; END OF INTERRUPT TO 8259 - 1	
  1003                                  	;
  1004                                  	; 23/05/2016
  1005                                  rtc_int_2:
  1006                                  	; 22/05/2016
  1007 000006E4 803D[2D2D0100]00        	cmp	byte [p_change], 0 ; in 'set_run_sequence', in 'rtc_p'
  1008 000006EB 7615                    	jna	short timer_int_return ; 23/05/2016	
  1009                                  	; present process must be changed with high priority process	
  1010 000006ED 30C0                    	xor	al, al
  1011 000006EF A2[2D2D0100]            	mov	[p_change], al ; 0
  1012                                  	;
  1013 000006F4 803D[7F300100]FF        	cmp     byte [sysflg], 0FFh ; user or system space ?
  1014 000006FB 7415                    	je	short rtc_int_3     ; user space ([sysflg]= 0FFh)
  1015                                  
  1016                                  	; system space, wait for 'sysret'
  1017                                  	; to change running process 	
  1018                                  	; with high priority (event) process
  1019                                  
  1020 000006FD A2[CA300100]            	mov	[u.quant], al ; 0
  1021                                  
  1022                                  timer_int_return: ; 23/05/2016 - jump from 'rtc_int' ('rtc_int_2')
  1023 00000702 A1[483D0100]            	mov 	eax, [cr3reg] 		; previous value/content of cr3 register
  1024 00000707 0F22D8                   	mov	cr3, eax  ; restore cr3 register content
  1025                                  	;
  1026 0000070A 61                      	popad ; edi, esi, ebp, temp (icrement esp by 4), ebx, edx, ecx, eax
  1027                                  	;
  1028 0000070B 0FA9                    	pop	gs
  1029 0000070D 0FA1                    	pop	fs
  1030 0000070F 07                      	pop	es
  1031 00000710 1F                      	pop	ds
  1032 00000711 CF                      	iretd	; return from interrupt
  1033                                  
  1034                                  rtc_int_3:
  1035 00000712 FE05[7F300100]          	inc	byte [sysflg] 	; now, we are in system space
  1036                                  	;
  1037 00000718 E95FAF0000                      jmp     sysrelease ; change running process immediatelly 
  1038                                  
  1039                                  	; 06/06/2016
  1040                                  	; 23/05/2016
  1041                                  	; 22/05/2016
  1042                                  	; 19/05/2016 - TRDOS 386 (TRDOS v2.0)
  1043                                  	; 26/02/2015
  1044                                  	; 07/09/2014
  1045                                  	; 25/08/2014
  1046                                  rtc_int:       ; Real Time Clock Interrupt (IRQ 8)
  1047                                  	; 22/05/2016
  1048 0000071D 1E                      	push	ds ; ** ; 23/05/2016
  1049 0000071E 50                      	push	eax ; *
  1050 0000071F 66B81000                	mov	ax, KDATA
  1051 00000723 8ED8                    	mov	ds, ax
  1052                                  	;
  1053 00000725 8A25[26200100]          	mov	ah, [RTC_2Hz] ;  2 Hz interrupt to 1 Hz function
  1054 0000072B 80F401                  	xor	ah, 1
  1055 0000072E 8825[26200100]          	mov	[RTC_2Hz], ah ; 1 = 0.5 second, 0 = 1 second
  1056 00000734 7549                    	jnz	short rtc_int_return ; half second
  1057                                  	; 1 second
  1058                                  rtc_int_0:
  1059                                  	; 22/05/2016
  1060 00000736 58                      	pop	eax ; *
  1061                                  	;
  1062                                  	; 14/10/2015 ('timer_int')
  1063                                  	; Here, we are simulating system call entry (for task switch)
  1064                                  	; (If multitasking is enabled, 
  1065                                  	; 'clock' procedure may jump to 'sysrelease')
  1066                                  	;push	ds ; ** ; 23/05/2016
  1067 00000737 06                      	push	es
  1068 00000738 0FA0                    	push	fs
  1069 0000073A 0FA8                    	push	gs
  1070 0000073C 60                      	pushad  ; eax, ecx, edx, ebx, esp -before pushad-, ebp, esi, edi
  1071 0000073D 66B91000                	mov     cx, KDATA
  1072                                          ;mov    ds, cx ; 06/06/2016
  1073 00000741 8EC1                            mov     es, cx
  1074 00000743 8EE1                            mov     fs, cx
  1075 00000745 8EE9                            mov     gs, cx
  1076                                  	;
  1077 00000747 0F20D9                  	mov	ecx, cr3
  1078 0000074A 890D[483D0100]          	mov	[cr3reg], ecx ; save current cr3 register value/content
  1079                                  	;
  1080 00000750 3B0D[A81F0100]          	cmp 	ecx, [k_page_dir]
  1081 00000756 7420                    	je	short rtc_int_1
  1082                                  	;
  1083                                  	; timer interrupt has been occurred while OS is in user mode
  1084 00000758 FC                      	cld 	; 06/06/2016
  1085 00000759 A3[88300100]            	mov 	[u.r0], eax
  1086 0000075E 89E1                    	mov	ecx, esp
  1087 00000760 83C130                  	add	ecx, ESPACE ; 4 * 12 (stack frame)	
  1088 00000763 890D[80300100]          	mov	[u.sp], ecx ; kernel stack pointer at the start of interrupt
  1089 00000769 8925[84300100]          	mov	[u.usp], esp ; kernel stack points to user's registers   
  1090                                  	;
  1091 0000076F 8B0D[A81F0100]          	mov	ecx, [k_page_dir]
  1092 00000775 0F22D9                  	mov	cr3, ecx
  1093                                  
  1094                                  rtc_int_1:
  1095                                  	; Timer event (kernel) functions must be performed with
  1096                                  	; 1 second intervals - TRDOS 386 (TRDOS v2.0) feature ! -
  1097                                   	;	
  1098                                  	; 25/08/2014
  1099 00000778 E8DC020000              	call	rtc_p  ; 19/05/2016 - major modification 
  1100                                  	; 23/05/2016
  1101 0000077D 28E4                    	sub	ah, ah ; 0
  1102                                  	; 22/05/2016 - TRDOS 386 timer event modifications
  1103                                  rtc_int_return: ; 19/05/2016
  1104                                  	; 22/02/2015 - dsectpm.s
  1105                                  	; [ source: http://wiki.osdev.org/RTC ]
  1106                                  	; read status register C to complete procedure
  1107                                  	;(it is needed to get a next IRQ 8) 
  1108 0000077F B00C                    	mov	al, 0Ch ; 
  1109 00000781 E670                    	out	70h, al ; select register C
  1110 00000783 90                      	nop
  1111 00000784 E471                    	in	al, 71h ; just throw away contents
  1112                                  	; 22/02/2015
  1113 00000786 B020                    	MOV	AL,EOI		; END OF INTERRUPT
  1114                                  	;CLI			; DISABLE INTERRUPTS TILL STACK CLEARED
  1115 00000788 E6A0                    	OUT	INTB00,AL	; FOR CONTROLLER #2
  1116                                  
  1117                                  	; 23/05/2016
  1118 0000078A B020                    	MOV	AL,EOI		; GET END OF INTERRUPT MASK
  1119                                  	;CLI			; DISABLE INTERRUPTS TILL STACK CLEARED
  1120 0000078C E620                    	OUT	INTA00,AL	; END OF INTERRUPT TO 8259 - 1	
  1121                                  	;
  1122                                  	; 23/05/2016
  1123 0000078E 20E4                    	and	ah, ah
  1124 00000790 0F844EFFFFFF                    jz      rtc_int_2
  1125                                  	
  1126                                  	; ah = 1 (half second)
  1127 00000796 58                      	pop	eax ; *
  1128 00000797 1F                      	pop	ds  ; **
  1129 00000798 CF                      	iretd
  1130                                  
  1131                                  ; ////////////////
  1132                                  
  1133                                  	; 28/08/2014
  1134                                  irq0:
  1135 00000799 6A00                            push 	dword 0
  1136 0000079B EB48                    	jmp	short which_irq
  1137                                  irq1:
  1138 0000079D 6A01                            push 	dword 1
  1139 0000079F EB44                    	jmp	short which_irq
  1140                                  irq2:
  1141 000007A1 6A02                            push 	dword 2
  1142 000007A3 EB40                    	jmp	short which_irq
  1143                                  irq3:
  1144                                  	; 20/11/2015
  1145                                  	; 24/10/2015
  1146 000007A5 2EFF15[DDDD0000]        	call	dword [cs:com2_irq3]
  1147 000007AC 6A03                    	push 	dword 3
  1148 000007AE EB35                    	jmp	short which_irq
  1149                                  irq4:
  1150                                  	; 20/11/2015
  1151                                  	; 24/10/2015
  1152 000007B0 2EFF15[D9DD0000]        	call	dword [cs:com1_irq4]
  1153 000007B7 6A04                            push 	dword 4
  1154 000007B9 EB2A                    	jmp	short which_irq
  1155                                  irq5:
  1156 000007BB 6A05                            push 	dword 5
  1157 000007BD EB26                    	jmp	short which_irq
  1158                                  irq6:
  1159 000007BF 6A06                            push 	dword 6
  1160 000007C1 EB22                    	jmp	short which_irq
  1161                                  irq7:
  1162 000007C3 6A07                            push 	dword 7
  1163 000007C5 EB1E                    	jmp	short which_irq
  1164                                  irq8:
  1165 000007C7 6A08                            push 	dword 8
  1166 000007C9 EB1A                    	jmp	short which_irq
  1167                                  irq9:
  1168 000007CB 6A09                            push 	dword 9
  1169 000007CD EB16                    	jmp	short which_irq
  1170                                  irq10:
  1171 000007CF 6A0A                            push 	dword 10
  1172 000007D1 EB12                    	jmp	short which_irq
  1173                                  irq11:
  1174 000007D3 6A0B                            push 	dword 11
  1175 000007D5 EB0E                    	jmp	short which_irq
  1176                                  irq12:
  1177 000007D7 6A0C                            push 	dword 12
  1178 000007D9 EB0A                    	jmp	short which_irq
  1179                                  irq13:
  1180 000007DB 6A0D                            push 	dword 13
  1181 000007DD EB06                    	jmp	short which_irq
  1182                                  irq14:
  1183 000007DF 6A0E                            push 	dword 14
  1184 000007E1 EB02                    	jmp	short which_irq
  1185                                  irq15:
  1186 000007E3 6A0F                            push 	dword 15
  1187                                  	;jmp	short which_irq
  1188                                  
  1189                                  	; 19/10/2015
  1190                                  	; 29/08/2014
  1191                                  	; 21/08/2014
  1192                                  which_irq:
  1193 000007E5 870424                  	xchg	eax, [esp]  ; 28/08/2014
  1194 000007E8 53                      	push	ebx
  1195 000007E9 56                      	push	esi
  1196 000007EA 57                      	push	edi
  1197 000007EB 1E                      	push 	ds
  1198 000007EC 06                      	push 	es
  1199                                  	;
  1200 000007ED 88C3                    	mov	bl, al
  1201                                  	;
  1202 000007EF B810000000              	mov	eax, KDATA
  1203 000007F4 8ED8                    	mov	ds, ax
  1204 000007F6 8EC0                    	mov	es, ax
  1205                                  	; 19/10/2015
  1206 000007F8 FC                      	cld
  1207                                          ; 27/08/2014
  1208 000007F9 8105[52ED0000]A000-             add     dword [scr_row], 0A0h
  1208 00000801 0000               
  1209                                  	;
  1210 00000803 B417                    	mov	ah, 17h	; blue (1) background, 
  1211                                  			; light gray (7) forecolor
  1212 00000805 8B3D[52ED0000]                  mov     edi, [scr_row]
  1213 0000080B B049                    	mov	al, 'I'
  1214 0000080D 66AB                    	stosw
  1215 0000080F B052                    	mov	al, 'R'
  1216 00000811 66AB                    	stosw
  1217 00000813 B051                    	mov	al, 'Q'
  1218 00000815 66AB                    	stosw
  1219 00000817 B020                    	mov	al, ' '
  1220 00000819 66AB                    	stosw
  1221 0000081B 88D8                    	mov	al, bl
  1222 0000081D 3C0A                    	cmp	al, 10
  1223 0000081F 7208                    	jb	short iix
  1224 00000821 B031                    	mov	al, '1'
  1225 00000823 66AB                    	stosw
  1226 00000825 88D8                    	mov	al, bl
  1227 00000827 2C0A                    	sub	al, 10
  1228                                  iix:
  1229 00000829 0430                    	add	al, '0'
  1230 0000082B 66AB                    	stosw
  1231 0000082D B020                    	mov	al, ' '
  1232 0000082F 66AB                    	stosw
  1233 00000831 B021                    	mov	al, '!'
  1234 00000833 66AB                    	stosw
  1235 00000835 B020                    	mov	al, ' '
  1236 00000837 66AB                    	stosw
  1237                                  	; 23/02/2015
  1238 00000839 80FB07                  	cmp	bl, 7 ; check for IRQ 8 to IRQ 15 
  1239 0000083C 0F8695010000            	jna	iiret
  1240 00000842 B020                    	mov	al, 20h  ; END OF INTERRUPT COMMAND TO
  1241 00000844 E6A0                    	out	0A0h, al ; the 2nd 8259
  1242 00000846 E98C010000              	jmp     iiret
  1243                                  	;
  1244                                  	; 22/08/2014
  1245                                  	;mov	al, 20h ; END OF INTERRUPT COMMAND TO 8259
  1246                                  	;out	20h, al	; 8259 PORT
  1247                                  	;
  1248                                  	;pop	es
  1249                                  	;pop	ds
  1250                                  	;pop	edi
  1251                                  	;pop	esi
  1252                                  	;pop	ebx
  1253                                  	;pop 	eax
  1254                                  	;iret
  1255                                  
  1256                                  	; 02/04/2015
  1257                                  	; 25/08/2014
  1258                                  exc0:
  1259 0000084B 6A00                            push 	dword 0
  1260 0000084D E990000000                      jmp     cpu_except
  1261                                  exc1:
  1262 00000852 6A01                            push 	dword 1
  1263 00000854 E989000000                      jmp     cpu_except
  1264                                  exc2:
  1265 00000859 6A02                            push 	dword 2
  1266 0000085B E982000000                      jmp     cpu_except
  1267                                  exc3:
  1268 00000860 6A03                            push 	dword 3
  1269 00000862 EB7E                            jmp     cpu_except
  1270                                  exc4:
  1271 00000864 6A04                            push 	dword 4
  1272 00000866 EB7A                            jmp     cpu_except
  1273                                  exc5:
  1274 00000868 6A05                            push 	dword 5
  1275 0000086A EB76                            jmp     cpu_except
  1276                                  exc6:
  1277 0000086C 6A06                            push 	dword 6
  1278 0000086E EB72                            jmp     cpu_except
  1279                                  exc7:
  1280 00000870 6A07                            push 	dword 7
  1281 00000872 EB6E                            jmp     cpu_except
  1282                                  exc8:
  1283                                  	; [esp] = Error code
  1284 00000874 6A08                            push 	dword 8
  1285 00000876 EB5C                            jmp     cpu_except_en
  1286                                  exc9:
  1287 00000878 6A09                            push 	dword 9
  1288 0000087A EB66                            jmp     cpu_except
  1289                                  exc10:
  1290                                  	; [esp] = Error code
  1291 0000087C 6A0A                            push 	dword 10
  1292 0000087E EB54                            jmp     cpu_except_en
  1293                                  exc11:
  1294                                  	; [esp] = Error code
  1295 00000880 6A0B                            push 	dword 11
  1296 00000882 EB50                            jmp     cpu_except_en
  1297                                  exc12:
  1298                                  	; [esp] = Error code
  1299 00000884 6A0C                            push 	dword 12
  1300 00000886 EB4C                            jmp     cpu_except_en
  1301                                  exc13:
  1302                                  	; [esp] = Error code
  1303 00000888 6A0D                            push 	dword 13
  1304 0000088A EB48                            jmp     cpu_except_en
  1305                                  exc14:
  1306                                  	; [esp] = Error code
  1307 0000088C 6A0E                            push 	dword 14
  1308 0000088E EB44                    	jmp	short cpu_except_en
  1309                                  exc15:
  1310 00000890 6A0F                            push 	dword 15
  1311 00000892 EB4E                            jmp     cpu_except
  1312                                  exc16:
  1313 00000894 6A10                            push 	dword 16
  1314 00000896 EB4A                            jmp     cpu_except
  1315                                  exc17:
  1316                                  	; [esp] = Error code
  1317 00000898 6A11                            push 	dword 17
  1318 0000089A EB38                    	jmp	short cpu_except_en
  1319                                  exc18:
  1320 0000089C 6A12                            push 	dword 18
  1321 0000089E EB42                    	jmp	short cpu_except
  1322                                  exc19:
  1323 000008A0 6A13                            push 	dword 19
  1324 000008A2 EB3E                    	jmp	short cpu_except
  1325                                  exc20:
  1326 000008A4 6A14                            push 	dword 20
  1327 000008A6 EB3A                    	jmp	short cpu_except
  1328                                  exc21:
  1329 000008A8 6A15                            push 	dword 21
  1330 000008AA EB36                    	jmp	short cpu_except
  1331                                  exc22:
  1332 000008AC 6A16                            push 	dword 22
  1333 000008AE EB32                    	jmp	short cpu_except
  1334                                  exc23:
  1335 000008B0 6A17                            push 	dword 23
  1336 000008B2 EB2E                    	jmp	short cpu_except
  1337                                  exc24:
  1338 000008B4 6A18                            push 	dword 24
  1339 000008B6 EB2A                    	jmp	short cpu_except
  1340                                  exc25:
  1341 000008B8 6A19                            push 	dword 25
  1342 000008BA EB26                    	jmp	short cpu_except
  1343                                  exc26:
  1344 000008BC 6A1A                            push 	dword 26
  1345 000008BE EB22                    	jmp	short cpu_except
  1346                                  exc27:
  1347 000008C0 6A1B                            push 	dword 27
  1348 000008C2 EB1E                    	jmp	short cpu_except
  1349                                  exc28:
  1350 000008C4 6A1C                            push 	dword 28
  1351 000008C6 EB1A                    	jmp	short cpu_except
  1352                                  exc29:
  1353 000008C8 6A1D                            push 	dword 29
  1354 000008CA EB16                    	jmp	short cpu_except
  1355                                  exc30:
  1356 000008CC 6A1E                            push 	dword 30
  1357 000008CE EB04                    	jmp	short cpu_except_en
  1358                                  exc31:
  1359 000008D0 6A1F                            push 	dword 31
  1360 000008D2 EB0E                            jmp     short cpu_except
  1361                                  
  1362                                  	; 19/10/2015
  1363                                  	; 19/09/2015
  1364                                  	; 01/09/2015
  1365                                  	; 28/08/2015
  1366                                  	; 28/08/2014
  1367                                  cpu_except_en:
  1368 000008D4 87442404                	xchg	eax, [esp+4] ; Error code
  1369 000008D8 36A3[643E0100]          	mov	[ss:error_code], eax
  1370 000008DE 58                      	pop	eax  ; Exception number
  1371 000008DF 870424                  	xchg	eax, [esp]
  1372                                  		; eax = eax before exception
  1373                                  		; [esp] -> exception number
  1374                                  		; [esp+4] -> EIP to return
  1375                                  	; 19/10/2015
  1376                                  	; 19/09/2015
  1377                                  	; 01/09/2015
  1378                                  	; 28/08/2015
  1379                                  	; 29/08/2014
  1380                                  	; 28/08/2014
  1381                                  	; 25/08/2014
  1382                                  	; 21/08/2014
  1383                                  cpu_except:	; CPU Exceptions
  1384 000008E2 FC                      	cld
  1385 000008E3 870424                  	xchg	eax, [esp] 
  1386                                  		; eax = Exception number
  1387                                  		; [esp] = eax (before exception)	
  1388 000008E6 53                      	push	ebx
  1389 000008E7 56                      	push	esi
  1390 000008E8 57                      	push	edi
  1391 000008E9 1E                      	push 	ds
  1392 000008EA 06                      	push 	es
  1393                                  	; 28/08/2015
  1394 000008EB 66BB1000                	mov	bx, KDATA
  1395 000008EF 8EDB                    	mov	ds, bx
  1396 000008F1 8EC3                    	mov	es, bx
  1397 000008F3 0F20DB                  	mov	ebx, cr3
  1398 000008F6 53                      	push	ebx ; (*) page directory
  1399                                  	; 19/10/2015
  1400 000008F7 FC                      	cld
  1401                                  	; 25/03/2015
  1402 000008F8 8B1D[A81F0100]          	mov	ebx, [k_page_dir]
  1403 000008FE 0F22DB                  	mov	cr3, ebx
  1404                                  	; 28/08/2015
  1405 00000901 83F80E                  	cmp	eax, 0Eh ; 14, PAGE FAULT	
  1406 00000904 7512                    	jne	short cpu_except_nfp
  1407 00000906 E88F3F0000              	call	page_fault_handler
  1408 0000090B 21C0                    	and 	eax, eax
  1409 0000090D 0F84C0000000                    jz	iiretp ; 01/09/2015
  1410 00000913 B80E000000              	mov	eax, 0Eh ; 14
  1411                                  cpu_except_nfp:
  1412                                  	; 02/04/2015
  1413 00000918 BB[F7050000]            	mov	ebx, hang
  1414 0000091D 875C241C                	xchg	ebx, [esp+28]
  1415                                  		; EIP (points to instruction which faults)
  1416                                  	  	; New EIP (hang)
  1417 00000921 891D[683E0100]          	mov	[FaultOffset], ebx
  1418 00000927 C744242008000000        	mov	dword [esp+32], KCODE ; kernel's code segment
  1419 0000092F 814C242400020000        	or	dword [esp+36], 200h ; enable interrupts (set IF)
  1420                                  	;
  1421 00000937 88C4                    	mov	ah, al
  1422 00000939 240F                    	and	al, 0Fh
  1423 0000093B 3C09                    	cmp	al, 9
  1424 0000093D 7602                    	jna	short h1ok
  1425 0000093F 0407                    	add	al, 'A'-':'
  1426                                  h1ok:
  1427 00000941 D0EC                    	shr	ah, 1
  1428 00000943 D0EC                    	shr	ah, 1
  1429 00000945 D0EC                    	shr	ah, 1
  1430 00000947 D0EC                    	shr	ah, 1
  1431 00000949 80FC09                  	cmp	ah, 9
  1432 0000094C 7603                    	jna	short h2ok
  1433 0000094E 80C407                  	add	ah, 'A'-':'
  1434                                  h2ok:	
  1435 00000951 86E0                    	xchg 	ah, al	
  1436 00000953 66053030                	add	ax, '00'
  1437 00000957 66A3[80ED0000]          	mov	[excnstr], ax
  1438                                  	;
  1439                                  	; 29/08/2014
  1440 0000095D A1[683E0100]            	mov	eax, [FaultOffset]
  1441 00000962 51                      	push	ecx
  1442 00000963 52                      	push	edx
  1443 00000964 89E3                    	mov	ebx, esp
  1444                                  	; 28/08/2015
  1445 00000966 B910000000              	mov	ecx, 16	  ; divisor value to convert binary number
  1446                                  			  ; to hexadecimal string
  1447                                  	;mov	ecx, 10	    ; divisor to convert	
  1448                                  			    ; binary number to decimal string
  1449                                  b2d1:
  1450 0000096B 31D2                    	xor	edx, edx
  1451 0000096D F7F1                    	div	ecx
  1452 0000096F 6652                    	push	dx
  1453 00000971 39C8                    	cmp	eax, ecx
  1454 00000973 73F6                    	jnb	short b2d1
  1455 00000975 BF[8BED0000]            	mov	edi, EIPstr ; EIP value
  1456                                  			    ; points to instruction which faults	
  1457                                  	; 28/08/2015
  1458 0000097A 89C2                    	mov	edx, eax
  1459                                  b2d2:
  1460                                  	;add	al, '0'
  1461 0000097C 8A82[662D0000]          	mov	al, [edx+hexchrs]
  1462 00000982 AA                      	stosb		    ; write hexadecimal digit to its place	
  1463 00000983 39E3                    	cmp	ebx, esp
  1464 00000985 7606                    	jna	short b2d3
  1465 00000987 6658                    	pop	ax
  1466 00000989 88C2                    	mov	dl, al
  1467 0000098B EBEF                    	jmp	short b2d2
  1468                                  b2d3:
  1469 0000098D B068                    	mov 	al, 'h' ; 28/08/2015
  1470 0000098F AA                      	stosb
  1471 00000990 B020                    	mov	al, 20h	    ; space
  1472 00000992 AA                      	stosb
  1473 00000993 30C0                    	xor	al, al	    ; to do it an ASCIIZ string	
  1474 00000995 AA                      	stosb
  1475                                  	;
  1476 00000996 5A                      	pop	edx
  1477 00000997 59                      	pop	ecx
  1478                                  	;
  1479 00000998 B44F                    	mov	ah, 4Fh	; red (4) background, 
  1480                                  			; white (F) forecolor
  1481 0000099A BE[70ED0000]            	mov	esi, exc_msg ; message offset
  1482                                  	;
  1483 0000099F EB19                    	jmp	short piemsg
  1484                                  	;
  1485                                          ;add    dword [scr_row], 0A0h
  1486                                          ;mov    edi, [scr_row]
  1487                                          ;
  1488                                  	;call 	printk
  1489                                  	;
  1490                                  	;mov	al, 20h ; END OF INTERRUPT COMMAND TO 8259
  1491                                  	;out	20h, al	; 8259 PORT
  1492                                  	;
  1493                                  	;pop	es
  1494                                  	;pop	ds
  1495                                  	;pop	edi
  1496                                  	;pop	esi
  1497                                  	;pop 	eax
  1498                                  	;iret
  1499                                  	
  1500                                  	; 18/04/2016
  1501                                  	; 28/08/2015
  1502                                  	; 23/02/2015
  1503                                  	; 20/08/2014
  1504                                  ignore_int:
  1505 000009A1 50                      	push	eax
  1506 000009A2 53                      	push	ebx ; 23/02/2015
  1507 000009A3 56                      	push	esi
  1508 000009A4 57                      	push	edi
  1509 000009A5 1E                      	push 	ds
  1510 000009A6 06                      	push 	es
  1511                                  	; 18/04/2016
  1512 000009A7 66B81000                	mov	ax, KDATA
  1513 000009AB 8ED8                    	mov	ds, ax
  1514 000009AD 8EC0                    	mov	es, ax
  1515                                  	; 28/08/2015
  1516 000009AF 0F20D8                  	mov	eax, cr3
  1517 000009B2 50                      	push	eax ; (*) page directory
  1518                                  	;
  1519 000009B3 B467                    	mov	ah, 67h	; brown (6) background, 
  1520                                  			; light gray (7) forecolor
  1521 000009B5 BE[5AED0000]            	mov	esi, int_msg ; message offset
  1522                                  piemsg:
  1523                                          ; 27/08/2014
  1524 000009BA 8105[52ED0000]A000-             add     dword [scr_row], 0A0h
  1524 000009C2 0000               
  1525 000009C4 8B3D[52ED0000]                  mov     edi, [scr_row]
  1526                                          ;
  1527 000009CA E867FCFFFF              	call 	printk
  1528                                  	;
  1529                                  	; 23/02/2015
  1530 000009CF B020                    	mov	al, 20h  ; END OF INTERRUPT COMMAND TO
  1531 000009D1 E6A0                    	out	0A0h, al ; the 2nd 8259
  1532                                  iiretp: ; 01/09/2015
  1533                                  	; 28/08/2015
  1534 000009D3 58                      	pop	eax ; (*) page directory
  1535 000009D4 0F22D8                  	mov	cr3, eax
  1536                                  	;
  1537                                  iiret:
  1538                                  	; 22/08/2014
  1539 000009D7 B020                    	mov	al, 20h ; END OF INTERRUPT COMMAND TO 8259
  1540 000009D9 E620                    	out	20h, al	; 8259 PORT
  1541                                  	;
  1542 000009DB 07                      	pop	es
  1543 000009DC 1F                      	pop	ds
  1544 000009DD 5F                      	pop	edi
  1545 000009DE 5E                      	pop	esi
  1546 000009DF 5B                      	pop	ebx ; 29/08/2014
  1547 000009E0 58                      	pop 	eax
  1548 000009E1 CF                      	iretd
  1549                                  
  1550                                  	; 23/05/2016
  1551                                  	; 22/08/2014
  1552                                  	; IBM PC/AT BIOS source code ----- 10/06/85 (bios.asm)
  1553                                  	; (INT 1Ah)
  1554                                  	;; Linux (v0.12) source code (main.c) by Linus Torvalds (1991)
  1555                                  time_of_day:
  1556 000009E2 E8F4490000              	call	UPD_IPR			; WAIT TILL UPDATE NOT IN PROGRESS
  1557 000009E7 726F                            jc      short time_of_day_retn ; 23/05/2016
  1558 000009E9 B000                    	mov	al, CMOS_SECONDS
  1559 000009EB E8064A0000              	call	CMOS_READ
  1560 000009F0 A2[18200100]            	mov	[time_seconds], al 
  1561 000009F5 B002                    	mov	al, CMOS_MINUTES
  1562 000009F7 E8FA490000              	call	CMOS_READ
  1563 000009FC A2[19200100]            	mov	[time_minutes], al 
  1564 00000A01 B004                    	mov	al, CMOS_HOURS
  1565 00000A03 E8EE490000              	call	CMOS_READ
  1566 00000A08 A2[1A200100]                    mov     [time_hours], al
  1567 00000A0D B006                    	mov	al, CMOS_DAY_WEEK 
  1568 00000A0F E8E2490000              	call	CMOS_READ
  1569 00000A14 A2[1B200100]            	mov	[date_wday], al
  1570 00000A19 B007                     	mov	al, CMOS_DAY_MONTH
  1571 00000A1B E8D6490000              	call	CMOS_READ
  1572 00000A20 A2[1C200100]            	mov	[date_day], al
  1573 00000A25 B008                    	mov	al, CMOS_MONTH
  1574 00000A27 E8CA490000              	call	CMOS_READ
  1575 00000A2C A2[1D200100]            	mov	[date_month], al
  1576 00000A31 B009                    	mov	al, CMOS_YEAR
  1577 00000A33 E8BE490000              	call	CMOS_READ
  1578 00000A38 A2[1E200100]            	mov	[date_year], al
  1579 00000A3D B032                    	mov	al, CMOS_CENTURY
  1580 00000A3F E8B2490000              	call	CMOS_READ
  1581 00000A44 A2[1F200100]            	mov	[date_century], al
  1582                                  	;
  1583 00000A49 B000                    	mov	al, CMOS_SECONDS
  1584 00000A4B E8A6490000              	call 	CMOS_READ
  1585 00000A50 3A05[18200100]          	cmp	al, [time_seconds]
  1586 00000A56 758A                    	jne	short time_of_day
  1587                                  
  1588                                  time_of_day_retn:
  1589 00000A58 C3                      	retn
  1590                                  
  1591                                  	; 10/06/2016
  1592                                  	; 07/06/2016
  1593                                  	; 06/06/2016
  1594                                  	; 23/05/2016
  1595                                  u_timer: 
  1596                                  	; Timer Events with 18.2 Hz Timer Ticks
  1597                                  	; (and also timer events with RTC seconds)
  1598                                  rtc_p:
  1599                                  	; 19/05/2016 - TRDOS 386 (TRDOS v2.0)
  1600                                  	; Major Modification:
  1601                                  	; Check and Perform Timer Events (for RTC)
  1602                                  	; 25/08/2014 - 07/09/2014
  1603                                  	; Retro UNIX 386 v1:
  1604                                   	; Print Real Time Clock content
  1605                                  	
  1606 00000A59 803D[2F2D0100]00        	cmp	byte [timer_events], 0 ; 07/06/2016
  1607 00000A60 7649                    	jna	short rtc_p5
  1608                                  
  1609 00000A62 8A0D[2F2D0100]          	mov	cl, [timer_events]
  1610                                  
  1611 00000A68 BE[4C3D0100]            	mov	esi, timer_set  ; beginning address of
  1612                                  				; timer events space
  1613                                  rtc_p0:
  1614 00000A6D 8B06                    	mov	eax, [esi]	
  1615 00000A6F 20C0                    	and	al, al ; 0 = free, >0 = process ID
  1616 00000A71 7413                    	jz	short rtc_p2
  1617                                  	;
  1618 00000A73 C1C810                  	ror	eax, 16
  1619                                  	; ah = response value, al = interrupt type
  1620 00000A76 3C01                    	cmp	al, 1 ; RTC interrupt ?
  1621 00000A78 7411                    	je	short rtc_p3 ; yes, check for response
  1622                                  	; 06/06/2016 - 18.2 Hz Timer Ticks
  1623 00000A7A 7706                    	ja	short rtc_p1 ; undefined ! ; 10/06/2016
  1624 00000A7C 836E080A                	sub	dword [esi+8], 10 ; 1 tick = 10
  1625 00000A80 7612                    	jna	short rtc_p4  ; continue for responding
  1626                                  rtc_p1:
  1627                                  	; 07/06/2016
  1628 00000A82 FEC9                    	dec	cl    ; remain count of timer events	
  1629 00000A84 7425                    	jz	short rtc_p5 
  1630                                  rtc_p2:	
  1631                                  	;cmp	esi, timer_set + 240 ; 15*16 (last event)
  1632                                  	;jnb	short rtc_p5 ; end of timer event space
  1633 00000A86 83C610                  	add	esi, 16 ; next timer event
  1634 00000A89 EBE2                    	jmp	short rtc_p0
  1635                                  rtc_p3:	 
  1636                                  	; current timer count ; 06/06/2016 (182)
  1637 00000A8B 816E08B6000000          	sub	dword [esi+8], 182 ; 1 second (10*18.2)
  1638 00000A92 77EE                    	ja	short rtc_p1  ; check for the next 
  1639                                  rtc_p4:	
  1640                                  	; it is the time of response! 
  1641 00000A94 8B5E04                  	mov	ebx, [esi+4] ; set (count limit) value
  1642 00000A97 895E08                  	mov	[esi+8], ebx ; reset count down value
  1643                                  			     ; to count limit
  1644                                  	; response address is physical address of
  1645                                  	; the program's response (signal return) byte
  1646                                  	; 06/06/2016
  1647 00000A9A 8B7E0C                  	mov	edi, [esi+12] ; response address
  1648 00000A9D 8827                    	mov	[edi], ah     ; response value 
  1649                                  	;
  1650 00000A9F C1C010                  	rol	eax, 16
  1651                                  	; al = process number  ; 10/06/2016
  1652 00000AA2 B202                    	mov	dl, 2 ; priority, 2 = event (high)	
  1653 00000AA4 E862D00000              	call	set_run_sequence ; 19/05/2016
  1654 00000AA9 EBD7                    	jmp	short rtc_p1 ; 10/06/2016
  1655                                  rtc_p5:	 
  1656 00000AAB C3                      	retn
  1657                                  
  1658                                  ; Default IRQ 7 handler against spurious IRQs (from master PIC)
  1659                                  ; 25/02/2015 (source: http://wiki.osdev.org/8259_PIC)
  1660                                  default_irq7:
  1661 00000AAC 6650                    	push	ax
  1662 00000AAE B00B                    	mov	al, 0Bh  ; In-Service register
  1663 00000AB0 E620                    	out	20h, al
  1664 00000AB2 EB00                            jmp short $+2
  1665 00000AB4 EB00                    	jmp short $+2
  1666 00000AB6 E420                    	in	al, 20h
  1667 00000AB8 2480                    	and 	al, 80h ; bit 7 (is it real IRQ 7 or fake?)
  1668 00000ABA 7404                            jz      short irq7_iret ; Fake (spurious) IRQ, do not send EOI 
  1669 00000ABC B020                            mov     al, 20h ; EOI
  1670 00000ABE E620                    	out	20h, al 
  1671                                  irq7_iret:
  1672 00000AC0 6658                    	pop	ax
  1673 00000AC2 CF                      	iretd
  1674                                  	
  1675                                  bcd_to_ascii:
  1676                                  	; 25/08/2014
  1677                                  	; INPUT ->
  1678                                  	;	al = Packed BCD number
  1679                                  	; OUTPUT ->
  1680                                  	;	ax  = ASCII word/number
  1681                                  	;
  1682                                  	; Erdogan Tan - 1998 (proc_hex) - TRDOS.ASM (2004-2011)
  1683                                  	;
  1684 00000AC3 D410                    	db 0D4h,10h                     ; Undocumented inst. AAM
  1685                                  					; AH = AL / 10h
  1686                                  					; AL = AL MOD 10h
  1687 00000AC5 660D3030                	or ax,'00'                      ; Make it ASCII based
  1688                                  
  1689 00000AC9 86E0                            xchg ah, al 
  1690                                  	
  1691 00000ACB C3                      	retn	
  1692                                  	
  1693                                  
  1694                                  %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: 29/05/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> ; 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 00000ACC 9C                  <1> 	pushfd	; 28/08/2014
    40 00000ACD 0E                  <1> 	push 	cs
    41 00000ACE E801000000          <1> 	call 	KEYBOARD_IO_1 ; getc_int
    42 00000AD3 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> ; 29/05/2016
   136                              <1> ; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
   137                              <1> int32h:  ; Keyboard BIOS
   138                              <1> 
   139                              <1> KEYBOARD_IO_1:	
   140 00000AD4 FB                  <1> 	sti				; INTERRUPTS BACK ON
   141                              <1> 	; 29/05/2016
   142 00000AD5 80642408BE          <1>         and     byte [esp+8], 10111110b ; clear zero flag and cary flag
   143                              <1> 	;
   144 00000ADA 1E                  <1> 	push	ds			; SAVE CURRENT DS
   145 00000ADB 53                  <1> 	push	ebx			; SAVE BX TEMPORARILY
   146                              <1> 	;push	ecx			; SAVE CX TEMPORARILY
   147 00000ADC 66BB1000            <1>         mov     bx, KDATA 
   148 00000AE0 8EDB                <1> 	mov	ds, bx			; PUT SEGMENT VALUE OF DATA AREA INTO DS
   149 00000AE2 08E4                <1> 	or	ah, ah			; CHECK FOR (AH)= 00H
   150 00000AE4 7439                <1> 	jz	short _K1		; ASCII_READ
   151 00000AE6 FECC                <1> 	dec	ah                      ; CHECK FOR (AH)= 01H
   152 00000AE8 7452                <1>         jz      short _K2               ; ASCII_STATUS
   153 00000AEA FECC                <1> 	dec	ah			; CHECK FOR (AH)= 02H
   154 00000AEC 0F8492000000        <1>         jz      _K3                     ; SHIFT STATUS
   155 00000AF2 FECC                <1> 	dec	ah			; CHECK FOR (AH)= 03H	
   156 00000AF4 0F8491000000        <1>         jz      _K300                   ; SET TYPAMATIC RATE/DELAY
   157 00000AFA 80EC02              <1> 	sub	ah, 2			; CHECK FOR (AH)= 05H	
   158 00000AFD 0F84B6000000        <1>         jz      _K500                   ; KEYBOARD WRITE         
   159                              <1> _KIO1:	
   160 00000B03 80EC0B              <1> 	sub	ah, 11			; AH =  10H
   161 00000B06 740B                <1> 	jz	short _K1E		; EXTENDED ASCII READ
   162 00000B08 FECC                <1> 	dec	ah			; CHECK FOR (AH)= 11H
   163 00000B0A 7421                <1> 	jz	short _K2E		; EXTENDED_ASCII_STATUS
   164 00000B0C FECC                <1> 	dec	ah			; CHECK FOR (AH)= 12H
   165 00000B0E 7456                <1> 	jz	short _K3E		; EXTENDED_SHIFT_STATUS
   166                              <1> _KIO_EXIT:
   167                              <1> 	;pop	ecx			; RECOVER REGISTER
   168 00000B10 5B                  <1> 	pop	ebx			; RECOVER REGISTER
   169 00000B11 1F                  <1> 	pop	ds			; RECOVER SEGMENT
   170 00000B12 CF                  <1> 	iretd				; INVALID COMMAND, EXIT
   171                              <1> 
   172                              <1> 	;-----	ASCII CHARACTER
   173                              <1> _K1E:	
   174 00000B13 E8CE000000          <1> 	call	_K1S			; GET A CHARACTER FROM THE BUFFER (EXTENDED)
   175 00000B18 E843010000          <1> 	call	_KIO_E_XLAT		; ROUTINE TO XLATE FOR EXTENDED CALLS
   176 00000B1D EBF1                <1> 	jmp	short _KIO_EXIT         ; GIVE IT TO THE CALLER
   177                              <1> _K1:	
   178 00000B1F E8C2000000          <1> 	call	_K1S			; GET A CHARACTER FROM THE BUFFER
   179 00000B24 E842010000          <1> 	call	_KIO_S_XLAT		; ROUTINE TO XLATE FOR STANDARD CALLS
   180 00000B29 72F4                <1> 	jc	short _K1		; CARRY SET MEANS TROW CODE AWAY
   181                              <1> _K1A:
   182 00000B2B EBE3                <1> 	jmp	short _KIO_EXIT         ; RETURN TO CALLER
   183                              <1> 
   184                              <1> 	;-----	ASCII STATUS
   185                              <1> _K2E:	
   186 00000B2D E8FF000000          <1> 	call	_K2S			; TEST FOR CHARACTER IN BUFFER (EXTENDED)
   187 00000B32 7420                <1> 	jz	short _K2B		; RETURN IF BUFFER EMPTY
   188 00000B34 9C                  <1> 	pushf				; SAVE ZF FROM TEST
   189 00000B35 E826010000          <1> 	call	_KIO_E_XLAT		; ROUTINE TO XLATE FOR EXTENDED CALLS
   190 00000B3A EB17                <1> 	jmp	short _K2A	        ; GIVE IT TO THE CALLER
   191                              <1> _K2:	
   192 00000B3C E8F0000000          <1> 	call	_K2S			; TEST FOR CHARACTER IN BUFFER
   193 00000B41 7411                <1> 	jz	short _K2B		; RETURN IF BUFFER EMPTY
   194 00000B43 9C                  <1> 	pushf				; SAVE ZF FROM TEST
   195 00000B44 E822010000          <1> 	call	_KIO_S_XLAT		; ROUTINE TO XLATE FOR STANDARD CALLS
   196 00000B49 7308                <1> 	jnc	short _K2A	        ; CARRY CLEAR MEANS PASS VALID CODE
   197 00000B4B 9D                  <1> 	popf				; INVALID CODE FOR THIS TYPE OF CALL
   198 00000B4C E895000000          <1> 	call	_K1S			; THROW THE CHARACTER AWAY
   199 00000B51 EBE9                <1> 	jmp	short _K2		; GO LOOK FOR NEXT CHAR, IF ANY
   200                              <1> _K2A:
   201 00000B53 9D                  <1> 	popf				; RESTORE ZF FROM TEST
   202                              <1> _K2B:
   203                              <1> 	;pop	ecx			; RECOVER REGISTER
   204 00000B54 5B                  <1> 	pop	ebx			; RECOVER REGISTER
   205 00000B55 1F                  <1> 	pop	ds			; RECOVER SEGMENT
   206                              <1> 	; (*) 29/05/2016
   207                              <1> 	; (*) retf 4			; THROW AWAY (e)FLAGS
   208 00000B56 7208                <1> 	jc	short _k2d
   209 00000B58 7505                <1> 	jnz	short _k2c
   210 00000B5A 804C240840          <1> 	or	byte [esp+8], 01000000b	; set zero flag bit of eflags register
   211                              <1> _k2c:
   212 00000B5F CF                  <1> 	iretd
   213                              <1> _k2d:
   214                              <1> 	; 29/05/2016 -set carry flag on stack-
   215                              <1> 	; [esp] = EIP
   216                              <1> 	; [esp+4] = CS
   217                              <1> 	; [esp+8] = E-FLAGS
   218 00000B60 804C240801          <1> 	or	byte [esp+8], 1  ; set carry bit of eflags register
   219                              <1> 	; [esp+12] = ESP (user)
   220                              <1> 	; [esp+16] = SS (User)
   221 00000B65 CF                  <1> 	iretd
   222                              <1> 
   223                              <1> 	
   224                              <1> 	; (*) 29/05/2016 - 'ref 4' intruction causes to stack fault
   225                              <1> 	; (OUTER-PRIVILEGE-LEVEL)
   226                              <1> 	; INTEL 80386 PROGRAMMER'S REFERENCE MANUAL 1986
   227                              <1> 	; // RETF instruction:
   228                              <1> 	;
   229                              <1> 	; IF OperandMode=32 THEN
   230                              <1>  	;    Load CS:EIP from stack;
   231                              <1>  	;    Set CS RPL to CPL;
   232                              <1>  	;    Increment eSP by 8 plus the immediate offset if it exists;
   233                              <1>  	;    Load SS:eSP from stack;
   234                              <1>  	; ELSE (* OperandMode=16 *)
   235                              <1>  	;    Load CS:IP from stack;
   236                              <1>  	;    Set CS RPL to CPL;
   237                              <1>  	;    Increment eSP by 4 plus the immediate offset if it exists;
   238                              <1> 	;    Load SS:eSP from stack;
   239                              <1>  	; FI;
   240                              <1> 	;
   241                              <1> 	; //
   242                              <1> 
   243                              <1> 	;-----	SHIFT STATUS
   244                              <1> _K3E:                                   ; GET THE EXTENDED SHIFT STATUS FLAGS
   245 00000B66 8A25[B2E80000]      <1> 	mov	ah, [KB_FLAG_1]		; GET SYSTEM SHIFT KEY STATUS
   246 00000B6C 80E404              <1> 	and	ah, SYS_SHIFT		; MASK ALL BUT SYS KEY BIT
   247                              <1> 	;mov	cl, 5			; SHIFT THEW SYSTEMKEY BIT OVER TO
   248                              <1> 	;shl	ah, cl			; BIT 7 POSITION
   249 00000B6F C0E405              <1>         shl	ah, 5
   250 00000B72 A0[B2E80000]        <1> 	mov	al, [KB_FLAG_1]		; GET SYSTEM SHIFT STATES BACK
   251 00000B77 2473                <1> 	and	al, 01110011b		; ELIMINATE SYS SHIFT, HOLD_STATE AND INS_SHIFT
   252 00000B79 08C4                <1> 	or	ah, al                  ; MERGE REMAINING BITS INTO AH
   253 00000B7B A0[B4E80000]        <1> 	mov	al, [KB_FLAG_3]		; GET RIGHT CTL AND ALT
   254 00000B80 240C                <1> 	and	al, 00001100b		; ELIMINATE LC_E0 AND LC_E1
   255 00000B82 08C4                <1> 	or	ah, al			; OR THE SHIFT FLAGS TOGETHER
   256                              <1> _K3:
   257 00000B84 A0[B1E80000]        <1> 	mov	al, [KB_FLAG]		; GET THE SHIFT STATUS FLAGS
   258 00000B89 EB85                <1> 	jmp	short _KIO_EXIT		; RETURN TO CALLER
   259                              <1> 
   260                              <1> 	;-----	SET TYPAMATIC RATE AND DELAY
   261                              <1> _K300:
   262 00000B8B 3C05                <1> 	cmp	al, 5			; CORRECT FUNCTION CALL?
   263 00000B8D 7581                <1> 	jne	short _KIO_EXIT		; NO, RETURN
   264 00000B8F F6C3E0              <1>      	test	bl, 0E0h		; TEST FOR OUT-OF-RANGE RATE
   265 00000B92 0F8578FFFFFF        <1>         jnz     _KIO_EXIT               ; RETURN IF SO
   266 00000B98 F6C7FC              <1> 	test	BH, 0FCh		; TEST FOR OUT-OF-RANGE DELAY
   267 00000B9B 0F856FFFFFFF        <1>         jnz     _KIO_EXIT               ; RETURN IF SO
   268 00000BA1 B0F3                <1> 	mov	al, KB_TYPA_RD		; COMMAND FOR TYPAMATIC RATE/DELAY		
   269 00000BA3 E8DA060000          <1> 	call	SND_DATA		; SEND TO KEYBOARD	
   270                              <1> 	;mov	cx, 5			; SHIFT COUNT
   271                              <1> 	;shl	bh, cl			; SHIFT DELAY OVER
   272 00000BA8 C0E705              <1> 	shl	bh, 5
   273 00000BAB 88D8                <1> 	mov	al, bl			; PUT IN RATE
   274 00000BAD 08F8                <1> 	or	al, bh			; AND DELAY
   275 00000BAF E8CE060000          <1> 	call	SND_DATA		; SEND TO KEYBOARD	
   276 00000BB4 E957FFFFFF          <1>         jmp     _KIO_EXIT               ; RETURN TO CALLER
   277                              <1> 
   278                              <1> 	;-----	WRITE TO KEYBOARD BUFFER
   279                              <1> _K500:
   280 00000BB9 56                  <1> 	push	esi			; SAVE SI (esi)
   281 00000BBA FA                  <1> 	cli				; 
   282 00000BBB 8B1D[C2E80000]      <1>      	mov	ebx, [BUFFER_TAIL]	; GET THE 'IN TO' POINTER TO THE BUFFER
   283 00000BC1 89DE                <1> 	mov	esi, ebx		; SAVE A COPY IN CASE BUFFER NOT FULL
   284 00000BC3 E8D3000000          <1> 	call	_K4			; BUMP THE POINTER TO SEE IF BUFFER IS FULL
   285 00000BC8 3B1D[BEE80000]      <1> 	cmp	ebx, [BUFFER_HEAD]	; WILL THE BUFFER OVERRUN IF WE STORE THIS?
   286 00000BCE 740D                <1> 	je	short _K502		; YES - INFORM CALLER OF ERROR		
   287 00000BD0 66890E              <1> 	mov	[esi], cx		; NO - PUT ASCII/SCAN CODE INTO BUFFER	
   288 00000BD3 891D[C2E80000]      <1> 	mov	[BUFFER_TAIL], ebx	; ADJUST 'IN TO' POINTER TO REFLECT CHANGE
   289 00000BD9 28C0                <1> 	sub	al, al			; TELL CALLER THAT OPERATION WAS SUCCESSFUL
   290 00000BDB EB02                <1> 	jmp	short _K504		; SUB INSTRUCTION ALSO RESETS CARRY FLAG
   291                              <1> _K502:
   292 00000BDD B001                <1> 	mov	al, 01h			; BUFFER FULL INDICATION
   293                              <1> _K504:
   294 00000BDF FB                  <1> 	sti				
   295 00000BE0 5E                  <1> 	pop	esi			; RECOVER SI (esi)
   296 00000BE1 E92AFFFFFF          <1>         jmp     _KIO_EXIT               ; RETURN TO CALLER WITH STATUS IN AL
   297                              <1> 
   298                              <1> 	;-----	READ THE KEY TO FIGURE OUT WHAT TO DO -----
   299                              <1> _K1S:
   300 00000BE6 FA                  <1> 	cli	; 03/12/2014
   301 00000BE7 8B1D[BEE80000]      <1>         mov     ebx, [BUFFER_HEAD] 	; GET POINTER TO HEAD OF BUFFER
   302 00000BED 3B1D[C2E80000]      <1>         cmp     ebx, [BUFFER_TAIL] 	; TEST END OF BUFFER
   303                              <1> 	;jne	short _K1U		; IF ANYTHING IN BUFFER SKIP INTERRUPT
   304 00000BF3 750F                <1> 	jne	short _k1x ; 03/12/2014
   305                              <1> 	;
   306                              <1> 	; 03/12/2014
   307                              <1> 	; 28/08/2014
   308                              <1> 	; PERFORM OTHER FUNCTION ?? here !
   309                              <1> 	;; MOV	AX, 9002h		; MOVE IN WAIT CODE & TYPE
   310                              <1> 	;; INT 	15H			; PERFORM OTHER FUNCTION
   311                              <1> _K1T:                                   ; ASCII READ
   312 00000BF5 FB                  <1> 	sti				; INTERRUPTS BACK ON DURING LOOP
   313 00000BF6 90                  <1> 	nop				; ALLOW AN INTERRUPT TO OCCUR
   314                              <1> _K1U:	
   315 00000BF7 FA                  <1> 	cli				; INTERRUPTS BACK OFF
   316 00000BF8 8B1D[BEE80000]      <1>         mov    	ebx, [BUFFER_HEAD] 	; GET POINTER TO HEAD OF BUFFER
   317 00000BFE 3B1D[C2E80000]      <1>         cmp     ebx, [BUFFER_TAIL] 	; TEST END OF BUFFER
   318                              <1> _k1x:
   319 00000C04 53                  <1> 	push	ebx			; SAVE ADDRESS		
   320 00000C05 9C                  <1> 	pushf				; SAVE FLAGS
   321 00000C06 E82F070000          <1> 	call	MAKE_LED		; GO GET MODE INDICATOR DATA BYTE
   322 00000C0B 8A1D[B3E80000]      <1> 	mov	bl, [KB_FLAG_2] 	; GET PREVIOUS BITS
   323 00000C11 30C3                <1> 	xor	bl, al			; SEE IF ANY DIFFERENT
   324 00000C13 80E307              <1> 	and	bl, 07h	; KB_LEDS	; ISOLATE INDICATOR BITS
   325 00000C16 7406                <1> 	jz	short _K1V		; IF NO CHANGE BYPASS UPDATE
   326 00000C18 E8C9060000          <1> 	call	SND_LED1
   327 00000C1D FA                  <1> 	cli				; DISABLE INTERRUPTS
   328                              <1> _K1V:
   329 00000C1E 9D                  <1> 	popf				; RESTORE FLAGS
   330 00000C1F 5B                  <1> 	pop	ebx			; RESTORE ADDRESS
   331 00000C20 74D3                <1>         je      short _K1T              ; LOOP UNTIL SOMETHING IN BUFFER
   332                              <1> 	;
   333 00000C22 668B03              <1> 	mov	ax, [ebx] 		; GET SCAN CODE AND ASCII CODE
   334 00000C25 E871000000          <1>         call    _K4                     ; MOVE POINTER TO NEXT POSITION
   335 00000C2A 891D[BEE80000]      <1>         mov     [BUFFER_HEAD], ebx      ; STORE VALUE IN VARIABLE
   336 00000C30 C3                  <1> 	retn				; RETURN
   337                              <1> 
   338                              <1> 	;-----	READ THE KEY TO SEE IF ONE IS PRESENT -----
   339                              <1> _K2S:
   340 00000C31 FA                  <1> 	cli				; INTERRUPTS OFF
   341 00000C32 8B1D[BEE80000]      <1>         mov     ebx, [BUFFER_HEAD]      ; GET HEAD POINTER
   342 00000C38 3B1D[C2E80000]      <1>         cmp     ebx, [BUFFER_TAIL]      ; IF EQUAL (Z=1) THEN NOTHING THERE
   343 00000C3E 668B03              <1> 	mov	ax, [ebx]
   344 00000C41 9C                  <1> 	pushf				; SAVE FLAGS
   345 00000C42 6650                <1> 	push	ax			; SAVE CODE
   346 00000C44 E8F1060000          <1> 	call	MAKE_LED		; GO GET MODE INDICATOR DATA BYTE
   347 00000C49 8A1D[B3E80000]      <1> 	mov	bl, [KB_FLAG_2] 	; GET PREVIOUS BITS
   348 00000C4F 30C3                <1> 	xor	bl, al			; SEE IF ANY DIFFERENT
   349 00000C51 80E307              <1> 	and	bl, 07h ; KB_LEDS	; ISOLATE INDICATOR BITS
   350 00000C54 7405                <1> 	jz	short _K2T		; IF NO CHANGE BYPASS UPDATE
   351 00000C56 E874060000          <1> 	call	SND_LED			; GO TURN ON MODE INDICATORS
   352                              <1> _K2T:
   353 00000C5B 6658                <1> 	pop	ax			; RESTORE CODE
   354 00000C5D 9D                  <1> 	popf				; RESTORE FLAGS
   355 00000C5E FB                  <1> 	sti				; INTERRUPTS BACK ON
   356 00000C5F C3                  <1> 	retn				; RETURN
   357                              <1> 
   358                              <1> 	;-----	ROUTINE TO TRANSLATE SCAN CODE PAIRS FOR EXTENDED CALLS -----
   359                              <1> _KIO_E_XLAT:
   360 00000C60 3CF0                <1> 	cmp	al, 0F0h		; IS IT ONE OF THE FILL-INs?
   361 00000C62 7506                <1> 	jne	short _KIO_E_RET	; NO, PASS IT ON
   362 00000C64 08E4                <1>         or 	ah, ah			; AH = 0 IS SPECIAL CASE
   363 00000C66 7402                <1>         jz	short _KIO_E_RET        ; PASS THIS ON UNCHANGED
   364 00000C68 30C0                <1> 	xor	al, al			; OTHERWISE SET AL = 0
   365                              <1> _KIO_E_RET:				
   366 00000C6A C3                  <1> 	retn				; GO BACK
   367                              <1> 
   368                              <1> 	;-----	ROUTINE TO TRANSLATE SCAN CODE PAIRS FOR STANDARD CALLS -----
   369                              <1> _KIO_S_XLAT:
   370 00000C6B 80FCE0              <1> 	cmp	ah, 0E0h		; IS IT KEYPAD ENTER OR / ?
   371 00000C6E 750F                <1> 	jne	short _KIO_S2		; NO, CONTINUE
   372 00000C70 3C0D                <1> 	cmp	al, 0Dh			; KEYPAD ENTER CODE?
   373 00000C72 7408                <1>         je	short _KIO_S1		; YES, MASSAGE A BIT
   374 00000C74 3C0A                <1> 	cmp	al, 0Ah			; CTRL KEYPAD ENTER CODE?
   375 00000C76 7404                <1>         je	short _KIO_S1		; YES, MASSAGE THE SAME
   376 00000C78 B435                <1> 	mov	ah, 35h			; NO, MUST BE KEYPAD /
   377                              <1> _kio_ret: ; 03/12/2014
   378 00000C7A F8                  <1> 	clc
   379 00000C7B C3                  <1> 	retn
   380                              <1> 	;jmp	short _KIO_USE		; GIVE TO CALLER
   381                              <1> _KIO_S1:				
   382 00000C7C B41C                <1> 	mov	ah, 1Ch			; CONVERT TO COMPATIBLE OUTPUT
   383                              <1> 	;jmp	short _KIO_USE		; GIVE TO CALLER
   384 00000C7E C3                  <1> 	retn
   385                              <1> _KIO_S2:		
   386 00000C7F 80FC84              <1> 	cmp	ah, 84h			; IS IT ONE OF EXTENDED ONES?
   387 00000C82 7715                <1> 	ja	short _KIO_DIS		; YES, THROW AWAY AND GET ANOTHER CHAR
   388 00000C84 3CF0                <1> 	cmp	al, 0F0h		; IS IT ONE OF THE FILL-INs?
   389 00000C86 7506                <1>         jne	short _KIO_S3		; NO, TRY LAST TEST
   390 00000C88 08E4                <1> 	or	ah, ah			; AH = 0 IS SPECIAL CASE
   391 00000C8A 740C                <1>         jz	short _KIO_USE		; PASS THIS ON UNCHANGED
   392 00000C8C EB0B                <1> 	jmp	short _KIO_DIS		; THROW AWAY THE REST
   393                              <1> _KIO_S3:
   394 00000C8E 3CE0                <1> 	cmp	al, 0E0h		; IS IT AN EXTENSION OF A PREVIOUS ONE?
   395                              <1> 	;jne	short _KIO_USE		; NO, MUST BE A STANDARD CODE
   396 00000C90 75E8                <1> 	jne	short _kio_ret
   397 00000C92 08E4                <1> 	or	ah, ah			; AH = 0 IS SPECIAL CASE
   398 00000C94 7402                <1>         jz	short _KIO_USE		; JUMP IF AH = 0
   399 00000C96 30C0                <1> 	xor	al, al			; CONVERT TO COMPATIBLE OUTPUT
   400                              <1> 	;jmp	short _KIO_USE		; PASS IT ON TO CALLER
   401                              <1> _KIO_USE:
   402                              <1> 	;clc				; CLEAR CARRY TO INDICATE GOOD CODE
   403 00000C98 C3                  <1> 	retn				; RETURN	
   404                              <1> _KIO_DIS:
   405 00000C99 F9                  <1> 	stc				; SET CARRY TO INDICATE DISCARD CODE
   406 00000C9A C3                  <1> 	retn				; RETURN
   407                              <1> 
   408                              <1> 	;-----	INCREMENT BUFFER POINTER ROUTINE -----
   409                              <1> _K4:    
   410 00000C9B 43                  <1> 	inc     ebx
   411 00000C9C 43                  <1> 	inc	ebx			; MOVE TO NEXT WORD IN LIST
   412 00000C9D 3B1D[BAE80000]      <1>         cmp     ebx, [BUFFER_END] 	; AT END OF BUFFER?
   413                              <1>         ;jne    short _K5               ; NO, CONTINUE
   414 00000CA3 7206                <1> 	jb	short _K5
   415 00000CA5 8B1D[B6E80000]      <1>         mov     ebx, [BUFFER_START]     ; YES, RESET TO BUFFER BEGINNING
   416                              <1> _K5:
   417 00000CAB C3                  <1> 	retn
   418                              <1> 
   419                              <1> ; 20/02/2015
   420                              <1> ; 05/12/2014
   421                              <1> ; 26/08/2014
   422                              <1> ; KEYBOARD (HARDWARE) INTERRUPT -  IRQ LEVEL 1
   423                              <1> ; (INT_09h - Retro UNIX 8086 v1 - U9.ASM, 07/03/2014)
   424                              <1> ;
   425                              <1> ; Derived from "KB_INT_1" procedure of IBM "pc-at" 
   426                              <1> ; rombios source code (06/10/1985)
   427                              <1> ; 'keybd.asm', HARDWARE INT 09h - (IRQ Level 1)
   428                              <1> 
   429                              <1> ; EQUATES (IBM PC-XT-286 BIOS, 1986, 'POSQEQU.INC')
   430                              <1> 
   431                              <1> ;--------- 8042 COMMANDS -------------------------------------------------------
   432                              <1> ENA_KBD		equ	0AEh		; ENABLE KEYBOARD COMMAND
   433                              <1> DIS_KBD		equ	0ADh		; DISABLE KEYBOARD COMMAND
   434                              <1> SHUT_CMD	equ	0FEh		; CAUSE A SHUTDOWN COMMAND
   435                              <1> ;--------- 8042 KEYBOARD INTERFACE AND DIAGNOSTIC CONTROL REGISTERS ------------
   436                              <1> STATUS_PORT	equ	064h		; 8042 STATUS PORT
   437                              <1> INPT_BUF_FULL	equ	00000010b 	; 1 = +INPUT BUFFER FULL
   438                              <1> PORT_A		equ	060h		; 8042 KEYBOARD SCAN CODE/CONTROL PORT
   439                              <1> ;---------- 8042 KEYBOARD RESPONSE ---------------------------------------------
   440                              <1> KB_ACK		equ	0FAh		; ACKNOWLEDGE PROM TRANSMISSION
   441                              <1> KB_RESEND	equ	0FEh		; RESEND REQUEST
   442                              <1> KB_OVER_RUN	equ	0FFh		; OVER RUN SCAN CODE
   443                              <1> ;---------- KEYBOARD/LED COMMANDS ----------------------------------------------
   444                              <1> KB_ENABLE	equ	0F4h		; KEYBOARD ENABLE
   445                              <1> LED_CMD		equ	0EDh		; LED WRITE COMMAND
   446                              <1> KB_TYPA_RD	equ	0F3h		; TYPAMATIC RATE/DELAY COMMAND
   447                              <1> ;---------- KEYBOARD SCAN CODES ------------------------------------------------
   448                              <1> NUM_KEY		equ	69		; SCAN CODE FOR	 NUMBER LOCK KEY
   449                              <1> SCROLL_KEY	equ	70		; SCAN CODE FOR	 SCROLL LOCK KEY
   450                              <1> ALT_KEY		equ	56		; SCAN CODE FOR	 ALTERNATE SHIFT KEY
   451                              <1> CTL_KEY		equ	29		; SCAN CODE FOR	 CONTROL KEY
   452                              <1> CAPS_KEY	equ	58		; SCAN CODE FOR	 SHIFT LOCK KEY
   453                              <1> DEL_KEY		equ	83		; SCAN CODE FOR	 DELETE KEY
   454                              <1> INS_KEY		equ	82		; SCAN CODE FOR	 INSERT KEY
   455                              <1> LEFT_KEY	equ	42		; SCAN CODE FOR	 LEFT SHIFT
   456                              <1> RIGHT_KEY	equ	54		; SCAN CODE FOR	 RIGHT SHIFT
   457                              <1> SYS_KEY		equ	84		; SCAN CODE FOR	 SYSTEM KEY
   458                              <1> ;---------- ENHANCED KEYBOARD SCAN CODES ---------------------------------------
   459                              <1> ID_1		equ	0ABh		; 1ST ID CHARACTER FOR KBX
   460                              <1> ID_2		equ	041h		; 2ND ID CHARACTER FOR KBX
   461                              <1> ID_2A		equ	054h		; ALTERNATE 2ND ID CHARACTER FOR KBX
   462                              <1> F11_M		equ	87		; F11 KEY MAKE
   463                              <1> F12_M		equ	88		; F12 KEY MAKE
   464                              <1> MC_E0		equ	224		; GENERAL MARKER CODE
   465                              <1> MC_E1		equ	225		; PAUSE KEY MARKER CODE
   466                              <1> ;---------- FLAG EQUATES WITHIN @KB_FLAG----------------------------------------
   467                              <1> RIGHT_SHIFT	equ	00000001b	; RIGHT SHIFT KEY DEPRESSED
   468                              <1> LEFT_SHIFT	equ	00000010b	; LEFT SHIFT KEY DEPRESSED
   469                              <1> CTL_SHIFT	equ	00000100b	; CONTROL SHIFT KEY DEPRESSED
   470                              <1> ALT_SHIFT	equ	00001000b	; ALTERNATE SHIFT KEY DEPRESSED
   471                              <1> SCROLL_STATE	equ	00010000b	; SCROLL LOCK STATE IS ACTIVE
   472                              <1> NUM_STATE	equ	00100000b	; NUM LOCK STATE IS ACTIVE
   473                              <1> CAPS_STATE	equ	01000000b	; CAPS LOCK STATE IS ACTIVE
   474                              <1> INS_STATE	equ	10000000b	; INSERT STATE IS ACTIVE
   475                              <1> ;---------- FLAG EQUATES WITHIN	@KB_FLAG_1 -------------------------------------
   476                              <1> L_CTL_SHIFT	equ	00000001b	; LEFT CTL KEY DOWN
   477                              <1> L_ALT_SHIFT	equ	00000010b	; LEFT ALT KEY DOWN
   478                              <1> SYS_SHIFT	equ	00000100b	; SYSTEM KEY DEPRESSED AND HELD
   479                              <1> HOLD_STATE	equ	00001000b	; SUSPEND KEY HAS BEEN TOGGLED
   480                              <1> SCROLL_SHIFT	equ	00010000b	; SCROLL LOCK KEY IS DEPRESSED
   481                              <1> NUM_SHIFT	equ	00100000b	; NUM LOCK KEY IS DEPRESSED
   482                              <1> CAPS_SHIFT	equ	01000000b	; CAPS LOCK KEY IS DEPRE55ED
   483                              <1> INS_SHIFT	equ	10000000b	; INSERT KEY IS DEPRESSED
   484                              <1> ;---------- FLAGS EQUATES WITHIN @KB_FLAG_2 -----------------------------------
   485                              <1> KB_LEDS		equ	00000111b	; KEYBOARD LED STATE BITS
   486                              <1> ;		equ	00000001b	; SCROLL LOCK INDICATOR
   487                              <1> ;		equ	00000010b	; NUM LOCK INDICATOR
   488                              <1> ;		equ	00000100b	; CAPS LOCK INDICATOR
   489                              <1> ;		equ	00001000b	; RESERVED (MUST BE ZERO)
   490                              <1> KB_FA		equ	00010000b	; ACKNOWLEDGMENT RECEIVED
   491                              <1> KB_FE		equ	00100000b	; RESEND RECEIVED FLAG
   492                              <1> KB_PR_LED	equ	01000000b	; MODE INDICATOR UPDATE
   493                              <1> KB_ERR		equ	10000000b	; KEYBOARD TRANSMIT ERROR FLAG
   494                              <1> ;----------- FLAGS EQUATES WITHIN @KB_FLAG_3 -----------------------------------
   495                              <1> LC_E1		equ	00000001b	; LAST CODE WAS THE E1 HIDDEN CODE
   496                              <1> LC_E0		equ	00000010b	; LAST CODE WAS THE E0 HIDDEN CODE
   497                              <1> R_CTL_SHIFT	equ	00000100b	; RIGHT CTL KEY DOWN
   498                              <1> R_ALT_SHIFT	equ	00001000b	; RIGHT ALT KEY DOWN
   499                              <1> GRAPH_ON	equ	00001000b	; ALT GRAPHICS KEY DOWN (WT ONLY)	
   500                              <1> KBX		equ	00010000b	; ENHANCED KEYBOARD INSTALLED
   501                              <1> SET_NUM_LK	equ	00100000b	; FORCE NUM LOCK IF READ ID AND KBX
   502                              <1> LC_AB		equ	01000000b	; LAST CHARACTER WAS FIRST ID CHARACTER
   503                              <1> RD_ID		equ	10000000b	; DOING A READ ID (MUST BE BIT0)
   504                              <1> ;
   505                              <1> ;----------- INTERRUPT EQUATES -------------------------------------------------
   506                              <1> EOI		equ	020h		; END OF INTERRUPT COMMAND TO 8259
   507                              <1> INTA00		equ	020h		; 8259 PORT
   508                              <1> 
   509                              <1> 
   510                              <1> kb_int:
   511                              <1> 
   512                              <1> ; 17/10/2015 ('ctrlbrk') 
   513                              <1> ; 05/12/2014
   514                              <1> ; 04/12/2014 (derived from pc-xt-286 bios source code -1986-)
   515                              <1> ; 26/08/2014
   516                              <1> ;
   517                              <1> ; 03/06/86  KEYBOARD BIOS
   518                              <1> ;
   519                              <1> ;--- HARDWARE INT 09H -- (IRQ LEVEL 1) ------------------------------------------
   520                              <1> ;										;
   521                              <1> ;	KEYBOARD INTERRUPT ROUTINE						;
   522                              <1> ;										;
   523                              <1> ;--------------------------------------------------------------------------------
   524                              <1> 
   525                              <1> KB_INT_1:
   526 00000CAC FB                  <1> 	sti				; ENABLE INTERRUPTS
   527                              <1> 	;push	ebp
   528 00000CAD 50                  <1> 	push	eax
   529 00000CAE 53                  <1> 	push	ebx
   530 00000CAF 51                  <1> 	push	ecx
   531 00000CB0 52                  <1> 	push	edx
   532 00000CB1 56                  <1> 	push	esi
   533 00000CB2 57                  <1> 	push	edi
   534 00000CB3 1E                  <1> 	push	ds
   535 00000CB4 06                  <1> 	push	es
   536 00000CB5 FC                  <1> 	cld				; FORWARD DIRECTION
   537 00000CB6 66B81000            <1> 	mov	ax, KDATA
   538 00000CBA 8ED8                <1> 	mov	ds, ax
   539 00000CBC 8EC0                <1> 	mov	es, ax
   540                              <1> 	;
   541                              <1> 	;-----	WAIT FOR KEYBOARD DISABLE COMMAND TO BE ACCEPTED
   542 00000CBE B0AD                <1> 	mov	al, DIS_KBD		; DISABLE THE KEYBOARD COMMAND
   543 00000CC0 E8A9050000          <1> 	call	SHIP_IT			; EXECUTE DISABLE
   544 00000CC5 FA                  <1> 	cli				; DISABLE INTERRUPTS
   545 00000CC6 B900000100          <1> 	mov	ecx, 10000h		; SET MAXIMUM TIMEOUT
   546                              <1> KB_INT_01:
   547 00000CCB E464                <1> 	in	al, STATUS_PORT		; READ ADAPTER STATUS
   548 00000CCD A802                <1> 	test	al, INPT_BUF_FULL	; CHECK INPUT BUFFER FULL STATUS BIT
   549 00000CCF E0FA                <1> 	loopnz	KB_INT_01		; WAIT FOR COMMAND TO BE ACCEPTED
   550                              <1> 	;
   551                              <1> 	;-----	READ CHARACTER FROM KEYBOARD INTERFACE
   552 00000CD1 E460                <1> 	in	al, PORT_A		; READ IN THE CHARACTER
   553                              <1> 	;
   554                              <1> 	;-----	SYSTEM HOOK INT 15H - FUNCTION 4FH (ON HARDWARE INT LEVEL 9H) 	
   555                              <1> 	;MOV	AH, 04FH		; SYSTEM INTERCEPT - KEY CODE FUNCTION
   556                              <1> 	;STC				; SET CY=1 (IN CASE OF IRET)
   557                              <1> 	;INT	15H			; CASETTE CALL (AL)=KEY SCAN CODE
   558                              <1> 	;				; RETURNS CY=1 FOR INVALID FUNCTION
   559                              <1> 	;JC	KB_INT_02		; CONTINUE IF CARRY FLAG SET ((AL)=CODE)
   560                              <1> 	;JMP	K26			; EXIT IF SYSTEM HANDLES SCAN CODE
   561                              <1> 	;				; EXT HANDLES HARDWARE EOI AND ENABLE		
   562                              <1> 	;
   563                              <1> 	;-----	CHECK FOR A RESEND COMMAND TO KEYBOARD
   564                              <1> KB_INT_02:				; 	  (AL)= SCAN CODE
   565 00000CD3 FB                  <1> 	sti				; ENABLE INTERRUPTS AGAIN
   566 00000CD4 3CFE                <1> 	cmp	al, KB_RESEND		; IS THE INPUT A RESEND
   567 00000CD6 7411                <1>         je      short KB_INT_4          ; GO IF RESEND
   568                              <1> 	;
   569                              <1> 	;-----	CHECK FOR RESPONSE TO A COMMAND TO KEYBOARD
   570 00000CD8 3CFA                <1> 	cmp	al, KB_ACK		; IS THE INPUT AN ACKNOWLEDGE
   571 00000CDA 751A                <1>         jne     short KB_INT_2          ; GO IF NOT
   572                              <1> 	;
   573                              <1> 	;-----	A COMMAND TO THE KEYBOARD WAS ISSUED
   574 00000CDC FA                  <1> 	cli				; DISABLE INTERRUPTS
   575 00000CDD 800D[B3E80000]10    <1> 	or	byte [KB_FLAG_2], KB_FA ; INDICATE ACK RECEIVED
   576 00000CE4 E97A020000          <1>         jmp     K26                     ; RETURN IF NOT (ACK RETURNED FOR DATA)
   577                              <1> 	;
   578                              <1> 	;-----	RESEND THE LAST BYTE
   579                              <1> KB_INT_4:
   580 00000CE9 FA                  <1> 	cli				; DISABLE INTERRUPTS
   581 00000CEA 800D[B3E80000]20    <1> 	or	byte [KB_FLAG_2], KB_FE ; INDICATE RESEND RECEIVED
   582 00000CF1 E96D020000          <1>         jmp     K26                     ; RETURN IF NOT ACK RETURNED FOR DATA)
   583                              <1> 	;
   584                              <1> ;-----	UPDATE MODE INDICATORS IF CHANGE IN STATE
   585                              <1> KB_INT_2:
   586 00000CF6 6650                <1> 	push 	ax			; SAVE DATA IN
   587 00000CF8 E83D060000          <1> 	call	MAKE_LED		; GO GET MODE INDICATOR DATA BYTE
   588 00000CFD 8A1D[B3E80000]      <1> 	mov	bl, [KB_FLAG_2] 	; GET PREVIOUS BITS
   589 00000D03 30C3                <1> 	xor	bl, al			; SEE IF ANY DIFFERENT
   590 00000D05 80E307              <1> 	and	bl, KB_LEDS		; ISOLATE INDICATOR BITS
   591 00000D08 7405                <1> 	jz	short UP0		; IF NO CHANGE BYPASS UPDATE
   592 00000D0A E8C0050000          <1> 	call	SND_LED			; GO TURN ON MODE INDICATORS
   593                              <1> UP0:
   594 00000D0F 6658                <1> 	pop	ax			; RESTORE DATA IN
   595                              <1> ;------------------------------------------------------------------------
   596                              <1> ;	START OF KEY PROCESSING						;
   597                              <1> ;------------------------------------------------------------------------
   598 00000D11 88C4                <1> 	mov	ah, al			; SAVE SCAN CODE IN AH ALSO
   599                              <1> 	;
   600                              <1> 	;-----	TEST FOR OVERRUN SCAN CODE FROM KEYBOARD
   601 00000D13 3CFF                <1> 	cmp	al, KB_OVER_RUN		; IS THIS AN OVERRUN CHAR
   602 00000D15 0F843F050000        <1>         je      K62			; BUFFER_FULL_BEEP
   603                              <1> 	;
   604                              <1> K16:	
   605 00000D1B 8A3D[B4E80000]      <1> 	mov	bh, [KB_FLAG_3]		; LOAD FLAGS FOR TESTING
   606                              <1> 	;
   607                              <1> 	;-----	TEST TO SEE IF A READ_ID IS IN PROGRESS
   608 00000D21 F6C7C0              <1> 	test 	bh, RD_ID+LC_AB 	; ARE WE DOING A READ ID?
   609 00000D24 7449                <1> 	jz	short NOT_ID		; CONTINUE IF NOT
   610 00000D26 7917                <1> 	jns	short TST_ID_2		; IS THE RD_ID FLAG ON?
   611 00000D28 3CAB                <1> 	cmp	al, ID_1		; IS THIS THE 1ST ID CHARACTER?
   612 00000D2A 7507                <1> 	jne	short RST_RD_ID
   613 00000D2C 800D[B4E80000]40    <1> 	or	byte [KB_FLAG_3], LC_AB ; INDICATE 1ST ID WAS OK
   614                              <1> RST_RD_ID:
   615 00000D33 8025[B4E80000]7F    <1> 	and	byte [KB_FLAG_3], ~RD_ID ; RESET THE READ ID FLAG
   616                              <1>         ;jmp    short ID_EX		; AND EXIT
   617 00000D3A E924020000          <1> 	jmp	K26
   618                              <1> 	;
   619                              <1> TST_ID_2:
   620 00000D3F 8025[B4E80000]BF    <1> 	and	byte [KB_FLAG_3], ~LC_AB ; RESET FLAG
   621 00000D46 3C54                <1> 	cmp	al, ID_2A		; IS THIS THE 2ND ID CHARACTER?
   622 00000D48 7419                <1>         je	short KX_BIT		; JUMP IF SO
   623 00000D4A 3C41                <1> 	cmp	al, ID_2		; IS THIS THE 2ND ID CHARACTER?
   624                              <1>         ;jne	short ID_EX		; LEAVE IF NOT
   625 00000D4C 0F8511020000        <1> 	jne	K26
   626                              <1> 	;
   627                              <1> 	;-----	A READ ID SAID THAT IT WAS ENHANCED KEYBOARD
   628 00000D52 F6C720              <1> 	test	bh, SET_NUM_LK 		; SHOULD WE SET NUM LOCK?
   629 00000D55 740C                <1>         jz      short KX_BIT		; EXIT IF NOT
   630 00000D57 800D[B1E80000]20    <1> 	or	byte [KB_FLAG], NUM_STATE ; FORCE NUM LOCK ON
   631 00000D5E E86C050000          <1> 	call	SND_LED			; GO SET THE NUM LOCK INDICATOR
   632                              <1> KX_BIT:
   633 00000D63 800D[B4E80000]10    <1> 	or	byte [KB_FLAG_3], KBX	; INDICATE ENHANCED KEYBOARD WAS FOUND
   634 00000D6A E9F4010000          <1> ID_EX:	jmp     K26			; EXIT
   635                              <1> 	;
   636                              <1> NOT_ID:
   637 00000D6F 3CE0                <1> 	cmp	al, MC_E0		; IS THIS THE GENERAL MARKER CODE?
   638 00000D71 750C                <1> 	jne	short TEST_E1
   639 00000D73 800D[B4E80000]12    <1> 	or	byte [KB_FLAG_3], LC_E0+KBX ; SET FLAG BIT, SET KBX, AND
   640                              <1> 	;jmp	short EXIT		; THROW AWAY THIS CODE
   641 00000D7A E9EB010000          <1> 	jmp	K26A	
   642                              <1> TEST_E1:	
   643 00000D7F 3CE1                <1> 	cmp	al, MC_E1		; IS THIS THE PAUSE KEY?
   644 00000D81 750C                <1> 	jne	short NOT_HC
   645 00000D83 800D[B4E80000]11    <1> 	or	byte [KB_FLAG_3], LC_E1+KBX ; SET FLAG BIT, SET KBX, AND
   646 00000D8A E9DB010000          <1> EXIT:	jmp	K26A			; THROW AWAY THIS CODE
   647                              <1> 	;
   648                              <1> NOT_HC:
   649 00000D8F 247F                <1> 	and	al, 07Fh		; TURN OFF THE BREAK BIT
   650 00000D91 F6C702              <1> 	test	bh, LC_E0		; LAST CODE THE E0 MARKER CODE
   651 00000D94 7414                <1> 	jz	short NOT_LC_E0		; JUMP IF NOT
   652                              <1> 	;
   653 00000D96 BF[9EE70000]        <1> 	mov	edi, _K6+6		; IS THIS A SHIFT KEY?
   654 00000D9B AE                  <1> 	scasb
   655 00000D9C 0F84C1010000        <1>         je      K26 ; K16B              ; YES, THROW AWAY & RESET FLAG
   656 00000DA2 AE                  <1> 	scasb
   657 00000DA3 757C                <1> 	jne	short K16A		; NO, CONTINUE KEY PROCESSING
   658                              <1> 	;jmp	short K16B		; YES, THROW AWAY & RESET FLAG
   659 00000DA5 E9B9010000          <1> 	jmp	K26
   660                              <1> 	;
   661                              <1> NOT_LC_E0:
   662 00000DAA F6C701              <1> 	test	bh, LC_E1		; LAST CODE THE E1 MARKER CODE?
   663 00000DAD 7435                <1> 	jz	short T_SYS_KEY		; JUMP IF NOT
   664 00000DAF B904000000          <1> 	mov	ecx, 4			; LENGHT OF SEARCH
   665 00000DB4 BF[9CE70000]        <1> 	mov	edi, _K6+4		; IS THIS AN ALT, CTL, OR SHIFT?
   666 00000DB9 F2AE                <1> 	repne	scasb			; CHECK IT
   667                              <1> 	;je	short EXIT		; THROW AWAY IF SO
   668 00000DBB 0F84A9010000        <1> 	je	K26A			
   669                              <1> 	;
   670 00000DC1 3C45                <1> 	cmp	al, NUM_KEY		; IS IT THE PAUSE KEY?
   671                              <1> 	;jne	short K16B		; NO, THROW AWAY & RESET FLAG
   672 00000DC3 0F859A010000        <1> 	jne	K26
   673 00000DC9 F6C480              <1> 	test	ah, 80h			; YES, IS IT THE BREAK OF THE KEY?
   674                              <1> 	;jnz	short K16B		; YES, THROW THIS AWAY, TOO	
   675 00000DCC 0F8591010000        <1> 	jnz	K26
   676                              <1>         ; 20/02/2015 
   677 00000DD2 F605[B2E80000]08    <1> 	test	byte [KB_FLAG_1],HOLD_STATE ;  NO, ARE WE PAUSED ALREADY?
   678                              <1> 	;jnz	short K16B		;  YES, THROW AWAY
   679 00000DD9 0F8584010000        <1> 	jnz	K26
   680 00000DDF E9E1020000          <1> 	jmp     K39P                    ; NO, THIS IS THE REAL PAUSE STATE
   681                              <1> 	;
   682                              <1> 	;-----	TEST FOR SYSTEM KEY
   683                              <1> T_SYS_KEY:
   684 00000DE4 3C54                <1> 	cmp	al, SYS_KEY		; IS IT THE SYSTEM KEY?
   685 00000DE6 7539                <1> 	jnz	short K16A		; CONTINUE IF NOT
   686                              <1> 	;
   687 00000DE8 F6C480              <1> 	test	ah, 80h			; CHECK IF THIS A BREAK CODE
   688 00000DEB 7524                <1> 	jnz	short K16C		; DO NOT TOUCH SYSTEM INDICATOR IF TRUE
   689                              <1> 	;
   690 00000DED F605[B2E80000]04    <1> 	test	byte [KB_FLAG_1], SYS_SHIFT ; SEE IF IN SYSTEM KEY HELD DOWN 
   691                              <1>         ;jnz	short K16B		; IF YES, DO NOT PROCESS SYSTEM INDICATOR	
   692 00000DF4 0F8569010000        <1> 	jnz     K26			
   693                              <1> 	;
   694 00000DFA 800D[B2E80000]04    <1> 	or	byte [KB_FLAG_1], SYS_SHIFT ; INDICATE SYSTEM KEY DEPRESSED
   695 00000E01 B020                <1> 	mov	al, EOI			; END OF INTERRUPT COMMAND
   696 00000E03 E620                <1> 	out	20h, al ;out INTA00, al	; SEND COMMAND TO INTERRUPT CONTROL PORT
   697                              <1> 					; INTERRUPT-RETURN-NO-EOI
   698 00000E05 B0AE                <1> 	mov	al, ENA_KBD		; INSURE KEYBOARD IS ENABLED
   699 00000E07 E862040000          <1> 	call	SHIP_IT			; EXECUTE ENABLE
   700                              <1> 	; !!! SYSREQ !!! function/system call (INTERRUPT) must be here !!!
   701                              <1> 	;MOV	AL, 8500H		; FUNCTION VALUE FOR MAKE OF SYSTEM KEY
   702                              <1> 	;STI				; MAKE SURE INTERRUPTS ENABLED
   703                              <1> 	;INT	15H			; USER INTERRUPT	
   704 00000E0C E965010000          <1>         jmp     K27A                    ; END PROCESSING
   705                              <1> 	;
   706                              <1> ;K16B:	jmp	K26			; IGNORE SYSTEM KEY
   707                              <1> 	;
   708                              <1> K16C:
   709 00000E11 8025[B2E80000]FB    <1> 	and	byte [KB_FLAG_1], ~SYS_SHIFT ; TURN OFF SHIFT KEY HELD DOWN
   710 00000E18 B020                <1> 	mov	al, EOI			; END OF INTERRUPT COMMAND
   711 00000E1A E620                <1> 	out	20h, al ;out INTA00, al ; SEND COMMAND TO INTERRUPT CONTROL PORT
   712                              <1> 					; INTERRUPT-RETURN-NO-EOI
   713                              <1> 	;MOV	AL, ENA_KBD		; INSURE KEYBOARD IS ENABLED
   714                              <1> 	;CALL	SHIP_IT			; EXECUTE ENABLE
   715                              <1> 	;
   716                              <1> 	;MOV	AX, 8501H		; FUNCTION VALUE FOR BREAK OF SYSTEM KEY
   717                              <1> 	;STI				; MAKE SURE INTERRUPTS ENABLED
   718                              <1> 	;INT	15H			; USER INTERRUPT
   719                              <1> 	;JMP	K27A			; INGONRE SYSTEM KEY				
   720                              <1> 	;
   721 00000E1C E94E010000          <1> 	jmp     K27			; IGNORE SYSTEM KEY
   722                              <1> 	;
   723                              <1> 	;-----	TEST FOR SHIFT KEYS
   724                              <1> K16A:
   725 00000E21 8A1D[B1E80000]      <1> 	mov	bl, [KB_FLAG]		; PUT STATE FLAGS IN BL
   726 00000E27 BF[98E70000]        <1> 	mov	edi, _K6		; SHIFT KEY TABLE offset
   727 00000E2C B908000000          <1> 	mov	ecx, _K6L		; LENGTH
   728 00000E31 F2AE                <1> 	repne	scasb			; LOOK THROUGH THE TABLE FOR A MATCH
   729 00000E33 88E0                <1> 	mov	al, ah			; RECOVER SCAN CODE
   730 00000E35 0F8510010000        <1>         jne     K25                     ; IF NO MATCH, THEN SHIFT NOT FOUND
   731                              <1> 	;
   732                              <1> 	;------	SHIFT KEY FOUND
   733                              <1> K17:
   734 00000E3B 81EF[99E70000]      <1>         sub     edi, _K6+1              ; ADJUST PTR TO SCAN CODE MATCH
   735 00000E41 8AA7[A0E70000]      <1>        	mov     ah, [edi+_K7]       	; GET MASK INTO AH
   736 00000E47 B102                <1> 	mov	cl, 2			; SETUP COUNT FOR FLAG SHIFTS
   737 00000E49 A880                <1> 	test	al, 80h			; TEST FOR BREAK KEY
   738 00000E4B 0F8596000000        <1>         jnz     K23                     ; JUMP OF BREAK
   739                              <1> 	;
   740                              <1> 	;-----	SHIFT MAKE FOUND, DETERMINE SET OR TOGGLE
   741                              <1> K17C:
   742 00000E51 80FC10              <1> 	cmp	ah, SCROLL_SHIFT
   743 00000E54 732B                <1> 	jae	short K18		; IF SCROLL SHIFT OR ABOVE, TOGGLE KEY
   744                              <1> 	;
   745                              <1> 	;-----	PLAIN SHIFT KEY, SET SHIFT ON
   746 00000E56 0825[B1E80000]      <1> 	or	[KB_FLAG], ah		; TURN ON SHIFT BIT
   747 00000E5C A80C                <1>         test	al, CTL_SHIFT+ALT_SHIFT ; IS IT ALT OR CTRL?
   748                              <1> 	;jnz	short K17D		; YES, MORE FLAGS TO SET
   749 00000E5E 0F84FF000000        <1> 	jz	K26			; NO, INTERRUPT RETURN
   750                              <1> K17D:
   751 00000E64 F6C702              <1> 	test	bh, LC_E0		; IS THIS ONE OF NEW KEYS?
   752 00000E67 740B                <1> 	jz 	short K17E		; NO, JUMP
   753 00000E69 0825[B4E80000]      <1> 	or	[KB_FLAG_3], ah		; SET BITS FOR RIGHT CTRL, ALT
   754 00000E6F E9EF000000          <1> 	jmp	K26			; INTERRUPT RETURN
   755                              <1> K17E:
   756 00000E74 D2EC                <1> 	shr	ah, cl			; MOVE FLAG BITS TWO POSITIONS
   757 00000E76 0825[B2E80000]      <1> 	or	[KB_FLAG_1], ah		; SET BITS FOR LEFT CTRL, ALT
   758 00000E7C E9E2000000          <1> 	jmp	K26
   759                              <1> 	;
   760                              <1> 	;-----	TOGGLED SHIFT KEY, TEST FOR 1ST MAKE OR NOT
   761                              <1> K18:					; SHIFT-TOGGLE
   762 00000E81 F6C304              <1> 	test	bl, CTL_SHIFT 		; CHECK CTL SHIFT STATE
   763                              <1>         ;jz    	short K18A              ; JUMP IF NOT CTL STATE
   764 00000E84 0F85C1000000        <1>         jnz     K25                     ; JUMP IF CTL STATE
   765                              <1> K18A:
   766 00000E8A 3C52                <1> 	cmp	al, INS_KEY		; CHECK FOR INSERT KEY
   767 00000E8C 7524                <1> 	jne	short K22		; JUMP IF NOT INSERT KEY
   768 00000E8E F6C308              <1> 	test	bl, ALT_SHIFT 		; CHECK FOR ALTERNATE SHIFT
   769                              <1>       	;jz	short K18B		; JUMP IF NOT ALTERNATE SHIFT	
   770 00000E91 0F85B4000000        <1>         jnz     K25                     ; JUMP IF ALTERNATE SHIFT
   771                              <1> K18B:
   772 00000E97 F6C702              <1> 	test	bh, LC_E0 ;20/02/2015	; IS THIS NEW INSERT KEY?
   773 00000E9A 7516                <1> 	jnz	short K22		; YES, THIS ONE'S NEVER A '0'
   774                              <1> K19:	
   775 00000E9C F6C320              <1> 	test	bl, NUM_STATE 		; CHECK FOR BASE STATE
   776 00000E9F 750C                <1> 	jnz	short K21		; JUMP IF NUM LOCK IS ON
   777 00000EA1 F6C303              <1> 	test	bl, LEFT_SHIFT+RIGHT_SHIFT ; TEST FOR SHIFT STATE
   778 00000EA4 740C                <1> 	jz	short K22		; JUMP IF BASE STATE
   779                              <1> K20:					; NUMERIC ZERO, NOT INSERT KEY
   780 00000EA6 88C4                <1> 	mov	ah, al			; PUT SCAN CODE BACK IN AH
   781 00000EA8 E99E000000          <1>         jmp     K25                     ; NUMERAL '0', STNDRD. PROCESSING
   782                              <1> K21:					; MIGHT BE NUMERIC
   783 00000EAD F6C303              <1> 	test	bl, LEFT_SHIFT+RIGHT_SHIFT
   784 00000EB0 74F4                <1> 	jz	short K20		; IS NUMERIC, STD. PROC.
   785                              <1> 	;
   786                              <1> K22:					; SHIFT TOGGLE KEY HIT; PROCESS IT
   787 00000EB2 8425[B2E80000]      <1> 	test	ah, [KB_FLAG_1] 	; IS KEY ALREADY DEPRESSED
   788 00000EB8 0F85A5000000        <1>         jnz     K26                     ; JUMP IF KEY ALREADY DEPRESSED
   789                              <1> K22A:
   790 00000EBE 0825[B2E80000]      <1>         or      [KB_FLAG_1], ah 	; INDICATE THAT THE KEY IS DEPRESSED
   791 00000EC4 3025[B1E80000]      <1> 	xor	[KB_FLAG], ah		; TOGGLE THE SHIFT STATE
   792                              <1> 	;
   793                              <1> 	;-----	TOGGLE LED IF CAPS, NUM  OR SCROLL KEY DEPRESSED
   794 00000ECA F6C470              <1> 	test	ah, CAPS_SHIFT+NUM_SHIFT+SCROLL_SHIFT ; SHIFT TOGGLE?
   795 00000ECD 7409                <1> 	jz	short K22B		; GO IF NOT
   796                              <1> 	;
   797 00000ECF 6650                <1> 	push	ax			; SAVE SCAN CODE AND SHIFT MASK
   798 00000ED1 E8F9030000          <1> 	call	SND_LED			; GO TURN MODE INDICATORS ON
   799 00000ED6 6658                <1> 	pop	ax			; RESTORE SCAN CODE
   800                              <1> K22B:
   801 00000ED8 3C52                <1> 	cmp	al, INS_KEY		; TEST FOR 1ST MAKE OF INSERT KEY
   802 00000EDA 0F8583000000        <1>         jne     K26                     ; JUMP IF NOT INSERT KEY
   803 00000EE0 88C4                <1> 	mov	ah, al		        ; SCAN CODE IN BOTH HALVES OF AX
   804 00000EE2 E999000000          <1>         jmp     K28                     ; FLAGS UPDATED, PROC. FOR BUFFER
   805                              <1> 	;
   806                              <1> 	;-----	BREAK SHIFT FOUND
   807                              <1> K23:					; BREAK-SHIFT-FOUND
   808 00000EE7 80FC10              <1> 	cmp	ah, SCROLL_SHIFT	; IS THIS A TOGGLE KEY
   809 00000EEA F6D4                <1> 	not	ah			; INVERT MASK
   810 00000EEC 7355                <1> 	jae	short K24		; YES, HANDLE BREAK TOGGLE
   811 00000EEE 2025[B1E80000]      <1> 	and	[KB_FLAG], ah		; TURN OFF SHIFT BIT
   812 00000EF4 80FCFB              <1> 	cmp	ah, ~CTL_SHIFT		; IS THIS ALT OR CTL?
   813 00000EF7 7730                <1> 	ja	short K23D		; NO, ALL DONE
   814                              <1> 	;
   815 00000EF9 F6C702              <1> 	test	bh, LC_E0		; 2ND ALT OR CTL?
   816 00000EFC 7408                <1> 	jz	short K23A		; NO, HANSLE NORMALLY
   817 00000EFE 2025[B4E80000]      <1> 	and 	[KB_FLAG_3], ah		; RESET BIT FOR RIGHT ALT OR CTL
   818 00000F04 EB08                <1> 	jmp	short K23B		; CONTINUE
   819                              <1> K23A:
   820 00000F06 D2FC                <1> 	sar	ah, cl			; MOVE THE MASK BIT TWO POSITIONS
   821 00000F08 2025[B2E80000]      <1> 	and	[KB_FLAG_1], ah		; RESET BIT FOR LEFT ALT AND CTL
   822                              <1> K23B:
   823 00000F0E 88C4                <1> 	mov	ah, al			; SAVE SCAN CODE
   824 00000F10 A0[B4E80000]        <1> 	mov	al, [KB_FLAG_3]		; GET RIGHT ALT & CTRL FLAGS
   825 00000F15 D2E8                <1> 	shr	al, cl			; MOVE TO BITS 1 & 0
   826 00000F17 0A05[B2E80000]      <1> 	or	al, [KB_FLAG_1]		; PUT IN LEFT ALT & CTL FLAGS
   827 00000F1D D2E0                <1> 	shl	al, cl			; MOVE BACK TO BITS 3 & 2
   828 00000F1F 240C                <1> 	and	al, ALT_SHIFT+CTL_SHIFT ; FILTER OUT OTHER GARBAGE
   829 00000F21 0805[B1E80000]      <1> 	or	[KB_FLAG], al		; PUT RESULT IN THE REAL FLAGS	
   830 00000F27 88E0                <1> 	mov	al, ah
   831                              <1> K23D:
   832 00000F29 3CB8                <1> 	cmp	al, ALT_KEY+80h		; IS THIS ALTERNATE SHIFT RELEASE
   833 00000F2B 7536                <1> 	jne	short K26		; INTERRUPT RETURN
   834                              <1> 	;	
   835                              <1> 	;-----	ALTERNATE SHIFT KEY RELEASED, GET THE VALUE INTO BUFFER
   836 00000F2D A0[B5E80000]        <1> 	mov	al, [ALT_INPUT]
   837 00000F32 B400                <1> 	mov	ah, 0			; SCAN CODE OF 0
   838 00000F34 8825[B5E80000]      <1> 	mov	[ALT_INPUT], ah 	; ZERO OUT THE FIELD
   839 00000F3A 3C00                <1> 	cmp	al, 0			; WAS THE INPUT = 0?
   840 00000F3C 7425                <1> 	je	short K26		; INTERRUPT_RETURN
   841                              <1>         ; 29/01/2016
   842                              <1> 	;jmp     K61                    ; IT WASN'T, SO PUT IN BUFFER
   843 00000F3E E9D0020000          <1> 	jmp	_K60
   844                              <1> 	;
   845                              <1> K24:					; BREAK-TOGGLE
   846 00000F43 2025[B2E80000]      <1> 	and	[KB_FLAG_1], ah 	; INDICATE NO LONGER DEPRESSED
   847 00000F49 EB18                <1> 	jmp	short K26		; INTERRUPT_RETURN
   848                              <1> 	;
   849                              <1> 	;-----	TEST FOR HOLD STATE
   850                              <1> 					; AL, AH = SCAN CODE
   851                              <1> K25:					; NO-SHIFT-FOUND
   852 00000F4B 3C80                <1> 	cmp	al, 80h			; TEST FOR BREAK KEY
   853 00000F4D 7314                <1> 	jae	short K26		; NOTHING FOR BREAK CHARS FROM HERE ON
   854 00000F4F F605[B2E80000]08    <1> 	test	byte [KB_FLAG_1], HOLD_STATE ; ARE WE IN HOLD STATE
   855 00000F56 7428                <1> 	jz	short K28		; BRANCH AROUND TEST IF NOT
   856 00000F58 3C45                <1> 	cmp	al, NUM_KEY
   857 00000F5A 7407                <1> 	je	short K26		; CAN'T END HOLD ON NUM_LOCK
   858 00000F5C 8025[B2E80000]F7    <1> 	and	byte [KB_FLAG_1], ~HOLD_STATE ; TURN OFF THE HOLD STATE BIT
   859                              <1> 	;
   860                              <1> K26:
   861 00000F63 8025[B4E80000]FC    <1> 	and	byte [KB_FLAG_3], ~(LC_E0+LC_E1) ; RESET LAST CHAR H.C. FLAG
   862                              <1> K26A:					; INTERRUPT-RETURN
   863 00000F6A FA                  <1> 	cli				; TURN OFF INTERRUPTS
   864 00000F6B B020                <1> 	mov	al, EOI			; END OF INTERRUPT COMMAND
   865 00000F6D E620                <1> 	out	20h, al	;out INTA00, al	; SEND COMMAND TO INTERRUPT CONTROL PORT
   866                              <1> K27:					; INTERRUPT-RETURN-NO-EOI
   867 00000F6F B0AE                <1> 	mov	al, ENA_KBD		; INSURE KEYBOARD IS ENABLED
   868 00000F71 E8F8020000          <1> 	call	SHIP_IT			; EXECUTE ENABLE
   869                              <1> K27A:
   870 00000F76 FA                  <1> 	cli				; DISABLE INTERRUPTS
   871 00000F77 07                  <1> 	pop	es			; RESTORE REGISTERS
   872 00000F78 1F                  <1> 	pop	ds
   873 00000F79 5F                  <1> 	pop	edi
   874 00000F7A 5E                  <1> 	pop	esi
   875 00000F7B 5A                  <1> 	pop	edx
   876 00000F7C 59                  <1> 	pop	ecx
   877 00000F7D 5B                  <1> 	pop	ebx
   878 00000F7E 58                  <1> 	pop	eax
   879                              <1> 	;pop	ebp
   880 00000F7F CF                  <1> 	iret				; RETURN
   881                              <1> 
   882                              <1> 	;-----	NOT IN	HOLD STATE
   883                              <1> K28:					; NO-HOLD-STATE
   884 00000F80 3C58                <1> 	cmp	al, 88			; TEST FOR OUT-OF-RANGE SCAN CODES
   885 00000F82 77DF                <1> 	ja	short K26		; IGNORE IF OUT-OF-RANGE	
   886                              <1> 	;
   887 00000F84 F6C308              <1> 	test	bl, ALT_SHIFT 		; ARE WE IN ALTERNATE SHIFT
   888                              <1>         ;jz	short K28A		; IF NOT ALTERNATE
   889 00000F87 0F84F1000000        <1>         jz      K38
   890                              <1> 	;
   891 00000F8D F6C710              <1> 	test	bh, KBX			; IS THIS THE ENCHANCED KEYBOARD?
   892 00000F90 740D                <1> 	jz	short K29		; NO, ALT STATE IS REAL
   893                              <1> 	 ;28/02/2015
   894 00000F92 F605[B2E80000]04    <1> 	test	byte [KB_FLAG_1], SYS_SHIFT ; YES, IS SYSREQ KEY DOWN?
   895                              <1> 	;jz	short K29		;  NO, ALT STATE IS REAL
   896 00000F99 0F85DF000000        <1> 	jnz	K38			; YES, THIS IS PHONY ALT STATE 
   897                              <1>         ;				; DUE TO PRESSING SYSREQ	
   898                              <1> ;K28A:	jmp	short K38
   899                              <1> 	;
   900                              <1> 	;-----	TEST FOR RESET KEY SEQUENCE (CTL ALT DEL)
   901                              <1> K29:					; TEST-RESET
   902 00000F9F F6C304              <1> 	test	bl, CTL_SHIFT 		; ARE WE IN CONTROL SHIFT ALSO?
   903 00000FA2 740B                <1> 	jz	short K31		; NO_RESET
   904 00000FA4 3C53                <1> 	cmp	al, DEL_KEY		; CTL-ALT STATE, TEST FOR DELETE KEY
   905 00000FA6 7507                <1> 	jne	short K31		; NO_RESET, IGNORE
   906                              <1> 	;
   907                              <1> 	;-----	CTL-ALT-DEL HAS BEEN FOUND
   908                              <1>  	; 26/08/2014
   909                              <1> cpu_reset:
   910                              <1> 	; IBM PC/AT ROM BIOS source code - 10/06/85 (TEST4.ASM - PROC_SHUTDOWN)
   911                              <1> 	; Send FEh (system reset command) to the keyboard controller.
   912 00000FA8 B0FE                <1> 	mov	al, SHUT_CMD		; SHUTDOWN COMMAND
   913 00000FAA E664                <1> 	out	STATUS_PORT, al		; SEND TO KEYBOARD CONTROL PORT
   914                              <1> khere:
   915 00000FAC F4                  <1> 	hlt				; WAIT FOR 80286 RESET
   916 00000FAD EBFD                <1> 	jmp 	short khere		; INSURE HALT
   917                              <1> 
   918                              <1> 	;
   919                              <1> 	;-----	IN ALTERNATE SHIFT, RESET NOT FOUND
   920                              <1> K31:					; NO-RESET
   921 00000FAF 3C39                <1> 	cmp	al, 57			; TEST FOR SPACE KEY
   922 00000FB1 7507                <1> 	jne	short K311		; NOT THERE
   923 00000FB3 B020                <1> 	mov	al, ' '			; SET SPACE CHAR
   924 00000FB5 E948020000          <1>         jmp     K57                     ; BUFFER_FILL
   925                              <1> K311:
   926 00000FBA 3C0F                <1> 	cmp	al, 15			; TEST FOR TAB KEY
   927 00000FBC 7509                <1> 	jne	short K312		; NOT THERE
   928 00000FBE 66B800A5            <1> 	mov	ax, 0A500h		; SET SPECIAL CODE FOR ALT-TAB
   929 00000FC2 E93B020000          <1>         jmp     K57                     ; BUFFER_FILL
   930                              <1> K312:
   931 00000FC7 3C4A                <1> 	cmp	al, 74			; TEST FOR KEY PAD -
   932 00000FC9 0F84A2000000        <1>         je      K37B                    ; GO PROCESS
   933 00000FCF 3C4E                <1> 	cmp	al, 78			; TEST FOR KEY PAD +
   934 00000FD1 0F849A000000        <1>         je      K37B                    ; GO PROCESS
   935                              <1> 	;
   936                              <1> 	;-----	LOOK FOR KEY PAD ENTRY
   937                              <1> K32:					; ALT-KEY-PAD
   938 00000FD7 BF[74E70000]        <1> 	mov	edi, K30		; ALT-INPUT-TABLE offset
   939 00000FDC B90A000000          <1> 	mov	ecx, 10			; LOOK FOR ENTRY USING KEYPAD
   940 00000FE1 F2AE                <1> 	repne	scasb			; LOOK FOR MATCH
   941 00000FE3 7525                <1> 	jne	short K33		; NO_ALT_KEYPAD
   942 00000FE5 F6C702              <1> 	test	bh, LC_E0		; IS THIS ONE OF THE NEW KEYS?
   943 00000FE8 0F858A000000        <1>         jnz     K37C                    ; YES, JUMP, NOT NUMPAD KEY
   944 00000FEE 81EF[75E70000]      <1> 	sub	edi, K30+1		; DI NOW HAS ENTRY VALUE
   945 00000FF4 A0[B5E80000]        <1> 	mov	al, [ALT_INPUT] 	; GET THE CURRENT BYTE
   946 00000FF9 B40A                <1> 	mov	ah, 10			; MULTIPLY BY 10
   947 00000FFB F6E4                <1> 	mul	ah
   948 00000FFD 6601F8              <1> 	add	ax, di			; ADD IN THE LATEST ENTRY
   949 00001000 A2[B5E80000]        <1> 	mov	[ALT_INPUT], al 	; STORE IT AWAY
   950                              <1> ;K32A:
   951 00001005 E959FFFFFF          <1>         jmp     K26                     ; THROW AWAY THAT KEYSTROKE
   952                              <1> 	;
   953                              <1> 	;-----	LOOK FOR SUPERSHIFT ENTRY
   954                              <1> K33:					; NO-ALT-KEYPAD
   955 0000100A C605[B5E80000]00    <1>         mov     byte [ALT_INPUT], 0     ; ZERO ANY PREVIOUS ENTRY INTO INPUT
   956 00001011 B91A000000          <1> 	mov	ecx, 26			; (DI),(ES) ALREADY POINTING
   957 00001016 F2AE                <1> 	repne	scasb			; LOOK FOR MATCH IN ALPHABET
   958 00001018 7450                <1> 	je	short K37A		; MATCH FOUND, GO FILLL THE BUFFER
   959                              <1> 	;
   960                              <1> 	;-----	LOOK FOR TOP ROW OF ALTERNATE SHIFT
   961                              <1> K34:					; ALT-TOP-ROW
   962 0000101A 3C02                <1> 	cmp	al, 2			; KEY WITH '1' ON IT
   963 0000101C 7253                <1> 	jb	short K37B		; MUST BE ESCAPE
   964 0000101E 3C0D                <1> 	cmp	al, 13			; IS IT IN THE REGION
   965 00001020 7705                <1> 	ja	short K35		; NO, ALT SOMETHING ELSE
   966 00001022 80C476              <1> 	add	ah, 118			; CONVERT PSEUDO SCAN CODE TO RANGE
   967 00001025 EB43                <1> 	jmp	short K37A		; GO FILL THE BUFFER
   968                              <1> 	;
   969                              <1> 	;-----	TRANSLATE ALTERNATE SHIFT PSEUDO SCAN CODES
   970                              <1> K35:					; ALT-FUNCTION
   971 00001027 3C57                <1> 	cmp	al, F11_M		; IS IT F11?	
   972 00001029 7209                <1> 	jb	short K35A ; 20/02/2015	; NO, BRANCH
   973 0000102B 3C58                <1> 	cmp	al, F12_M		; IS IT F12?
   974 0000102D 7705                <1> 	ja	short K35A ; 20/02/2015	; NO, BRANCH
   975 0000102F 80C434              <1> 	add	ah, 52			; CONVERT TO PSEUDO SCAN CODE
   976 00001032 EB36                <1> 	jmp	short K37A		; GO FILL THE BUFFER
   977                              <1> K35A:
   978 00001034 F6C702              <1> 	test	bh, LC_E0		; DO WE HAVE ONE OF THE NEW KEYS?
   979 00001037 7422                <1> 	jz	short K37		; NO, JUMP
   980 00001039 3C1C                <1> 	cmp	al, 28			; TEST FOR KEYPAD ENTER
   981 0000103B 7509                <1>         jne     short K35B              ; NOT THERE
   982 0000103D 66B800A6            <1> 	mov	ax, 0A600h		; SPECIAL CODE
   983 00001041 E9BC010000          <1> 	jmp	K57			; BUFFER FILL
   984                              <1> K35B:
   985 00001046 3C53                <1> 	cmp	al, 83			; TEST FOR DELETE KEY
   986 00001048 742E                <1> 	je	short K37C		; HANDLE WITH OTHER EDIT KEYS
   987 0000104A 3C35                <1> 	cmp	al, 53			; TEST FOR KEYPAD /
   988                              <1> 	;jne	short K32A		; NOT THERE, NO OTHER E0 SPECIALS	
   989 0000104C 0F8511FFFFFF        <1>         jne     K26
   990 00001052 66B800A4            <1> 	mov	ax, 0A400h		; SPECIAL CODE
   991 00001056 E9A7010000          <1> 	jmp	K57			; BUFFER FILL
   992                              <1> K37:
   993 0000105B 3C3B                <1> 	cmp	al, 59			; TEST FOR FUNCTION KEYS (F1)
   994 0000105D 7212                <1>         jb      short K37B		; NO FN, HANDLE W/OTHER EXTENDED
   995 0000105F 3C44                <1> 	cmp	al, 68			; IN KEYPAD REGION?
   996                              <1>         ;ja	short K32A		; IF SO, IGNORE
   997 00001061 0F87FCFEFFFF        <1>         ja      K26
   998 00001067 80C42D              <1> 	add	ah, 45			; CONVERT TO PSEUDO SCAN CODE
   999                              <1> K37A:
  1000 0000106A B000                <1> 	mov	al, 0			; ASCII CODE OF ZERO
  1001 0000106C E991010000          <1>         jmp     K57                     ; PUT IT IN THE BUFFER
  1002                              <1> K37B:
  1003 00001071 B0F0                <1> 	mov	al, 0F0h		; USE SPECIAL ASCII CODE
  1004 00001073 E98A010000          <1> 	jmp     K57                     ; PUT IT IN THE BUFFER
  1005                              <1> K37C:
  1006 00001078 0450                <1> 	add	al, 80			; CONVERT SCAN CODE (EDIT KEYS)
  1007 0000107A 88C4                <1> 	mov	ah, al			; (SCAN CODE NOT IN AH FOR INSERT)
  1008 0000107C EBEC                <1> 	jmp     short K37A              ; PUT IT IN THE BUFFER
  1009                              <1> 	;
  1010                              <1> 	;-----	NOT IN ALTERNATE SHIFT
  1011                              <1> K38:					; NOT-ALT-SHIFT
  1012                              <1> 					; BL STILL HAS SHIFT FLAGS
  1013 0000107E F6C304              <1> 	test	bl, CTL_SHIFT 		; ARE WE IN CONTROL SHIFT?
  1014                              <1> 	;jnz	short K38A		; YES, START PROCESSING	
  1015 00001081 0F84B0000000        <1>         jz      K44                     ; NOT-CTL-SHIFT
  1016                              <1> 	;
  1017                              <1> 	;-----	CONTROL SHIFT, TEST SPECIAL CHARACTERS
  1018                              <1> 	;-----	TEST FOR BREAK
  1019                              <1> K38A:
  1020 00001087 3C46                <1> 	cmp	al, SCROLL_KEY		; TEST FOR BREAK
  1021 00001089 7531                <1> 	jne	short K39		; JUMP, NO-BREAK
  1022 0000108B F6C710              <1> 	test	bh, KBX			; IS THIS THE ENHANCED KEYBOARD?
  1023 0000108E 7405                <1> 	jz	short K38B		; NO, BREAK IS VALID	
  1024 00001090 F6C702              <1> 	test	bh, LC_E0		; YES, WAS LAST CODE AN E0?
  1025 00001093 7427                <1> 	jz	short K39		; NO-BREAK, TEST FOR PAUSE	
  1026                              <1> K38B:
  1027 00001095 8B1D[BEE80000]      <1> 	mov	ebx, [BUFFER_HEAD] 	; RESET BUFFER TO EMPTY
  1028 0000109B 891D[C2E80000]      <1> 	mov	[BUFFER_TAIL], ebx
  1029 000010A1 C605[B0E80000]80    <1> 	mov	byte [BIOS_BREAK], 80h  ; TURN ON BIOS_BREAK BIT
  1030                              <1> 	;
  1031                              <1> 	;-----	ENABLE KEYBOARD
  1032 000010A8 B0AE                <1> 	mov	al, ENA_KBD		; ENABLE KEYBOARD
  1033 000010AA E8BF010000          <1> 	call	SHIP_IT			; EXECUTE ENABLE
  1034                              <1> 	;
  1035                              <1> 	; CTRL+BREAK code here !!!
  1036                              <1> 	;INT	1BH			; BREAK INTERRUPT VECTOR
  1037                              <1> 	; 17/10/2015	
  1038 000010AF E8F7440000          <1> 	call	ctrlbrk ; control+break subroutine
  1039                              <1> 	;
  1040 000010B4 6629C0              <1> 	sub	ax, ax			; PUT OUT DUMMY CHARACTER
  1041 000010B7 E946010000          <1>         jmp     K57                     ; BUFFER_FILL
  1042                              <1> 	;
  1043                              <1> 	;-----	TEST FOR PAUSE
  1044                              <1> K39:					; NO_BREAK
  1045 000010BC F6C710              <1> 	test	bh, KBX			; IS THIS THE ENHANCED KEYBOARD?
  1046 000010BF 7537                <1> 	jnz	short K41		; YES, THEN THIS CAN'T BE PAUSE	
  1047 000010C1 3C45                <1> 	cmp	al, NUM_KEY		; LOOK FOR PAUSE KEY
  1048 000010C3 7533                <1> 	jne	short K41		; NO-PAUSE
  1049                              <1> K39P:
  1050 000010C5 800D[B2E80000]08    <1> 	or	byte [KB_FLAG_1], HOLD_STATE ; TURN ON THE HOLD FLAG
  1051                              <1> 	;
  1052                              <1> 	;-----	ENABLE KEYBOARD
  1053 000010CC B0AE                <1> 	mov	al, ENA_KBD		; ENABLE KEYBOARD
  1054 000010CE E89B010000          <1> 	call	SHIP_IT			; EXECUTE ENABLE
  1055                              <1> K39A:
  1056 000010D3 B020                <1> 	mov	al, EOI			; END OF INTERRUPT TO CONTROL PORT
  1057 000010D5 E620                <1> 	out	20h, al ;out INTA00, al	; ALLOW FURTHER KEYSTROKE INTERRUPTS
  1058                              <1> 	;
  1059                              <1> 	;-----	DURING PAUSE INTERVAL, TURN COLOR CRT BACK ON
  1060 000010D7 803D[E6E80000]07    <1>         cmp     byte [CRT_MODE], 7      ; IS THIS BLACK AND WHITE CARD
  1061 000010DE 740A                <1>         je      short K40              	; YES, NOTHING TO DO
  1062 000010E0 66BAD803            <1> 	mov	dx, 03D8h		; PORT FOR COLOR CARD
  1063 000010E4 A0[E7E80000]        <1>         mov     al, [CRT_MODE_SET] 	; GET THE VALUE OF THE CURRENT MODE
  1064 000010E9 EE                  <1> 	out	dx, al			; SET THE CRT MODE, SO THAT CRT IS ON
  1065                              <1> 	;
  1066                              <1> K40:					; PAUSE-LOOP
  1067 000010EA F605[B2E80000]08    <1>         test    byte [KB_FLAG_1], HOLD_STATE ; CHECK HOLD STATE FLAG
  1068 000010F1 75F7                <1> 	jnz	short K40		; LOOP UNTIL FLAG TURNED OFF
  1069                              <1> 	;
  1070 000010F3 E977FEFFFF          <1>         jmp     K27                     ; INTERRUPT_RETURN_NO_EOI
  1071                              <1>         ;
  1072                              <1> 	;-----	TEST SPECIAL CASE KEY 55
  1073                              <1> K41:					; NO-PAUSE
  1074 000010F8 3C37                <1> 	cmp	al, 55			; TEST FOR */PRTSC KEY
  1075 000010FA 7513                <1> 	jne	short K42		; NOT-KEY-55
  1076 000010FC F6C710              <1> 	test	bh, KBX			; IS THIS THE ENHANCED KEYBOARD?
  1077 000010FF 7405                <1> 	jz	short K41A		; NO, CTL-PRTSC IS VALID	
  1078 00001101 F6C702              <1> 	test	bh, LC_E0		; YES, WAS LAST CODE AN E0?
  1079 00001104 7421                <1> 	jz	short K42B		; NO, TRANSLATE TO A FUNCTION
  1080                              <1> K41A:	
  1081 00001106 66B80072            <1> 	mov	ax, 114*256		; START/STOP PRINTING SWITCH
  1082 0000110A E9F3000000          <1>         jmp     K57                     ; BUFFER_FILL
  1083                              <1> 	;
  1084                              <1> 	;-----	SET UP TO TRANSLATE CONTROL SHIFT
  1085                              <1> K42:					; NOT-KEY-55
  1086 0000110F 3C0F                <1> 	cmp	al, 15			; IS IT THE TAB KEY?
  1087 00001111 7414                <1> 	je	short K42B		; YES, XLATE TO FUNCTION CODE
  1088 00001113 3C35                <1> 	cmp	al, 53			; IS IT THE / KEY?
  1089 00001115 750E                <1> 	jne	short K42A		; NO, NO MORE SPECIAL CASES	
  1090 00001117 F6C702              <1> 	test	bh, LC_E0		; YES, IS IT FROM THE KEY PAD?
  1091 0000111A 7409                <1> 	jz	short K42A		; NO, JUST TRANSLATE
  1092 0000111C 66B80095            <1> 	mov	ax, 9500h		; YES, SPECIAL CODE FOR THIS ONE
  1093 00001120 E9DD000000          <1> 	jmp	K57			; BUFFER FILL	
  1094                              <1> K42A: 
  1095                              <1> 	;;mov	ebx, _K8		; SET UP TO TRANSLATE CTL
  1096 00001125 3C3B                <1> 	cmp	al, 59			; IS IT IN CHARACTER TABLE?
  1097                              <1>         ;jb	short K45F              ; YES, GO TRANSLATE CHAR
  1098                              <1> 	;;jb	K56 ; 20/02/2015
  1099                              <1> 	;;jmp	K64 ; 20/02/2015
  1100                              <1> K42B:
  1101 00001127 BB[A8E70000]        <1> 	mov	ebx, _K8		; SET UP TO TRANSLATE CTL
  1102 0000112C 0F82AE000000        <1> 	jb	K56 ;; 20/02/2015	
  1103 00001132 E9B9000000          <1> 	jmp	K64	
  1104                              <1>         ;
  1105                              <1> 	;-----	NOT IN CONTROL SHIFT
  1106                              <1> K44:					; NOT-CTL-SHIFT
  1107 00001137 3C37                <1> 	cmp	al, 55			; PRINT SCREEN KEY?
  1108 00001139 7528                <1> 	jne	short K45		; NOT PRINT SCREEN
  1109 0000113B F6C710              <1> 	test	bh, KBX			; IS THIS ENHANCED KEYBOARD?
  1110 0000113E 7407                <1> 	jz	short K44A		; NO, TEST FOR SHIFT STATE	
  1111 00001140 F6C702              <1> 	test	bh, LC_E0		; YES, LAST CODE A MARKER?
  1112 00001143 7507                <1> 	jnz	short K44B		; YES, IS PRINT SCREEN
  1113 00001145 EB41                <1> 	jmp	short K45C		; NO, TRANSLATE TO '*' CHARACTER
  1114                              <1> K44A:
  1115 00001147 F6C303              <1> 	test	bl, LEFT_SHIFT+RIGHT_SHIFT ; NOT 101 KBD, SHIFT KEY DOWN?
  1116 0000114A 743C                <1> 	jz	short K45C		; NO, TRANSLATE TO '*' CHARACTER
  1117                              <1> 	;
  1118                              <1> 	;-----	ISSUE INTERRUPT TO INDICATE PRINT SCREEN FUNCTION
  1119                              <1> K44B:
  1120 0000114C B0AE                <1> 	mov	al, ENA_KBD		; INSURE KEYBOARD IS ENABLED
  1121 0000114E E81B010000          <1> 	call	SHIP_IT			; EXECUTE ENABLE
  1122 00001153 B020                <1> 	mov	al, EOI			; END OF CURRENT INTERRUPT
  1123 00001155 E620                <1> 	out	20h, al ;out INTA00, al	; SO FURTHER THINGS CAN HAPPEN
  1124                              <1> 	; Print Screen !!!		; ISSUE PRINT SCREEN INTERRUPT (INT 05h)
  1125                              <1> 	;PUSH 	BP			; SAVE POINTER
  1126                              <1> 	;INT 	5H			; ISSUE PRINT SCREEN INTERRUPT
  1127                              <1> 	;POP	BP			; RESTORE POINTER
  1128 00001157 8025[B4E80000]FC    <1>         and     byte [KB_FLAG_3], ~(LC_E0+LC_E1) ; ZERO OUT THESE FLAGS
  1129 0000115E E90CFEFFFF          <1>         jmp     K27                     ; GO BACK WITHOUT EOI OCCURRING
  1130                              <1> 	;
  1131                              <1> 	;-----	HANDLE IN-CORE KEYS
  1132                              <1> K45:					; NOT-PRINT-SCREEN
  1133 00001163 3C3A                <1> 	cmp	al, 58			; TEST FOR IN-CORE AREA
  1134 00001165 7734                <1> 	ja	short K46		; JUMP IF NOT
  1135 00001167 3C35                <1> 	cmp	al, 53			; IS THIS THE '/' KEY?
  1136 00001169 7505                <1> 	jne	short K45A		; NO, JUMP
  1137 0000116B F6C702              <1> 	test	bh, LC_E0		; WAS THE LAST CODE THE MARKER?
  1138 0000116E 7518                <1> 	jnz	short K45C		; YES, TRANSLATE TO CHARACTER
  1139                              <1> K45A:
  1140 00001170 B91A000000          <1> 	mov	ecx, 26			; LENGHT OF SEARCH
  1141 00001175 BF[7EE70000]        <1> 	mov	edi, K30+10		; POINT TO TABLE OF A-Z CHARS
  1142 0000117A F2AE                <1> 	repne	scasb			; IS THIS A LETTER KEY?
  1143                              <1> 		; 20/02/2015
  1144 0000117C 7505                <1> 	jne	short K45B              ; NO, SYMBOL KEY
  1145                              <1> 	;
  1146 0000117E F6C340              <1> 	test	bl, CAPS_STATE		; ARE WE IN CAPS_LOCK?
  1147 00001181 750C                <1> 	jnz	short K45D		; TEST FOR SURE
  1148                              <1> K45B:
  1149 00001183 F6C303              <1> 	test	bl, LEFT_SHIFT+RIGHT_SHIFT ; ARE WE IN SHIFT STATE?
  1150 00001186 750C                <1> 	jnz	short K45E		; YES, UPPERCASE
  1151                              <1> 					; NO, LOWERCASE
  1152                              <1> K45C:
  1153 00001188 BB[00E80000]        <1> 	mov	ebx, K10		; TRANSLATE TO LOWERCASE LETTERS
  1154 0000118D EB51                <1> 	jmp	short K56	
  1155                              <1> K45D:					; ALMOST-CAPS-STATE
  1156 0000118F F6C303              <1> 	test	bl, LEFT_SHIFT+RIGHT_SHIFT ; CL ON. IS SHIFT ON, TOO?
  1157 00001192 75F4                <1> 	jnz	short K45C		; SHIFTED TEMP OUT OF CAPS STATE
  1158                              <1> K45E:
  1159 00001194 BB[58E80000]        <1> 	mov	ebx, K11		; TRANSLATE TO UPPER CASE LETTERS
  1160 00001199 EB45                <1> K45F:	jmp	short K56
  1161                              <1> 	;
  1162                              <1> 	;-----	TEST FOR KEYS F1 - F10
  1163                              <1> K46:					; NOT IN-CORE AREA
  1164 0000119B 3C44                <1> 	cmp	al, 68			; TEST FOR F1 - F10
  1165                              <1> 	;ja	short K47		; JUMP IF NOT
  1166                              <1> 	;jmp	short K53		; YES, GO DO FN KEY PROCESS			
  1167 0000119D 7635                <1> 	jna	short K53		
  1168                              <1> 	;
  1169                              <1> 	;-----	HANDLE THE NUMERIC PAD KEYS
  1170                              <1> K47:					; NOT F1 - F10
  1171 0000119F 3C53                <1> 	cmp	al, 83			; TEST NUMPAD KEYS
  1172 000011A1 772D                <1> 	ja	short K52		; JUMP IF NOT
  1173                              <1> 	;
  1174                              <1> 	;-----	KEYPAD KEYS, MUST TEST NUM LOCK FOR DETERMINATION
  1175                              <1> K48:
  1176 000011A3 3C4A                <1> 	cmp	al , 74			; SPECIAL CASE FOR MINUS
  1177 000011A5 74ED                <1> 	je	short K45E		; GO TRANSLATE
  1178 000011A7 3C4E                <1> 	cmp	al , 78			; SPECIAL CASE FOR PLUS
  1179 000011A9 74E9                <1> 	je	short K45E		; GO TRANSLATE
  1180 000011AB F6C702              <1> 	test	bh, LC_E0		; IS THIS ONE OFTHE NEW KEYS?
  1181 000011AE 750A                <1> 	jnz	short K49		; YES, TRANSLATE TO BASE STATE
  1182                              <1> 	;		
  1183 000011B0 F6C320              <1> 	test 	bl, NUM_STATE		; ARE WE IN NUM LOCK
  1184 000011B3 7514                <1> 	jnz	short K50		; TEST FOR SURE
  1185 000011B5 F6C303              <1> 	test	bl, LEFT_SHIFT+RIGHT_SHIFT ; ARE WE IN SHIFT STATE?
  1186                              <1> 	;jnz	short K51		; IF SHIFTED, REALLY NUM STATE
  1187 000011B8 75DA                <1> 	jnz	short K45E
  1188                              <1> 	;
  1189                              <1> 	;-----	BASE CASE FOR KEYPAD
  1190                              <1> K49:					
  1191 000011BA 3C4C                <1> 	cmp	al, 76			; SPECIAL CASE FOR BASE STATE 5
  1192 000011BC 7504                <1> 	jne	short K49A		; CONTINUE IF NOT KEYPAD 5
  1193 000011BE B0F0                <1> 	mov	al, 0F0h		; SPECIAL ASCII CODE	
  1194 000011C0 EB40                <1> 	jmp	short K57		; BUFFER FILL
  1195                              <1> K49A:
  1196 000011C2 BB[00E80000]        <1> 	mov	ebx, K10		; BASE CASE TABLE	
  1197 000011C7 EB27                <1> 	jmp	short K64		; CONVERT TO PSEUDO SCAN
  1198                              <1> 	;
  1199                              <1> 	;-----	MIGHT BE NUM LOCK, TEST SHIFT STATUS
  1200                              <1> K50:					; ALMOST-NUM-STATE
  1201 000011C9 F6C303              <1>         test    bl, LEFT_SHIFT+RIGHT_SHIFT
  1202 000011CC 75EC                <1> 	jnz 	short K49		; SHIFTED TEMP OUT OF NUM STATE
  1203 000011CE EBC4                <1> K51:	jmp	short K45E		; REALLY NUM STATE
  1204                              <1> 	;
  1205                              <1> 	;-----	TEST FOR THE NEW KEYS ON WT KEYBOARDS 
  1206                              <1> K52:					; NOT A NUMPAD KEY
  1207 000011D0 3C56                <1> 	cmp	al, 86			; IS IT THE NEW WT KEY?
  1208                              <1> 	;jne	short K53		; JUMP IF NOT
  1209                              <1> 	;jmp	short K45B		; HANDLE WITH REST OF LETTER KEYS
  1210 000011D2 74AF                <1> 	je	short K45B		
  1211                              <1> 	;
  1212                              <1> 	;-----	MUST BE F11 OR F12 
  1213                              <1> K53:					; F1 - F10 COME HERE, TOO
  1214 000011D4 F6C303              <1> 	test	bl, LEFT_SHIFT+RIGHT_SHIFT ; TEST SHIFT STATE
  1215 000011D7 74E1                <1> 	jz	short K49		; JUMP, LOWER CASE PSEUDO SC'S
  1216                              <1> 		; 20/02/2015 
  1217 000011D9 BB[58E80000]        <1> 	mov	ebx, K11		; UPPER CASE PSEUDO SCAN CODES
  1218 000011DE EB10                <1> 	jmp	short K64		; TRANSLATE SCAN
  1219                              <1> 	;
  1220                              <1> 	;-----	TRANSLATE THE CHARACTER
  1221                              <1> K56:					; TRANSLATE-CHAR
  1222 000011E0 FEC8                <1> 	dec	al			; CONVERT ORIGIN
  1223 000011E2 D7                  <1> 	xlat    			; CONVERT THE SCAN CODE TO ASCII
  1224 000011E3 F605[B4E80000]02    <1> 	test	byte [KB_FLAG_3], LC_E0	; IS THIS A NEW KEY?
  1225 000011EA 7416                <1> 	jz	short K57		; NO, GO FILL BUFFER
  1226 000011EC B4E0                <1> 	mov	ah, MC_E0		; YES, PUT SPECIAL MARKER IN AH
  1227 000011EE EB12                <1> 	jmp	short K57		; PUT IT INTO THE BUFFER	
  1228                              <1> 	;
  1229                              <1> 	;-----	TRANSLATE SCAN FOR PSEUDO SCAN CODES
  1230                              <1> K64:					; TRANSLATE-SCAN-ORGD
  1231 000011F0 FEC8                <1> 	dec	al			; CONVERT ORIGIN
  1232 000011F2 D7                  <1>        	xlat    	                ; CTL TABLE SCAN
  1233 000011F3 88C4                <1> 	mov	ah, al			; PUT VALUE INTO AH
  1234 000011F5 B000                <1> 	mov	al, 0			; ZERO ASCII CODE
  1235 000011F7 F605[B4E80000]02    <1> 	test	byte [KB_FLAG_3], LC_E0	; IS THIS A NEW KEY?
  1236 000011FE 7402                <1> 	jz	short K57		; NO, GO FILL BUFFER
  1237 00001200 B0E0                <1> 	mov	al, MC_E0		; YES, PUT SPECIAL MARKER IN AL
  1238                              <1> 	;
  1239                              <1> 	;-----	PUT CHARACTER INTO BUFFER
  1240                              <1> K57:					; BUFFER_FILL
  1241 00001202 3CFF                <1> 	cmp	al, -1			; IS THIS AN IGNORE CHAR
  1242                              <1>         ;je	short K59		; YES, DO NOTHING WITH IT
  1243 00001204 0F8459FDFFFF        <1> 	je      K26			; YES, DO NOTHING WITH IT
  1244 0000120A 80FCFF              <1> 	cmp	ah, -1			; LOOK FOR -1 PSEUDO SCAN
  1245                              <1>         ;jne	short K61		; NEAR_INTERRUPT_RETURN
  1246 0000120D 0F8450FDFFFF        <1> 	je      K26			; INTERRUPT_RETURN
  1247                              <1> ;K59:					; NEAR_INTERRUPT_RETURN
  1248                              <1> ;	jmp	K26			; INTERRUPT_RETURN
  1249                              <1> 
  1250                              <1> _K60: ; 29/01/2016
  1251 00001213 80FC68              <1> 	cmp	ah, 68h	; ALT + F1 key
  1252 00001216 721F                <1> 	jb	short K61
  1253 00001218 80FC6F              <1> 	cmp	ah, 6Fh ; ALT + F8 key	
  1254 0000121B 771A                <1> 	ja	short K61
  1255                              <1> 	;
  1256 0000121D 8A1D[D61F0100]      <1> 	mov	bl, [ACTIVE_PAGE]
  1257 00001223 80C368              <1> 	add	bl, 68h
  1258 00001226 38E3                <1> 	cmp	bl, ah
  1259 00001228 740D                <1> 	je	short K61
  1260 0000122A 6650                <1> 	push	ax
  1261 0000122C 88E0                <1> 	mov	al, ah
  1262 0000122E 2C68                <1> 	sub	al, 68h
  1263 00001230 E8B1050000          <1> 	call	set_active_page
  1264 00001235 6658                <1> 	pop	ax
  1265                              <1> K61:					; NOT-CAPS-STATE
  1266 00001237 8B1D[C2E80000]      <1> 	mov	ebx, [BUFFER_TAIL] 	; GET THE END POINTER TO THE BUFFER
  1267 0000123D 89DE                <1> 	mov	esi, ebx		; SAVE THE VALUE
  1268 0000123F E857FAFFFF          <1> 	call	_K4			; ADVANCE THE TAIL
  1269 00001244 3B1D[BEE80000]      <1> 	cmp	ebx, [BUFFER_HEAD] 	; HAS THE BUFFER WRAPPED AROUND
  1270 0000124A 740E                <1> 	je	short K62		; BUFFER_FULL_BEEP
  1271 0000124C 668906              <1> 	mov	[esi], ax		; STORE THE VALUE
  1272 0000124F 891D[C2E80000]      <1> 	mov	[BUFFER_TAIL], ebx 	; MOVE THE POINTER UP
  1273 00001255 E909FDFFFF          <1> 	jmp	K26
  1274                              <1> 	;;cli				; TURN OFF INTERRUPTS
  1275                              <1> 	;;mov	al, EOI			; END OF INTERRUPT COMMAND
  1276                              <1> 	;;out	INTA00, al		; SEND COMMAND TO INTERRUPT CONTROL PORT
  1277                              <1> 	;MOV	AL, ENA_KBD		; INSURE KEYBOARD IS ENABLED
  1278                              <1> 	;CALL	SHIP_IT			; EXECUTE ENABLE
  1279                              <1> 	;MOV	AX, 9102H		; MOVE IN POST CODE & TYPE
  1280                              <1> 	;INT	15H			; PERFORM OTHER FUNCTION
  1281                              <1> 	;;and	byte [KB_FLAG_3],~(LC_E0+LC_E1) ; RESET LAST CHAR H.C. FLAG
  1282                              <1> 	;JMP	K27A			; INTERRUPT_RETURN
  1283                              <1> 	;;jmp   K27                    
  1284                              <1> 	;
  1285                              <1> 	;-----	BUFFER IS FULL SOUND THE BEEPER
  1286                              <1> K62:
  1287 0000125A B020                <1> 	mov	al, EOI			; ENABLE INTERRUPT CONTROLLER CHIP
  1288 0000125C E620                <1> 	out	INTA00, al
  1289 0000125E 66B9A602            <1> 	mov	cx, 678			; DIVISOR FOR 1760 HZ
  1290 00001262 B304                <1> 	mov	bl, 4			; SHORT BEEP COUNT (1/16 + 1/64 DELAY)
  1291 00001264 E8A2090000          <1> 	call	beep			; GO TO COMMON BEEP HANDLER
  1292 00001269 E901FDFFFF          <1> 	jmp     K27			; EXIT   
  1293                              <1> 
  1294                              <1> SHIP_IT:
  1295                              <1> 	;---------------------------------------------------------------------------------
  1296                              <1> 	; SHIP_IT
  1297                              <1> 	;	THIS ROUTINES HANDLES TRANSMISSION OF COMMAND AND DATA BYTES
  1298                              <1> 	;	TO THE KEYBOARD CONTROLLER.
  1299                              <1> 	;---------------------------------------------------------------------------------
  1300                              <1> 	;
  1301 0000126E 6650                <1> 	push	ax			; SAVE DATA TO SEND
  1302                              <1> 
  1303                              <1> 	;-----	WAIT FOR COMMAND TO ACCEPTED
  1304 00001270 FA                  <1> 	cli				; DISABLE INTERRUPTS TILL DATA SENT
  1305                              <1> 	; xor	ecx, ecx		; CLEAR TIMEOUT COUNTER
  1306 00001271 B900000100          <1> 	mov	ecx, 10000h			
  1307                              <1> S10:
  1308 00001276 E464                <1> 	in	al, STATUS_PORT		; READ KEYBOARD CONTROLLER STATUS
  1309 00001278 A802                <1> 	test	al, INPT_BUF_FULL	; CHECK FOR ITS INPUT BUFFER BUSY
  1310 0000127A E0FA                <1> 	loopnz	S10			; WAIT FOR COMMAND TO BE ACCEPTED
  1311                              <1> 
  1312 0000127C 6658                <1> 	pop	ax			; GET DATA TO SEND
  1313 0000127E E664                <1> 	out	STATUS_PORT, al		; SEND TO KEYBOARD CONTROLLER
  1314 00001280 FB                  <1> 	sti				; ENABLE INTERRUPTS AGAIN
  1315 00001281 C3                  <1> 	retn				; RETURN TO CALLER
  1316                              <1> 
  1317                              <1> SND_DATA:
  1318                              <1> 	; ---------------------------------------------------------------------------------
  1319                              <1> 	; SND_DATA
  1320                              <1> 	;	THIS ROUTINES HANDLES TRANSMISSION OF COMMAND AND DATA BYTES
  1321                              <1> 	;	TO THE KEYBOARD AND RECEIPT OF ACKNOWLEDGEMENTS. IT ALSO
  1322                              <1> 	;	HANDLES ANY RETRIES IF REQUIRED
  1323                              <1> 	; ---------------------------------------------------------------------------------
  1324                              <1> 	;
  1325 00001282 6650                <1> 	push	ax			; SAVE REGISTERS
  1326 00001284 6653                <1> 	push	bx
  1327 00001286 51                  <1> 	push	ecx
  1328 00001287 88C7                <1> 	mov	bh, al			; SAVE TRANSMITTED BYTE FOR RETRIES
  1329 00001289 B303                <1> 	mov	bl, 3			; LOAD RETRY COUNT
  1330                              <1> SD0:
  1331 0000128B FA                  <1> 	cli				; DISABLE INTERRUPTS
  1332 0000128C 8025[B3E80000]CF    <1> 	and	byte [KB_FLAG_2], ~(KB_FE+KB_FA) ; CLEAR ACK AND RESEND FLAGS
  1333                              <1> 	;
  1334                              <1> 	;-----	WAIT FOR COMMAND TO BE ACCEPTED
  1335 00001293 B900000100          <1> 	mov	ecx, 10000h		; MAXIMUM WAIT COUNT
  1336                              <1> SD5:
  1337 00001298 E464                <1> 	in	al, STATUS_PORT		; READ KEYBOARD PROCESSOR STATUS PORT
  1338 0000129A A802                <1> 	test	al, INPT_BUF_FULL	; CHECK FOR ANY PENDING COMMAND
  1339 0000129C E0FA                <1> 	loopnz	SD5			; WAIT FOR COMMAND TO BE ACCEPTED
  1340                              <1> 	;
  1341 0000129E 88F8                <1> 	mov	al, bh			; REESTABLISH BYTE TO TRANSMIT
  1342 000012A0 E660                <1> 	out	PORT_A, al		; SEND BYTE
  1343 000012A2 FB                  <1> 	sti				; ENABLE INTERRUPTS
  1344                              <1> 	;mov	cx, 01A00h		; LOAD COUNT FOR 10 ms+
  1345 000012A3 B9FFFF0000          <1> 	mov	ecx, 0FFFFh
  1346                              <1> SD1:
  1347 000012A8 F605[B3E80000]30    <1> 	test	byte [KB_FLAG_2], KB_FE+KB_FA ; SEE IF EITHER BIT SET
  1348 000012AF 750F                <1> 	jnz	short SD3		; IF SET, SOMETHING RECEIVED GO PROCESS
  1349 000012B1 E2F5                <1> 	loop	SD1			; OTHERWISE WAIT
  1350                              <1> SD2:
  1351 000012B3 FECB                <1> 	dec	bl			; DECREMENT RETRY COUNT
  1352 000012B5 75D4                <1> 	jnz	short SD0		; RETRY TRANSMISSION
  1353 000012B7 800D[B3E80000]80    <1> 	or	byte [KB_FLAG_2], KB_ERR ; TURN ON TRANSMIT ERROR FLAG
  1354 000012BE EB09                <1> 	jmp	short SD4		; RETRIES EXHAUSTED FORGET TRANSMISSION
  1355                              <1> SD3:
  1356 000012C0 F605[B3E80000]10    <1> 	test	byte [KB_FLAG_2], KB_FA ; SEE IF THIS IS AN ACKNOWLEDGE
  1357 000012C7 74EA                <1> 	jz	short SD2		; IF NOT, GO RESEND
  1358                              <1> SD4:	
  1359 000012C9 59                  <1> 	pop	ecx			; RESTORE REGISTERS
  1360 000012CA 665B                <1> 	pop	bx
  1361 000012CC 6658                <1> 	pop	ax
  1362 000012CE C3                  <1> 	retn				; RETURN, GOOD TRANSMISSION
  1363                              <1> 
  1364                              <1> SND_LED:
  1365                              <1> 	; ---------------------------------------------------------------------------------
  1366                              <1> 	; SND_LED
  1367                              <1> 	;	THIS ROUTINES TURNS ON THE MODE INDICATORS.
  1368                              <1> 	;
  1369                              <1> 	;----------------------------------------------------------------------------------
  1370                              <1> 	;
  1371 000012CF FA                  <1> 	cli				; TURN OFF INTERRUPTS
  1372 000012D0 F605[B3E80000]40    <1> 	test	byte [KB_FLAG_2], KB_PR_LED ; CHECK FOR MODE INDICATOR UPDATE
  1373 000012D7 755F                <1> 	jnz 	short SL1		; DON'T UPDATE AGAIN IF UPDATE UNDERWAY
  1374                              <1> 	;
  1375 000012D9 800D[B3E80000]40    <1> 	or	byte [KB_FLAG_2], KB_PR_LED ; TURN ON UPDATE IN PROCESS
  1376 000012E0 B020                <1> 	mov	al, EOI			; END OF INTERRUPT COMMAND
  1377 000012E2 E620                <1> 	out	20h, al ;out INTA00, al	; SEND COMMAND TO INTERRUPT CONTROL PORT
  1378 000012E4 EB11                <1> 	jmp	short SL0		; GO SEND MODE INDICATOR COMMAND
  1379                              <1> SND_LED1:
  1380 000012E6 FA                  <1> 	cli				; TURN OFF INTERRUPTS
  1381 000012E7 F605[B3E80000]40    <1> 	test	byte [KB_FLAG_2], KB_PR_LED ; CHECK FOR MODE INDICATOR UPDATE
  1382 000012EE 7548                <1> 	jnz	short SL1		; DON'T UPDATE AGAIN IF UPDATE UNDERWAY
  1383                              <1> 	;
  1384 000012F0 800D[B3E80000]40    <1> 	or	byte [KB_FLAG_2], KB_PR_LED ; TURN ON UPDATE IN PROCESS
  1385                              <1> SL0:
  1386 000012F7 B0ED                <1> 	mov	al, LED_CMD		; LED CMD BYTE
  1387 000012F9 E884FFFFFF          <1> 	call	SND_DATA		; SEND DATA TO KEYBOARD
  1388 000012FE FA                  <1> 	cli
  1389 000012FF E836000000          <1> 	call	MAKE_LED		; GO FORM INDICATOR DATA BYTE
  1390 00001304 8025[B3E80000]F8    <1> 	and	byte [KB_FLAG_2], 0F8h	; ~KB_LEDS ; CLEAR MODE INDICATOR BITS
  1391 0000130B 0805[B3E80000]      <1> 	or	[KB_FLAG_2], al 	; SAVE PRESENT INDICATORS FOR NEXT TIME
  1392 00001311 F605[B3E80000]80    <1> 	test	byte [KB_FLAG_2], KB_ERR ; TRANSMIT ERROR DETECTED
  1393 00001318 750F                <1> 	jnz	short SL2		; IF SO, BYPASS SECOND BYTE TRANSMISSION
  1394                              <1> 	;
  1395 0000131A E863FFFFFF          <1> 	call	SND_DATA		; SEND DATA TO KEYBOARD
  1396 0000131F FA                  <1> 	cli				; TURN OFF INTERRUPTS
  1397 00001320 F605[B3E80000]80    <1> 	test	byte [KB_FLAG_2], KB_ERR ; TRANSMIT ERROR DETECTED
  1398 00001327 7408                <1> 	jz	short SL3		; IF NOT, DON'T SEND AN ENABLE COMMAND
  1399                              <1> SL2:
  1400 00001329 B0F4                <1> 	mov	al, KB_ENABLE		; GET KEYBOARD CSA ENABLE COMMAND
  1401 0000132B E852FFFFFF          <1> 	call	SND_DATA		; SEND DATA TO KEYBOARD
  1402 00001330 FA                  <1> 	cli				; TURN OFF INTERRUPTS
  1403                              <1> SL3:
  1404 00001331 8025[B3E80000]3F    <1> 	and	byte [KB_FLAG_2], ~(KB_PR_LED+KB_ERR) ; TURN OFF MODE INDICATOR
  1405                              <1> SL1:					; UPDATE AND TRANSMIT ERROR FLAG
  1406 00001338 FB                  <1> 	sti				; ENABLE INTERRUPTS
  1407 00001339 C3                  <1> 	retn				; RETURN TO CALLER
  1408                              <1> 
  1409                              <1> MAKE_LED:
  1410                              <1> 	;---------------------------------------------------------------------------------
  1411                              <1> 	; MAKE_LED
  1412                              <1> 	;	THIS ROUTINES FORMS THE DATA BYTE NECESSARY TO TURN ON/OFF
  1413                              <1> 	;	THE MODE INDICATORS.
  1414                              <1> 	;---------------------------------------------------------------------------------
  1415                              <1> 	;
  1416                              <1> 	;push 	cx			; SAVE CX
  1417 0000133A A0[B1E80000]        <1> 	mov	al, [KB_FLAG]		; GET CAPS & NUM LOCK INDICATORS
  1418 0000133F 2470                <1> 	and	al, CAPS_STATE+NUM_STATE+SCROLL_STATE ; ISOLATE INDICATORS
  1419                              <1> 	;mov	cl, 4			; SHIFT COUNT
  1420                              <1> 	;rol	al, cl			; SHIFT BITS OVER TO TURN ON INDICATORS
  1421 00001341 C0C004              <1> 	rol	al, 4 ; 20/02/2015
  1422 00001344 2407                <1> 	and	al, 07h			; MAKE SURE ONLY MODE BITS ON
  1423                              <1> 	;pop	cx
  1424 00001346 C3                  <1> 	retn				; RETURN TO CALLER
  1425                              <1> 
  1426                              <1> ; % include 'kybdata.s'   ; KEYBOARD DATA
  1427                              <1> 
  1428                              <1> 
  1429                              <1> ; /// End Of KEYBOARD FUNCTIONS ///
  1695                                  
  1696                                  %include 'video.s' ; 07/03/2015
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.0 - video.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 30/07/2016
     5                              <1> ; ----------------------------------------------------------------------------
     6                              <1> ; Beginning: 16/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> ; 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 00001347 9C                  <1> 	pushfd
    35 00001348 0E                  <1> 	push 	cs
    36 00001349 E851000000          <1> 	call 	VIDEO_IO_1
    37 0000134E 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 0000134F [FB130000]          <1> M1:	dd	SET_MODE	; TABLE OF ROUTINES WITHIN VIDEO I/O
   191 00001353 [57170000]          <1> 	dd	SET_CTYPE
   192 00001357 [7E170000]          <1> 	dd	SET_CPOS
   193 0000135B [91170000]          <1> 	dd	READ_CURSOR
   194                              <1> 	;dd	VIDEO_RETURN	; READ_LPEN
   195 0000135F [E4130000]          <1> 	dd	set_mode_ncm	; Set mode without clearing video memory
   196 00001363 [C3170000]          <1> 	dd	ACT_DISP_PAGE
   197 00001367 [5A180000]          <1> 	dd	SCROLL_UP
   198 0000136B [7E190000]          <1> 	dd	SCROLL_DOWN
   199 0000136F [FF190000]          <1> 	dd	READ_AC_CURRENT
   200 00001373 [571A0000]          <1> 	dd	WRITE_AC_CURRENT
   201 00001377 [7D1A0000]          <1> 	dd	WRITE_C_CURRENT
   202 0000137B [24230000]          <1> 	dd	SET_COLOR
   203 0000137F [8F230000]          <1> 	dd	WRITE_DOT
   204 00001383 [5A230000]          <1> 	dd	READ_DOT
   205 00001387 [FF1A0000]          <1> 	dd	WRITE_TTY
   206 0000138B [CD130000]          <1> 	dd	VIDEO_STATE
   207 0000138F [00140000]          <1> 	dd	VIDEO_RETURN	; RESERVED
   208 00001393 [5B280000]          <1> 	dd	font_setup    ; 10/07/2016 (TRDOS 386)
   209 00001397 [00140000]          <1> 	dd	VIDEO_RETURN	; RESERVED
   210 0000139B [6C1C0000]          <1> 	dd	WRITE_STRING  ; 23/06/2016 (TRDOS 386)
   211                              <1> M1L	EQU	$ - M1
   212                              <1> 
   213                              <1> ; 04/07/2016
   214                              <1> ; 12/05/2016
   215                              <1> ; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
   216                              <1> int31h:  ; Video BIOS
   217                              <1> 
   218                              <1> ; BH = Video page number
   219                              <1> ; BL = Color/Attribute
   220                              <1> ; AH = Function number
   221                              <1> ; AL = Character
   222                              <1> 
   223                              <1> VIDEO_IO_1:
   224 0000139F FB                  <1> 	sti				; INTERRUPTS BACK ON
   225 000013A0 FC                  <1> 	cld				; SET DIRECTION FORWARD
   226 000013A1 80FC14              <1> 	cmp	ah, M1L/4		; TEST FOR WITHIN TABLE RANGE
   227 000013A4 7326                <1> 	jnb	short M4		; BRANCH TO EXIT IF NOT A VALID COMMAND
   228                              <1> 
   229 000013A6 06                  <1> 	push	es
   230 000013A7 1E                  <1> 	push	ds			; SAVE WORK AND PARAMETER REGISTERS
   231 000013A8 52                  <1> 	push	edx
   232 000013A9 51                  <1> 	push	ecx
   233 000013AA 53                  <1> 	push	ebx
   234 000013AB 56                  <1> 	push	esi
   235 000013AC 57                  <1> 	push	edi
   236 000013AD 55                  <1> 	push	ebp
   237 000013AE 66BE1000            <1> 	mov	si, KDATA 		; POINT DS: TO DATA SEGMENT
   238 000013B2 8EDE                <1> 	mov	ds, si
   239 000013B4 8EC6                <1> 	mov	es, si
   240 000013B6 BF00800B00          <1> 	mov	edi, 0B8000h		; GET offset FOR COLOR CARD
   241 000013BB A3[242D0100]        <1> 	mov	[video_eax], eax ; 12/05/2016 
   242                              <1> 	; 23/03/2016
   243 000013C0 C0E402              <1> 	shl	ah, 2  ; dword		; TIMES 2 FOR WORD TABLE LOOKUP
   244 000013C3 0FB6F4              <1> 	movzx	esi, ah			; MOVE OFFSET INTO LOOK UP REGISTER (SI)
   245                              <1> 	;mov	ah, [CRT_MODE]		; MOVE CURRENT MODE INTO (AH) REGISTER
   246                              <1> 
   247 000013C6 FFA6[4F130000]      <1> 	JMP	dword [esi+M1]		; GO TO SELECTED FUNCTION
   248                              <1> 
   249                              <1> M4:					; COMMAND NOT VALID
   250 000013CC CF                  <1> 	iret				; DO NOTHING IF NOT IN VALID RANGE
   251                              <1> 
   252                              <1> VIDEO_STATE:
   253                              <1> 	; 26/06/2016
   254                              <1> 	; 12/05/2016
   255                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
   256                              <1> 
   257                              <1> ;---------------------------------------------------
   258                              <1> ; VIDEO STATE
   259                              <1> ;  RETURNS THE CURRENT VIDEO STATE IN AX
   260                              <1> ;  AH = NUMBER OF COLUMNS ON THE SCREEN
   261                              <1> ;  AL = CURRENT VIDEO MODE
   262                              <1> ;  BH = CURRENT ACTIVE PAGE
   263                              <1> ;---------------------------------------------------
   264                              <1> 
   265 000013CD 8A25[E8E80000]      <1> 	mov	ah, [CRT_COLS]	; GET NUMBER OF COLUMNS
   266 000013D3 A0[E6E80000]        <1> 	mov	al, [CRT_MODE]	; CURRENT MODE
   267                              <1> 	;movzx	esi, al
   268                              <1> 	;mov	ah, [esi+M6] 
   269                              <1> 	; BH = active page
   270 000013D8 8A3D[D61F0100]      <1> 	mov	bh, [ACTIVE_PAGE] ; GET CURRENT ACTIVE PAGE
   271 000013DE 5D                  <1> 	pop	ebp		; RECOVER REGISTERS
   272 000013DF 5F                  <1> 	pop	edi
   273 000013E0 5E                  <1> 	pop	esi
   274 000013E1 59                  <1> 	pop	ecx		; DISCARD SAVED BX
   275 000013E2 EB25                <1> 	jmp	short M15	; RETURN TO CALLER
   276                              <1> 
   277                              <1> set_mode_ncm:
   278                              <1> 	; 04/07/2016 - TRDOS 386 (TRDOS v2.0)
   279                              <1> 	; set mode without clearing the video memory
   280                              <1> 	; (ony for graphics modes)
   281 000013E4 3C07                <1> 	cmp	al, 7 ; IBM PC CGA modes
   282 000013E6 7613                <1> 	jna	short SET_MODE ; normal function (clear)
   283                              <1> 	; do not clear memory
   284 000013E8 A2[332D0100]        <1> 	mov	[noclearmem], al ; > 0
   285 000013ED E81E000000          <1> 	call	_set_mode
   286 000013F2 C605[332D0100]00    <1> 	mov	byte [noclearmem], 0
   287 000013F9 EB05                <1>         jmp     short VIDEO_RETURN
   288                              <1> 
   289                              <1> 	; 30/07/2016
   290                              <1> 	; 29/07/2016
   291                              <1> 	; 27/07/2016
   292                              <1> 	; 26/07/2016
   293                              <1> 	; 25/07/2016
   294                              <1> 	; 23/07/2016
   295                              <1> 	; 18/07/2016
   296                              <1> 	; 02/07/2016
   297                              <1> 	; 26/06/2016
   298                              <1> 	; 24/06/2016
   299                              <1> 	; 29/05/2016 - TRDOS 386 (TRDOS v2.0)
   300                              <1> SET_MODE:
   301                              <1> 	; For 32 bit TRDOS and Retro UNIX 386:
   302                              <1> 	;	valid video mode: 03h only!
   303                              <1> 	;	(VGA modes will be selected with another routine)
   304                              <1> 	;
   305                              <1> 	; set_txt_mode ; 80*25 (16 fore colors, 8 back colors)
   306                              <1> 
   307                              <1> ;------------------------------------------------------
   308                              <1> ; SET MODE					      :
   309                              <1> ;	THIS ROUTINE INITIALIZES THE ATTACHMENT TO    :
   310                              <1> ;	THE SELECTED MODE, THE SCREEN IS BLANKED.     :
   311                              <1> ; INPUT						      :
   312                              <1> ;	(AL) - MODE SELECTED (RANGE 0-7)	      :
   313                              <1> ; OUTPUT					      :
   314                              <1> ;	NONE					      :
   315                              <1> ;------------------------------------------------------
   316                              <1> 
   317 000013FB E810000000          <1> 	call	_set_mode ; 24/06/2016 (set_txt_mode)
   318                              <1> 
   319                              <1> ; 12/05/2016
   320                              <1> ; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
   321                              <1> 
   322                              <1> ;-----	NORMAL RETURN FROM ALL VIDEO RETURNS
   323                              <1> 
   324                              <1> VIDEO_RETURN:
   325 00001400 A1[242D0100]        <1> 	mov	eax, [video_eax] ; 12/05/2016
   326                              <1> _video_return:
   327 00001405 5D                  <1> 	pop	ebp
   328 00001406 5F                  <1> 	pop	edi
   329 00001407 5E                  <1> 	pop	esi
   330 00001408 5B                  <1> 	pop	ebx
   331                              <1> M15:	; VIDEO_RETURN_C
   332 00001409 59                  <1> 	pop	ecx
   333 0000140A 5A                  <1> 	pop	edx
   334 0000140B 1F                  <1> 	pop	ds
   335 0000140C 07                  <1> 	pop	es	; RECOVER SEGMENTS
   336 0000140D CF                  <1> 	iret		; ALL DONE
   337                              <1> 
   338                              <1> set_txt_mode:
   339                              <1> 	; 29/07/2016
   340                              <1> 	; 27/06/2016
   341 0000140E B003                <1> 	mov	al, 3
   342                              <1> 
   343                              <1> ; 30/07/2016
   344                              <1> ; 29/07/2016
   345                              <1> ; 27/07/2016
   346                              <1> ; 26/07/2016
   347                              <1> ; 25/07/2016
   348                              <1> ; 23/07/2016
   349                              <1> ; 18/07/2016
   350                              <1> ; 07/07/2016
   351                              <1> ; 04/07/2016
   352                              <1> ; 03/07/2016
   353                              <1> ; 02/07/2016
   354                              <1> ; 26/06/2016
   355                              <1> ; 24/06/2016 (set_txt_mode -> _set_mode)
   356                              <1> ; 17/06/2016
   357                              <1> ; 29/05/2016
   358                              <1> ; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
   359                              <1> _set_mode:
   360                              <1> 	; 24/06/2016
   361 00001410 3805[E6E80000]      <1> 	cmp	[CRT_MODE], al  ; current mode = requested mode ?
   362 00001416 750D                <1> 	jne	short _sm_0
   363 00001418 3C03                <1> 	cmp	al, 3		; text, 80*25 color, default mode
   364                              <1> 				; for TRDOS 386 MainProg
   365 0000141A 755F                <1>         jne     short _sm_2	;  multiscreen is only for mode 3
   366                              <1> 
   367                              <1> 	; If '_set_mode' procedure is called for video mode 3
   368                              <1> 	;     while video mode is 3, video page will be cleared
   369                              <1> 	;     and cursor position of video page will be reset.	  
   370                              <1> 	
   371                              <1> 	; 29/07/2016
   372 0000141C 800D[312D0100]80    <1> 	or	byte [p_crt_mode], 80h ; clear page indicator
   373 00001423 EB5B                <1>         jmp     short _sm_3
   374                              <1> _sm_0:  
   375 00001425 803D[E6E80000]03    <1> 	cmp	byte [CRT_MODE], 3
   376 0000142C 7534                <1>         jne     short _sm_1
   377                              <1> 
   378                              <1> 	; If '_set_mode' procedure is called for a video mode
   379                              <1> 	;     except video mode 3, while current video mode
   380                              <1> 	;     is 3; all video pages of mode 3 will be copied 
   381                              <1> 	;     to 98000h address as backup, before mode change.	
   382                              <1> 
   383                              <1> _sm_save_pm:
   384                              <1> 	; 03/07/2016
   385                              <1> 	; save video pages
   386 0000142E BE00800B00          <1> 	mov	esi, 0B8000h
   387 00001433 BF00800900          <1> 	mov	edi, 98000h ; 30/07/2016
   388 00001438 B900200000          <1> 	mov	ecx, (0B8000h-0B0000h)/4
   389 0000143D F3A5                <1> 	rep	movsd
   390                              <1> 
   391 0000143F C605[312D0100]03    <1> 	mov	byte [p_crt_mode], 3 ; previous mode, backup sign
   392                              <1> 	;mov	cl, [ACTIVE_PAGE]
   393                              <1> 	;mov	[p_crt_page], cl
   394                              <1> 
   395                              <1> 	; save cursor positions
   396 00001446 BE[C61F0100]        <1> 	mov	esi, CURSOR_POSN
   397 0000144B BF[362D0100]        <1> 	mov	edi, cursor_pposn    ; cursor positions backup
   398 00001450 B104                <1> 	mov	cl, 4
   399 00001452 F3A5                <1> 	rep	movsd
   400                              <1> 
   401                              <1> 	; 29/07/2016
   402                              <1> 	;mov	[ACTIVE_PAGE], cl ; 0
   403 00001454 860D[D61F0100]      <1> 	xchg	cl, [ACTIVE_PAGE]
   404 0000145A 880D[322D0100]      <1> 	mov	[p_crt_page], cl     ; previous page (for mode 3)	
   405                              <1> 	; [ACTIVE_PAGE] = 0 
   406 00001460 EB19                <1> 	jmp	short _sm_2
   407                              <1> 
   408                              <1> _sm_1:
   409 00001462 3C03                <1> 	cmp	al, 3		; text, 80*25 color, default mode
   410                              <1> 				; for TRDOS 386 MainProg
   411 00001464 7515                <1> 	jne	short _sm_2  ;  multiscreen is only for mode 3
   412                              <1> 
   413                              <1> 	; If '_set_mode' procedure is called for video mode 3
   414                              <1> 	;     while video mode is not 3 and if there is video
   415                              <1> 	;     page backup for video mode 3, all (of 8) mode 3
   416                              <1> 	;     video pages will be restored from 98000h.
   417                              <1> 
   418 00001466 803D[312D0100]03    <1> 	cmp	byte [p_crt_mode], 3 ; previous mode, backup sign
   419 0000146D 750C                <1> 	jne	short _sm_2 ; there is no (multiscreen) video pages
   420                              <1> 			 ; to be restored
   421 0000146F 8A0D[322D0100]      <1> 	mov	cl, [p_crt_page]
   422 00001475 880D[D61F0100]      <1> 	mov	[ACTIVE_PAGE], cl
   423                              <1> 
   424                              <1> _sm_2:
   425 0000147B A2[E6E80000]        <1> 	mov	[CRT_MODE], al  ; save mode in global variable
   426                              <1> _sm_3:
   427                              <1> 	; 30/07/2016
   428                              <1> 	; 26/07/2016
   429                              <1> 	; 25/07/2016
   430                              <1> 	; set_mode_vga:
   431                              <1> 	; 18/07/2016
   432                              <1> 	; 14/07/2016
   433                              <1> 	; 09/07/2016
   434                              <1> 	; 04/07/2016
   435                              <1> 	; 03/07/2016 (TRDOS 386 = TRDOS v2.0)
   436                              <1> 	; /// video mode 13h ///
   437                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
   438                              <1> 	; vgabios-0.7a (2011)
   439                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
   440                              <1> 	; 'vgabios.c', 'vgatables.h'
   441                              <1> 	;
   442                              <1> 	; Oracle VirtualBox 5.0.24 VGABios Source Code
   443                              <1> 	; ('vgabios.c', 'vgatables.h', 'vgafonts.h', 'vgarom.asm')
   444                              <1> 	;
   445 00001480 88C4                <1> 	mov	ah, al
   446 00001482 B910000000          <1> 	mov	ecx, vga_mode_count 	
   447 00001487 BE[02E90000]        <1> 	mov	esi, vga_modes
   448 0000148C 31DB                <1> 	xor	ebx, ebx
   449                              <1> _sm_4:
   450 0000148E AC                  <1> 	lodsb
   451 0000148F 38C4                <1> 	cmp	ah, al
   452 00001491 740C                <1> 	je	short _sm_5
   453 00001493 FEC3                <1> 	inc	bl
   454 00001495 E2F7                <1> 	loop	_sm_4
   455                              <1> 
   456                              <1> 	; UNIMPLEMENTED VIDEO MODE !
   457 00001497 31C0                <1> 	xor	eax, eax
   458 00001499 A3[242D0100]        <1>         mov     [video_eax], eax ; 0 
   459 0000149E C3                  <1> 	retn
   460                              <1> 
   461                              <1> ;-----	eBX POINTS TO CORRECT ROW OF INITIALIZATION TABLE	
   462                              <1> 
   463                              <1> _sm_5: 	; 25/07/2016
   464 0000149F 89DE                <1> 	mov	esi, ebx
   465 000014A1 81C6[52E90000]      <1> 	add	esi, vga_memmodel
   466 000014A7 8A06                <1> 	mov	al, [esi]
   467 000014A9 A2[4A2D0100]        <1> 	mov	[VGA_MTYPE], al
   468                              <1> 
   469 000014AE 89DF                <1> 	mov	edi, ebx
   470 000014B0 81C7[62E90000]      <1> 	add	edi, vga_dac_s 	
   471 000014B6 C0E302              <1> 	shl	bl, 2 ; byte -> dword
   472 000014B9 81C3[12E90000]      <1> 	add	ebx, vga_mode_tbl_ptr
   473                              <1> 
   474                              <1> 	;mov	dword [VGA_BASE], 0B8000h
   475                              <1> 	;cmp	ah, 0Dh ; [CRT_MODE]
   476                              <1> 	;jb	short M9 
   477                              <1> 	;mov	dword [VGA_BASE], 0A0000h
   478                              <1> ;M9:
   479 000014BF 8B33                <1> 	mov	esi, [ebx]
   480 000014C1 89F3                <1> 	mov	ebx, esi
   481 000014C3 83C614              <1> 	add	esi, vga_p_cm_pos ; ebx + 20
   482 000014C6 668B06              <1> 	mov	ax, [esi]       ; get the cursor mode from the table
   483 000014C9 66A3[FFE80000]      <1> 	mov	[CURSOR_MODE], ax ; save cursor mode (initial value)
   484                              <1> 	; al = 6, ah = 7
   485                              <1> 	; al = 0Dh, ah = 0Eh ; 25/07/2016
   486 000014CF E830020000          <1> 	call	cursor_shape_fix
   487                              <1> 	; al = 14, ah = 15  (If [CHAR_HEIGHT] = 16)
   488 000014D4 668906              <1> 	mov	[esi], ax
   489                              <1> 
   490 000014D7 56                  <1> 	push	esi ; *	
   491                              <1> 
   492 000014D8 8A25[EDE80000]      <1> 	mov	ah, [VGA_MODESET_CTL]
   493 000014DE 80E408              <1> 	and	ah, 8 ; default palette loading ?
   494 000014E1 7524                <1> 	jnz	short _sm_6
   495 000014E3 66BAC603            <1> 	mov	dx, 3C6h ; VGAREG_PEL_MASK (DAC mask register)
   496 000014E7 B0FF                <1> 	mov	al, 0FFh ; PEL mask
   497 000014E9 EE                  <1> 	out	dx, al
   498 000014EA 8A27                <1> 	mov	ah, [edi] ; DAC model (selection number)
   499 000014EC E82D0F0000          <1> 	call	load_dac_palette
   500                              <1> 	; ecx = 0
   501 000014F1 F605[EDE80000]02    <1> 	test	byte [VGA_MODESET_CTL], 2 ; gray scale summing
   502 000014F8 740D                <1> 	jz	short _sm_6
   503 000014FA 53                  <1> 	push	ebx
   504 000014FB 29DB                <1> 	sub	ebx, ebx ; sub bl, bl
   505 000014FD 66B90001            <1>         mov     cx, 256 
   506 00001501 E86B0F0000          <1> 	call	gray_scale_summing
   507 00001506 5B                  <1> 	pop	ebx	
   508                              <1> _sm_6:
   509                              <1> 	; Reset Attribute Ctl flip-flop
   510 00001507 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
   511 0000150B EC                  <1>  	in	al, dx
   512                              <1> 	; Set Attribute Ctl
   513 0000150C 89DE                <1> 	mov	esi, ebx ; addr of params tbl for selected mode
   514 0000150E 83C623              <1> 	add	esi, 35  ; actl regs
   515 00001511 30E4                <1> 	xor	ah, ah ; 0
   516 00001513 66BAC003            <1> 	mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
   517                              <1> _sm_7:
   518 00001517 88E0                <1> 	mov	al, ah
   519 00001519 EE                  <1> 	out	dx, al ; index
   520 0000151A AC                  <1> 	lodsb
   521                              <1> 	; DX = 3C0h = VGAREG_ACTL_WRITE_DATA
   522 0000151B EE                  <1> 	out	dx, al ; value
   523 0000151C FEC4                <1> 	inc	ah
   524 0000151E 80FC14              <1> 	cmp	ah, 20 ; number of actl registers
   525 00001521 72F4                <1> 	jb	short _sm_7
   526                              <1> 	;
   527 00001523 88E0                <1> 	mov	al, ah ; 20
   528 00001525 EE                  <1> 	out	dx, al ; index
   529 00001526 28C0                <1> 	sub	al, al ; 0
   530 00001528 EE                  <1> 	out	dx, al ; value
   531                              <1> 	;
   532                              <1> 	; Set Sequencer Ctl
   533 00001529 89DE                <1> 	mov	esi, ebx ; addr of params tbl for selected mode
   534 0000152B 83C605              <1> 	add	esi, 5 ; sequ regs
   535                              <1> 	;
   536 0000152E 66BAC403            <1> 	mov	dx, 3C4h  ; VGAREG_SEQU_ADDRESS
   537 00001532 EE                  <1> 	out	dx, al ; 0
   538 00001533 6642                <1> 	inc	dx ; 3C5h ; VGAREG_SEQU_DATA
   539 00001535 B003                <1> 	mov	al, 3
   540 00001537 EE                  <1> 	out	dx, al
   541 00001538 B401                <1> 	mov	ah, 1	
   542                              <1> _sm_8:
   543 0000153A 88E0                <1> 	mov	al, ah
   544                              <1> 	;mov	dx, 3C4h ; VGAREG_SEQU_ADDRESS
   545 0000153C 664A                <1> 	dec	dx
   546 0000153E EE                  <1> 	out	dx, al ; index
   547 0000153F AC                  <1> 	lodsb
   548 00001540 6642                <1> 	inc	dx ; 3C5h ; VGAREG_SEQU_DATA
   549 00001542 EE                  <1> 	out	dx, al
   550 00001543 80FC04              <1> 	cmp	ah, 4 ; number of sequ regs
   551 00001546 7304                <1> 	jnb	short _sm_9		
   552 00001548 FEC4                <1> 	inc	ah 
   553 0000154A EBEE                <1> 	jmp	short _sm_8
   554                              <1> _sm_9:
   555                              <1> 	; Set Grafx Ctl
   556 0000154C 89DE                <1> 	mov	esi, ebx ; addr of params tbl for selected mode
   557 0000154E 83C637              <1> 	add	esi, 55 ; grdc regs
   558 00001551 30E4                <1> 	xor	ah, ah ; 0
   559                              <1> _sm_10:
   560 00001553 88E0                <1> 	mov	al, ah
   561 00001555 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
   562 00001559 EE                  <1> 	out	dx, al	
   563 0000155A AC                  <1> 	lodsb
   564 0000155B 6642                <1> 	inc	dx ; 3CFh ; VGAREG_GRDC_DATA
   565 0000155D EE                  <1> 	out	dx, al
   566 0000155E FEC4                <1> 	inc	ah
   567 00001560 80FC09              <1> 	cmp	ah, 9 ; number of grdc regs
   568 00001563 72EE                <1> 	jb	short _sm_10
   569                              <1> 	;
   570                              <1> 	; Disable CRTC write protection
   571 00001565 66BAD403            <1> 	mov	dx, 3D4h  ; VGAREG_VGA_CRTC_ADDRESS
   572                              <1> 	;mov	al, 11h
   573                              <1> 	;our	dx, al
   574                              <1> 	;inc	dx
   575                              <1> 	;sub	al, al
   576                              <1> 	;out	dx, al
   577 00001569 66B81100            <1> 	mov	ax, 11h
   578 0000156D 66EF                <1> 	out	dx, ax
   579 0000156F 89DE                <1> 	mov	esi, ebx ; addr of params tbl for selected mode
   580 00001571 83C60A              <1> 	add	esi, 10 ; crtc regs
   581                              <1> 	; ah = 0
   582                              <1> _sm_11:
   583 00001574 88E0                <1> 	mov	al, ah
   584                              <1> 	; dx = 3D4h = VGAREG_VGA_CRTC_ADDRESS
   585 00001576 EE                  <1> 	out	dx, al ; index
   586 00001577 AC                  <1> 	lodsb
   587 00001578 6642                <1> 	inc	dx  ; VGAREG_VGA_CRTC_ADDRESS + 1
   588 0000157A EE                  <1> 	out	dx, al ; value
   589 0000157B 80FC18              <1> 	cmp	ah, 24 ; number of crtc registers - 1
   590 0000157E 7306                <1> 	jnb	short _sm_12
   591 00001580 FEC4                <1> 	inc	ah
   592 00001582 664A                <1> 	dec	dx ; 3D4h
   593 00001584 EBEE                <1> 	jmp	short _sm_11
   594                              <1> _sm_12:
   595                              <1> 	; Set the misc register
   596 00001586 66BACC03            <1> 	mov	dx, 3CCh ; VGAREG_READ_MISC_OUTPUT
   597 0000158A 8A4309              <1> 	mov	al, [ebx+9] ; misc reg
   598 0000158D EE                  <1> 	out	dx, al
   599                              <1> 	;
   600                              <1> 	; Enable video
   601 0000158E 66BAC003            <1> 	mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
   602 00001592 B020                <1> 	mov	al, 20h  
   603 00001594 EE                  <1>         out     dx, al   ; set bit 5 to 1
   604 00001595 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
   605 00001599 EC                  <1> 	in	al, dx
   606                              <1> 	;
   607 0000159A 803D[332D0100]00    <1> 	cmp	byte [noclearmem], 0
   608 000015A1 773B                <1>         ja      short _sm_15
   609                              <1> 
   610                              <1> 	; 29/07/2016
   611 000015A3 31C0                <1> 	xor	eax, eax
   612 000015A5 B900400000          <1> 	mov	ecx, 4000h ; 16K words (32K)
   613 000015AA 803D[4A2D0100]02    <1>         cmp     byte [VGA_MTYPE], 2  ; CTEXT, MTEXT, CGA
   614 000015B1 7710                <1> 	ja	short _sm_14    ; no ? (0A0000h)
   615 000015B3 BF00800B00          <1> 	mov	edi, 0B8000h
   616 000015B8 7404                <1> 	je	short _sm_13	; CGA graphics mode
   617 000015BA 66B82007            <1> 	mov	ax, 0720h	; CGA text mode
   618                              <1> _sm_13:
   619 000015BE F366AB              <1> 	rep	stosw
   620 000015C1 EB1B                <1> 	jmp	short _sm_15		
   621                              <1> 
   622                              <1> _sm_14:
   623 000015C3 BF00000A00          <1> 	mov	edi, 0A0000h
   624                              <1> 	; ecx = 16384 dwords  (64K)
   625 000015C8 66BAC403            <1> 	mov	dx, 3C4h ; VGAREG_SEQU_ADDRESS
   626 000015CC B002                <1> 	mov	al, 2
   627 000015CE EE                  <1> 	out	dx, al
   628                              <1> 	;mov	dx, 3C5h ; VGAREG_SEQU_DATA
   629 000015CF 6642                <1> 	inc	dx
   630 000015D1 EC                  <1> 	in	al, dx ; mmask
   631 000015D2 6650                <1> 	push	ax
   632 000015D4 B00F                <1> 	mov	al, 0Fh ; all planes
   633 000015D6 EE                  <1> 	out	dx, al
   634 000015D7 30C0                <1> 	xor	al, al ; 0
   635 000015D9 F3AB                <1> 	rep	stosd	; ecx = 163684 (64K)
   636 000015DB 6658                <1> 	pop	ax
   637 000015DD EE                  <1> 	out	dx, al  ; mmask
   638                              <1> _sm_15:
   639                              <1> 	; ebx = addr of params tbl for selected mode
   640 000015DE 8A03                <1> 	mov	al, [ebx] ; num of columns, 'twidth'
   641 000015E0 A2[E8E80000]        <1> 	mov	[CRT_COLS], al
   642                              <1> 	; 26/07/2016
   643                              <1> 	; CRTC_ADDRESS = 3D4h (always)
   644 000015E5 8A6301              <1> 	mov	ah, [ebx+1] ; num of rows, 'theightm1'
   645 000015E8 FEC4                <1> 	inc	ah ; 09/07/2016
   646 000015EA 8825[EEE80000]      <1> 	mov	[VGA_ROWS], ah
   647                              <1> 	; 29/07/2016
   648                              <1> 	; length of regen buffer in bytes
   649 000015F0 668B4B03            <1> 	mov	cx, [ebx+3] ; 'slength_l'
   650 000015F4 66890D[342D0100]    <1> 	mov	[CRT_LEN], cx
   651                              <1> 	;
   652                              <1> 	; 27/07/2016
   653 000015FB 30E4                <1> 	xor	ah, ah
   654 000015FD A0[D61F0100]        <1> 	mov	al, [ACTIVE_PAGE] ; may be > 0 for mode 3
   655                              <1> 	;mul	word [CRT_LEN] ; 4096 for mode 3
   656 00001602 66F7E1              <1> 	mul	cx ; 29/07/2016
   657 00001605 66A3[C41F0100]      <1> 	mov	[CRT_START], ax
   658                              <1> 	;
   659 0000160B B060                <1> 	mov	al, 60h
   660 0000160D 803D[332D0100]00    <1> 	cmp	byte [noclearmem], 0
   661 00001614 7602                <1> 	jna	short _sm_16
   662 00001616 0480                <1> 	add	al, 80h
   663                              <1> _sm_16:
   664 00001618 A2[EBE80000]        <1> 	mov	[VGA_VIDEO_CTL], al
   665 0000161D C605[ECE80000]F9    <1> 	mov	byte [VGA_SWITCHES], 0F9h
   666 00001624 8025[EDE80000]7F    <1> 	and	byte [VGA_MODESET_CTL], 7Fh
   667                              <1> 
   668 0000162B 5E                  <1> 	pop	esi ; *
   669                              <1> 
   670                              <1> 	; 26/07/2016
   671                              <1> 	; 07/07/2016
   672 0000162C 668B0D[FFE80000]    <1> 	mov	cx, [CURSOR_MODE] ; restore cursor mode (initial value)
   673 00001633 66870E              <1> 	xchg	cx, [esi] ; cl = start line, ch = end line
   674                              <1> 			  ; reset to initial value
   675 00001636 86E9                <1> 	xchg 	ch, cl  ; ch = start line, cl = end line  
   676 00001638 66890D[FFE80000]    <1> 	mov	[CURSOR_MODE], cx ; save (fixed) cursor mode
   677                              <1> 
   678                              <1> 	; 27/07/2016
   679 0000163F 803D[4A2D0100]02    <1> 	cmp	byte [VGA_MTYPE], 2 ; CTEXT, MTEXT
   680 00001646 7317                <1> 	jnb	short _sm_17
   681                              <1> 
   682                              <1> 	; Set cursor shape
   683                              <1> 	;mov	cx, 0607h
   684                              <1> 	;call	_set_ctype
   685                              <1> 
   686                              <1> 	; 29/07/2016
   687 00001648 B40A                <1> 	mov	ah, 10	; 6845 register for cursor set
   688 0000164A E88E050000          <1> 	call	m16	; output cx register
   689                              <1> 	
   690                              <1> 	; 25/07/2016
   691 0000164F 803D[E6E80000]03    <1>         cmp     byte [CRT_MODE], 03h
   692 00001656 7507                <1> 	jne	short _sm_17
   693                              <1> 	; 26/07/2016
   694                              <1> 
   695 00001658 A0[D61F0100]        <1> 	mov	al, [ACTIVE_PAGE]
   696 0000165D EB0C                <1> 	jmp	short _sm_18
   697                              <1> _sm_17:
   698                              <1> 	; Set cursor pos for page 0..7
   699 0000165F 6629C0              <1> 	sub	ax, ax ; eax = 0
   700 00001662 BF[C61F0100]        <1> 	mov	edi, CURSOR_POSN
   701 00001667 AB                  <1> 	stosd	
   702 00001668 AB                  <1> 	stosd
   703 00001669 AB                  <1> 	stosd
   704 0000166A AB                  <1> 	stosd
   705                              <1> 	;; Set active page 0
   706                              <1> 	;mov	[ACTIVE_PAGE], al ; 0
   707                              <1> _sm_18:
   708                              <1> 	; 29/07/2016
   709 0000166B 803D[4A2D0100]02    <1> 	cmp	byte [VGA_MTYPE], 2 ; CTEXT, MTEXT
   710 00001672 0F8386000000        <1>         jnb	_sm_23
   711                              <1> 
   712                              <1> 	;cmp	byte [CHAR_HEIGHT], 16
   713                              <1> 	;je	short _sm_19
   714                              <1> 
   715                              <1>  	;; copy and activate 8x16 font
   716                              <1> 	
   717                              <1> 	; 26/07/2016
   718 00001678 B004                <1> 	mov	al, 04h
   719                              <1> 	;sub	bl, bl
   720                              <1> 	; AX = 1104H ; Load ROM 8x16 Character Set
   721                              <1> 	; (BL = font block to load (EGA: 0-3; VGA: 0-7))
   722 0000167A E850140000          <1> 	call	load_text_8_16_pat
   723                              <1> 
   724                              <1> 	; video_func_1103h:
   725                              <1> 	; biosfn_set_text_block_specifier:
   726                              <1> 	; BL = font block selector code	
   727                              <1> 	; NOTE: TRDOS 386 only uses and sets font block 0
   728                              <1> 	; (It is as BL = 0 for TRDOS 386)
   729 0000167F 66BAC403            <1> 	mov	dx, 3C4h ; VGAREG_SEQU_ADDRESS
   730                              <1> 	;mov	ah, bl
   731 00001683 28E4                <1> 	sub	ah, ah ; 0
   732 00001685 B003                <1> 	mov	al, 03h
   733 00001687 66EF                <1> 	out	dx, ax
   734                              <1> _sm_19:
   735                              <1> 	; 29/07/2016
   736                              <1> 	; 26/07/2016
   737                              <1> 	; 24/06/2016
   738                              <1> 	;mov	edi, 0B8000h
   739                              <1> 	;mov	cx, 4000h ; 16K words (32K)
   740                              <1> 	;
   741 00001689 30C0                <1> 	xor	al, al
   742 0000168B 3805[312D0100]      <1>         cmp     byte [p_crt_mode], al ; 0 
   743 00001691 7707                <1>         ja      short _sm_20 ; 3h, 80h or 83h
   744                              <1> 
   745                              <1> 	; 30/07/2016
   746                              <1> 	; 24/06/2016
   747                              <1> 	; TRDOS 386 (TRDOS v2) 'set mode' modification
   748                              <1> 	; (for multiscreen feature):
   749                              <1> 	; If '_set_mode' procedure is called for video mode 3
   750                              <1> 	;     while video mode is 3, video page will be cleared
   751                              <1> 	;     and cursor position of video page will be reset.	  
   752                              <1> 	; If '_set_mode' procedure is called for a video mode
   753                              <1> 	;     except video mode 3, while current video mode
   754                              <1> 	;     is 3; all video pages of mode 3 will be copied 
   755                              <1> 	;     to 98000h address as backup, before mode change.	 	
   756                              <1> 	; If '_set_mode' procedure is called for video mode 3
   757                              <1> 	;     while video mode is not 3 and if there is video
   758                              <1> 	;     page backup for video mode 3, all (of 8) mode 3
   759                              <1> 	;     video pages will be restored from 98000h.
   760                              <1> 
   761 00001693 A2[D61F0100]        <1> 	mov	[ACTIVE_PAGE], al ; 0
   762                              <1> 	;mov	ax, 0720h
   763                              <1> 	;;mov	cx, 4000h ; 16K words (32K)
   764                              <1> 	;;mov	edi, 0B8000h
   765                              <1> 	;rep	stosw
   766                              <1> 	;sub	al, al
   767 00001698 EB64                <1> 	jmp	short _sm_23
   768                              <1> _sm_20:
   769                              <1> 	; Previous video mode is 3
   770                              <1> 	; New video mode is 3 while current video mode is not 3
   771                              <1> 	; (multi screen) video pages will be restored from 0B0000h
   772                              <1> 
   773 0000169A 0FB61D[D61F0100]    <1> 	movzx	ebx, byte [ACTIVE_PAGE]
   774 000016A1 D0E3                <1> 	shl	bl, 1 ; * 2
   775 000016A3 81C3[C61F0100]      <1> 	add	ebx, CURSOR_POSN
   776                              <1> 
   777                              <1> 	; 29/07/2016
   778 000016A9 F605[312D0100]7F    <1> 	test    byte [p_crt_mode], 7Fh ; 83h or 3h
   779 000016B0 7427                <1> 	jz	short _sm_21	; do not restore video pages
   780                              <1> 
   781                              <1> 	;; restore video pages
   782 000016B2 BE00800900          <1> 	mov	esi, 98000h ; 30/07/2016 
   783 000016B7 BF00800B00          <1> 	mov	edi, 0B8000h
   784 000016BC 66B90020            <1> 	mov	cx, 2000h ; 8K dwords (32K)
   785 000016C0 F3A5                <1> 	rep	movsd
   786                              <1> 
   787                              <1> 	; restore cursor positions
   788 000016C2 BE[362D0100]        <1> 	mov	esi, cursor_pposn
   789 000016C7 BF[C61F0100]        <1> 	mov	edi, CURSOR_POSN
   790                              <1> 	;mov	ecx, 4	; restore all cursor positions (16 bytes)
   791 000016CC B104                <1> 	mov	cl, 4
   792 000016CE F3A5                <1> 	rep 	movsd
   793                              <1> 
   794 000016D0 F605[312D0100]80    <1>         test    byte [p_crt_mode], 80h
   795 000016D7 7420                <1> 	jz	short _sm_22 ; do not clear current video pages
   796                              <1> _sm_21:
   797                              <1> 	; clear video page
   798 000016D9 668B0D[342D0100]    <1> 	mov	cx, [CRT_LEN] ; 4096 
   799 000016E0 66D1E9              <1> 	shr	cx, 1 ; 2072
   800 000016E3 66B82007            <1> 	mov	ax, 0720h
   801 000016E7 BF00800B00          <1> 	mov	edi, 0B8000h ; [crt_base]
   802 000016EC 66033D[C41F0100]    <1> 	add	di, [CRT_START]
   803 000016F3 F366AB              <1> 	rep	stosw	; FILL THE REGEN BUFFER WITH BLANKS
   804                              <1> 	;
   805 000016F6 66890B              <1> 	mov	[ebx], cx ; reset cursor position
   806                              <1> _sm_22:
   807 000016F9 A2[312D0100]        <1> 	mov	[p_crt_mode], al ; 0
   808                              <1> _sm_23:
   809                              <1> 	; al = video page number
   810                              <1> 	; [CRT_LEN] = length of regen buffer in bytes
   811 000016FE E8E8000000          <1> 	call	_set_active_page
   812                              <1> 
   813                              <1> ;-----	NORMAL RETURN FROM ALL VIDEO RETURNS
   814 00001703 C3                  <1> 	retn
   815                              <1> 
   816                              <1> cursor_shape_fix:
   817                              <1> 	; 07/07/2016
   818                              <1> 	; (Cursor start and cursor end line values -6,7-
   819                              <1> 	; will be fixed depending on character height)
   820                              <1> 	;
   821                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
   822                              <1> 	; vgabios-0.7a (2011)
   823                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
   824                              <1> 	; 'vgabios.c', ' biosfn_set_cursor_shape (CH,CL)'
   825                              <1> 	;
   826                              <1> 	; INPUT ->
   827                              <1> 	;	AL = cursor start line (=6)
   828                              <1> 	;	AH = cursor end line (=7)
   829                              <1> 	; OUTPUT ->
   830                              <1> 	;	AL = cursor start line (=14)
   831                              <1> 	;	AH = cursor end line (=15)
   832                              <1> 	;
   833                              <1> 	;; if((modeset_ctl&0x01)&&(cheight>8)&&(CL<8)&&(CH<0x20))
   834                              <1> 
   835                              <1> 	;test	byte [VGA_MODESET_CTL], 1 ; VGA active
   836                              <1> 	;jz	short csf_3
   837 00001704 803D[EAE80000]08    <1> 	cmp	byte [CHAR_HEIGHT], 8
   838 0000170B 7649                <1> 	jna	short csf_3
   839 0000170D 80FC08              <1> 	cmp	ah, 8
   840 00001710 7344                <1> 	jnb	short csf_3
   841 00001712 3C20                <1> 	cmp	al, 20h
   842 00001714 7340                <1> 	jnb	short csf_3
   843                              <1> 	;
   844 00001716 6650                <1> 	push	ax
   845                              <1> 	; {
   846                              <1>    	; if(CL!=(CH+1))	
   847 00001718 FEC0                <1> 	inc	al
   848 0000171A 38C4                <1> 	cmp	ah, al   ; ah != al + 1
   849 0000171C 740F                <1>         je      short csf_1
   850                              <1> 	; CH = ((CH+1) * cheight / 8) -1;
   851 0000171E 8A25[EAE80000]      <1> 	mov	ah, [CHAR_HEIGHT]
   852 00001724 F6E4                <1> 	mul	ah
   853 00001726 C0E803              <1> 	shr	al, 3 ; / 8
   854 00001729 FEC8                <1> 	dec	al ; - 1
   855 0000172B EB0E                <1> 	jmp	short csf_2 
   856                              <1> csf_1: 	
   857                              <1>  	; }
   858                              <1>    	; else		; ah = al + 1
   859                              <1>     	; {
   860 0000172D FEC4                <1> 	inc	ah	; ah = ah + 1   
   861                              <1> 	; CH = ((CL+1) * cheight / 8) - 2;
   862 0000172F A0[EAE80000]        <1> 	mov	al, [CHAR_HEIGHT]
   863 00001734 F6E4                <1> 	mul	ah
   864 00001736 C0E803              <1> 	shr	al, 3 ; / 8
   865 00001739 2C02                <1> 	sub	al, 2 ; - 2
   866                              <1> 	; al = 14 (if [CHAR_HEIGHT] = 16)
   867                              <1> csf_2:
   868 0000173B 880424              <1> 	mov	[esp], al
   869 0000173E 8A642401            <1> 	mov	ah, [esp+1]
   870                              <1> 	; CL = ((CL+1) * cheight / 8) - 1;
   871 00001742 FEC4                <1> 	inc	ah 
   872 00001744 A0[EAE80000]        <1> 	mov	al, [CHAR_HEIGHT]
   873 00001749 F6E4                <1> 	mul	ah
   874 0000174B C0E803              <1> 	shr	al, 3 ; / 8
   875 0000174E FEC8                <1> 	dec	al ; - 1
   876 00001750 88442401            <1> 	mov	[esp+1], al
   877                              <1> 	; ah = 15 (if [CHAR_HEIGHT] = 16)
   878                              <1> 	;
   879 00001754 6658                <1> 	pop	ax
   880                              <1> csf_3:
   881 00001756 C3                  <1> 	retn
   882                              <1> 
   883                              <1> SET_CTYPE:
   884                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
   885 00001757 E805000000          <1> 	call	_set_ctype
   886 0000175C E99FFCFFFF          <1>         jmp     VIDEO_RETURN
   887                              <1> 
   888                              <1> _set_ctype:
   889                              <1> 	; 02/09/2014 (Retro UNIX 386 v1)
   890                              <1> 	;
   891                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
   892                              <1> 
   893                              <1> 	; (CH) = BITS 4-0 = START LINE FOR CURSOR
   894                              <1> 	;  ** HARDWARE WILL ALWAYS CAUSE BLINK
   895                              <1> 	;  ** SETTING BIT 5 OR 6 WILL CAUSE ERRATIC BLINKING
   896                              <1> 	;     OR NO CURSOR AT ALL
   897                              <1> 	; (CL) = BITS 4-0 = END LINE FOR CURSOR
   898                              <1> 
   899                              <1> ;------------------------------------------------
   900                              <1> ; SET_CTYPE
   901                              <1> ;	THIS ROUTINE SETS THE CURSOR VALUE
   902                              <1> ; INPUT
   903                              <1> ;	(CX) HAS CURSOR VALUE CH-START LINE, CL-STOP LINE
   904                              <1> ; OUTPUT	
   905                              <1> ;	NONE
   906                              <1> ;------------------------------------------------
   907                              <1> 
   908                              <1> 	; 07/07/2016
   909                              <1> 	; Fixing cursor start and stop line depending on
   910                              <1> 	; current character height (=16)
   911                              <1> 	; (Note: Default/initial values are 6 and 7.
   912                              <1> 	; If set values are 6 (start) & 7 (stop) and 
   913                              <1> 	; [CHAR_HEIGHT] = 16 :
   914                              <1> 	; After fixing, start line will be 14, stop line
   915                              <1> 	; will be 15.)
   916 00001761 6689C8              <1> 	mov	ax, cx
   917 00001764 86C4                <1> 	xchg	al, ah
   918                              <1> 	; AL = start line, AH = stop line
   919 00001766 E899FFFFFF          <1> 	call	cursor_shape_fix
   920                              <1> 	; AL = start line (fixed), AH = stop line (fixed)
   921 0000176B 6689C1              <1> 	mov	cx, ax
   922 0000176E 86E9                <1> 	xchg	ch, cl
   923                              <1> 	; CH = start line (fixed), CL = stop line (fixed)
   924                              <1> 	;
   925 00001770 B40A                <1> 	mov	ah, 10	; 6845 register for cursor set
   926 00001772 66890D[FFE80000]    <1> 	mov	[CURSOR_MODE], cx ; save in data area
   927                              <1> 	;call	m16	; output cx register
   928                              <1> 	;retn
   929 00001779 E95F040000          <1>         jmp     m16
   930                              <1> 
   931                              <1> SET_CPOS:
   932                              <1> 	; 07/07/2016
   933                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
   934 0000177E 80FF07              <1> 	cmp	bh, 7 ; video page > 7 ; 07/07/2016
   935 00001781 0F8779FCFFFF        <1> 	ja	VIDEO_RETURN
   936                              <1> 	;
   937 00001787 E826040000          <1> 	call	_set_cpos
   938 0000178C E96FFCFFFF          <1>         jmp     VIDEO_RETURN
   939                              <1> 
   940                              <1> READ_CURSOR:
   941                              <1> 	; 07/07/2016
   942                              <1> 	; 12/05/2016
   943                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
   944                              <1> 	;
   945                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
   946                              <1> 
   947                              <1> ;------------------------------------------------------
   948                              <1> ; READ_CURSOR
   949                              <1> ;	THIS ROUTINE READS THE CURRENT CURSOR VALUE FROM THE
   950                              <1> ;	845, FORMATS IT, AND SENDS IT BACK TO THE CALLER
   951                              <1> ; INPUT
   952                              <1> ;	BH - PAGE OF CURSOR
   953                              <1> ; OUTPUT
   954                              <1> ;	DX - ROW, COLUMN OF THE CURRENT CURSOR POSITION
   955                              <1> ;	CX - CURRENT CURSOR MODE
   956                              <1> ;------------------------------------------------------
   957                              <1> 
   958                              <1> 	; BH = Video page number (0 to 7)
   959                              <1> 
   960                              <1> 	; 07/07/2016
   961 00001791 80FF07              <1> 	cmp	bh, 7 ; video page > 7 (invalid)
   962 00001794 7606                <1> 	jna	short read_cursor_1
   963                              <1> 	; invalid video page (input) 
   964 00001796 31C9                <1> 	xor	ecx, ecx ; 0
   965 00001798 31D2                <1> 	xor	edx, edx ; 0
   966 0000179A EB0C                <1> 	jmp	short read_cursor_2
   967                              <1> read_cursor_1:
   968 0000179C E815000000          <1> 	call	get_cpos
   969 000017A1 0FB70D[FFE80000]    <1> 	movzx	ecx, word [CURSOR_MODE]
   970                              <1> read_cursor_2:
   971 000017A8 5D                  <1> 	pop	ebp
   972 000017A9 5F                  <1> 	pop	edi
   973 000017AA 5E                  <1> 	pop	esi
   974 000017AB 5B                  <1> 	pop	ebx
   975 000017AC 58                  <1> 	pop	eax  ; DISCARD SAVED CX AND DX
   976 000017AD 58                  <1> 	pop	eax
   977 000017AE A1[242D0100]        <1> 	mov	eax, [video_eax] ; 12/05/2016
   978 000017B3 1F                  <1> 	pop	ds
   979 000017B4 07                  <1> 	pop	es
   980 000017B5 CF                  <1> 	iret
   981                              <1> 
   982                              <1> get_cpos:
   983                              <1> 	; 12/05/2016
   984                              <1> 	; 16/01/2016
   985                              <1> 	; BH = Video page number (0 to 7)
   986                              <1> 	;
   987 000017B6 D0E7                <1> 	shl	bh, 1 ; WORD OFFSET
   988 000017B8 0FB6F7              <1> 	movzx	esi, bh 
   989 000017BB 0FB796[C61F0100]    <1> 	movzx	edx, word [esi+CURSOR_POSN]
   990 000017C2 C3                  <1> 	retn
   991                              <1> 
   992                              <1> ACT_DISP_PAGE:
   993                              <1> 	; 07/07/2016
   994                              <1> 	; 26/06/2016
   995                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
   996                              <1> 	;
   997                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
   998                              <1> 	;
   999                              <1> ;-----------------------------------------------------
  1000                              <1> ; ACT_DISP_PAGE
  1001                              <1> ;	THIS ROUTINE SETS THE ACTIVE DISPLAY PAGE, ALLOWING
  1002                              <1> ;	THE FULL USE OF THE MEMORY SET ASIDE FOR THE VIDEO ATTACHMENT
  1003                              <1> ; INPUT
  1004                              <1> ;	AL HAS THE NEW ACTIVE DISPLAY PAGE
  1005                              <1> ; OUTPUT
  1006                              <1> ;	THE 6845 IS RESET TO DISPLAY THAT PAGE
  1007                              <1> ;-----------------------------------------------------
  1008                              <1> 	; 07/07/2016
  1009 000017C3 3C07                <1> 	cmp	al, 7	; > 7 = invalid video page number
  1010 000017C5 0F8735FCFFFF        <1> 	ja	VIDEO_RETURN
  1011 000017CB 803D[E6E80000]03    <1>         cmp     byte [CRT_MODE], 3
  1012 000017D2 7408                <1> 	je	short adp_1
  1013 000017D4 20C0                <1> 	and 	al, al
  1014 000017D6 0F8524FCFFFF        <1>         jnz     VIDEO_RETURN
  1015                              <1> 	;sub	al, al ; 0 ; force to page 0
  1016                              <1> adp_1:	
  1017 000017DC E805000000          <1> 	call	set_active_page
  1018 000017E1 E91AFCFFFF          <1>         jmp     VIDEO_RETURN
  1019                              <1> 
  1020                              <1> set_active_page:   ; tty_sw
  1021                              <1> 	; 26/07/2016
  1022                              <1> 	; 26/06/2016
  1023                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  1024                              <1> 	; 30/06/2015
  1025                              <1> 	; 04/03/2014  (act_disp_page --> tty_sw)
  1026                              <1> 	; 10/12/2013
  1027                              <1> 	; 04/12/2013
  1028                              <1> 	;
  1029 000017E6 A2[D61F0100]        <1> 	mov	[ACTIVE_PAGE], al ; save active page value ; [ptty]
  1030                              <1> _set_active_page:
  1031                              <1> 	; 27/06/2015
  1032 000017EB 0FB6D8              <1> 	movzx	ebx, al
  1033                              <1> 	;
  1034 000017EE 6698                <1> 	cbw	; 07/09/2014 (ah=0)
  1035 000017F0 66F725[342D0100]    <1> 	mul	word [CRT_LEN]  ; get saved length of regen buffer
  1036                              <1> 				; display page times regen length
  1037                              <1> 	; 10/12/2013
  1038 000017F7 66A3[C41F0100]      <1> 	mov	[CRT_START], ax ; save start address for later
  1039 000017FD 6689C1              <1> 	mov	cx, ax ; start address to cx
  1040                              <1> _M16:
  1041                              <1> 	;sar	cx, 1
  1042 00001800 66D1E9              <1> 	shr	cx, 1	; divide by 2 for 6845 handling
  1043 00001803 B40C                <1> 	mov	ah, 12	; 6845 register for start address
  1044 00001805 E8D3030000          <1> 	call	m16
  1045                              <1> 	;sal	bx, 1
  1046                              <1> 	; 01/09/2014
  1047 0000180A D0E3                <1> 	shl	bl, 1	; *2 for word offset
  1048 0000180C 81C3[C61F0100]      <1> 	add	ebx, CURSOR_POSN
  1049 00001812 668B13              <1> 	mov	dx, [ebx] ; get cursor for this page
  1050                              <1> 	; 16/01/2016
  1051                              <1> 	;call	m18
  1052                              <1> 	;retn
  1053 00001815 E9AF030000          <1> 	jmp	m18
  1054                              <1> 
  1055                              <1> position:
  1056                              <1> 	; 24/06/2016
  1057                              <1> 	; 12/05/2016 - TRDOS 386 (TRDOS v2.0)
  1058                              <1> 	; 27/06/2015
  1059                              <1> 	; 02/09/2014
  1060                              <1> 	; 30/08/2014 (Retro UNIX 386 v1)
  1061                              <1> 	; 04/12/2013 (Retro UNIX 8086 v1)
  1062                              <1> 	;
  1063                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  1064                              <1> 	;
  1065                              <1> ;-----------------------------------------
  1066                              <1> ; POSITION
  1067                              <1> ;	THIS SERVICE ROUTINE CALCULATES THE REGEN BUFFER ADDRESS
  1068                              <1> ;	OF A CHARACTER IN THE ALPHA MODE
  1069                              <1> ; INPUT
  1070                              <1> ;	AX = ROW, COLUMN POSITION
  1071                              <1> ; OUTPUT
  1072                              <1> ;	AX = OFFSET OF CHAR POSITION IN REGEN BUFFER
  1073                              <1> ;-----------------------------------------
  1074                              <1> 
  1075                              <1> 	; DX = ROW, COLUMN POSITION
  1076 0000181A 0FB605[E8E80000]    <1> 	movzx	eax, byte [CRT_COLS] ; 24/06/2016
  1077 00001821 F6E6                <1> 	mul	dh	 ; row value
  1078 00001823 30F6                <1> 	xor	dh, dh   ; 0	
  1079 00001825 6601D0              <1> 	add	ax, dx	 ; add column value to the result
  1080 00001828 66D1E0              <1> 	shl	ax, 1	; * 2 for attribute bytes
  1081                              <1> 		; EAX = AX = OFFSET OF CHAR POSITION IN REGEN BUFFER 
  1082 0000182B C3                  <1> 	retn
  1083                              <1> 
  1084                              <1> find_position:
  1085                              <1> 	; 24/06/2016
  1086                              <1> 	; 12/05/2016 - TRDOS 386 (TRDOS v2.0)
  1087                              <1> 	; 27/06/2015
  1088                              <1> 	; 07/09/2014
  1089                              <1> 	; 02/09/2014
  1090                              <1> 	; 30/08/2014 (Retro UNIX 386 v1)
  1091                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  1092                              <1> 
  1093 0000182C 0FB6CF              <1> 	movzx	ecx, bh ; video page number
  1094 0000182F 89CE                <1> 	mov	esi, ecx
  1095 00001831 66D1E6              <1> 	shl	si, 1
  1096 00001834 668B96[C61F0100]    <1> 	mov	dx, [esi+CURSOR_POSN]
  1097 0000183B 740C                <1> 	jz	short p21
  1098 0000183D 6631F6              <1> 	xor	si, si
  1099                              <1> p20:
  1100 00001840 660335[342D0100]    <1> 	add	si, [CRT_LEN] ; 24/06/2016
  1101                              <1> 	;add	si, 80*25*2 ; add length of buffer for one page		
  1102 00001847 E2F7                <1> 	loop	p20
  1103                              <1> p21:
  1104 00001849 6621D2              <1> 	and	dx, dx
  1105 0000184C 7407                <1> 	jz	short p22
  1106 0000184E E8C7FFFFFF          <1> 	call 	position ; determine location in regen in page
  1107 00001853 01C6                <1> 	add	esi, eax ; add location to start of regen page
  1108                              <1> p22:	
  1109                              <1> 	;mov	dx, [addr_6845] ; get base address of active display			
  1110                              <1> 	;mov	dx, 03D4h ; I/O address of color card
  1111                              <1> 	;add	dx, 6	; point at status port
  1112 00001855 66BADA03            <1> 	mov	dx, 03DAh ; status port
  1113                              <1> 	; cx = 0
  1114 00001859 C3                  <1> 	retn
  1115                              <1> 
  1116                              <1> SCROLL_UP:
  1117                              <1> 	; 07/07/2016
  1118                              <1> 	; 26/06/2016
  1119                              <1> 	; 12/05/2016
  1120                              <1> 	; 30/01/2016
  1121                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  1122                              <1> 	; 07/09/2014
  1123                              <1> 	; 02/09/2014
  1124                              <1> 	; 01/09/2014 (Retro UNIX 386 v1 - beginning)
  1125                              <1> 	; 04/04/2014
  1126                              <1> 	; 04/12/2013
  1127                              <1> 	;
  1128                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  1129                              <1> 	;
  1130                              <1> ;----------------------------------------------
  1131                              <1> ; SCROLL UP
  1132                              <1> ;	THIS ROUTINE MOVES A BLOCK OF CHARACTERS UP
  1133                              <1> ;	ON THE SCREEN
  1134                              <1> ; INPUT
  1135                              <1> ;	(AH) = CURRENT CRT MODE
  1136                              <1> ;	(AL) = NUMBER OF ROWS TO SCROLL
  1137                              <1> ;	(CX) = ROW/COLUMN OF UPPER LEFT CORNER
  1138                              <1> ;	(DX) = ROW/COLUMN OF LOWER RIGHT CORNER
  1139                              <1> ;	(BH) = ATTRIBUTE TO BE USED ON BLANKED LINE
  1140                              <1> ;	(DS) = DATA SEGMENT
  1141                              <1> ;	(ES) = REGEN BUFFER SEGMENT
  1142                              <1> ; OUTPUT
  1143                              <1> ;	NONE -- THE REGEN BUFFER IS MODIFIED
  1144                              <1> ;--------------------------------------------
  1145                              <1> 
  1146                              <1> 	; 07/07/2016
  1147 0000185A 38F5                <1> 	cmp	ch, dh
  1148 0000185C 0F879EFBFFFF        <1> 	ja	VIDEO_RETURN
  1149 00001862 38D1                <1> 	cmp	cl, dl
  1150 00001864 0F8796FBFFFF        <1> 	ja	VIDEO_RETURN
  1151                              <1> 	;
  1152 0000186A E805000000          <1> 	call	_scroll_up
  1153 0000186F E98CFBFFFF          <1>         jmp     VIDEO_RETURN
  1154                              <1> 
  1155                              <1> _scroll_up:  ; from 'write_tty'
  1156                              <1> 	;
  1157                              <1> 	; cl = left upper column
  1158                              <1> 	; ch = left upper row
  1159                              <1> 	; dl = right lower column
  1160                              <1> 	; dh = right lower row
  1161                              <1> 	;
  1162                              <1> 	; al = line count 
  1163                              <1> 	; bl = attribute to be used on blanked line	
  1164                              <1> 	; bh = video page number (0 to 7)
  1165                              <1> 
  1166 00001874 E896000000          <1> 	call	test_line_count ; 16/01/2016
  1167                              <1> 
  1168 00001879 8A25[E6E80000]      <1> 	mov	ah, [CRT_MODE] ; current video mode	
  1169                              <1> 	;cmp	ah, 4
  1170                              <1>  	;jb	short n0
  1171                              <1> 	;cmp	byte [CRT_MODE], 4
  1172 0000187F 80FC04              <1>         cmp	ah, 4 ; 07/07/2016
  1173 00001882 0F83B7040000        <1> 	jnb     GRAPHICS_UP ; 26/06/2016
  1174                              <1> 
  1175                              <1> 	;cmp	ah, 7 ; TEST FOR BW CARD
  1176                              <1> 	;jne	GRAPHICS_UP
  1177                              <1> n0:
  1178                              <1> 	; 07/07/2016
  1179 00001888 80FF07              <1> 	cmp	bh, 7 ; video page number
  1180 0000188B 7606                <1> 	jna	short n1
  1181 0000188D 8A3D[D61F0100]      <1> 	mov	bh, [ACTIVE_PAGE]
  1182                              <1> n1:
  1183 00001893 88DC                <1> 	mov	ah, bl ; attribute
  1184 00001895 6650                <1> 	push	ax ; *
  1185                              <1> 	;mov 	esi, [CRT_BASE]
  1186 00001897 BE00800B00          <1>         mov     esi, 0B8000h  
  1187 0000189C 3A3D[D61F0100]      <1>         cmp     bh, [ACTIVE_PAGE]
  1188 000018A2 750B                <1> 	jne	short n2
  1189                              <1> 	;
  1190 000018A4 66A1[C41F0100]      <1>         mov     ax, [CRT_START]
  1191 000018AA 6601C6              <1>         add     si, ax
  1192 000018AD EB11                <1>         jmp     short n4
  1193                              <1> n2:
  1194 000018AF 20FF                <1>         and     bh, bh
  1195 000018B1 740D                <1> 	jz	short n4
  1196 000018B3 88F8                <1> 	mov	al, bh
  1197                              <1> n3:
  1198 000018B5 660335[342D0100]    <1>         add	si, [CRT_LEN]
  1199 000018BC FEC8                <1>         dec	al
  1200 000018BE 75F5                <1> 	jnz	short n3
  1201                              <1> n4:	
  1202 000018C0 E85D000000          <1> 	call	scroll_position ; 16/01/2016
  1203 000018C5 7420                <1>         jz      short n6 
  1204                              <1> 
  1205 000018C7 01CE                <1>         add     esi, ecx ; from address for scroll
  1206 000018C9 88F5                <1> 	mov	ch, dh  ; #rows in block
  1207 000018CB 28C5                <1> 	sub	ch, al	; #rows to be moved
  1208                              <1> n5:
  1209 000018CD E894000000          <1> 	call	n10 ; 16/01/2016
  1210                              <1> 	
  1211 000018D2 51                  <1>         push	ecx
  1212 000018D3 0FB60D[E8E80000]    <1> 	movzx	ecx, byte [CRT_COLS] 
  1213 000018DA 00C9                <1> 	add	cl, cl
  1214 000018DC 01CE                <1>         add	esi, ecx  ; next line
  1215 000018DE 01CF                <1>         add	edi, ecx
  1216 000018E0 59                  <1> 	pop	ecx
  1217                              <1> 
  1218 000018E1 FECD                <1> 	dec	ch	 ; count of lines to move
  1219 000018E3 75E8                <1> 	jnz	short n5 ; row loop
  1220                              <1> 	; ch = 0
  1221 000018E5 88C6                <1> 	mov	dh, al	 ; #rows	
  1222                              <1> n6:
  1223                              <1> 	; attribute in ah
  1224 000018E7 B020                <1> 	mov	al, ' '	 ; fill with blanks
  1225                              <1> n7:
  1226 000018E9 E885000000          <1> 	call	n11 ; 16/01/2016
  1227                              <1> 
  1228 000018EE 8A0D[E8E80000]      <1> 	mov	cl, [CRT_COLS]
  1229 000018F4 00C9                <1> 	add	cl, cl
  1230 000018F6 01CF                <1>         add	edi, ecx
  1231                              <1> 
  1232 000018F8 FECE                <1> 	dec	dh
  1233 000018FA 75ED                <1> 	jnz	short n7
  1234                              <1> n16:
  1235 000018FC 3A3D[D61F0100]      <1> 	cmp	bh, [ACTIVE_PAGE]
  1236 00001902 750A                <1> 	jne	short n8
  1237                              <1> 	
  1238                              <1> 	;cmp	byte [CRT_MODE], 7	; is this the black and white card
  1239                              <1> 	;je	short n8		; if so, skip the mode reset
  1240                              <1> 
  1241 00001904 A0[E7E80000]        <1> 	mov	al, [CRT_MODE_SET] ; get the value of mode set
  1242 00001909 66BAD803            <1> 	mov	dx, 03D8h ; always set color card port
  1243 0000190D EE                  <1> 	out	dx, al
  1244                              <1> n8:
  1245 0000190E C3                  <1> 	retn
  1246                              <1> 
  1247                              <1> test_line_count:
  1248                              <1> 	; 12/05/2016
  1249                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  1250                              <1> 	; 07/09/2014 (scroll_up)
  1251 0000190F 08C0                <1> 	or	al, al
  1252 00001911 740E                <1> 	jz	short al_set2
  1253 00001913 6652                <1> 	push	dx
  1254 00001915 28EE                <1> 	sub	dh, ch  ; subtract upper row from lower row number
  1255 00001917 FEC6                <1> 	inc	dh	; adjust difference by 1
  1256 00001919 38C6                <1> 	cmp	dh, al 	; line count = amount of rows in window?
  1257 0000191B 7502                <1> 	jne	short al_set1 ; if not the we're all set
  1258 0000191D 30C0                <1> 	xor	al, al	; otherwise set al to zero
  1259                              <1> al_set1:
  1260 0000191F 665A                <1> 	pop	dx
  1261                              <1> al_set2:
  1262 00001921 C3                  <1> 	retn
  1263                              <1> 
  1264                              <1> scroll_position:
  1265                              <1> 	; 26/06/2016
  1266                              <1> 	; 30/01/2016
  1267                              <1>         ; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  1268                              <1> 	; 07/09/2014 (scroll_up)
  1269                              <1> 
  1270 00001922 6652                <1> 	push	dx
  1271 00001924 6689CA              <1> 	mov	dx, cx	; now, upper left position in DX
  1272 00001927 E8EEFEFFFF          <1> 	call	position
  1273 0000192C 01C6                <1> 	add	esi, eax
  1274 0000192E 89F7                <1> 	mov	edi, esi
  1275 00001930 665A                <1> 	pop	dx	; lower right position in DX
  1276 00001932 6629CA              <1> 	sub	dx, cx
  1277 00001935 FEC6                <1> 	inc	dh	; dh = #rows 
  1278 00001937 FEC2                <1> 	inc	dl	; dl = #cols in block
  1279 00001939 59                  <1> 	pop	ecx 	; return address
  1280 0000193A 6658                <1> 	pop	ax	; * ; al = line count, ah = attribute
  1281 0000193C 51                  <1> 	push	ecx	; return address
  1282 0000193D 0FB7C8              <1> 	movzx	ecx, ax
  1283 00001940 8A25[E8E80000]      <1> 	mov	ah, [CRT_COLS]
  1284 00001946 F6E4                <1> 	mul	ah	; determine offset to from address
  1285 00001948 6601C0              <1> 	add	ax, ax  ; *2 for attribute byte
  1286                              <1> 	;
  1287 0000194B 6650                <1> 	push	ax	; offset 
  1288 0000194D 6652                <1> 	push	dx
  1289                              <1> 	;
  1290                              <1> 	; 04/04/2014
  1291 0000194F 66BADA03            <1> 	mov	dx, 3DAh ; guaranteed to be color card here	
  1292                              <1> n9:                      ; wait_display_enable
  1293 00001953 EC                  <1>         in      al, dx   ; get port
  1294 00001954 A808                <1> 	test	al, RVRT ; wait for vertical retrace	
  1295 00001956 74FB                <1> 	jz	short n9 ; wait_display_enable
  1296 00001958 B025                <1> 	mov	al, 25h
  1297 0000195A B2D8                <1> 	mov	dl, 0D8h ; address control port
  1298 0000195C EE                  <1> 	out	dx, al	; turn off video during vertical retrace
  1299 0000195D 665A                <1> 	pop	dx	; #rows, #cols
  1300 0000195F 6658                <1>        	pop	ax	; offset
  1301 00001961 6691                <1> 	xchg	ax, cx	; 
  1302                              <1> 	; ecx = offset, al = line count, ah = attribute
  1303                              <1> 	;
  1304 00001963 08C0                <1> 	or	al, al
  1305 00001965 C3                  <1> 	retn
  1306                              <1> n10:
  1307                              <1> 	; Move rows
  1308 00001966 88D1                <1> 	mov	cl, dl	; get # of cols to move
  1309 00001968 56                  <1> 	push	esi
  1310 00001969 57                  <1> 	push	edi	; save start address
  1311                              <1> n10r:
  1312 0000196A 66A5                <1> 	movsw		; move that line on screen
  1313 0000196C FEC9                <1> 	dec	cl
  1314 0000196E 75FA                <1>         jnz     short n10r
  1315 00001970 5F                  <1> 	pop	edi
  1316 00001971 5E                  <1> 	pop	esi	; recover addresses
  1317 00001972 C3                  <1> 	retn
  1318                              <1> n11:
  1319                              <1> 	; Clear rows
  1320                              <1>                 	; dh =  #rows
  1321 00001973 88D1                <1>         mov	cl, dl	; get # of cols to clear
  1322 00001975 57                  <1>         push    edi     ; save address
  1323                              <1> n11r:
  1324 00001976 66AB                <1>         stosw           ; store fill character
  1325 00001978 FEC9                <1> 	dec	cl
  1326 0000197A 75FA                <1>         jnz     short n11r
  1327 0000197C 5F                  <1>         pop     edi     ; recover address
  1328 0000197D C3                  <1> 	retn
  1329                              <1> 
  1330                              <1> SCROLL_DOWN:
  1331                              <1> 	; 07/07/2016
  1332                              <1> 	; 27/06/2016
  1333                              <1> 	; 26/06/2016
  1334                              <1> 	; 12/05/2016
  1335                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  1336                              <1> 	;
  1337                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  1338                              <1> 
  1339                              <1> ;------------------------------------------
  1340                              <1> ; SCROLL DOWN
  1341                              <1> ;	THIS ROUTINE MOVES THE CHARACTERS WITHIN A DEFINED
  1342                              <1> ;	BLOCK DOWN ON THE SCREEN, FILLING THE TOP LINES
  1343                              <1> ;	WITH A DEFINED CHARACTER
  1344                              <1> ; INPUT
  1345                              <1> ;	(AH) = CURRENT CRT MODE
  1346                              <1> ;	(AL) = NUMBER OF LINES TO SCROLL
  1347                              <1> ;	(CX) = UPPER LEFT CORNER OF RECION
  1348                              <1> ;	(DX) = LOWER RIGHT CORNER OF REGION
  1349                              <1> ;	(BH) = FILL CHARACTER
  1350                              <1> ;	(DS) = DATA SEGMENT
  1351                              <1> ;	(ES) = REGEN SEGMENT
  1352                              <1> ; OUTPUT
  1353                              <1> ;	NONE -- SCREEN IS SCROLLED
  1354                              <1> ;------------------------------------------
  1355                              <1> 
  1356                              <1> 	; 07/07/2016
  1357 0000197E 38F5                <1> 	cmp	ch, dh
  1358 00001980 0F877AFAFFFF        <1> 	ja	VIDEO_RETURN
  1359 00001986 38D1                <1> 	cmp	cl, dl
  1360 00001988 0F8772FAFFFF        <1> 	ja	VIDEO_RETURN
  1361                              <1> 	;
  1362 0000198E E805000000          <1> 	call	_scroll_down
  1363 00001993 E968FAFFFF          <1>         jmp     VIDEO_RETURN
  1364                              <1> 
  1365                              <1> _scroll_down: ; 27/06/2016
  1366                              <1> 
  1367                              <1> 	; cl = left upper column
  1368                              <1> 	; ch = left upper row
  1369                              <1> 	; dl = right lower column
  1370                              <1> 	; dh = right lower row
  1371                              <1> 	;
  1372                              <1> 	; al = line count 
  1373                              <1> 	; bl = attribute to be used on blanked line	
  1374                              <1> 	; bh = video page number (0 to 7)
  1375                              <1> 
  1376                              <1> 	; !!!!
  1377 00001998 FD                  <1> 	std		; DIRECTION FOR SCROLL DOWN
  1378                              <1> 	; !!!!
  1379 00001999 E871FFFFFF          <1> 	call	test_line_count ; 16/01/2016
  1380                              <1> 	
  1381 0000199E 8A25[E6E80000]      <1> 	mov	ah, [CRT_MODE] ; current video mode	
  1382                              <1> 	;cmp	ah, 4
  1383                              <1>  	;jb	short _n0
  1384                              <1> 	;cmp	byte [CRT_MODE], 4
  1385 000019A4 80FC04              <1>         cmp	ah, 4 ; 07/07/2016
  1386 000019A7 0F8360070000        <1> 	jnb     GRAPHICS_DOWN ; 26/06/2016
  1387                              <1> 
  1388                              <1> 	;cmp	ah, 7 ; TEST FOR BW CARD
  1389                              <1> 	;jne	GRAPHICS_DOWN
  1390                              <1> _n0:
  1391                              <1> 	; 07/07/2016
  1392 000019AD 80FF07              <1> 	cmp	bh, 7 ; video page number
  1393 000019B0 7606                <1> 	jna	short n12
  1394 000019B2 8A3D[D61F0100]      <1> 	mov	bh, [ACTIVE_PAGE]
  1395                              <1> 	;
  1396                              <1> n12:			; CONTINUE_DOWN
  1397 000019B8 88DC                <1> 	mov	ah, bl
  1398 000019BA 6650                <1> 	push	ax	; * ; save attribute in ah
  1399 000019BC 6689D0              <1> 	mov	ax, dx	; LOWER RIGHT CORNER
  1400 000019BF E85EFFFFFF          <1> 	call	scroll_position	; GET REGEN LOCATION
  1401 000019C4 741F                <1> 	jz	short n14
  1402 000019C6 29CE                <1> 	sub	esi, ecx  ; SI IS FROM ADDRESS
  1403 000019C8 88F5                <1> 	mov	ch, dh  ; #rows in block
  1404 000019CA 28C5                <1> 	sub	ch, al	; #rows to be moved
  1405                              <1> n13:
  1406 000019CC E895FFFFFF          <1> 	call	n10	; MOVE ONE ROW
  1407                              <1> 
  1408 000019D1 51                  <1> 	push	ecx
  1409 000019D2 8A0D[E8E80000]      <1> 	mov	cl, [CRT_COLS] 
  1410 000019D8 00C9                <1> 	add	cl, cl
  1411 000019DA 29CE                <1>         sub	esi, ecx  ; next line
  1412 000019DC 29CF                <1>         sub	edi, ecx
  1413 000019DE 59                  <1>         pop	ecx
  1414                              <1> 	
  1415 000019DF FECD                <1> 	dec	ch	 ; count of lines to move
  1416 000019E1 75E9                <1> 	jnz	short n13 ; row loop
  1417                              <1> 	; ch = 0
  1418 000019E3 88C6                <1> 	mov	dh, al	 ; #rows
  1419                              <1> n14:
  1420                              <1> 	; attribute in ah
  1421 000019E5 B020                <1> 	mov	al, ' '	 ; fill with blanks
  1422                              <1> n15:
  1423 000019E7 E887FFFFFF          <1> 	call	n11 ; 16/01/2016
  1424                              <1> 
  1425 000019EC 8A0D[E8E80000]      <1> 	mov	cl, [CRT_COLS]
  1426 000019F2 00C9                <1> 	add	cl, cl
  1427 000019F4 29CF                <1>         sub	edi, ecx
  1428                              <1>         
  1429 000019F6 FECE                <1> 	dec	dh
  1430 000019F8 75ED                <1> 	jnz	short n15
  1431                              <1> 	;
  1432 000019FA E9FDFEFFFF          <1> 	jmp	n16 ; 27/06/2016
  1433                              <1> 
  1434                              <1> ;	cmp	bh, [ACTIVE_PAGE]
  1435                              <1> ;	jne	short n16
  1436                              <1> ;
  1437                              <1> ;	;cmp	byte [CRT_MODE], 7	; is this the black and white card
  1438                              <1> ;	;je	short n16		; if so, skip the mode reset
  1439                              <1> ;
  1440                              <1> ;	mov	al, [CRT_MODE_SET] ; get the value of mode set
  1441                              <1> ;	mov	dx, 03D8h ; always set color card port
  1442                              <1> ;	out	dx, al
  1443                              <1> ;n16:
  1444                              <1> ;	; !!!!
  1445                              <1> ;	cld		; Clear direction flag !
  1446                              <1> ;	; !!!!
  1447                              <1> ;	retn
  1448                              <1> 
  1449                              <1> READ_AC_CURRENT:
  1450                              <1> 	; 08/07/2016
  1451                              <1> 	; 26/06/2016
  1452                              <1> 	; 12/05/2016
  1453                              <1> 	; 18/01/2016
  1454                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  1455                              <1> 	;
  1456                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  1457                              <1> 	;
  1458                              <1> 	; 08/07/2016
  1459 000019FF 803D[E6E80000]07    <1>         cmp     byte [CRT_MODE], 7 ; 6!?
  1460 00001A06 7607                <1> 	jna	short read_ac_c
  1461 00001A08 31C0                <1> 	xor	eax, eax
  1462 00001A0A E9F6F9FFFF          <1>         jmp     _video_return 
  1463                              <1> read_ac_c:
  1464 00001A0F E805000000          <1> 	call	_read_ac_current
  1465                              <1> 	; 12/05/2016
  1466                              <1>         ;jmp     VIDEO_RETURN
  1467 00001A14 E9ECF9FFFF          <1> 	jmp	_video_return
  1468                              <1> 
  1469                              <1> ;------------------------------------------------------------------------
  1470                              <1> ; READ_AC_CURRENT							:
  1471                              <1> ;	THIS ROUTINE READS THE ATTRIBUTE AND CHARACTER AT THE CURRENT	:
  1472                              <1> ;	CURSOR POSITION AND RETURNS THEM TO THE CALLER			:
  1473                              <1> ; INPUT									:
  1474                              <1> ;	(AH) = CURRENT CRT MODE						:
  1475                              <1> ;	(BH) = DISPLAY PAGE ( ALPHA MODES ONLY )			:
  1476                              <1> ;	(DS) = DATA SEGMENT						:
  1477                              <1> ;	(ES) = REGEN SEGMENT						:
  1478                              <1> ; OUTPUT								:
  1479                              <1> ;	(AL) = CHARACTER READ						:
  1480                              <1> ;	(AH) = ATTRIBUTE READ						:
  1481                              <1> ;------------------------------------------------------------------------
  1482                              <1> 
  1483                              <1> _read_ac_current:
  1484                              <1> 	; 26/06/2016
  1485                              <1> 	; 12/05/2016 
  1486                              <1> 	; 18/01/2016
  1487                              <1> 
  1488                              <1> 	;mov	ah, [CRT_MODE] ; current video mode	
  1489                              <1> 	;cmp	ah, 4
  1490                              <1>  	;jb	short p10
  1491 00001A19 803D[E6E80000]04    <1> 	cmp	byte [CRT_MODE], 4
  1492 00001A20 0F833C080000        <1> 	jnb     GRAPHICS_READ ; 26/06/2016
  1493                              <1> 
  1494                              <1> 	;cmp	ah, 7 ; TEST FOR BW CARD
  1495                              <1> 	;jne	GRAPHICS_READ
  1496                              <1> p10:
  1497 00001A26 E801FEFFFF          <1> 	call	find_position	; GET REGEN LOCATION AND PORT ADDRESS
  1498                              <1> 	;
  1499                              <1> 	; esi = regen location
  1500                              <1> 	; dx = status port
  1501                              <1> 	;
  1502 00001A2B 8A25[E6E80000]      <1> 	mov	ah, [CRT_MODE]	
  1503 00001A31 80EC02              <1> 	sub	ah, 2
  1504 00001A34 D0EC                <1> 	shr	ah, 1
  1505 00001A36 7515                <1> 	jnz	short p13
  1506                              <1> 
  1507                              <1> 	; WAIT FOR HORIZONTAL RETRACE OR VERTICAL RETRACE IF COLOR 80
  1508                              <1> p11:
  1509 00001A38 FB                  <1> 	sti		; enable interrupts first
  1510 00001A39 3A3D[D61F0100]      <1> 	cmp     bh, [ACTIVE_PAGE]
  1511 00001A3F 750C                <1> 	jne	short p13 
  1512 00001A41 FA                  <1> 	cli 		; block interrupts for single loop
  1513 00001A42 EC                  <1> 	in	al, dx	; get status from the adapter
  1514 00001A43 A801                <1> 	test	al, RHRZ ; is horizontal retrace low
  1515 00001A45 75F1                <1> 	jnz	short p11 ; wait until it is
  1516                              <1> p12:			;  wait for either retrace high
  1517 00001A47 EC                  <1> 	in	al, dx ; get status again
  1518 00001A48 A809                <1> 	test	al, RVRT+RHRZ ; is horizontal or vertical retrace high
  1519 00001A4A 74FB                <1> 	jz	short p12 ; wait until either retrace active
  1520 00001A4C FB                  <1> 	sti
  1521                              <1> p13:
  1522 00001A4D 81C600800B00        <1> 	add	esi, 0B8000h 
  1523 00001A53 668B06              <1> 	mov	ax, [esi]
  1524                              <1> 
  1525 00001A56 C3                  <1> 	retn	; 18/01/2016
  1526                              <1> 
  1527                              <1> WRITE_AC_CURRENT:
  1528                              <1> 	; 08/07/2016
  1529                              <1> 	; 26/06/2016
  1530                              <1> 	; 24/06/2016
  1531                              <1> 	; 12/05/2016
  1532                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  1533                              <1> 	;
  1534                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  1535                              <1> 	;
  1536                              <1> ;----------------------------------------------------------------
  1537                              <1> ; WRITE_AC_CURRENT						:
  1538                              <1> ;	THTS ROUTINE WRITES THE ATTRIBUTE AND CHARACTER		:
  1539                              <1> ;	AT THE CURRENT CURSOR POSITION				:
  1540                              <1> ; INPUT								:
  1541                              <1> ;	(AH) = CURRENT CRT MODE					:
  1542                              <1> ;	(BH) = DISPLAY PAGE					:
  1543                              <1> ;	(CX) = COUNT OF CHARACTERS TO WRITE			:
  1544                              <1> ;	(AL) = CHAR TO WRITE					:
  1545                              <1> ;	(BL) = ATTRIBUTE OF CHAR TO WRITE			:
  1546                              <1> ;	(DS) = DATA SEGMENT					:
  1547                              <1> ;	(ES) = REGEN SEGMENT					:
  1548                              <1> ; OUTPUT							:
  1549                              <1> ;	DISPLAY REGEN BUFFER UPDATED				:
  1550                              <1> ;----------------------------------------------------------------
  1551                              <1> 
  1552                              <1> 	; 08/07/2016
  1553 00001A57 803D[E6E80000]07    <1> 	cmp	byte [CRT_MODE], 7 ; 6!?
  1554 00001A5E 760A                <1> 	jna	short write_ac_c
  1555                              <1> 
  1556 00001A60 E8730A0000          <1> 	call	vga_write_char_attr
  1557 00001A65 E996F9FFFF          <1> 	jmp     VIDEO_RETURN	
  1558                              <1> 
  1559                              <1> write_ac_c:
  1560 00001A6A E834000000          <1> 	call	_write_c_current
  1561                              <1> 
  1562 00001A6F 0FB6F7              <1> 	movzx	esi, bh ; video page number (0 to 7)	
  1563 00001A72 889E[EFE80000]      <1> 	mov	[esi+chr_attrib], bl ; color/attribute
  1564                              <1> 
  1565 00001A78 E983F9FFFF          <1>         jmp     VIDEO_RETURN
  1566                              <1> 
  1567                              <1> WRITE_C_CURRENT:
  1568                              <1> 	; 08/07/2016
  1569                              <1> 	; 26/06/2016
  1570                              <1> 	; 12/05/2016
  1571                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  1572                              <1> 	;
  1573                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  1574                              <1> 	;
  1575                              <1> ;----------------------------------------------------------------
  1576                              <1> ; WRITE_C_CURRENT						:
  1577                              <1> ;	THIS ROUTINE WRITES THE CHARACTER AT			:
  1578                              <1> ;	THE CURRENT CURSOR POSITION, ATTRIBUTE UNCHANGED	:
  1579                              <1> ; INPUT								:
  1580                              <1> ;	(AH) = CURRENT CRT MODE					:
  1581                              <1> ;	(BH) = DISPLAY PAGE					:
  1582                              <1> ;	(CX) = COUNT OF CHARACTERS TO WRITE			:
  1583                              <1> ;	(AL) = CHAR TO WRITE					:
  1584                              <1> ;	(DS) = DATA SEGMENT					:
  1585                              <1> ;	(ES) = REGEN SEGMENT					:
  1586                              <1> ; OUTPUT							:
  1587                              <1> ;	DISPLAY REGEN BUFFER UPDATED				:
  1588                              <1> ;----------------------------------------------------------------
  1589                              <1> 
  1590                              <1> 	; 08/07/2016
  1591 00001A7D 803D[E6E80000]07    <1> 	cmp	byte [CRT_MODE], 7 ; 6!?
  1592 00001A84 760A                <1> 	jna	short write_c_c
  1593                              <1> 
  1594 00001A86 E84D0A0000          <1> 	call	vga_write_char_only
  1595 00001A8B E970F9FFFF          <1> 	jmp     VIDEO_RETURN	
  1596                              <1> 
  1597                              <1> write_c_c:
  1598                              <1> 	;and	bh, 7 ; video page number (<= 7)
  1599 00001A90 0FB6F7              <1> 	movzx	esi, bh	
  1600 00001A93 8A9E[EFE80000]      <1> 	mov	bl, [esi+chr_attrib]
  1601                              <1> 
  1602 00001A99 E805000000          <1> 	call	_write_c_current
  1603 00001A9E E95DF9FFFF          <1>         jmp     VIDEO_RETURN
  1604                              <1> 
  1605                              <1> _write_c_current:  ; from 'write_tty'
  1606                              <1> 	; 26/06/2016
  1607                              <1> 	; 24/06/2016
  1608                              <1> 	; 12/05/2016
  1609                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  1610                              <1> 	; 30/08/2014 (Retro UNIX 386 v1)
  1611                              <1> 	; 18/01/2014
  1612                              <1> 	; 04/12/2013
  1613                              <1> 	;
  1614                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  1615                              <1> 
  1616                              <1> 	;mov	ah, [CRT_MODE] ; current video mode	
  1617                              <1> 	;cmp	ah, 4
  1618                              <1>  	;jb	short p40
  1619 00001AA3 803D[E6E80000]04    <1> 	cmp	byte [CRT_MODE], 4
  1620 00001AAA 0F8302070000        <1>         jnb     GRAPHICS_WRITE ; 26/06/2016
  1621                              <1> 
  1622                              <1> 	;cmp	ah, 7 ; TEST FOR BW CARD
  1623                              <1> 	;jne	GRAPHICS_WRITE
  1624                              <1> p40:
  1625                              <1> 	; al = character
  1626                              <1> 	; bl = color/attribute
  1627                              <1> 	; bh = video page
  1628                              <1> 	; cx = count of characters to write
  1629 00001AB0 6652                <1> 	push	dx
  1630 00001AB2 88DC                <1> 	mov	ah, bl  ; color/attribute (12/05/2016)
  1631 00001AB4 6650                <1> 	push	ax	; save character & attribute/color
  1632 00001AB6 6651                <1> 	push	cx
  1633 00001AB8 E86FFDFFFF          <1> 	call 	find_position  ; get regen location and port address
  1634 00001ABD 6659                <1> 	pop	cx
  1635                              <1> 	; esi = regen location
  1636                              <1> 	; dx = status port
  1637                              <1> 	;
  1638 00001ABF 81C600800B00        <1> 	add	esi, 0B8000h ; 30/08/2014 (crt_base) 
  1639                              <1> 	;
  1640 00001AC5 8A25[E6E80000]      <1> 	mov	ah, [CRT_MODE]	
  1641 00001ACB 80EC02              <1> 	sub	ah, 2
  1642 00001ACE D0EC                <1> 	shr	ah, 1
  1643 00001AD0 7519                <1> 	jnz	short p44    ; 26/06/2016
  1644                              <1> 
  1645                              <1> 	; WAIT FOR HORIZONTAL RETRACE OR VERTICAL RETRACE IF COLOR 80
  1646                              <1> p41:
  1647 00001AD2 FB                  <1> 	sti		; enable interrupts first
  1648 00001AD3 3A3D[D61F0100]      <1> 	cmp     bh, [ACTIVE_PAGE]
  1649 00001AD9 7510                <1> 	jne	short p44 
  1650 00001ADB FA                  <1> 	cli 		; block interrupts for single loop
  1651 00001ADC EC                  <1> 	in	al, dx	; get status from the adapter
  1652 00001ADD A808                <1> 	test	al, RVRT ; check for vertical retrace first
  1653 00001ADF 7509                <1> 	jnz	short p43 ; Do fast write now if vertical retrace
  1654 00001AE1 A801                <1> 	test	al, RHRZ ; is horizontal retrace low
  1655 00001AE3 75ED                <1> 	jnz	short p41 ; wait until it is
  1656                              <1> p42:			;  wait for either retrace high
  1657 00001AE5 EC                  <1> 	in	al, dx ; get status again
  1658 00001AE6 A809                <1> 	test	al, RVRT+RHRZ ; is horizontal or vertical retrace high
  1659 00001AE8 74FB                <1> 	jz	short p42 ; wait until either retrace active
  1660                              <1> p43:	
  1661 00001AEA FB                  <1> 	sti
  1662                              <1> p44:
  1663 00001AEB 668B0424            <1> 	mov	ax, [esp] ; restore the character (al) & attribute (ah)
  1664 00001AEF 668906              <1> 	mov	[esi], ax
  1665                              <1> 
  1666 00001AF2 6649                <1> 	dec	cx
  1667 00001AF4 7404                <1> 	jz	short p45
  1668                              <1> 
  1669 00001AF6 46                  <1> 	inc	esi
  1670 00001AF7 46                  <1> 	inc	esi
  1671 00001AF8 EBD8                <1> 	jmp	short p41
  1672                              <1> p45:	
  1673 00001AFA 6658                <1> 	pop	ax
  1674 00001AFC 665A                <1> 	pop	dx
  1675 00001AFE C3                  <1> 	retn
  1676                              <1> 
  1677                              <1> ; 09/07/2016
  1678                              <1> ; 26/06/2016
  1679                              <1> ; 24/06/2016
  1680                              <1> ; 12/05/2016
  1681                              <1> ; 18/01/2016
  1682                              <1> ; 16/01/2016 - TRDOS 386 (TRDOS v2.0)
  1683                              <1> ; 30/06/2015
  1684                              <1> ; 27/06/2015
  1685                              <1> ; 11/03/2015
  1686                              <1> ; 02/09/2014
  1687                              <1> ; 30/08/2014
  1688                              <1> ; VIDEO FUNCTIONS
  1689                              <1> ; (write_tty - Retro UNIX 8086 v1 - U9.ASM, 01/02/2014)
  1690                              <1> 
  1691                              <1> WRITE_TTY:
  1692                              <1> 	; 09/07/2016
  1693                              <1> 	; 01/07/2016
  1694                              <1> 	; 26/06/2016
  1695                              <1> 	; 24/06/2016
  1696                              <1> 	; 13/05/2016
  1697                              <1> 	; 12/05/2016
  1698                              <1> 	; 30/01/2016
  1699                              <1> 	; 18/01/2016
  1700                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  1701                              <1> 	; 13/08/2015
  1702                              <1> 	; 02/09/2014
  1703                              <1> 	; 30/08/2014 (Retro UNIX 386 v1 - beginning)
  1704                              <1> 	; 01/02/2014 (Retro UNIX 8086 v1 - last update)
  1705                              <1> 	; 03/12/2013 (Retro UNIX 8086 v1 - beginning)	
  1706                              <1> 	; (Modified registers: EAX, EBX, ECX, EDX, ESI, EDI)
  1707                              <1> 	;
  1708                              <1> 	; INPUT -> AL = Character to be written
  1709                              <1> 	;	   BL = Color (Forecolor, Backcolor)
  1710                              <1> 	;	   BH = Video Page (0 to 7)
  1711                              <1> 
  1712                              <1> 	; 09/07/2016
  1713 00001AFF 803D[E6E80000]07    <1>         cmp     byte [CRT_MODE], 7
  1714 00001B06 760A                <1> 	jna 	short write_tty_cga
  1715                              <1> 
  1716 00001B08 E86F0C0000          <1> 	call	vga_write_teletype
  1717 00001B0D E9EEF8FFFF          <1> 	jmp	VIDEO_RETURN
  1718                              <1> 
  1719                              <1> write_tty_cga:
  1720                              <1> 	; 13/05/2016
  1721                              <1> 	;call	_write_tty
  1722                              <1> 	; 01/07/2016
  1723 00001B12 E818000000          <1> 	call	_write_tty_m3
  1724 00001B17 E9E4F8FFFF          <1> 	jmp	VIDEO_RETURN
  1725                              <1> 
  1726                              <1> RVRT	equ	00001000b	; VIDEO VERTICAL RETRACE BIT
  1727                              <1> RHRZ	equ	00000001b	; VIDEO HORIZONTAL RETRACE BIT
  1728                              <1> 
  1729                              <1> ; Derived from "WRITE_TTY" procedure of IBM "pc-at" rombios source code
  1730                              <1> ; (06/10/1985), 'video.asm', INT 10H, VIDEO_IO
  1731                              <1> ;
  1732                              <1> ; 06/10/85  VIDEO DISPLAY BIOS
  1733                              <1> ;
  1734                              <1> ;--- WRITE_TTY ------------------------------------------------------------------
  1735                              <1> ;										:
  1736                              <1> ;   THIS INTERFACE PROVIDES A TELETYPE LIKE INTERFACE TO THE			:
  1737                              <1> ;   VIDEO CARDS. THE INPUT CHARACTER IS WRITTEN TO THE CURRENT			:
  1738                              <1> ;   CURSOR POSITION, AND THE CURSOR IS MOVED TO THE NEXT POSITION.		:
  1739                              <1> ;   IF THE CURSOR LEAVES THE LAST COLUMN OF THE FIELD, THE COLUMN		:
  1740                              <1> ;   IS SET TO ZERO, AND THE ROW VALUE IS INCREMENTED. IF THE ROW		:
  1741                              <1> ;   ROW VALUE LEAVES THE FIELD, THE CURSOR IS PLACED ON THE LAST ROW,		:
  1742                              <1> ;   FIRST COLUMN, AND THE ENTIRE SCREEN IS SCROLLED UP ONE LINE.		:
  1743                              <1> ;   WHEN THE SCREEN IS SCROLLED UP, THE ATTRIBUTE FOR FILLING THE		:
  1744                              <1> ;   NEWLY BLANKED LINE IS READ FROM THE CURSOR POSITION ON THE PREVIOUS		:
  1745                              <1> ;   LINE BEFORE THE SCROLL, IN CHARACTER MODE. IN GRAPHICS MODE,		:
  1746                              <1> ;   THE 0 COLOR IS USED.							:
  1747                              <1> ;   ENTRY --									:
  1748                              <1> ;     (AH) = CURRENT CRT MODE							:
  1749                              <1> ;     (AL) = CHARACTER TO BE WRITTEN						:
  1750                              <1> ;	    NOTE THAT BACK SPACE, CARRIAGE RETURN, BELL AND LINE FEED ARE	:
  1751                              <1> ;	    HANDLED AS COMMANDS RATHER THAN AS DISPLAY GRAPHICS CHARACTERS	:
  1752                              <1> ;     (BL) = FOREGROUND COLOR FOR CHAR WRITE IF CURRENTLY IN A GRAPHICS MODE	:
  1753                              <1> ;   EXIT -- 									:
  1754                              <1> ;     ALL REGISTERS SAVED							:
  1755                              <1> ;--------------------------------------------------------------------------------
  1756                              <1> 
  1757                              <1> ; 08/07/2016
  1758                              <1> ; 26/06/2016
  1759                              <1> ; 24/06/2016
  1760                              <1> _write_tty:	; 13/05/2016
  1761 00001B1C FA                  <1> 	cli
  1762                              <1> 	;
  1763                              <1> 	; 01/09/2014
  1764 00001B1D 803D[E6E80000]03    <1> 	cmp	byte [CRT_MODE], 3
  1765 00001B24 7409                <1> 	je	short _write_tty_m3
  1766                              <1> 	;
  1767                              <1> set_mode_3:
  1768 00001B26 53                  <1> 	push	ebx
  1769 00001B27 50                  <1> 	push	eax
  1770 00001B28 E8E3F8FFFF          <1> 	call	_set_mode
  1771 00001B2D 58                  <1> 	pop	eax
  1772 00001B2E 5B                  <1> 	pop	ebx
  1773                              <1> 	;
  1774                              <1> _write_tty_m3: ; 24/06/2016 (m3 -> _write_tty_m3)
  1775 00001B2F 0FB6F7              <1> 	movzx 	esi, bh ; 12/05/2016
  1776 00001B32 66D1E6              <1> 	shl	si, 1
  1777 00001B35 81C6[C61F0100]      <1> 	add	esi, CURSOR_POSN
  1778 00001B3B 668B16              <1> 	mov	dx, [esi]
  1779                              <1> 	;
  1780                              <1> 	; dx now has the current cursor position
  1781                              <1> 	;
  1782 00001B3E 3C0D                <1> 	cmp	al, 0Dh	; CR	; is it carriage return or control character
  1783 00001B40 7636                <1> 	jbe	short u8
  1784                              <1> 	;
  1785                              <1> 	; write the char to the screen
  1786                              <1> u0:	
  1787                              <1> 	; al = character
  1788                              <1> 	; bl = attribute/color
  1789                              <1> 	; bh = video page number (0 to 7)
  1790                              <1> 	;
  1791 00001B42 66B90100            <1> 	mov	cx, 1  ; 24/06/2016
  1792                              <1> 	; cx = count of characters to write
  1793                              <1> 	;
  1794 00001B46 E858FFFFFF          <1> 	call	_write_c_current ; 16/01/2015
  1795                              <1> 	;
  1796                              <1> 	; position the cursor for next char
  1797 00001B4B FEC2                <1> 	inc	dl		; next column
  1798 00001B4D 3A15[E8E80000]      <1> 	cmp	dl, [CRT_COLS]  ; test for column overflow 
  1799 00001B53 755D                <1>         jne     _set_cpos
  1800 00001B55 B200                <1> 	mov	dl, 0		; column = 0
  1801                              <1> u10:				; (line feed found)
  1802 00001B57 80FE18              <1> 	cmp	dh, 25-1 	; check for last row
  1803 00001B5A 7218                <1> 	jb 	short u6
  1804                              <1> 	;
  1805                              <1> 	; scroll required
  1806                              <1> u1:	
  1807                              <1> 	; SET CURSOR POSITION (04/12/2013)
  1808 00001B5C E851000000          <1> 	call	_set_cpos
  1809                              <1> 	;
  1810                              <1> 	; determine value to fill with during scroll
  1811                              <1> u2:
  1812                              <1> 	; bh = video page number
  1813                              <1> 	;
  1814 00001B61 E8B3FEFFFF          <1> 	call	_read_ac_current ; 18/01/2016
  1815                              <1> 	;
  1816                              <1> 	; al = character, ah = attribute
  1817                              <1> 	; bh = video page number 	
  1818                              <1> u3:
  1819                              <1> 	;;mov	ax, 0601h 	; scroll one line
  1820                              <1> 	;;sub	cx, cx		; upper left corner
  1821                              <1> 	;;mov	dh, 25-1 	; lower right row
  1822                              <1> 	;;;mov	dl, [CRT_COLS]
  1823                              <1> 	;mov	dl, 80		; lower right column	
  1824                              <1> 	;;dec	dl
  1825                              <1> 	;;mov	dl, 79
  1826                              <1> 
  1827                              <1> 	;;call	scroll_up	; 04/12/2013
  1828                              <1> 	;;; 11/03/2015
  1829                              <1> 	; 02/09/2014
  1830                              <1> 	;;;mov	cx, [crt_ulc] ; Upper left corner  (0000h)
  1831                              <1> 	;;;mov	dx, [crt_lrc] ; Lower right corner (184Fh)
  1832                              <1> 	; 11/03/2015
  1833 00001B66 6629C9              <1> 	sub	cx, cx
  1834 00001B69 66BA4F18            <1> 	mov	dx, 184Fh ; dl = 79 (column), dh = 24 (row)
  1835                              <1> 	;
  1836 00001B6D B001                <1> 	mov	al, 1		; scroll 1 line up
  1837                              <1> 		; ah = attribute
  1838                              <1> 	;mov	bl, al ; 12/05/2016
  1839 00001B6F E900FDFFFF          <1> 	jmp	_scroll_up	; 16/01/2016
  1840                              <1> ;u4:
  1841                              <1> 	;;int	10h		; video-call return
  1842                              <1> 				; scroll up the screen
  1843                              <1> 				; tty return
  1844                              <1> ;u5:
  1845                              <1> 	;retn			; return to the caller
  1846                              <1> 
  1847                              <1> u6:				; set-cursor-inc
  1848 00001B74 FEC6                <1> 	inc	dh		; next row
  1849                              <1> 				; set cursor
  1850                              <1> ;u7:					
  1851                              <1> 	;;mov	ah, 02h
  1852                              <1> 	;;jmp	short u4 	; establish the new cursor
  1853                              <1> 	;call	_set_cpos
  1854                              <1> 	;jmp 	short u5
  1855 00001B76 EB3A                <1> 	jmp     _set_cpos
  1856                              <1> 
  1857                              <1> 	; check for control characters
  1858                              <1> u8:
  1859 00001B78 7436                <1> 	je	short u9
  1860 00001B7A 3C0A                <1> 	cmp	al, 0Ah		; is it a line feed (0Ah)
  1861 00001B7C 74D9                <1> 	je	short u10
  1862 00001B7E 3C07                <1> 	cmp	al, 07h 	; is it a bell
  1863 00001B80 747A                <1> 	je	short u11
  1864 00001B82 3C08                <1> 	cmp	al, 08h		; is it a backspace
  1865                              <1> 	;jne	short u0
  1866 00001B84 7422                <1> 	je	short bs	; 12/12/2013
  1867                              <1> 	; 12/12/2013 (tab stop)
  1868 00001B86 3C09                <1> 	cmp	al, 09h		; is it a tab stop
  1869 00001B88 75B8                <1> 	jne	short u0
  1870 00001B8A 88D0                <1> 	mov	al, dl
  1871 00001B8C 6698                <1> 	cbw
  1872 00001B8E B108                <1> 	mov	cl, 8
  1873 00001B90 F6F1                <1> 	div	cl
  1874 00001B92 28E1                <1> 	sub	cl, ah
  1875                              <1> ts:
  1876                              <1> 	; 02/09/2014
  1877                              <1> 	; 01/09/2014
  1878 00001B94 B020                <1> 	mov	al, 20h
  1879                              <1> tsloop:
  1880 00001B96 6651                <1> 	push	cx
  1881 00001B98 6650                <1> 	push	ax
  1882                              <1> 	;mov	bh, [ACTIVE_PAGE]
  1883 00001B9A E890FFFFFF          <1> 	call	_write_tty_m3 ; 24/06/2016 (m3 -> _write_tty_m3)
  1884 00001B9F 6658                <1> 	pop	ax  ; ah = attribute/color
  1885 00001BA1 6659                <1> 	pop	cx
  1886 00001BA3 FEC9                <1> 	dec	cl
  1887 00001BA5 75EF                <1> 	jnz	short tsloop
  1888 00001BA7 C3                  <1> 	retn
  1889                              <1> bs:	
  1890                              <1> 	; back space found
  1891                              <1> 
  1892 00001BA8 08D2                <1> 	or	dl, dl 		; is it already at start of line
  1893                              <1> 	;je	short u7 	; set_cursor
  1894 00001BAA 7406                <1> 	jz	short _set_cpos
  1895 00001BAC 664A                <1> 	dec	dx     		; no -- just move it back
  1896                              <1> 	;jmp	short u7
  1897 00001BAE EB02                <1> 	jmp	short _set_cpos
  1898                              <1> 
  1899                              <1> 	; carriage return found
  1900                              <1> u9:
  1901 00001BB0 B200                <1> 	mov	dl, 0 		; move to first column
  1902                              <1> 	;jmp	short u7
  1903                              <1> 	;jmp	short _set_cpos ; 30/01/2016
  1904                              <1> 
  1905                              <1> 	; line feed found
  1906                              <1> ;u10:
  1907                              <1> ;	cmp	dh, 25-1 	; bottom of screen
  1908                              <1> ;	jne	short u6 	; no, just set the cursor
  1909                              <1> ;       jmp     u1              ; yes, scroll the screen
  1910                              <1> 
  1911                              <1> _set_cpos:
  1912                              <1> 	; 12/05/2016 - TRDOS 386 (TRDOS v2.0)
  1913                              <1> 	; 27/06/2015
  1914                              <1> 	; 01/09/2014
  1915                              <1> 	; 30/08/2014 (Retro UNIX 386 v1)
  1916                              <1> 	;
  1917                              <1> 	; 04/12/2013 - 12/12/2013 (Retro UNIX 8086 v1) 
  1918                              <1> 	;
  1919                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  1920                              <1> 	;
  1921                              <1> ;----------------------------------------------
  1922                              <1> ; SET_CPOS
  1923                              <1> ;	THIS ROUTINE SETS THE CURRENT CURSOR POSITION TO THE
  1924                              <1> ;	NEW X-Y VALUES PASSED
  1925                              <1> ; INPUT
  1926                              <1> ;	DX - ROW,COLUMN OF NEW CURSOR
  1927                              <1> ;	BH - DISPLAY PAGE OF CURSOR
  1928                              <1> ; OUTPUT
  1929                              <1> ;	CURSOR ID SET AT 6845 IF DISPLAY PAGE IS CURRENT DISPLAY
  1930                              <1> ;----------------------------------------------
  1931                              <1> 	;
  1932 00001BB2 BE[C61F0100]        <1> 	mov	esi, CURSOR_POSN
  1933 00001BB7 0FB6C7              <1>         movzx   eax, bh	; BH = video page number
  1934                              <1> ;	or	al, al
  1935                              <1> ;	jz	short _set_cpos_0
  1936 00001BBA D0E0                <1>         shl     al, 1   ; word offset
  1937 00001BBC 01C6                <1>         add     esi, eax
  1938                              <1> ;_set_cpos_0:
  1939 00001BBE 668916              <1> 	mov	[esi], dx ; save the pointer
  1940 00001BC1 383D[D61F0100]      <1> 	cmp	[ACTIVE_PAGE], bh
  1941 00001BC7 7532                <1> 	jne	short m17
  1942                              <1> 	;call	m18	; CURSOR SET
  1943                              <1> ;m17:			; SET_CPOS_RETURN
  1944                              <1> 	; 01/09/2014
  1945                              <1> ;	retn
  1946                              <1> 		; DX  = row/column
  1947                              <1> m18:
  1948 00001BC9 E84CFCFFFF          <1> 	call	position ; determine location in regen buffer	
  1949 00001BCE 668B0D[C41F0100]    <1> 	mov	cx, [CRT_START]
  1950 00001BD5 6601C1              <1> 	add	cx, ax  ; add char position in regen buffer
  1951                              <1> 			; to the start address (offset) for this page
  1952 00001BD8 66D1E9              <1> 	shr	cx, 1	; divide by 2 for char only count
  1953 00001BDB B40E                <1> 	mov	ah, 14	; register number for cursor
  1954                              <1> 	;call	m16	; output value to the 6845	
  1955                              <1> 	;retn
  1956                              <1> 
  1957                              <1> 	;-----	THIS ROUTINE OUTPUTS THE CX REGISTER
  1958                              <1> 	;	TO THE 6845 REGISTERS NAMED IN (AH)
  1959                              <1> m16:
  1960 00001BDD FA                  <1> 	cli
  1961                              <1> 	;mov	dx, [addr_6845] ; address register
  1962 00001BDE 66BAD403            <1> 	mov 	dx, 03D4h ; I/O address of color card
  1963 00001BE2 88E0                <1> 	mov	al, ah	; get value
  1964 00001BE4 EE                  <1> 	out	dx, al	; register set
  1965 00001BE5 6642                <1> 	inc	dx	; data register
  1966 00001BE7 EB00                <1> 	jmp	$+2	; i/o delay
  1967 00001BE9 88E8                <1> 	mov	al, ch	; data
  1968 00001BEB EE                  <1> 	out	dx, al	
  1969 00001BEC 664A                <1> 	dec	dx	
  1970 00001BEE 88E0                <1> 	mov	al, ah
  1971 00001BF0 FEC0                <1> 	inc	al	; point to other data register
  1972 00001BF2 EE                  <1> 	out	dx, al	; set for second register
  1973 00001BF3 6642                <1> 	inc	dx
  1974 00001BF5 EB00                <1> 	jmp	$+2	; i/o delay
  1975 00001BF7 88C8                <1> 	mov	al, cl	; second data value
  1976 00001BF9 EE                  <1> 	out	dx, al
  1977 00001BFA FB                  <1> 	sti
  1978                              <1> m17:
  1979 00001BFB C3                  <1> 	retn
  1980                              <1> 
  1981                              <1> beeper: 
  1982                              <1> 	; 12/05/2016 - TRDOS 386 (TRDOS v2.0)
  1983                              <1> 	; 30/08/2014 (Retro UNIX 386 v1)
  1984                              <1> 	; 18/01/2014
  1985                              <1> 	; 03/12/2013
  1986                              <1> 	; bell found
  1987                              <1> u11:
  1988 00001BFC FB                  <1> 	sti
  1989 00001BFD 3A3D[D61F0100]      <1> 	cmp	bh, [ACTIVE_PAGE]
  1990 00001C03 7551                <1> 	jne	short u12	; Do not sound the beep 
  1991                              <1> 				; if it is not written on the active page
  1992 00001C05 66B93305            <1> 	mov	cx, 1331 	; divisor for 896 hz tone
  1993 00001C09 B31F                <1> 	mov	bl, 31		; set count for 31/64 second for beep
  1994                              <1> 	;call	beep		; sound the pod bell
  1995                              <1> 	;jmp	short u5 	; tty_return
  1996                              <1> 	;retn
  1997                              <1> 	
  1998                              <1> TIMER	equ 	040h   		; 8254 TIMER - BASE ADDRESS
  1999                              <1> PORT_B	equ	061h		; PORT B READ/WRITE DIAGNOSTIC REGISTER
  2000                              <1> GATE2	equ	00000001b	; TIMER 2 INPUT CATE CLOCK BIT
  2001                              <1> SPK2	equ	00000010b	; SPEAKER OUTPUT DATA ENABLE BIT
  2002                              <1> 
  2003                              <1> beep:
  2004                              <1> 	; 07/02/2015
  2005                              <1> 	; 30/08/2014 (Retro UNIX 386 v1)
  2006                              <1> 	; 18/01/2014
  2007                              <1> 	; 03/12/2013
  2008                              <1> 	;
  2009                              <1> 	; TEST4.ASM - 06/10/85  POST AND BIOS UTILITY ROUTINES
  2010                              <1> 	;
  2011                              <1> 	; ROUTINE TO SOUND THE BEEPER USING TIMER 2 FOR TONE
  2012                              <1> 	;
  2013                              <1> 	; ENTRY:
  2014                              <1> 	;    (BL) = DURATION COUNTER ( 1 FOR 1/64 SECOND )
  2015                              <1> 	;    (CX) = FREQUENCY DIVISOR (1193180/FREQUENCY) (1331 FOR 886 HZ)
  2016                              <1> 	; EXIT:				:
  2017                              <1> 	;    (AX),(BL),(CX) MODIFIED.
  2018                              <1> 
  2019 00001C0B 9C                  <1> 	pushf  ; 18/01/2014	; save interrupt status
  2020 00001C0C FA                  <1> 	cli			; block interrupts during update
  2021 00001C0D B0B6                <1> 	mov	al, 10110110b	; select timer 2, lsb, msb binary
  2022 00001C0F E643                <1> 	out	TIMER+3, al 	; write timer mode register
  2023 00001C11 EB00                <1> 	jmp	$+2		; I/O delay
  2024 00001C13 88C8                <1> 	mov	al, cl		; divisor for hz (low)
  2025 00001C15 E642                <1> 	out	TIMER+2,AL	; write timer 2 count - lsb
  2026 00001C17 EB00                <1> 	jmp	$+2		; I/O delay
  2027 00001C19 88E8                <1> 	mov	al, ch		; divisor for hz (high)
  2028 00001C1B E642                <1> 	out	TIMER+2, al	; write timer 2 count - msb
  2029 00001C1D E461                <1> 	in	al, PORT_B	; get current setting of port
  2030 00001C1F 88C4                <1> 	mov	ah, al		; save that setting
  2031 00001C21 0C03                <1> 	or	al, GATE2+SPK2	; gate timer 2 and turn speaker on
  2032 00001C23 E661                <1> 	out	PORT_B, al	; and restore interrupt status
  2033                              <1> 	;popf	; 18/01/2014
  2034 00001C25 FB                  <1> 	sti
  2035                              <1> g7:				; 1/64 second per count (bl)
  2036 00001C26 B90B040000          <1> 	mov	ecx, 1035	; delay count for 1/64 of a second	
  2037 00001C2B E827000000          <1> 	call	waitf		; go to beep delay 1/64 count
  2038 00001C30 FECB                <1> 	dec	bl		; (bl) length count expired?
  2039 00001C32 75F2                <1> 	jnz	short g7	; no - continue beeping speaker
  2040                              <1> 	;
  2041                              <1> 	;pushf			; save interrupt status
  2042 00001C34 FA                  <1> 	cli  	; 18/01/2014	; block interrupts during update
  2043 00001C35 E461                <1> 	in	al, PORT_B	; get current port value
  2044                              <1>         ;or      al, not (GATE2+SPK2) ; isolate current speaker bits in case
  2045 00001C37 0CFC                <1>         or      al, ~(GATE2+SPK2)
  2046 00001C39 20C4                <1>         and	ah, al		; someone turned them off during beep
  2047 00001C3B 88E0                <1> 	mov	al, ah		; recover value of port
  2048                              <1>         ;or      al, not (GATE2+SPK2) ; force speaker data off
  2049 00001C3D 0CFC                <1> 	or 	al, ~(GATE2+SPK2) ; isolate current speaker bits in case
  2050 00001C3F E661                <1> 	out	PORT_B, al	; and stop speaker timer
  2051                              <1> 	;popf			; restore interrupt flag state
  2052 00001C41 FB                  <1> 	sti
  2053 00001C42 B90B040000          <1> 	mov	ecx, 1035	; force 1/64 second delay (short)
  2054 00001C47 E80B000000          <1> 	call	waitf		; minimum delay between all beeps
  2055                              <1> 	;pushf			; save interrupt status
  2056 00001C4C FA                  <1> 	cli			; block interrupts during update
  2057 00001C4D E461                <1> 	in	al, PORT_B	; get current port value in case	
  2058 00001C4F 2403                <1> 	and	al, GATE2+SPK2	; someone turned them on
  2059 00001C51 08E0                <1> 	or	al, ah		; recover value of port_b
  2060 00001C53 E661                <1> 	out	PORT_B, al	; restore speaker status
  2061 00001C55 9D                  <1> 	popf			; restore interrupt flag state
  2062                              <1> u12:	
  2063 00001C56 C3                  <1> 	retn
  2064                              <1> 
  2065                              <1> REFRESH_BIT equ	00010000b 	; REFRESH TEST BIT
  2066                              <1> 
  2067                              <1> WAITF:
  2068                              <1> waitf:
  2069                              <1> 	; 30/08/2014 (Retro UNIX 386 v1)
  2070                              <1> 	; 03/12/2013
  2071                              <1> 	;
  2072                              <1> ;	push ax			; save work register (ah)	
  2073                              <1> ;waitf1:
  2074                              <1> 				; use timer 1 output bits
  2075                              <1> ;	in	al, PORT_B	; read current counter output status
  2076                              <1> ;	and	al, REFRESH_BIT	; mask for refresh determine bit
  2077                              <1> ;	cmp	al, ah		; did it just change
  2078                              <1> ;	je	short waitf1	; wait for a change in output line
  2079                              <1> ;	;
  2080                              <1> ;	mov	ah, al		; save new lflag state
  2081                              <1> ;	loop	waitf1		; decrement half cycles till count end		
  2082                              <1> ;	;
  2083                              <1> ;	pop	ax		; restore (ah)
  2084                              <1> ;	retn			; return (cx)=0
  2085                              <1> 
  2086                              <1> ; 06/02/2015 (unix386.s <-- dsectrm2.s)
  2087                              <1> ; 17/12/2014 (dsectrm2.s)
  2088                              <1> ; WAITF
  2089                              <1> ; /// IBM PC-XT Model 286 System BIOS Source Code - Test 4 - 06/10/85 ///
  2090                              <1> ;
  2091                              <1> ;---WAITF-----------------------------------------------------------------------
  2092                              <1> ;	FIXED TIME WAIT ROUTINE (HARDWARE CONTROLLED - NOT PROCESSOR)
  2093                              <1> ; ENTRY:
  2094                              <1> ;	(CX) =	COUNT OF 15.085737 MICROSECOND INTERVALS TO WAIT
  2095                              <1> ;	      	MEMORY REFRESH TIMER 1 OUTPUT USED AS REFERENCE
  2096                              <1> ; EXIT:
  2097                              <1> ;	       	AFTER (CX) TIME COUNT (PLUS OR MINUS 16 MICROSECONDS)
  2098                              <1> ;	(CX) = 0	
  2099                              <1> ;-------------------------------------------------------------------------------
  2100                              <1> 
  2101                              <1> ; Refresh period: 30 micro seconds (15-80 us)
  2102                              <1> ; (16/12/2014 - AWARDBIOS 1999 - ATORGS.ASM, WAIT_REFRESH)
  2103                              <1> 
  2104                              <1> ;WAITF:					; DELAY FOR (CX)*15.085737 US
  2105 00001C57 6650                <1> 	PUSH	AX			; SAVE WORK REGISTER (AH)
  2106                              <1> 	; 16/12/2014
  2107                              <1> 	;shr	cx, 1			; convert to count of 30 micro seconds
  2108 00001C59 D1E9                <1> 	shr	ecx, 1	; 21/02/2015
  2109                              <1> ;17/12/2014	
  2110                              <1> ;WAITF1:
  2111                              <1> ;	IN	AL, PORT_B   ;061h	; READ CURRENT COUNTER OUTPUT STATUS
  2112                              <1> ;	AND	AL, REFRESH_BIT	;00010000b ; MASK FOR REFRESH DETERMINE BIT
  2113                              <1> ;	CMP	AL, AH			; DID IT JUST CHANGE
  2114                              <1> ;	JE	short WAITF1		; WAIT FOR A CHANGE IN OUTPUT LINE
  2115                              <1> ;	MOV	AH, AL			; SAVE NEW FLAG STATE
  2116                              <1> ;	LOOP	WAITF1			; DECREMENT HALF CYCLES TILL COUNT END		
  2117                              <1> 	;
  2118                              <1> 	; 17/12/2014
  2119                              <1> 	;
  2120                              <1> 	; Modification from 'WAIT_REFRESH' procedure of AWARD BIOS - 1999
  2121                              <1> 	;
  2122                              <1> ;WAIT_REFRESH:  Uses port 61, bit 4 to have CPU speed independent waiting.
  2123                              <1> ;   	INPUT:  CX = number of refresh periods to wait
  2124                              <1> ;     	       (refresh periods = 1 per 30 microseconds on most machines)
  2125                              <1> WR_STATE_0:
  2126 00001C5B E461                <1> 	IN	AL,PORT_B		; IN AL,SYS1
  2127 00001C5D A810                <1> 	TEST	AL,010H
  2128 00001C5F 74FA                <1> 	JZ	SHORT WR_STATE_0
  2129                              <1> WR_STATE_1:
  2130 00001C61 E461                <1> 	IN	AL,PORT_B		; IN AL,SYS1
  2131 00001C63 A810                <1> 	TEST	AL,010H
  2132 00001C65 75FA                <1> 	JNZ	SHORT WR_STATE_1
  2133 00001C67 E2F2                <1>         LOOP    WR_STATE_0
  2134                              <1> 	;
  2135 00001C69 6658                <1> 	POP	AX			; RESTORE (AH)
  2136 00001C6B C3                  <1> 	RETn				; (CX) = 0
  2137                              <1> 
  2138                              <1> ; 09/07/2016
  2139                              <1> ; 01/07/2016
  2140                              <1> ; 24/06/2016
  2141                              <1> ; 23/06/2016 - TRDOS 386 (TRDOS v2.0)
  2142                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  2143                              <1> ;-------------------------------------------------------------------------------
  2144                              <1> ; WRITE_STRING								       :
  2145                              <1> ;	THIS ROUTINE WRITES A STRING OF CHARACTERS TO THE CRT.		       :
  2146                              <1> ; INPUT 								       :
  2147                              <1> ;	(AL) = WRITE STRING COMMAND  0 - 3				       :
  2148                              <1> ;	(BH) = DISPLAY PAGE (ACTIVE PAGE)				       :
  2149                              <1> ;	(CX) = COUNT OF CHARACTERS TO WRITE, IF (CX) = 0 THEN RETURN	       :
  2150                              <1> ;	(DX) = CURSOR POSITION FOR START OF STRING WRITE		       :
  2151                              <1> ;	(BL) = ATTRIBUTE OF CHARACTER TO WRITE IF (AL) = 0  OR	(AL) = 1       :
  2152                              <1> ;	(eBP) = SOURCE STRING OFFSET					       :
  2153                              <1> ; OUTPUT								       :
  2154                              <1> ;	NONE								       :
  2155                              <1> ;-------------------------------------------------------------------------------
  2156                              <1> 
  2157                              <1> ; AL = 00h: Assign all characters the attribute in BL; do not update cursor
  2158                              <1> ; AL = 01h: Assign all characters the attribute in BL; update cursor
  2159                              <1> ; AL = 02h: Use attributes in string; do not update cursor
  2160                              <1> ; AL = 03h: Use attributes in string; update cursor
  2161                              <1> 
  2162                              <1> WRITE_STRING:
  2163                              <1> 	; 09/07/2016
  2164 00001C6C 803D[E6E80000]07    <1> 	cmp	byte [CRT_MODE], 7 ; 6?!
  2165 00001C73 0F8787F7FFFF        <1> 	ja	VIDEO_RETURN		; not a valid function for VGA modes
  2166                              <1> 	;
  2167 00001C79 A2[302D0100]        <1> 	mov	[w_str_cmd], al		; save (AL) command
  2168 00001C7E 3C04                <1> 	CMP	AL, 4			; TEST FOR INVALID WRITE STRING OPTION
  2169 00001C80 0F837AF7FFFF        <1> 	JNB	VIDEO_RETURN		; IF OPTION INVALID THEN RETURN
  2170                              <1> 
  2171                              <1>         ;JCXZ   VIDEO_RETURN            ; IF ZERO LENGTH STRING THEN RETURN
  2172                              <1> 
  2173 00001C86 67E351              <1>         jcxz    P55			; 01/07/2016
  2174                              <1> 
  2175                              <1> 
  2176                              <1> 	; 01/07/2016
  2177                              <1> 	;and	ecx, 0FFFFh
  2178                              <1> 	; ECX = byte count
  2179                              <1> 	;push	ecx
  2180 00001C89 89EE                <1> 	mov	esi, ebp ; user buffer
  2181 00001C8B BF00000700          <1> 	mov	edi, Cluster_Buffer  ; system buffer
  2182 00001C90 E805BD0000          <1> 	call	transfer_from_user_buffer
  2183                              <1> 	;pop	ecx
  2184 00001C95 0F8265F7FFFF        <1> 	jc	VIDEO_RETURN
  2185                              <1> 	; ecx = transfer (byte) count = character count
  2186 00001C9B BD00000700          <1> 	mov	ebp, Cluster_Buffer
  2187                              <1> 	;
  2188 00001CA0 0FB6F7              <1> 	movzx	esi, bh			; GET CURRENT CURSOR PAGE
  2189 00001CA3 66D1E6              <1> 	SAL	SI,1			; CONVERT TO PAGE OFFSET  (SI= PAGE)
  2190                              <1> 	; *****
  2191 00001CA6 66FFB6[C61F0100]    <1> 	PUSH	word [eSI+CURSOR_POSN]	; SAVE CURRENT CURSOR POSITION IN STACK
  2192                              <1> 
  2193                              <1> 	;MOV	AX,0200H		; SET NEW CURSOR POSITION
  2194                              <1> 	;INT	10H
  2195                              <1> P50next:	
  2196 00001CAD 53                  <1> 	push	ebx ; ****
  2197 00001CAE 51                  <1> 	push	ecx ; ***
  2198 00001CAF 56                  <1> 	push	esi ; **
  2199 00001CB0 52                  <1> 	push	edx ; *
  2200 00001CB1 E8FCFEFFFF          <1> 	call	_set_cpos
  2201                              <1> P50:
  2202 00001CB6 8A4500              <1> 	MOV	AL, [eBP]		; GET CHARACTER FROM INPUT STRING
  2203 00001CB9 45                  <1> 	INC	eBP			; BUMP POINTER TO CHARACTER
  2204                              <1> 
  2205                              <1> ;-----	TEST FOR SPECIAL CHARACTER'S
  2206                              <1> 
  2207 00001CBA 3C08                <1> 	CMP	AL, 08H			; IS IT A BACKSPACE
  2208 00001CBC 740C                <1> 	JE	short P51		; BACK_SPACE
  2209 00001CBE 3C0D                <1> 	CMP	AL, 0Dh ; CR		; IS IT CARRIAGE RETURN
  2210 00001CC0 7408                <1> 	JE	short P51		; CAR_RET
  2211 00001CC2 3C0A                <1> 	CMP	AL, 0Ah ; LF		; IS IT A LINE FEED
  2212 00001CC4 7404                <1> 	JE	short P51		; LINE_FEED
  2213 00001CC6 3C07                <1> 	CMP	AL, 07h			; IS IT A BELL
  2214 00001CC8 7515                <1> 	JNE	short P52		; IF NOT THEN DO WRITE CHARACTER
  2215                              <1> P51:
  2216                              <1> 	;MOV	AH,0EH			; TTY_CHARACTER_WRITE
  2217                              <1> 	;INT	10H			; WRITE TTY CHARACTER TO THE CRT
  2218                              <1> 	
  2219 00001CCA E860FEFFFF          <1> 	call	_write_tty_m3
  2220                              <1> 
  2221 00001CCF 5A                  <1> 	pop	edx ; *
  2222 00001CD0 5E                  <1> 	pop	esi ; **
  2223                              <1> 
  2224 00001CD1 668B96[C61F0100]    <1> 	MOV	DX, [eSI+CURSOR_POSN]	; GET CURRENT CURSOR POSITION
  2225 00001CD8 EB46                <1> 	JMP	SHORT P54		; SET CURSOR POSITION AND CONTINUE
  2226                              <1> P55:
  2227 00001CDA E921F7FFFF          <1> 	JMP	VIDEO_RETURN
  2228                              <1> P52:
  2229 00001CDF 66B90100            <1> 	MOV	CX, 1			; SET CHARACTER WRITE AMOUNT TO ONE
  2230 00001CE3 803D[302D0100]02    <1> 	CMP	byte [w_str_cmd], 2	; IS THE ATTRIBUTE IN THE STRING
  2231 00001CEA 7204                <1> 	JB	short P53		; IF NOT THEN SKIP
  2232 00001CEC 8A5D00              <1> 	MOV	BL, [eBP]		; ELSE GET NEW ATTRIBUTE
  2233 00001CEF 45                  <1> 	INC	eBP			; BUMP STRING POINTER
  2234                              <1> P53:
  2235                              <1> 	;MOV	AH,09H			; GOT_CHARACTER
  2236                              <1> 	;INT	10H			; WRITE CHARACTER TO THE CRT
  2237                              <1> 
  2238 00001CF0 E8AEFDFFFF          <1> 	call	_write_c_current
  2239                              <1> 	
  2240 00001CF5 5A                  <1> 	pop	edx ; *	
  2241                              <1> 	
  2242 00001CF6 0FB6F7              <1> 	movzx	esi, bh ; video page number (0 to 7)	
  2243 00001CF9 889E[EFE80000]      <1> 	mov	[esi+chr_attrib], bl ; color/attribute
  2244                              <1> 
  2245 00001CFF FEC2                <1> 	INC	DL			; INCREMENT COLUMN COUNTER
  2246 00001D01 3A15[E8E80000]      <1> 	CMP	DL, [CRT_COLS]		; IF COLS ARE WITHIN RANGE FOR THIS MODE
  2247 00001D07 7217                <1> 	JB	short P54		;    THEN GO TO COLUMNS SET
  2248 00001D09 FEC6                <1> 	INC	DH			; BUMP ROW COUNTER BY ONE
  2249 00001D0B 28D2                <1> 	SUB	DL, DL			; SET COLUMN COUNTER TO ZERO
  2250 00001D0D 80FE19              <1> 	CMP	DH, 25			; IF ROWS ARE LESS THAN 25 THEN
  2251 00001D10 720E                <1> 	JB	short P54		; GO TO ROWS_COLUMNS_SET
  2252                              <1> 
  2253 00001D12 66B80A0E            <1> 	MOV	AX,0E0AH		; ELSE SCROLL SCREEN
  2254                              <1> 	;INT	10H			; RESET ROW COUNTER TO 24
  2255                              <1> 
  2256 00001D16 E814FEFFFF          <1> 	call	_write_tty_m3
  2257                              <1> 	
  2258 00001D1B 66BA0018            <1> 	mov	dx, 1800h		; Column = 0, Row = 24
  2259 00001D1F 5E                  <1> 	pop	esi ; **
  2260                              <1> P54:
  2261                              <1> 					; ROW_COLUMNS_SET
  2262                              <1> 	;MOV	AX,0200H		; SET NEW CURSOR POSITION COMMAND
  2263                              <1> 	;INT	10H			; ESTABLISH NEW CURSOR POSITION
  2264                              <1> 
  2265 00001D20 59                  <1> 	pop	ecx ; ***
  2266 00001D21 5B                  <1> 	pop	ebx ; ****
  2267                              <1> 
  2268                              <1> 	;LOOP	P50			; DO IT ONCE MORE UNTIL (CX) = ZERO
  2269 00001D22 6649                <1> 	dec	cx
  2270 00001D24 7587                <1> 	jnz	short P50next
  2271                              <1> 
  2272 00001D26 665A                <1> 	POP	DX  ; *****		; RESTORE OLD CURSOR COORDINATES
  2273                              <1> 	
  2274 00001D28 F605[302D0100]01    <1> 	test	byte [w_str_cmd], 1	; IF CURSOR WAS NOT TO BE MOVED
  2275 00001D2F 0F85CBF6FFFF        <1> 	JNZ	VIDEO_RETURN		; THEN EXIT WITHOUT RESETTING OLD VALUE
  2276                              <1> 	
  2277                              <1> 	;MOV	AX,0200H		; ELSE RESTORE OLD CURSOR POSITION
  2278                              <1> 	;INT	10H
  2279                              <1> 					; DONE - EXIT WRITE STRING
  2280 00001D35 E878FEFFFF          <1> 	call	_set_cpos
  2281 00001D3A E9C1F6FFFF          <1> 	JMP	VIDEO_RETURN		; RETURN TO CALLER
  2282                              <1> 
  2283                              <1> 
  2284                              <1> ; 07/07/2016
  2285                              <1> ; 27/06/2016 - TRDOS 386 (TRDOS v2.0)
  2286                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  2287                              <1> ;------------------------------------------------------
  2288                              <1> ;  SCROLL UP
  2289                              <1> ;   THIS ROUTINE SCROLLS UP THE INFORMATION ON THE CRT
  2290                              <1> ; ENTRY ---
  2291                              <1> ;  CH,CL = UPPER LEFT CORNER OF REGION TO SCROLL
  2292                              <1> ;  DH,DL = LOWER RIGHT CORNER OF REGION TO SCROLL
  2293                              <1> ;   BOTH OF THE ABOVE ARE IN CHARACTER POSITIONS
  2294                              <1> ;  BH = FILL VALUE FOR BLANKED LINES
  2295                              <1> ;  AL = # LINES TO SCROLL (AL=0 MEANS BLANK THE ENTIRE FIELD)
  2296                              <1> ;  DS = DATA SEGMENT
  2297                              <1> ;  ES = REGEN SEGMENT
  2298                              <1> ; EXIT --
  2299                              <1> ;  NOTHING, THE SCREEN IS SCROLLED
  2300                              <1> ;--------------------------------------------------------
  2301                              <1> 
  2302                              <1> 	; cl = upper left column
  2303                              <1> 	; ch = upper left row
  2304                              <1> 	; dl = lower rigth column
  2305                              <1> 	; dh = lower right row
  2306                              <1> 	;
  2307                              <1> 	; al = line count (AL=0 means blank entire fields)
  2308                              <1> 	; bl = fill value for blanked lines	
  2309                              <1> 	; bh = unused
  2310                              <1> 
  2311                              <1> GRAPHICS_UP:
  2312                              <1> 	; 07/07/2016
  2313                              <1> 	;AH = Current video mode, [CRT_MODE]
  2314 00001D3F 80FC07              <1> 	cmp	ah, 7
  2315 00001D42 7766                <1> 	ja	short vga_graphics_up
  2316                              <1> 	;je	n0
  2317                              <1> 
  2318 00001D44 88C7                <1> 	MOV	bh, al			; save line count in BH
  2319 00001D46 6689C8              <1> 	MOV	AX, CX			; GET UPPER LEFT POSITION INTO AX REG
  2320                              <1> 
  2321                              <1> ;-----	USE CHARACTER SUBROUTINE FOR POSITIONING
  2322                              <1> ;-----	ADDRESS RETURNED IS MULTIPLIED BY 2 FROM CORRECT VALUE
  2323                              <1> 
  2324 00001D49 E8C3050000          <1> 	CALL	GRAPH_POSN
  2325 00001D4E 0FB7F8              <1> 	MOVzx	eDI, AX			; SAVE RESULT AS DESTINATION ADDRESS
  2326                              <1> 
  2327                              <1> ;-----	DETERMINE SIZE OF WINDOW
  2328                              <1> 
  2329 00001D51 6629CA              <1> 	SUB	DX, CX
  2330 00001D54 6681C20101          <1>         ADD     DX, 101h                ; ADJUST VALUES
  2331 00001D59 C0E602              <1> 	SAL	DH, 2			; MULTIPLY ROWS BY 4 AT 8 VERT DOTS/CHAR
  2332                              <1> 					; AND EVEN/ODD ROWS
  2333                              <1> ;-----	DETERMINE CRT MODE
  2334                              <1> 
  2335 00001D5C 803D[E6E80000]06    <1> 	CMP	byte [CRT_MODE], 6	; TEST FOR MEDIUM RES
  2336 00001D63 7305                <1>         JNC     short _R7_              ; FIND_SOURCE
  2337                              <1> 
  2338                              <1> ;-----	MEDIUM RES UP
  2339 00001D65 D0E2                <1> 	SAL	DL, 1			; # COLUMNS * 2, SINCE 2 BYTES/CHAR
  2340 00001D67 66D1E7              <1> 	SAL	DI, 1			; OFFSET *2 SINCE 2 BYTES/CHAR
  2341                              <1> 
  2342                              <1> ;-----	DETERMINE THE SOURCE ADDRESS IN THE BUFFER
  2343                              <1> _R7_:                                   ; FIND_SOURCE
  2344 00001D6A 81C700800B00        <1> 	add	edi, 0B8000h
  2345 00001D70 C0E702              <1> 	sal	bh, 2			; multiply number of lines by 4
  2346 00001D73 7431                <1>         JZ      short _R11              ; IF ZERO, THEN BLANK ENTIRE FIELD
  2347 00001D75 B050                <1> 	MOV	AL, 80			; 80 BYTES/ROW
  2348 00001D77 F6E7                <1> 	mul	bh			; determine offset to source
  2349 00001D79 0FB7F0              <1> 	movzx	esi, ax			; offset to source
  2350 00001D7C 01FE                <1> 	add	eSI, eDI		; SET UP SOURCE
  2351 00001D7E 88F4                <1> 	MOV	AH, DH			; NUMBER OF ROWS IN FIELD
  2352 00001D80 28FC                <1> 	sub	ah, bh			; determine number to move
  2353                              <1> 
  2354                              <1> ;-----	LOOP THROUGH, MOVING ONE ROW AT A TIME, BOTH EVEN AND ODD FIELDS
  2355                              <1> _R8:                                    ; ROW_LOOP
  2356 00001D82 E8FC030000          <1>         CALL    _R17                    ; MOVE ONE ROW
  2357 00001D87 6681EEB01F          <1> 	SUB	SI, 2000h-80		; MOVE TO NEXT ROW
  2358 00001D8C 6681EFB01F          <1> 	SUB	DI, 2000h-80
  2359 00001D91 FECC                <1> 	DEC	AH			; NUMBER OF ROWS TO MOVE
  2360 00001D93 75ED                <1>         JNZ     short _R8               ; CONTINUE TILL ALL MOVED
  2361                              <1> 
  2362                              <1> ;-----	FILL IN THE VACATED LINE(S)
  2363                              <1> _R9:                                    ; CLEAR ENTRY
  2364 00001D95 88D8                <1> 	mov	al, bl			; attribute to fill with
  2365                              <1> _R10_:
  2366 00001D97 E803040000          <1>         CALL    _R18                    ; CLEAR THAT ROW
  2367 00001D9C 6681EFB01F          <1> 	SUB	DI, 2000h-80		; POINT TO NEXT LINE
  2368 00001DA1 FECF                <1> 	dec	bh			; number of lines to fill
  2369 00001DA3 75F2                <1>         JNZ     short _R10_             ; CLEAR LOOP
  2370 00001DA5 C3                  <1> 	retn				; EVERYYHING DONE
  2371                              <1> 
  2372                              <1> _R11:                                   ; BLANK_FIELD
  2373 00001DA6 88F7                <1> 	mov	bh, dh			; set blank count to everything in field
  2374 00001DA8 EBEB                <1>         JMP     short _R9               ; CLEAR THE FIELD
  2375                              <1> 
  2376                              <1> vga_graphics_up:
  2377                              <1> 	; 07/07/2016 - TRDOS 386 (TRDOS v2.0)
  2378                              <1> 	;
  2379                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  2380                              <1> 	; vgabios-0.7a (2011)
  2381                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  2382                              <1> 	; 'vgabios.c', 'biosfn_scroll'
  2383                              <1> 	;
  2384                              <1> 
  2385                              <1> 	; cl = upper left column
  2386                              <1> 	; ch = upper left row
  2387                              <1> 	; dl = lower rigth column
  2388                              <1> 	; dh = lower right row
  2389                              <1> 	;
  2390                              <1> 	; al = line count (AL=0 means blank entire fields)
  2391                              <1> 	; (bl = fill value for blanked lines)	
  2392                              <1> 	; bh = unused
  2393                              <1> 	;
  2394                              <1> 	; ah = [CRT_MODE], current video mode	
  2395                              <1> 
  2396 00001DAA BE[02E90000]        <1> 	mov	esi, vga_modes
  2397 00001DAF 89F7                <1> 	mov	edi, esi
  2398 00001DB1 83C710              <1> 	add	edi, vga_mode_count
  2399                              <1> vga_g_up_0:
  2400 00001DB4 AC                  <1> 	lodsb
  2401 00001DB5 38E0                <1> 	cmp	al, ah ; [CRT_MODE]
  2402 00001DB7 7405                <1> 	je	short vga_g_up_1
  2403 00001DB9 39FE                <1> 	cmp	esi, edi
  2404 00001DBB 72F7                <1> 	jb	short vga_g_up_0
  2405 00001DBD C3                  <1> 	retn	; nothing to do
  2406                              <1> vga_g_up_1:
  2407 00001DBE 83C64F              <1> 	add	esi, vga_memmodel - (vga_modes + 1)  
  2408                              <1> 	; [ESI] = VGA memory model number (LINEAR8, PLANAR4, PLANAR1)
  2409                              <1> 	
  2410                              <1> 	; if(rlr>=nbrows)rlr=nbrows-1;
  2411                              <1>  	; if(clr>=nbcols)clr=nbcols-1;
  2412                              <1>  	; if(nblines>nbrows)nblines=0;
  2413                              <1>  	; cols=clr-cul+1;
  2414                              <1> 
  2415 00001DC1 3A35[EEE80000]      <1> 	cmp	dh, [VGA_ROWS]
  2416 00001DC7 7208                <1> 	jb	short vga_g_up_2
  2417 00001DC9 8A35[EEE80000]      <1> 	mov	dh, [VGA_ROWS]
  2418 00001DCF FECE                <1> 	dec	dh
  2419                              <1> vga_g_up_2:
  2420 00001DD1 3A15[E8E80000]      <1> 	cmp	dl, [CRT_COLS]  ; = [VGA_COLS]
  2421 00001DD7 7208                <1> 	jb	short vga_g_up_3
  2422 00001DD9 8A15[E8E80000]      <1> 	mov	dl, [CRT_COLS]
  2423 00001DDF FECA                <1> 	dec	dl
  2424                              <1> vga_g_up_3:	
  2425 00001DE1 3A05[EEE80000]      <1> 	cmp	al, [VGA_ROWS]
  2426 00001DE7 7602                <1> 	jna	short vga_g_up_4
  2427 00001DE9 28C0                <1> 	sub	al, al ; 0
  2428                              <1> vga_g_up_4:
  2429 00001DEB 88F7                <1> 	mov	bh, dh ; clr
  2430 00001DED 28CF                <1> 	sub	bh, cl ; cul
  2431 00001DEF FEC7                <1> 	inc	bh ; cols = clr-cul+1
  2432                              <1> 
  2433 00001DF1 20C0                <1> 	and	al, al ; nblines = 0
  2434 00001DF3 755E                <1> 	jnz	short vga_g_up_6
  2435 00001DF5 20ED                <1> 	and	ch, ch ; rul = 0
  2436 00001DF7 755A                <1> 	jnz	short vga_g_up_6
  2437 00001DF9 20C9                <1> 	and	cl, cl ; cul = 0
  2438 00001DFB 7556                <1> 	jnz	short vga_g_up_6
  2439                              <1> 
  2440 00001DFD 6650                <1> 	push	ax
  2441 00001DFF A0[EEE80000]        <1> 	mov	al, [VGA_ROWS]
  2442 00001E04 FEC8                <1> 	dec	al  
  2443 00001E06 38C6                <1> 	cmp	dh, al ; rlr = nbrows-1
  2444 00001E08 7547                <1> 	jne	short vga_g_up_5
  2445 00001E0A A0[E8E80000]        <1>         mov     al, [CRT_COLS]  ; = VGA_COLS
  2446 00001E0F FEC8                <1> 	dec	al 
  2447 00001E11 38C2                <1>  	cmp	dl, al ; clr = nbcols-1
  2448 00001E13 753C                <1> 	jne	short vga_g_up_5
  2449 00001E15 6658                <1> 	pop	ax
  2450                              <1> 
  2451 00001E17 66B80502            <1> 	mov	ax, 0205h
  2452 00001E1B 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  2453 00001E1F 66EF                <1> 	out	dx, ax
  2454 00001E21 A0[EEE80000]        <1> 	mov	al, [VGA_ROWS]
  2455 00001E26 8A25[E8E80000]      <1> 	mov	ah, [CRT_COLS] ; = [VGA_COLS]
  2456 00001E2C F6E4                <1> 	mul	ah
  2457 00001E2E 0FB7D0              <1> 	movzx	edx, ax
  2458 00001E31 0FB605[EAE80000]    <1> 	movzx	eax, byte [CHAR_HEIGHT]
  2459 00001E38 F7E2                <1> 	mul	edx
  2460 00001E3A C1E802              <1> 	shr	eax, 2 ; byte count -> dword count	
  2461 00001E3D 89C1                <1> 	mov	ecx, eax
  2462 00001E3F 29C0                <1> 	sub	eax, eax ; 0
  2463 00001E41 BF00000A00          <1> 	mov	edi, 0A0000h
  2464 00001E46 F3AB                <1> 	rep	stosd		
  2465                              <1> 	
  2466 00001E48 B005                <1> 	mov	al, 5
  2467 00001E4A 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  2468 00001E4E 66EF                <1> 	out	dx, ax ; 0005h	
  2469                              <1> 
  2470 00001E50 C3                  <1> 	retn
  2471                              <1> 
  2472                              <1> vga_g_up_5:
  2473 00001E51 6658                <1> 	pop	ax
  2474                              <1> 
  2475                              <1> vga_g_up_6:
  2476                              <1> 	; [ESI] = VGA memory model number for current video mode
  2477                              <1>         ;
  2478                              <1>         ; LINEAR8 equ 5
  2479                              <1>         ; PLANAR4 equ 4
  2480                              <1>         ; PLANAR1 equ 3
  2481                              <1> 
  2482 00001E53 803E04              <1> 	cmp	byte [esi], PLANAR4
  2483 00001E56 7429                <1> 	je	short vga_g_up_planar
  2484 00001E58 803E03              <1> 	cmp	byte [esi], PLANAR1
  2485 00001E5B 7424                <1> 	je	short vga_g_up_planar
  2486                              <1> vga_g_up_linear8:
  2487                              <1> 	; 07/07/2016 (TEMPORARY)
  2488                              <1> 	;
  2489                              <1> 	; cl = upper left column ; cul
  2490                              <1> 	; ch = upper left row ; rul
  2491                              <1> 	; dl = lower rigth column ; clr
  2492                              <1> 	; dh = lower right row ; rlr
  2493                              <1> 
  2494                              <1> vga_g_up_l0:
  2495                              <1>  	;{for(i=rul;i<=rlr;i++)
  2496                              <1>   	; if((i+nblines>rlr)||(nblines==0))
  2497 00001E5D 08C0                <1> 	or	al, al
  2498 00001E5F 7414                <1> 	jz	short vga_g_up_l1
  2499 00001E61 88C4                <1> 	mov	ah, al
  2500 00001E63 00EC                <1> 	add	ah, ch
  2501                              <1> 	;jc	short vga_g_up_l1	
  2502 00001E65 38F4                <1> 	cmp	ah, dh
  2503 00001E67 770C                <1> 	ja	short vga_g_up_l1
  2504                              <1> 	; else
  2505                              <1> 	;  vgamem_copy_pl4(cul,i+nblines,i,cols,nbcols,cheight);
  2506 00001E69 E800010000          <1> 	call	vgamem_copy_l8 
  2507 00001E6E FEC5                <1> 	inc	ch
  2508 00001E70 38F5                <1> 	cmp	ch, dh
  2509 00001E72 76E9                <1> 	jna	short vga_g_up_l0
  2510 00001E74 C3                  <1> 	retn
  2511                              <1> 
  2512                              <1> vga_g_up_l1:
  2513                              <1> 	; vgamem_fill_pl4(cul,i,cols,nbcols,cheight,attr);
  2514 00001E75 E84C010000          <1> 	call	vgamem_fill_l8
  2515 00001E7A FEC5                <1> 	inc	ch
  2516 00001E7C 38F5                <1> 	cmp	ch, dh
  2517 00001E7E 76DD                <1> 	jna	short vga_g_up_l0
  2518 00001E80 C3                  <1> 	retn
  2519                              <1> 		 
  2520                              <1> vga_g_up_planar:
  2521                              <1> 	; cl = upper left column ; cul
  2522                              <1> 	; ch = upper left row ; rul
  2523                              <1> 	; dl = lower rigth column ; clr
  2524                              <1> 	; dh = lower right row ; rlr
  2525                              <1> vga_g_up_pl0:
  2526                              <1>  	;{for(i=rul;i<=rlr;i++)
  2527                              <1>   	; if((i+nblines>rlr)||(nblines==0))
  2528 00001E81 08C0                <1> 	or	al, al
  2529 00001E83 7414                <1> 	jz	short vga_g_up_pl1
  2530 00001E85 88C4                <1> 	mov	ah, al
  2531 00001E87 00EC                <1> 	add	ah, ch
  2532                              <1> 	;jc	short vga_g_up_pl1	
  2533 00001E89 38F4                <1> 	cmp	ah, dh
  2534 00001E8B 770C                <1> 	ja	short vga_g_up_pl1
  2535                              <1> 	; else
  2536                              <1> 	;  vgamem_copy_pl4(cul,i+nblines,i,cols,nbcols,cheight);
  2537 00001E8D E813000000          <1> 	call	vgamem_copy_pl4
  2538 00001E92 FEC5                <1> 	inc	ch 
  2539 00001E94 38F5                <1> 	cmp	ch, dh
  2540 00001E96 76E9                <1> 	jna	short vga_g_up_pl0
  2541 00001E98 C3                  <1> 	retn
  2542                              <1> 
  2543                              <1> vga_g_up_pl1:
  2544                              <1> 	; vgamem_fill_pl4(cul,i,cols,nbcols,cheight,attr);
  2545 00001E99 E877000000          <1> 	call	vgamem_fill_pl4
  2546 00001E9E FEC5                <1> 	inc	ch
  2547 00001EA0 38F5                <1> 	cmp	ch, dh
  2548 00001EA2 76DD                <1> 	jna	short vga_g_up_pl0
  2549 00001EA4 C3                  <1> 	retn
  2550                              <1> 
  2551                              <1> vgamem_copy_pl4:
  2552                              <1> 	; 07/07/2016 - TRDOS 386 (TRDOS v2.0)
  2553                              <1> 	;
  2554                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  2555                              <1> 	; vgabios-0.7a (2011)
  2556                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  2557                              <1> 	; 'vgabios.c', 'vgamem_copy_pl4'
  2558                              <1> 	;
  2559                              <1> 	; vgamem_copy_pl4(xstart,ysrc,ydest,cols,nbcols,cheight)
  2560                              <1> 	; cl = xstart, ah = ysrc (i+nblines), ch = ydest (i),
  2561                              <1> 	; bh = cols, [CRT_COLS] = nbcols, [CHAR_HEIGHT] = cheight
  2562                              <1> 
  2563                              <1> 	; src=ysrc*cheight*nbcols+xstart;
  2564                              <1> 	; dest=ydest*cheight*nbcols+xstart;
  2565                              <1> 
  2566 00001EA5 52                  <1> 	push	edx
  2567 00001EA6 50                  <1> 	push	eax
  2568                              <1> 
  2569                              <1> 	; outw(VGAREG_GRDC_ADDRESS, 0x0105)
  2570 00001EA7 66B80501            <1> 	mov	ax, 0105h
  2571 00001EAB 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  2572 00001EAF 66EF                <1> 	out	dx, ax
  2573                              <1> 
  2574 00001EB1 8A642401            <1>         mov     ah, [esp+1]
  2575 00001EB5 0FB6D4              <1> 	movzx	edx, ah ; ysrc
  2576 00001EB8 0FB605[EAE80000]    <1> 	movzx	eax, byte [CHAR_HEIGHT]
  2577 00001EBF 8A25[E8E80000]      <1> 	mov	ah, [CRT_COLS] ; nbcols
  2578 00001EC5 F6E4                <1> 	mul	ah 
  2579 00001EC7 50                  <1> 	push	eax ; cheight * nbcols
  2580 00001EC8 F7E2                <1> 	mul	edx ; * ysrc
  2581                              <1> 	; eax = ysrc * cheight * nbcols
  2582                              <1> 	; edx = 0
  2583 00001ECA 88CA                <1> 	mov	dl, cl ; edx = xstart	
  2584 00001ECC 01D0                <1>  	add	eax, edx
  2585 00001ECE 89C6                <1> 	mov	esi, eax ; src
  2586 00001ED0 88EA                <1> 	mov	dl, ch ; ydest
  2587 00001ED2 58                  <1> 	pop	eax ; cheight * nbcols
  2588 00001ED3 F7E2                <1> 	mul	edx
  2589                              <1> 	; eax = ydest * cheight * nbcols
  2590 00001ED5 88CA                <1> 	mov	dl, cl ; edx = xstart	
  2591 00001ED7 01D0                <1>  	add	eax, edx
  2592 00001ED9 89C7                <1> 	mov	edi, eax ; dest
  2593                              <1> 	; esi = src
  2594                              <1> 	; edi = dest
  2595                              <1> 	; for(i=0;i<cheight;i++)
  2596                              <1>   	; {
  2597                              <1>    	;  memcpyb(0xa000,dest+i*nbcols,0xa000,src+i*nbcols,cols);
  2598                              <1>   	; }
  2599 00001EDB 51                  <1> 	push	ecx
  2600 00001EDC B900000A00          <1> 	mov	ecx, 0A0000h
  2601 00001EE1 01CE                <1> 	add	esi, ecx
  2602 00001EE3 01CF                <1> 	add	edi, ecx
  2603 00001EE5 8A35[EAE80000]      <1> 	mov	dh, [CHAR_HEIGHT]
  2604 00001EEB 28D2                <1> 	sub	dl, dl ; i
  2605                              <1> vgamem_copy_pl4_0:
  2606 00001EED 56                  <1> 	push	esi
  2607 00001EEE 57                  <1> 	push	edi
  2608 00001EEF 0FB605[E8E80000]    <1> 	movzx	eax, byte [CRT_COLS]
  2609 00001EF6 F6E2                <1> 	mul	dl
  2610                              <1> 	; eax = i * nbcols
  2611 00001EF8 01C7                <1> 	add	edi, eax ; dest+i*nbcols
  2612 00001EFA 01C6                <1> 	add	esi, eax
  2613 00001EFC 0FB6CF              <1> 	movzx	ecx, bh ; cols
  2614 00001EFF F3A4                <1> 	rep	movsb
  2615 00001F01 5F                  <1> 	pop	edi
  2616 00001F02 5E                  <1> 	pop	esi
  2617 00001F03 FECE                <1> 	dec	dh
  2618 00001F05 75E6                <1> 	jnz	short vgamem_copy_pl4_0
  2619                              <1> vgamem_copy_pl4_1:
  2620 00001F07 59                  <1> 	pop	ecx
  2621                              <1> 
  2622                              <1> 	; outw(VGAREG_GRDC_ADDRESS, 0x0005);
  2623 00001F08 66B80500            <1> 	mov	ax, 0005h
  2624 00001F0C 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  2625 00001F10 66EF                <1> 	out	dx, ax
  2626                              <1> 
  2627 00001F12 58                  <1> 	pop	eax
  2628 00001F13 5A                  <1> 	pop	edx
  2629                              <1> 
  2630 00001F14 C3                  <1> 	retn	
  2631                              <1> 
  2632                              <1> vgamem_fill_pl4:
  2633                              <1> 	; 07/07/2016 - TRDOS 386 (TRDOS v2.0)
  2634                              <1> 	;
  2635                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  2636                              <1> 	; vgabios-0.7a (2011)
  2637                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  2638                              <1> 	; 'vgabios.c', 'vgamem_fill_pl4'
  2639                              <1> 	;
  2640                              <1> 	; vgamem_fill_pl4(xstart,ystart,cols,nbcols,cheight,attr)
  2641                              <1> 	; cl = xstart, edi = ch = ystart, bh = cols,
  2642                              <1> 	; [CRT_COLS] = nbcols, [CHAR_HEIGHT] = cheight, attr = 0
  2643                              <1> 
  2644                              <1> 	; dest=ystart*cheight*nbcols+xstart;
  2645 00001F15 52                  <1> 	push	edx
  2646 00001F16 50                  <1> 	push	eax
  2647                              <1> 
  2648                              <1> 	; outw(VGAREG_GRDC_ADDRESS, 0x0205)
  2649 00001F17 66B80502            <1> 	mov	ax, 0205h
  2650 00001F1B 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  2651 00001F1F 66EF                <1> 	out	dx, ax
  2652                              <1> 
  2653 00001F21 0FB605[EAE80000]    <1>         movzx   eax, byte [CHAR_HEIGHT]
  2654 00001F28 F6E5                <1> 	mul	ch
  2655 00001F2A 0FB615[E8E80000]    <1> 	movzx	edx, byte [CRT_COLS] ; = [VGA_COLS]
  2656 00001F31 F7E2                <1> 	mul	edx
  2657                              <1> 	; edx  = 0
  2658 00001F33 88CA                <1> 	mov	dl, cl 
  2659 00001F35 01D0                <1> 	add	eax, edx
  2660 00001F37 89C7                <1> 	mov	edi, eax
  2661                              <1> 	; edi = dest
  2662                              <1> 	; for(i=0;i<cheight;i++)
  2663                              <1>   	; {
  2664                              <1>    	;  memsetb(0xa000,dest+i*nbcols,attr,cols);
  2665                              <1>   	; }
  2666 00001F39 81C700000A00        <1> 	add	edi, 0A0000h
  2667 00001F3F 51                  <1> 	push	ecx
  2668 00001F40 8A35[EAE80000]      <1> 	mov	dh, [CHAR_HEIGHT]
  2669 00001F46 28D2                <1> 	sub	dl, dl ; i
  2670                              <1> vgamem_fill_pl4_0:
  2671 00001F48 57                  <1> 	push	edi
  2672 00001F49 0FB605[E8E80000]    <1> 	movzx	eax, byte [CRT_COLS]
  2673 00001F50 F6E2                <1> 	mul	dl
  2674                              <1> 	; eax = i * nbcols
  2675 00001F52 01C7                <1> 	add	edi, eax ; dest+i*nbcols
  2676 00001F54 28C0                <1> 	sub	al, al ; 0
  2677 00001F56 0FB6CF              <1> 	movzx	ecx, bh ; cols
  2678                              <1>  	; al = 0 = attr
  2679 00001F59 F3AA                <1> 	rep	stosb
  2680 00001F5B 5F                  <1> 	pop	edi
  2681 00001F5C FECE                <1> 	dec	dh
  2682 00001F5E 75E8                <1> 	jnz	short vgamem_fill_pl4_0
  2683                              <1> vgamem_fill_pl4_1:
  2684 00001F60 59                  <1> 	pop	ecx
  2685                              <1> 
  2686                              <1> 	; outw(VGAREG_GRDC_ADDRESS, 0x0005);
  2687 00001F61 66B80500            <1> 	mov	ax, 0005h
  2688 00001F65 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  2689 00001F69 66EF                <1> 	out	dx, ax
  2690                              <1> 
  2691 00001F6B 58                  <1> 	pop	eax
  2692 00001F6C 5A                  <1> 	pop	edx 
  2693                              <1> 	
  2694 00001F6D C3                  <1> 	retn
  2695                              <1> 
  2696                              <1> vgamem_copy_l8:
  2697                              <1> 	; 07/07/2016 - TRDOS 386 (TRDOS v2.0)
  2698                              <1> 	;
  2699                              <1> 	; TEMPORARY
  2700                              <1> 	;
  2701                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  2702                              <1> 	; vgabios-0.7a (2011)
  2703                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  2704                              <1> 	; 'vgabios.c', 'vgamem_copy_pl4'
  2705                              <1> 	;
  2706                              <1> 	; vgamem_copy_pl4(xstart,ysrc,ydest,cols,nbcols,cheight)
  2707                              <1> 	; cl = xstart, ah = ysrc (i+nblines), ch = ydest (i),
  2708                              <1> 	; bh = cols, [CRT_COLS] = nbcols, [CHAR_HEIGHT] = cheight
  2709                              <1> 
  2710                              <1> 	; src=ysrc*cheight*nbcols+xstart;
  2711                              <1> 	; dest=ydest*cheight*nbcols+xstart;
  2712                              <1> 
  2713 00001F6E 52                  <1> 	push	edx
  2714 00001F6F 50                  <1> 	push	eax
  2715                              <1> 
  2716                              <1> 	;; outw(VGAREG_GRDC_ADDRESS, 0x0105)
  2717                              <1> 	;mov	ax, 0105h
  2718                              <1> 	;mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  2719                              <1> 	;out	dx, ax
  2720                              <1> 
  2721                              <1> 	;movzx	ah, [esp+1]
  2722                              <1> 
  2723 00001F70 0FB6D4              <1> 	movzx	edx, ah ; ysrc
  2724 00001F73 0FB605[EAE80000]    <1> 	movzx	eax, byte [CHAR_HEIGHT]
  2725 00001F7A 8A25[E8E80000]      <1> 	mov	ah, [CRT_COLS] ; nbcols
  2726 00001F80 F6E4                <1> 	mul	ah 
  2727 00001F82 50                  <1> 	push	eax ; cheight * nbcols
  2728 00001F83 F7E2                <1> 	mul	edx ; * ysrc
  2729                              <1> 	; eax = ysrc * cheight * nbcols
  2730                              <1> 	; edx = 0
  2731 00001F85 88CA                <1> 	mov	dl, cl ; edx = xstart	
  2732 00001F87 01D0                <1>  	add	eax, edx
  2733 00001F89 89C6                <1> 	mov	esi, eax ; src
  2734 00001F8B 88EA                <1> 	mov	dl, ch ; ydest
  2735 00001F8D 58                  <1> 	pop	eax ; cheight * nbcols
  2736 00001F8E F7E2                <1> 	mul	edx
  2737                              <1> 	; eax = ydest * cheight * nbcols
  2738 00001F90 88CA                <1> 	mov	dl, cl ; edx = xstart	
  2739 00001F92 01D0                <1>  	add	eax, edx
  2740 00001F94 89C7                <1> 	mov	edi, eax ; dest
  2741                              <1> 	; esi = src
  2742                              <1> 	; edi = dest
  2743                              <1> 	; for(i=0;i<cheight;i++)
  2744                              <1>   	; {
  2745                              <1>    	;  memcpyb(0xa000,dest+i*nbcols,0xa000,src+i*nbcols,cols);
  2746                              <1>   	; }
  2747 00001F96 51                  <1> 	push	ecx
  2748 00001F97 B900000A00          <1> 	mov	ecx, 0A0000h
  2749 00001F9C 01CE                <1> 	add	esi, ecx
  2750 00001F9E 01CF                <1> 	add	edi, ecx
  2751 00001FA0 8A35[EAE80000]      <1> 	mov	dh, [CHAR_HEIGHT]
  2752 00001FA6 28D2                <1> 	sub	dl, dl ; i
  2753                              <1> vgamem_copy_l8_0:
  2754 00001FA8 56                  <1> 	push	esi
  2755 00001FA9 57                  <1> 	push	edi
  2756 00001FAA 0FB605[E8E80000]    <1> 	movzx	eax, byte [CRT_COLS]
  2757 00001FB1 F6E2                <1> 	mul	dl
  2758                              <1> 	; eax = i * nbcols
  2759 00001FB3 01C7                <1> 	add	edi, eax ; dest+i*nbcols
  2760 00001FB5 01C6                <1> 	add	esi, eax
  2761 00001FB7 0FB6CF              <1> 	movzx	ecx, bh ; cols
  2762 00001FBA F3A4                <1> 	rep	movsb
  2763 00001FBC 5F                  <1> 	pop	edi
  2764 00001FBD 5E                  <1> 	pop	esi
  2765 00001FBE FECE                <1> 	dec	dh
  2766 00001FC0 75E6                <1> 	jnz	short vgamem_copy_l8_0
  2767                              <1> vgamem_copy_l8_1:
  2768 00001FC2 59                  <1> 	pop	ecx
  2769                              <1> 
  2770                              <1> 	;; outw(VGAREG_GRDC_ADDRESS, 0x0005);
  2771                              <1> 	;mov	ax, 0005h
  2772                              <1> 	;mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  2773                              <1> 	;out	dx, ax
  2774                              <1> 
  2775 00001FC3 58                  <1> 	pop	eax
  2776 00001FC4 5A                  <1> 	pop	edx
  2777                              <1> 
  2778 00001FC5 C3                  <1> 	retn
  2779                              <1> 
  2780                              <1> vgamem_fill_l8:
  2781                              <1> 	; 07/07/2016 - TRDOS 386 (TRDOS v2.0)
  2782                              <1> 	;
  2783                              <1> 	; TEMPORARY
  2784                              <1> 	;
  2785                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  2786                              <1> 	; vgabios-0.7a (2011)
  2787                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  2788                              <1> 	; 'vgabios.c', 'vgamem_fill_pl4'
  2789                              <1> 	;
  2790                              <1> 	; vgamem_fill_pl4(xstart,ystart,cols,nbcols,cheight,attr)
  2791                              <1> 	; cl = xstart, edi = ch = ystart, bh = cols,
  2792                              <1> 	; [CRT_COLS] = nbcols, [CHAR_HEIGHT] = cheight, attr = 0
  2793                              <1> 
  2794                              <1> 	; dest=ystart*cheight*nbcols+xstart;
  2795 00001FC6 52                  <1> 	push	edx
  2796 00001FC7 50                  <1> 	push	eax
  2797                              <1> 
  2798                              <1> 	;; outw(VGAREG_GRDC_ADDRESS, 0x0205)
  2799                              <1> 	;mov	ax, 0205h
  2800                              <1> 	;mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  2801                              <1> 	;out	dx, ax
  2802                              <1> 
  2803 00001FC8 0FB605[EAE80000]    <1>         movzx   eax, byte [CHAR_HEIGHT]
  2804 00001FCF F6E5                <1> 	mul	ch
  2805 00001FD1 0FB615[E8E80000]    <1> 	movzx	edx, byte [CRT_COLS] ; = [VGA_COLS]
  2806 00001FD8 F7E2                <1> 	mul	edx
  2807                              <1> 	; edx  = 0
  2808 00001FDA 88CA                <1> 	mov	dl, cl 
  2809 00001FDC 01D0                <1> 	add	eax, edx
  2810 00001FDE 89C7                <1> 	mov	edi, eax
  2811                              <1> 	; edi = dest
  2812                              <1> 	; for(i=0;i<cheight;i++)
  2813                              <1>   	; {
  2814                              <1>    	;  memsetb(0xa000,dest+i*nbcols,attr,cols);
  2815                              <1>   	; }
  2816 00001FE0 81C700000A00        <1> 	add	edi, 0A0000h
  2817 00001FE6 51                  <1> 	push	ecx
  2818 00001FE7 8A35[EAE80000]      <1> 	mov	dh, [CHAR_HEIGHT]
  2819 00001FED 28D2                <1> 	sub	dl, dl ; i
  2820                              <1> vgamem_fill_l8_0:
  2821 00001FEF 57                  <1> 	push	edi
  2822 00001FF0 0FB605[E8E80000]    <1> 	movzx	eax, byte [CRT_COLS]
  2823 00001FF7 F6E2                <1> 	mul	dl
  2824                              <1> 	; eax = i * nbcols
  2825 00001FF9 01C7                <1> 	add	edi, eax ; dest+i*nbcols
  2826 00001FFB 28C0                <1> 	sub	al, al ; 0
  2827 00001FFD 0FB6CF              <1> 	movzx	ecx, bh ; cols
  2828                              <1>  	; al = 0 = attr
  2829 00002000 F3AA                <1> 	rep	stosb
  2830 00002002 5F                  <1> 	pop	edi
  2831 00002003 FECE                <1> 	dec	dh
  2832 00002005 75E8                <1> 	jnz	short vgamem_fill_l8_0
  2833                              <1> vgamem_fill_l8_1:
  2834 00002007 59                  <1> 	pop	ecx
  2835                              <1> 
  2836                              <1> 	;; outw(VGAREG_GRDC_ADDRESS, 0x0005);
  2837                              <1> 	;mov	ax, 0005h
  2838                              <1> 	;mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  2839                              <1> 	;out	dx, ax
  2840                              <1> 
  2841 00002008 58                  <1> 	pop	eax
  2842 00002009 5A                  <1> 	pop	edx 
  2843                              <1> 
  2844 0000200A C3                  <1> 	retn
  2845                              <1> 
  2846                              <1> vga_graphics_down:
  2847                              <1> 	; 07/07/2016 - TRDOS 386 (TRDOS v2.0)
  2848                              <1> 	;
  2849                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  2850                              <1> 	; vgabios-0.7a (2011)
  2851                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  2852                              <1> 	; 'vgabios.c', 'biosfn_scroll'
  2853                              <1> 	;
  2854                              <1> 
  2855                              <1> 	; cl = upper left column
  2856                              <1> 	; ch = upper left row
  2857                              <1> 	; dl = lower rigth column
  2858                              <1> 	; dh = lower right row
  2859                              <1> 	;
  2860                              <1> 	; al = line count (AL=0 means blank entire fields)
  2861                              <1> 	; (bl = fill value for blanked lines)	
  2862                              <1> 	; bh = unused
  2863                              <1> 	;
  2864                              <1> 	; ah = [CRT_MODE], current video mode	
  2865                              <1> 
  2866 0000200B FC                  <1>         cld     ; !!! Clear direction flag !!! 
  2867                              <1> 
  2868 0000200C BE[02E90000]        <1> 	mov	esi, vga_modes
  2869 00002011 89F7                <1> 	mov	edi, esi
  2870 00002013 83C710              <1> 	add	edi, vga_mode_count
  2871                              <1> vga_g_down_0:
  2872 00002016 AC                  <1> 	lodsb
  2873 00002017 38E0                <1> 	cmp	al, ah ; [CRT_MODE]
  2874 00002019 7405                <1> 	je	short vga_g_down_1
  2875 0000201B 39FE                <1> 	cmp	esi, edi
  2876 0000201D 72F7                <1> 	jb	short vga_g_down_0
  2877 0000201F C3                  <1> 	retn	; nothing to do
  2878                              <1> vga_g_down_1:
  2879 00002020 83C64F              <1> 	add	esi, vga_memmodel - (vga_modes + 1)  
  2880                              <1> 	; [ESI] = VGA memory model number (LINEAR8, PLANAR4, PLANAR1)
  2881                              <1> 	
  2882                              <1> 	; if(rlr>=nbrows)rlr=nbrows-1;
  2883                              <1>  	; if(clr>=nbcols)clr=nbcols-1;
  2884                              <1>  	; if(nblines>nbrows)nblines=0;
  2885                              <1>  	; cols=clr-cul+1;
  2886                              <1> 
  2887 00002023 3A35[EEE80000]      <1> 	cmp	dh, [VGA_ROWS]
  2888 00002029 7208                <1> 	jb	short vga_g_down_2
  2889 0000202B 8A35[EEE80000]      <1> 	mov	dh, [VGA_ROWS]
  2890 00002031 FECE                <1> 	dec	dh
  2891                              <1> vga_g_down_2:
  2892 00002033 3A15[E8E80000]      <1> 	cmp	dl, [CRT_COLS]  ; = [VGA_COLS]
  2893 00002039 7208                <1> 	jb	short vga_g_down_3
  2894 0000203B 8A15[E8E80000]      <1> 	mov	dl, [CRT_COLS]
  2895 00002041 FECA                <1> 	dec	dl
  2896                              <1> vga_g_down_3:	
  2897 00002043 3A05[EEE80000]      <1> 	cmp	al, [VGA_ROWS]
  2898 00002049 7602                <1> 	jna	short vga_g_down_4
  2899 0000204B 28C0                <1> 	sub	al, al ; 0
  2900                              <1> vga_g_down_4:
  2901 0000204D 88F7                <1> 	mov	bh, dh ; clr
  2902 0000204F 28CF                <1> 	sub	bh, cl ; cul
  2903 00002051 FEC7                <1> 	inc	bh ; cols = clr-cul+1
  2904                              <1> 
  2905 00002053 20C0                <1> 	and	al, al ; nblines = 0
  2906 00002055 755E                <1> 	jnz	short vga_g_down_6
  2907 00002057 20ED                <1> 	and	ch, ch ; rul = 0
  2908 00002059 755A                <1> 	jnz	short vga_g_down_6
  2909 0000205B 20C9                <1> 	and	cl, cl ; cul = 0
  2910 0000205D 7556                <1> 	jnz	short vga_g_down_6
  2911                              <1> 
  2912 0000205F 6650                <1> 	push	ax
  2913 00002061 A0[EEE80000]        <1> 	mov	al, [VGA_ROWS]
  2914 00002066 FEC8                <1> 	dec	al  
  2915 00002068 38C6                <1> 	cmp	dh, al ; rlr = nbrows-1
  2916 0000206A 7547                <1> 	jne	short vga_g_down_5
  2917 0000206C A0[E8E80000]        <1>         mov     al, [CRT_COLS]  ; = VGA_COLS
  2918 00002071 FEC8                <1> 	dec	al 
  2919 00002073 38C2                <1>  	cmp	dl, al ; clr = nbcols-1
  2920 00002075 753C                <1> 	jne	short vga_g_down_5
  2921 00002077 6658                <1> 	pop	ax
  2922                              <1> 
  2923 00002079 66B80502            <1> 	mov	ax, 0205h
  2924 0000207D 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  2925 00002081 66EF                <1> 	out	dx, ax
  2926 00002083 A0[EEE80000]        <1> 	mov	al, [VGA_ROWS]
  2927 00002088 8A25[E8E80000]      <1> 	mov	ah, [CRT_COLS] ; = [VGA_COLS]
  2928 0000208E F6E4                <1> 	mul	ah
  2929 00002090 0FB7D0              <1> 	movzx	edx, ax
  2930 00002093 0FB605[EAE80000]    <1> 	movzx	eax, byte [CHAR_HEIGHT]
  2931 0000209A F7E2                <1> 	mul	edx
  2932 0000209C C1E802              <1> 	shr	eax, 2 ; byte count -> dword count	
  2933 0000209F 89C1                <1> 	mov	ecx, eax
  2934 000020A1 29C0                <1> 	sub	eax, eax ; 0
  2935 000020A3 BF00000A00          <1> 	mov	edi, 0A0000h
  2936 000020A8 F3AB                <1> 	rep	stosd		
  2937                              <1> 	
  2938 000020AA B005                <1> 	mov	al, 5
  2939 000020AC 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  2940 000020B0 66EF                <1> 	out	dx, ax ; 0005h	
  2941                              <1> 
  2942 000020B2 C3                  <1> 	retn
  2943                              <1> 
  2944                              <1> vga_g_down_5:
  2945 000020B3 6658                <1> 	pop	ax
  2946                              <1> 
  2947                              <1> vga_g_down_6:
  2948                              <1> 	; [ESI] = VGA memory model number for current video mode
  2949                              <1>         ;
  2950                              <1>         ; LINEAR8 equ 5
  2951                              <1>         ; PLANAR4 equ 4
  2952                              <1>         ; PLANAR1 equ 3
  2953                              <1> 
  2954 000020B5 803E04              <1> 	cmp	byte [esi], PLANAR4
  2955 000020B8 742C                <1> 	je	short vga_g_down_planar
  2956 000020BA 803E03              <1> 	cmp	byte [esi], PLANAR1
  2957 000020BD 7427                <1> 	je	short vga_g_down_planar
  2958                              <1> vga_g_down_linear8:
  2959                              <1> 	; 07/07/2016 (TEMPORARY)
  2960                              <1> 	;
  2961                              <1> 	; cl = upper left column ; cul
  2962                              <1> 	; ch = upper left row ; rul
  2963                              <1> 	; dl = lower rigth column ; clr
  2964                              <1> 	; dh = lower right row ; rlr
  2965                              <1> 
  2966                              <1> vga_g_down_l0:
  2967                              <1> 	;{for(i=rlr;i>=rul;i--)
  2968                              <1>         ; if((i<rul+nblines)||(nblines==0))
  2969 000020BF 08C0                <1> 	or	al, al
  2970 000020C1 741C                <1> 	jz	short vga_g_down_l2
  2971 000020C3 88C4                <1> 	mov	ah, al
  2972 000020C5 00EC                <1> 	add	ah, ch
  2973                              <1> 	;jc	short vga_g_down_l2	
  2974 000020C7 86EE                <1> 	xchg	ch, dh
  2975 000020C9 38E5                <1> 	cmp	ch, ah
  2976 000020CB 7212                <1> 	jb	short vga_g_down_l2
  2977 000020CD 88EC                <1> 	mov	ah, ch
  2978 000020CF 28C4                <1> 	sub	ah, al ; ah = i - nblines
  2979                              <1> 	; else
  2980                              <1> 	; vgamem_copy_pl4(cul,i,i-nblines,cols,nbcols,cheight);
  2981 000020D1 E898FEFFFF          <1> 	call	vgamem_copy_l8
  2982                              <1> vga_g_down_l1:
  2983 000020D6 86F5                <1> 	xchg	dh, ch
  2984 000020D8 FECE                <1> 	dec	dh 
  2985 000020DA 38EE                <1> 	cmp	dh, ch
  2986 000020DC 73E1                <1> 	jnb	short vga_g_down_l0
  2987 000020DE C3                  <1> 	retn
  2988                              <1> 
  2989                              <1> vga_g_down_l2:
  2990                              <1> 	; vgamem_fill_pl4(cul,i,cols,nbcols,cheight,attr);
  2991 000020DF E8E2FEFFFF          <1> 	call	vgamem_fill_l8
  2992 000020E4 EBF0                <1> 	jmp	short vga_g_down_l1
  2993                              <1> 		 
  2994                              <1> vga_g_down_planar:
  2995                              <1> 	; cl = upper left column ; cul
  2996                              <1> 	; ch = upper left row ; rul
  2997                              <1> 	; dl = lower rigth column ; clr
  2998                              <1> 	; dh = lower right row ; rlr
  2999                              <1> vga_g_down_pl0:
  3000                              <1>  	;{for(i=rlr;i>=rul;i--)
  3001                              <1>         ; if((i<rul+nblines)||(nblines==0))
  3002 000020E6 08C0                <1> 	or	al, al
  3003 000020E8 741C                <1> 	jz	short vga_g_down_pl2
  3004 000020EA 88C4                <1> 	mov	ah, al
  3005 000020EC 00EC                <1> 	add	ah, ch
  3006                              <1> 	;jc	short vga_g_down_pl2	
  3007 000020EE 86EE                <1> 	xchg	ch, dh
  3008 000020F0 38E5                <1> 	cmp	ch, ah
  3009 000020F2 7212                <1> 	jb	short vga_g_down_pl2
  3010 000020F4 88EC                <1> 	mov	ah, ch
  3011 000020F6 28C4                <1> 	sub	ah, al ; ah = i - nblines
  3012                              <1> 	; else
  3013                              <1> 	; vgamem_copy_pl4(cul,i,i-nblines,cols,nbcols,cheight);
  3014 000020F8 E8A8FDFFFF          <1> 	call	vgamem_copy_pl4
  3015                              <1> vga_g_down_pl1:
  3016 000020FD 86F5                <1> 	xchg	dh, ch
  3017 000020FF FECE                <1> 	dec	dh 
  3018 00002101 38EE                <1> 	cmp	dh, ch
  3019 00002103 73E1                <1> 	jnb	short vga_g_down_pl0
  3020 00002105 C3                  <1> 	retn
  3021                              <1> 
  3022                              <1> vga_g_down_pl2:
  3023                              <1> 	; vgamem_fill_pl4(cul,i,cols,nbcols,cheight,attr);
  3024 00002106 E80AFEFFFF          <1> 	call	vgamem_fill_pl4
  3025 0000210B EBF0                <1> 	jmp	short vga_g_down_pl1
  3026                              <1> 
  3027                              <1> ; 07/07/2016
  3028                              <1> ; 27/06/2016 - TRDOS 386 (TRDOS v2.0)
  3029                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  3030                              <1> ;------------------------------------------------------
  3031                              <1> ; SCROLL DOWN
  3032                              <1> ;  THIS ROUTINE SCROLLS DOWN THE INFORMATION ON THE CRT
  3033                              <1> ; ENTRY --
  3034                              <1> ;  CH,CL = UPPER LEFT CORNER OF REGION TO SCROLL
  3035                              <1> ;  DH,DL = LOWER RIGHT CORNER OF REGION TO SCROLL
  3036                              <1> ;   BOTH OF THE ABOVE ARE IN CHARACTER POSITIONS
  3037                              <1> ;  BH = FILL VALUE FOR BLANKED LINES
  3038                              <1> ;  AL = # LINES TO SCROLL (AL=0 MEANS BLANK THE ENTIRE FIELD)
  3039                              <1> ;  DS = DATA SEGMENT
  3040                              <1> ;  ES = REGEN SEGMENT
  3041                              <1> ; EXIT --
  3042                              <1> ;  NOTHING, THE SCREEN IS SCROLLED
  3043                              <1> ;--------------------------------------------------------
  3044                              <1> 
  3045                              <1> 	; cl = upper left column
  3046                              <1> 	; ch = upper left row
  3047                              <1> 	; dl = lower rigth column
  3048                              <1> 	; dh = lower right row
  3049                              <1> 	;
  3050                              <1> 	; al = line count (AL=0 means blank entire fields)
  3051                              <1> 	; bl = fill value for blanked lines	
  3052                              <1> 	; bh = unused
  3053                              <1> 
  3054                              <1> GRAPHICS_DOWN:
  3055                              <1> 	; 07/07/2016
  3056                              <1> 	;AH = Current video mode, [CRT_MODE]
  3057                              <1> 	;STD				; SET DIRECTION
  3058 0000210D 80FC07              <1> 	cmp	ah, 7
  3059 00002110 0F87F5FEFFFF        <1>         ja      vga_graphics_down
  3060                              <1> 	;je	_n0
  3061                              <1> 
  3062 00002116 88C7                <1> 	MOV	bh, al			; save line count in BH
  3063 00002118 6689D0              <1> 	MOV	AX, DX			; GET LOWER RIGHT POSITION INTO AX REG
  3064                              <1> 
  3065                              <1> ;-----	USE CHARACTER SUBROUTINE FOR POSITIONING
  3066                              <1> ;-----	ADDRESS RETURNED IS MULTIPLIED BY 2 FROM CORRECT VALUE
  3067                              <1> 
  3068 0000211B E8F1010000          <1> 	CALL	GRAPH_POSN
  3069 00002120 0FB7F8              <1> 	MOVzx	eDI, AX			; SAVE RESULT AS DESTINATION ADDRESS
  3070                              <1> 
  3071                              <1> ;-----	DETERMINE SIZE OF WINDOW
  3072                              <1> 
  3073 00002123 6629CA              <1> 	SUB	DX, CX
  3074 00002126 6681C20101          <1>         ADD     DX, 101h                ; ADJUST VALUES
  3075 0000212B C0E602              <1> 	SAL	DH, 2			; MULTIPLY ROWS BY 4 AT 8 VERT DOTS/CHAR
  3076                              <1> 					; AND EVEN/ODD ROWS
  3077                              <1> 
  3078                              <1> ;-----	DETERMINE CRT MODE
  3079                              <1> 
  3080 0000212E 803D[E6E80000]06    <1> 	CMP	byte [CRT_MODE], 6	; TEST FOR MEDIUM RES
  3081 00002135 7307                <1>         JNC     short _R12              ; FIND_SOURCE_DOWN
  3082                              <1> 
  3083                              <1> ;-----	MEDIUM RES DOWN
  3084 00002137 D0E2                <1> 	SAL	DL, 1			; # COLUMNS * 2, SINCE 2 BYTES/CHAR
  3085 00002139 66D1E7              <1> 	SAL	DI, 1			; OFFSET *2 SINCE 2 BYTES/CHAR
  3086 0000213C 6647                <1> 	INC	DI			; POINT TO LAST BYTE
  3087                              <1> 
  3088                              <1> ;-----	DETERMINE THE SOURCE ADDRESS IN THE BUFFER
  3089                              <1> 
  3090                              <1> _R12:                                   ; FIND_SOURCE_DOWN
  3091 0000213E 81C700800B00        <1> 	add	edi, 0B8000h		
  3092 00002144 6681C7F000          <1> 	ADD	DI, 240			; POINT TO LAST ROW OF PIXELS
  3093 00002149 C0E702              <1> 	sal	bh, 2			; multiply number of lines by 4
  3094 0000214C 74(06)              <1> 	JZ	short 6			; IF ZERO, THEN BLANK ENTIRE FIELD
  3095 0000214E B050                <1> 	MOV	AL, 80			; 80 BYTES/ROW
  3096 00002150 F6E7                <1> 	mul	bh			; determine offset to source
  3097 00002152 89FE                <1> 	MOV	eSI, eDI		; SET UP SOURCE
  3098 00002154 6629C6              <1> 	SUB	SI, AX			; SUBTRACT THE OFFSET
  3099 00002157 88F4                <1> 	MOV	AH, DH			; NUMBER OF ROWS IN FIELD
  3100 00002159 28FC                <1> 	sub	ah, bh			; determine number to move
  3101                              <1> 
  3102                              <1> ;-----	LOOP THROUGH, MOVING ONE ROW AT A TIME, BOTH EVEN AND ODD FIELDS
  3103                              <1> 
  3104                              <1> _R13:                                   ; ROW_LOOP_DOWN
  3105 0000215B E823000000          <1>         CALL    _R17                    ; MOVE ONE ROW
  3106 00002160 6681EE5020          <1> 	SUB	SI, 2000h+80		; MOVE TO NEXT ROW
  3107 00002165 6681EF5020          <1> 	SUB	DI, 2000h+80
  3108 0000216A FECC                <1> 	DEC	AH			; NUMBER OF ROWS TO MOVE
  3109 0000216C 75ED                <1>         JNZ     short _R13              ; CONTINUE TILL ALL MOVED
  3110                              <1> 
  3111                              <1> ;-----	FILL IN THE VACATED LINE(S)
  3112                              <1> _R14:                                   ; CLEAR_ENTRY_DOWN
  3113 0000216E 88D8                <1> 	mov	al, bl			; attribute to fill with
  3114                              <1> _R15_:                                  ; CLEAR_LOOP_DOWN
  3115 00002170 E82A000000          <1> 	CALL	_R18			; CLEAR A ROW
  3116 00002175 6681EF5020          <1> 	SUB	DI, 2000h+80		; POINT TO NEXT LINE
  3117 0000217A FECF                <1> 	dec	bh			; number of lines to fill
  3118 0000217C 75F2                <1>         JNZ     short _R15_             ; CLEAR_LOOP_DOWN
  3119                              <1> 
  3120 0000217E C3                  <1> 	retn				; EVERYYHING DONE
  3121                              <1> 
  3122                              <1> _R16:                                   ; BLANK_FIELD_DOWN
  3123 0000217F 88F7                <1> 	mov	bh, dh			; set blank count to everything in field
  3124 00002181 EBEB                <1>         JMP     short _R14              ; CLEAR THE FIELD
  3125                              <1> 
  3126                              <1> ; 27/06/2016 - TRDOS 386 (TRDOS v2.0)
  3127                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  3128                              <1> 
  3129                              <1> ;-----	ROUTINE TO MOVE ONE ROW OF INFORMATION
  3130                              <1> 
  3131                              <1> _R17:
  3132 00002183 0FB6CA              <1> 	MOVzx	ecx, DL			; NUMBER OF BYTES IN THE ROW
  3133 00002186 56                  <1> 	PUSH	eSI
  3134 00002187 57                  <1> 	PUSH	eDI			; SAVE POINTERS
  3135 00002188 F3A4                <1> 	REP	MOVSB			; MOVE THE EVEN FIELD
  3136 0000218A 5F                  <1> 	POP	eDI
  3137 0000218B 5E                  <1> 	POP	eSI
  3138 0000218C 6681C60020          <1> 	ADD	SI, 2000h
  3139 00002191 6681C70020          <1> 	ADD	DI, 2000h		; POINT TO THE ODD FIELD
  3140 00002196 56                  <1> 	PUSH	eSI
  3141 00002197 57                  <1> 	PUSH	eDI			; SAVE THE POINTERS
  3142 00002198 88D1                <1> 	MOV	CL, DL			; COUNT BACK
  3143 0000219A F3A4                <1> 	REP	MOVSB			; MOVE THE ODD FIELD
  3144 0000219C 5F                  <1> 	POP	eDI
  3145 0000219D 5E                  <1> 	POP	eSI			; POINTERS BACK
  3146 0000219E C3                  <1> 	RETn				; RETURN TO CALLER
  3147                              <1> 
  3148                              <1> ;-----	CLEAR A SINGLE ROW
  3149                              <1> 
  3150                              <1> _R18:
  3151 0000219F 0FB6CA              <1> 	MOVzx	ecx, DL			; NUMBER OF BYTES IN FIELD
  3152 000021A2 57                  <1> 	PUSH	eDI			; SAVE POINTER
  3153 000021A3 F3AA                <1> 	REP	STOSB			; STORE THE NEW VALUE
  3154 000021A5 5F                  <1> 	POP	eDI			; POINTER BACK
  3155 000021A6 6681C70020          <1> 	ADD	DI, 2000h		; POINT TO ODD FIELD
  3156 000021AB 57                  <1> 	PUSH	eDI
  3157 000021AC 88D1                <1> 	MOV	CL, DL
  3158 000021AE F3AA                <1> 	REP	STOSB			; FILL THE ODD FIELD
  3159 000021B0 5F                  <1> 	POP	eDI
  3160 000021B1 C3                  <1> 	RETn				; RETURN TO CALLER
  3161                              <1> 
  3162                              <1> ; 04/07/2016
  3163                              <1> ; 01/07/2016
  3164                              <1> ; 30/06/2016 - TRDOS 386 (TRDOS v2.0)
  3165                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  3166                              <1> ;--------------------------------------------------
  3167                              <1> ; GRAPHICS WRITE
  3168                              <1> ;  THIS ROUTINE WRITES THE ASCII CHARACTER TO THE CURRENT
  3169                              <1> ;  POSITION ON THE SCREEN.
  3170                              <1> ; ENTRY --
  3171                              <1> ;  AL = CHARACTER TO WRITE
  3172                              <1> ;  BL = COLOR ATTRIBUTE TO BE USED FOR FOREGROUND COLOR
  3173                              <1> ;	IF BIT 7 IS SET, THE CHAR IS XOR'D INTO THE REGEN BUFFER
  3174                              <1> ;	(0 IS USED FOR THE BACKGROUND COLOR)
  3175                              <1> ;  CX = NUMBER OF CHARS TO WRITE
  3176                              <1> ;  DS = DATA SEGMENT
  3177                              <1> ;  ES = REGEN SEGMENT
  3178                              <1> ; EXIT --
  3179                              <1> ;  NOTHING IS RETURNED
  3180                              <1> ;
  3181                              <1> ; GRAPHICS READ
  3182                              <1> ;  THIS ROUTINE READS THE ASCII CHARACTER AT THE CURRENT CURSOR
  3183                              <1> ;  POSITION ON THE SCREEN BY MATCHING THE DOTS ON THE SCREEN TO THE
  3184                              <1> ;  CHARACTER GENERATOR CODE POINTS
  3185                              <1> ; ENTRY --
  3186                              <1> ;  NONE (0 IS ASSUMED AS THE BACKGROUND COLOR)
  3187                              <1> ; EXIT --
  3188                              <1> ;  AL = CHARACTER READ AT THAT POSITION (0 RETURNED IF NONE FOUND)
  3189                              <1> ;
  3190                              <1> ; FOR BOTH ROUTINES, THE IMAGES USED TO FORM CHARS ARE CONTAINED IN ROM
  3191                              <1> ;  FOR THE 1ST 128 CHARS.  TO ACCESS CHARS IN THE SECOND HALF, THE USER
  3192                              <1> ;  MUST INITIALIZE THE VECTOR AT INTERRUPT 1FH (LOCATION 0007CH) TO
  3193                              <1> ;  POINT TO THE USER SUPPLIED TABLE OF GRAPHIC IMAGES (8X8 BOXES).
  3194                              <1> ;  FAILURE TO DO SO WILL CAUSE IN STRANGE RESULTS
  3195                              <1> ;-----------------------------------------------------
  3196                              <1> 
  3197                              <1> GRAPHICS_WRITE:
  3198 000021B2 25FF000000          <1> 	and 	eax, 0FFh		; ZERO TO HIGH OF CODE POINT
  3199 000021B7 50                  <1> 	PUSH	eAX			; SAVE CODE POINT VALUE
  3200                              <1> 
  3201                              <1> ;-----	DETERMINE POSITION IN REGEN BUFFER TO PUT CODE POINTS
  3202                              <1> 
  3203 000021B8 E84D010000          <1> 	CALL	S26			; FIND LOCATION IN REGEN BUFFER
  3204 000021BD 89C7                <1> 	MOV	eDI, eAX		; REGEN POINTER IN DI
  3205                              <1> 
  3206                              <1> ;-----	DETERMINE REGION TO GET CODE POINTS FROM
  3207                              <1> 
  3208 000021BF 58                  <1> 	POP	eAX			; RECOVER CODE POINT
  3209                              <1> 
  3210 000021C0 BE[40F40000]        <1> 	MOV	eSI, CRT_CHAR_GEN	; OFFSET OF IMAGES
  3211                              <1> 
  3212                              <1> ;-----	DETERMINE GRAPHICS MODE IN OPERATION
  3213                              <1> 					; DETERMINE_MODE
  3214 000021C5 66C1E003            <1> 	SAL	AX, 3			; MULTIPLY CODE POINT VALUE BY 8
  3215 000021C9 01C6                <1> 	ADD	eSI, eAX		; SI HAS OFFSET OF DESIRED CODES
  3216                              <1> 	
  3217 000021CB 803D[E6E80000]06    <1> 	CMP	byte [CRT_MODE], 6
  3218 000021D2 7231                <1> 	JC	short S6		; TEST FOR MEDIUM RESOLUTION MODE
  3219                              <1> 
  3220                              <1> ;-----	HIGH RESOLUTION MODE
  3221                              <1> 
  3222 000021D4 81C700800B00        <1> 	add	edi, 0B8000h
  3223                              <1> S1:					; HIGH_CHAR
  3224 000021DA 57                  <1> 	PUSH	eDI			; SAVE REGEN POINTER
  3225 000021DB 56                  <1> 	PUSH	eSI			; SAVE CODE POINTER
  3226 000021DC B604                <1> 	MOV	DH, 4			; NUMBER OF TIMES THROUGH LOOP
  3227                              <1> S2:
  3228 000021DE AC                  <1> 	LODSB				; GET BYTE FROM CODE POINTS
  3229 000021DF F6C380              <1> 	TEST	BL, 80H			; SHOULD WE USE THE FUNCTION
  3230 000021E2 7515                <1> 	JNZ	short S5		; TO PUT CHAR IN
  3231 000021E4 AA                  <1> 	STOSB				; STORE IN REGEN BUFFER
  3232 000021E5 AC                  <1> 	LODSB
  3233                              <1> S4:
  3234 000021E6 8887FF1F0000        <1> 	MOV	[eDI+2000H-1], AL ; STORE IN SECOND HALF
  3235 000021EC 83C74F              <1> 	ADD	eDI, 79			; MOVE TO NEXT ROW IN REGEN
  3236 000021EF FECE                <1> 	DEC	DH			; DONE WITH LOOP
  3237 000021F1 75EB                <1> 	JNZ	short S2
  3238 000021F3 5E                  <1> 	POP	eSI
  3239 000021F4 5F                  <1> 	POP	eDI			; RECOVER REGEN POINTER
  3240 000021F5 47                  <1> 	INC	eDI			; POINT TO NEXT CHAR POSITION
  3241 000021F6 E2E2                <1> 	LOOP	S1			; MORE CHARS TO WRITE
  3242 000021F8 C3                  <1> 	retn
  3243                              <1> 
  3244                              <1> S5:
  3245 000021F9 3207                <1> 	XOR	AL, [eDI]		; EXCLUSIVE OR WITH CURRENT
  3246 000021FB AA                  <1> 	STOSB				; STORE THE CODE POINT
  3247 000021FC AC                  <1> 	LODSB				; AGAIN FOR ODD FIELD
  3248 000021FD 3287FF1F0000        <1> 	XOR	AL, [eDI+2000H-1]
  3249 00002203 EBE1                <1> 	JMP	short S4		; BACK TO MAINSTREAM
  3250                              <1> 
  3251                              <1> ;-----	MEDIUM RESOLUTION WRITE
  3252                              <1> S6:					; MED_RES_WRITE
  3253 00002205 88DA                <1> 	MOV	DL, BL			; SAVE HIGH COLOR BIT
  3254 00002207 66D1E7              <1> 	SAL	DI, 1			; OFFSET*2 SINCE 2 BYTES/CHAR
  3255                              <1> 					; EXPAND BL TO FULL WORD OF COLOR
  3256 0000220A 80E303              <1> 	AND	BL, 3			; ISOLATE THE COLOR BITS ( LOW 2 BITS )
  3257 0000220D B055                <1> 	MOV	AL, 055H 		; GET BIT CONVERSION MULTIPLIER
  3258 0000220F F6E3                <1> 	MUL	BL			; EXPAND 2 COLOR BITS TO 4 REPLICATIONS
  3259 00002211 88C3                <1> 	MOV	BL, AL			; PLACE BACK IN WORK REGISTER
  3260 00002213 88C7                <1> 	MOV	BH, AL			; EXPAND TO 8 REPLICATIONS OF COLOR BITS
  3261 00002215 81C700800B00        <1> 	add	edi, 0B8000h
  3262                              <1> S7:                                     ; MED_CHAR
  3263 0000221B 57                  <1> 	PUSH	eDI			; SAVE REGEN POINTER
  3264 0000221C 56                  <1> 	PUSH	eSI			; SAVE THE CODE POINTER
  3265 0000221D B604                <1> 	MOV	DH, 4			; NUMBER OF LOOPS
  3266                              <1> S8:
  3267 0000221F AC                  <1> 	LODSB				; GET CODE POINT
  3268 00002220 E8B3000000          <1> 	CALL	S21			; DOUBLE UP ALL THE BITS
  3269 00002225 6621D8              <1> 	AND	AX, BX			; CONVERT TO FOREGROUND COLOR ( 0 BACK )
  3270 00002228 86E0                <1> 	XCHG	AH, AL			; SWAP HIGH/LOW BYTES FOR WORD MOVE
  3271 0000222A F6C280              <1> 	TEST	DL, 80H			; IS THIS XOR FUNCTION
  3272 0000222D 7403                <1> 	JZ	short S9		; NO, STORE IT IN AS IS
  3273 0000222F 663307              <1> 	XOR	AX, [eDI]		; DO FUNCTION WITH LOW/HIGH
  3274                              <1> S9:
  3275 00002232 668907              <1> 	MOV	[eDI], AX		; STORE FIRST BYTE HIGH, SECOND LOW
  3276 00002235 AC                  <1> 	LODSB				; GET CODE POINT
  3277 00002236 E89D000000          <1> 	CALL	S21
  3278 0000223B 6621D8              <1> 	AND	AX, BX			; CONVERT TO COLOR
  3279 0000223E 86E0                <1> 	XCHG	AH, AL			; SWAP HIGH/LOW BYTES FOR WORD MOVE
  3280 00002240 F6C280              <1> 	TEST	DL, 80H			; AGAIN, IS THIS XOR FUNCTION
  3281 00002243 7407                <1> 	JZ	short _S10		; NO, JUST STORE THE VALUES
  3282 00002245 66338700200000      <1> 	XOR	AX, [eDI+2000H]		; FUNCTION WITH FIRST HALF LOW
  3283                              <1> _S10:
  3284 0000224C 66898700200000      <1> 	MOV	[eDI+2000H], AX		; STORE SECOND PORTION HIGH
  3285 00002253 6683C750            <1> 	ADD	DI, 80			; POINT TO NEXT LOCATION
  3286 00002257 FECE                <1> 	DEC	DH
  3287 00002259 75C4                <1> 	JNZ	short S8		; KEEP GOING
  3288 0000225B 5E                  <1> 	POP	eSI			; RECOVER CODE POINTER
  3289 0000225C 5F                  <1> 	POP	eDI			; RECOVER REGEN POINTER
  3290 0000225D 47                  <1> 	INC	eDI			; POINT TO NEXT CHAR POSITION
  3291 0000225E 47                  <1> 	INC	eDI
  3292 0000225F E2BA                <1> 	LOOP	S7			; MORE TO WRITE
  3293 00002261 C3                  <1> 	retn
  3294                              <1> 
  3295                              <1> ; 04/07/2016
  3296                              <1> ; 01/07/2016
  3297                              <1> ; 30/06/2016 - TRDOS 386 (TRDOS v2.0)
  3298                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  3299                              <1> ;----------------------------------------
  3300                              <1> ; GRAPHICS READ
  3301                              <1> ;----------------------------------------
  3302                              <1> GRAPHICS_READ:
  3303 00002262 E8A3000000          <1> 	CALL	S26			; CONVERTED TO OFFSET IN REGEN
  3304 00002267 89C6                <1> 	MOV	eSI, eAX		; SAVE IN SI
  3305 00002269 81C600800B00        <1> 	add	esi, 0B8000h		; 01/07/2016
  3306 0000226F 83EC08              <1> 	SUB	eSP, 8			; ALLOCATE SPACE FOR THE READ CODE POINT
  3307 00002272 89E5                <1> 	MOV	eBP, eSP		; POINTER TO SAVE AREA
  3308                              <1> 
  3309                              <1> ;-----	DETERMINE GRAPHICS MODES
  3310 00002274 B604                <1> 	mov	dh, 4			; number of passes ; 01/07/2016
  3311 00002276 803D[E6E80000]06    <1> 	CMP	byte [CRT_MODE], 6
  3312 0000227D 7219                <1> 	JC	short S12		; MEDIUM RESOLUTION
  3313                              <1> 
  3314                              <1> ;-----	HIGH RESOLUTION READ
  3315                              <1> ;-----	GET VALUES FROM REGEN BUFFER AND CONVERT TO CODE POINT
  3316                              <1> 	;MOV	DH,4			; NUMBER OF PASSES
  3317                              <1> S11:
  3318 0000227F 8A06                <1> 	MOV	AL, [eSI] 		; GET FIRST BYTE
  3319 00002281 884500              <1> 	MOV	[eBP], AL 		; SAVE IN STORAGE AREA
  3320 00002284 45                  <1> 	INC	eBP			; NEXT LOCATION
  3321 00002285 8A8600200000        <1> 	MOV	AL, [eSI+2000H]		; GET LOWER REGION BYTE
  3322 0000228B 884500              <1> 	MOV	[eBP], AL 		; ADJUST AND STORE
  3323 0000228E 45                  <1> 	INC	eBP
  3324 0000228F 83C650              <1> 	ADD	eSI, 80			; POINTER INTO REGEN
  3325 00002292 FECE                <1> 	DEC	DH			; LOOP CONTROL
  3326 00002294 75E9                <1> 	JNZ	short S11		; DO IT SOME MORE
  3327 00002296 EB1D                <1> 	JMP	SHORT S14		; GO MATCH THE SAVED CODE POINTS
  3328                              <1> 
  3329                              <1> ;-----	MEDIUM RESOLUTION READ
  3330                              <1> S12:	
  3331 00002298 66D1E6              <1> 	SAL	SI, 1			; OFFSET*2 SINCE 2 BYTES/CHAR
  3332                              <1> 	;MOV	DH, 4			; NUMBER OF PASSES
  3333                              <1> S13:
  3334 0000229B E84D000000          <1> 	CALL	S23			; GET BYTES FROM REGEN INTO SINGLE SAVE
  3335 000022A0 81C6FE1F0000        <1> 	ADD	eSI, 2000H-2		; GO TO LOWER REGION
  3336 000022A6 E842000000          <1> 	CALL	S23			; GET THIS PAIR INTO SAVE
  3337 000022AB 81EEB21F0000        <1> 	SUB	eSI, 2000H-80+2		; ADJUST POINTER BACK INTO UPPER
  3338 000022B1 FECE                <1> 	DEC	DH
  3339 000022B3 75E6                <1> 	JNZ	short S13		; KEEP GOING UNTIL ALL 8 DONE
  3340                              <1> 
  3341                              <1> ;-----	SAVE AREA HAS CHARACTER IN IT, MATCH IT
  3342                              <1> S14:					; FIND_CHAR
  3343 000022B5 BF[40F40000]        <1> 	MOV	eDI, CRT_CHAR_GEN	; ESTABLISH ADDRESSING
  3344 000022BA 83ED08              <1> 	SUB	eBP, 8			; ADJUST POINTER TO START OF SAVE AREA
  3345 000022BD 89EE                <1> 	MOV	eSI, eBP
  3346                              <1> S15:
  3347 000022BF 66B80001            <1> 	mov	ax, 256			; NUMBER TO TEST AGAINST
  3348                              <1> S16:
  3349 000022C3 56                  <1> 	PUSH	eSI			; SAVE SAVE AREA POINTER
  3350 000022C4 57                  <1> 	PUSH	eDI			; SAVE CODE POINTER
  3351                              <1> 	;MOV	eCX, 4			; NUMBER OF WORDS TO MATCH
  3352                              <1> 	;REPE	CMPSW			; COMPARE THE 8 BYTES AS WORDS
  3353 000022C5 A7                  <1> 	cmpsd				; compare first 4 bytes 
  3354 000022C6 7501                <1> 	jne	short S17		; 
  3355 000022C8 A7                  <1> 	cmpsd				; compare last 4 bytes
  3356                              <1> S17:
  3357 000022C9 5F                  <1> 	POP	eDI			; RECOVER THE POINTERS
  3358 000022CA 5E                  <1> 	POP	eSI
  3359                              <1> 	;JZ	short S18		; IF ZERO FLAG SET, THEN MATCH OCCURRED
  3360 000022CB 7407                <1> 	je	short S18
  3361                              <1> 	;				; NO MATCH, MOVE ON TO NEXT
  3362 000022CD 83C708              <1> 	ADD	eDI, 8			; NEXT CODE POINT
  3363 000022D0 6648                <1> 	dec	ax			; LOOP CONTROL
  3364 000022D2 75EF                <1> 	JNZ	short S16		; DO ALL OF THEM
  3365                              <1> 
  3366                              <1> ;-----	CHARACTER IS FOUND ( AL=0 IF NOT FOUND )
  3367                              <1> S18:	
  3368 000022D4 83C408              <1> 	ADD	eSP, 8			; READJUST THE STACK, THROW AWAY SAVE
  3369 000022D7 C3                  <1> 	retn				; ALL DONE
  3370                              <1> 
  3371                              <1> ; 30/06/2016 - TRDOS 386 (TRDOS v2.0)
  3372                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  3373                              <1> ;--------------------------------------------
  3374                              <1> ; EXPAND BYTE
  3375                              <1> ;  THIS ROUTINE TAKES THE BYTE IN AL AND DOUBLES ALL
  3376                              <1> ;  OF THE BITS, TURNING THE 8 BITS INTO 16 BITS.
  3377                              <1> ;  THE RESULT IS LEFT IN AX
  3378                              <1> ;--------------------------------------------
  3379                              <1> S21:
  3380 000022D8 6651                <1> 	PUSH	CX			; SAVE REGISTER
  3381                              <1> 	;MOV	CX, 8			; SHIFT COUNT REGISTER FOR ONE BYTE
  3382 000022DA B108                <1> 	mov	cl, 8
  3383                              <1> S22:
  3384 000022DC D0C8                <1> 	ROR	AL,1			; SHIFT BITS, LOW BIT INTO CARRY FLAG
  3385 000022DE 66D1DD              <1> 	RCR	BP,1			; MOVE CARRY FLAG (LOW BIT INTO RESULTS
  3386 000022E1 66D1FD              <1> 	SAR	BP,1			; SIGN EXTEND HIGH BIT (DOUBLE IT)
  3387                              <1> 	;LOOP	S22			; REPEAT FOR ALL 8 BITS
  3388 000022E4 FEC9                <1> 	dec	cl
  3389 000022E6 75F4                <1> 	jnz	short S22
  3390 000022E8 6695                <1> 	XCHG	AX, BP			; MOVE RESULTS TO PARAMETER REGISTER
  3391 000022EA 6659                <1> 	POP	CX			; RECOVER REGISTER
  3392 000022EC C3                  <1> 	RETn				; ALL DONE
  3393                              <1> 
  3394                              <1> ; 01/07/2016 - TRDOS 386 (TRDOS v2.0)
  3395                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  3396                              <1> ;--------------------------------------------------
  3397                              <1> ; MED_READ_BYTE
  3398                              <1> ; THIS ROUTINE WILL TAKE 2 BYTES FROM THE REGEN BUFFER,
  3399                              <1> ;  COMPARE AGAINST THE CURRENT FOREGROUND COLOR, AND PLACE
  3400                              <1> ;  THE CORRESPONDING ON/OFF BIT PATTERN INTO THE CURRENT
  3401                              <1> ;  POSITION IN THE SAVE AREA
  3402                              <1> ; ENTRY --
  3403                              <1> ;  SI,DS = POINTER TO REGEN AREA OF INTEREST
  3404                              <1> ;  BX = EXPANDED FOREGROUND COLOR
  3405                              <1> ;  BP = POINTER TO SAVE AREA
  3406                              <1> ; EXIT --
  3407                              <1> ;  SI AND BP ARE INCREMENTED
  3408                              <1> ;----------------------------------------------------
  3409                              <1> S23:
  3410 000022ED 66AD                <1> 	LODSW				; GET FIRST BYTE AND SECOND BYTES
  3411 000022EF 86C4                <1> 	XCHG	AL, AH			; SWAP FOR COMPARE
  3412 000022F1 66B900C0            <1> 	MOV	CX, 0C000H		; 2 BIT MASK TO TEST THE ENTRIES
  3413 000022F5 B200                <1> 	MOV	DL, 0			; RESULT REGISTER
  3414                              <1> S24:
  3415 000022F7 6685C8              <1> 	TEST	AX, CX			; IS THIS SECTION BACKCROUND?
  3416 000022FA 7401                <1>         JZ      short S25               ; IF ZERO, IT IS BACKGROUND (CARRY=0)
  3417 000022FC F9                  <1> 	STC				; WASN'T, SO SET CARRY
  3418                              <1> S25:
  3419 000022FD D0D2                <1> 	RCL	DL, 1			; MOVE THAT BIT INTO THE RESULT
  3420 000022FF 66C1E902            <1> 	SHR	CX, 2			; MOVE THE MASK TO THE RIGHT BY 2 BITS
  3421 00002303 73F2                <1> 	JNC	short S24		; DO IT AGAIN IF MASK DIDN'T FALL OUT
  3422 00002305 885500              <1> 	MOV	[eBP], DL 		; STORE RESULT IN SAVE AREA
  3423 00002308 45                  <1> 	INC	eBP			; ADJUST POINTER
  3424 00002309 C3                  <1> 	RETn				; ALL DONE
  3425                              <1> 
  3426                              <1> ; 30/06/2016 - TRDOS 386 (TRDOS v2.0)
  3427                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  3428                              <1> ;-----------------------------------------
  3429                              <1> ; V4_POSITION
  3430                              <1> ;  THIS ROUTINE TAKES THE CURSOR POSITION CONTAINED IN
  3431                              <1> ;  THE MEMORY LOCATION, AND CONVERTS IT INTO AN OFFSET
  3432                              <1> ;  INTO THE REGEN BUFFER, ASSUMING ONE BYTE/CHAR.
  3433                              <1> ;  FOR MEDIUM RESOLUTION GRAPHICS, THE NUMBER MUST
  3434                              <1> ;  BE DOUBLED.
  3435                              <1> ; ENTRY -- NO REGISTERS,MEMORY LOCATION @CURSOR_POSN IS USED
  3436                              <1> ; EXIT--
  3437                              <1> ;  AX CONTAINS OFFSET INTO REGEN BUFFER
  3438                              <1> ;-----------------------------------------
  3439                              <1> S26:
  3440 0000230A 0FB705[C61F0100]    <1> 	movzx	eax, word [CURSOR_POSN]	; GET CURRENT CURSOR
  3441                              <1> GRAPH_POSN:
  3442 00002311 53                  <1> 	PUSH	eBX			; SAVE REGISTER
  3443 00002312 0FB6D8              <1> 	movzx	ebx, al			; SAVE A COPY OF CURRENT CURSOR
  3444 00002315 A0[E8E80000]        <1> 	MOV	AL, [CRT_COLS]		; GET BYTES PER COLUMN
  3445 0000231A F6E4                <1> 	MUL	AH			; MULTIPLY BY ROWS
  3446 0000231C 66C1E002            <1> 	SHL	AX, 2			; MULTIPLY * 4 SINCE 4 ROWS/BYTE
  3447 00002320 01D8                <1> 	ADD	eAX, eBX		; DETERMINE OFFSET
  3448 00002322 5B                  <1> 	POP	eBX			; RECOVER POINTER
  3449 00002323 C3                  <1> 	RETn				; ALL DONE
  3450                              <1> 
  3451                              <1> ; 09/07/2016
  3452                              <1> ; 01/07/2016 - TRDOS 386 (TRDOS v2.0)
  3453                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  3454                              <1> ;---------------------------------------------
  3455                              <1> ; SET_COLOR
  3456                              <1> ;	THIS ROUTINE WILL ESTABLISH THE BACKGROUND COLOR, THE OVERSCAN COLOR,
  3457                              <1> ;	AND THE FOREGROUND COLOR SET FOR MEDIUM RESOLUTION GRAPHICS
  3458                              <1> ; INPUT
  3459                              <1> ;	(BH) HAS COLOR ID
  3460                              <1> ;		IF BH=0, THE BACKGROUND COLOR VALUE IS SET
  3461                              <1> ;			FROM THE LOW BITS OF BL (0-31)
  3462                              <1> ;		IF BH=1, THE PALETTE SELECTION IS MADE
  3463                              <1> ;			BASED ON THE LOW BIT OF BL:
  3464                              <1> ;				0 = GREEN, RED, YELLOW FOR COLORS 1,2,3
  3465                              <1> ;				1 = BLUE, CYAN, MAGENTA FOR COLORS 1,2,3
  3466                              <1> ;	(BL) HAS THE COLOR VALUE TO BE USED
  3467                              <1> ; OUTPUT
  3468                              <1> ;	THE COLOR SELECTION IS UPDATED
  3469                              <1> ;----------------------------------------------
  3470                              <1> SET_COLOR:
  3471 00002324 803D[E6E80000]07    <1>         cmp     byte [CRT_MODE], 7      ; 09/07/2016
  3472 0000232B 0F87CFF0FFFF        <1> 	ja	VIDEO_RETURN		; nothing to do for VGA modes	 
  3473                              <1> 
  3474                              <1> 	;MOV	DX, [ADDR_6845]		; I/O PORT FOR PALETTE
  3475                              <1> 	;mov	dx, 3D4h
  3476                              <1> 	;ADD	DX,5			; OVERSCAN PORT
  3477 00002331 66BAD903            <1> 	mov	dx, 3D9h
  3478 00002335 A0[E9E80000]        <1> 	MOV	AL, [CRT_PALETTE] 	; GET THE CURRENT PALETTE VALUE
  3479 0000233A 08FF                <1> 	OR	BH, BH			; IS THIS COLOR 0?
  3480 0000233C 7512                <1> 	JNZ	short M20		; OUTPUT COLOR 1
  3481                              <1> 
  3482                              <1> ;-----	HANDLE COLOR 0 BY SETTING THE BACKGROUND COLOR
  3483                              <1> 
  3484 0000233E 24E0                <1> 	AND	AL, 0E0H 		; TURN OFF LOW 5 BITS OF CURRENT
  3485 00002340 80E31F              <1> 	AND	BL, 01FH 		; TURN OFF HIGH 3 BITS OF INPUT VALUE
  3486 00002343 08D8                <1> 	OR	AL, BL			; PUT VALUE INTO REGISTER
  3487                              <1> M19:					; OUTPUT THE PALETTE
  3488 00002345 EE                  <1> 	OUT	DX, AL			; OUTPUT COLOR SELECTION TO 3D9 PORT
  3489 00002346 A2[E9E80000]        <1> 	MOV	[CRT_PALETTE], AL 	; SAVE THE COLOR VALUE
  3490 0000234B E9B0F0FFFF          <1> 	JMP	VIDEO_RETURN
  3491                              <1> 
  3492                              <1> ;-----	HANDLE COLOR 1 BY SELECTING THE PALETTE TO BE USED
  3493                              <1> 
  3494                              <1> M20:
  3495 00002350 24DF                <1> 	AND	AL, 0DFH 		; TURN OFF PALETTE SELECT BIT
  3496 00002352 D0EB                <1> 	SHR	BL, 1			; TEST THE LOW ORDER BIT OF BL
  3497 00002354 73EF                <1> 	JNC	short M19		; ALREADY DONE
  3498 00002356 0C20                <1> 	OR	AL, 20H			; TURN ON PALETTE SELECT BIT
  3499 00002358 EBEB                <1> 	JMP	short M19		; GO DO IT
  3500                              <1> 
  3501                              <1> ; 09/07/2016
  3502                              <1> ; 01/07/2016 - TRDOS 386 (TRDOS v2.0)
  3503                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  3504                              <1> ;--------------------------------------------
  3505                              <1> ; READ DOT -- WRITE DOT
  3506                              <1> ; THESE ROUTINES WILL WRITE A DOT, OR READ THE
  3507                              <1> ;  DOT AT THE INDICATED LOCATION
  3508                              <1> ; ENTRY --
  3509                              <1> ;   DX = ROW (0-199)	(THE ACTUAL VALUE DEPENDS ON THE MODE)
  3510                              <1> ;   CX = COLUMN ( 0-639) ( THE VALUES ARE NOT RANGE CHECKED )
  3511                              <1> ;   AL = DOT VALUE TO WRITE (1,2 OR 4 BITS DEPENDING ON MODE,
  3512                              <1> ;	REQUIRED FOR WRITE DOT ONLY, RIGHT JUSTIFIED)
  3513                              <1> ;	BIT 7 OF AL = 1 INDICATES XOR THE VALUE INTO THE LOCATION
  3514                              <1> ;   DS = DATA SEGMENT
  3515                              <1> ;   ES = REGEN SEGMENT
  3516                              <1> ;
  3517                              <1> ; EXIT
  3518                              <1> ;	AL = DOT VALUE READ, RIGHT JUSTIFIED, READ ONLY
  3519                              <1> ;----------------------------------------------
  3520                              <1> 
  3521                              <1> READ_DOT:
  3522                              <1> 	; 09/07/2016
  3523 0000235A 8A25[E6E80000]      <1> 	mov	ah,  [CRT_MODE]
  3524 00002360 80FC07              <1> 	cmp	ah, 7 ; 6!?
  3525 00002363 760A                <1> 	jna	short read_dot_cga
  3526                              <1> 
  3527 00002365 E896030000          <1> 	call	vga_read_pixel
  3528                              <1> 	; al = pixel value
  3529 0000236A E996F0FFFF          <1> 	jmp	_video_return
  3530                              <1> 
  3531                              <1> read_dot_cga:
  3532                              <1> 	;je	VIDEO_RETURN ; 7	
  3533 0000236F 80FC04              <1> 	cmp	ah, 4 ; graphics ? 
  3534 00002372 0F8288F0FFFF        <1> 	jb	VIDEO_RETURN ; no, text mode, nothing to do
  3535                              <1> 
  3536 00002378 E855000000          <1> 	CALL	R3			; DETERMINE BYTE POSITION OF DOT
  3537 0000237D 8A06                <1> 	MOV	AL, [eSI]		; GET THE BYTE
  3538 0000237F 20E0                <1> 	AND	AL, AH			; MASK OFF THE OTHER BITS IN THE BYTE
  3539 00002381 D2E0                <1> 	SHL	AL, CL			; LEFT JUSTIFY THE VALUE
  3540 00002383 88F1                <1> 	MOV	CL, DH			; GET NUMBER OF BITS IN RESULT
  3541 00002385 D2C0                <1> 	ROL	AL, CL			; RIGHT JUSTIFY THE RESULT
  3542                              <1> 	;JMP	VIDEO_RETURN		; RETURN FROM VIDEO I/O
  3543 00002387 0FB6C0              <1> 	movzx	eax, al
  3544 0000238A E976F0FFFF          <1> 	jmp	_video_return
  3545                              <1> 
  3546                              <1> ; 09/07/2016
  3547                              <1> ; 01/07/2016 - TRDOS 386 (TRDOS v2.0)
  3548                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  3549                              <1> 
  3550                              <1> WRITE_DOT:
  3551                              <1> 	; 09/07/2016
  3552 0000238F 8A25[E6E80000]      <1> 	mov	ah, [CRT_MODE]
  3553 00002395 80FC07              <1> 	cmp	ah, 7 ; 6!?
  3554 00002398 760A                <1> 	jna	short write_dot_cga
  3555                              <1> 	
  3556 0000239A E8D0020000          <1> 	call	vga_write_pixel
  3557 0000239F E95CF0FFFF          <1> 	jmp	VIDEO_RETURN
  3558                              <1> 
  3559                              <1> write_dot_cga:
  3560                              <1> 	;je	VIDEO_RETURN ; 7	
  3561 000023A4 80FC04              <1> 	cmp	ah, 4 ; graphics ? 
  3562 000023A7 0F8253F0FFFF        <1> 	jb	VIDEO_RETURN ; no, text mode, nothing to do
  3563                              <1> 
  3564                              <1> 	;PUSH	AX			; SAVE DOT VALUE
  3565 000023AD 6650                <1> 	PUSH	AX			; TWICE
  3566 000023AF E81E000000          <1> 	CALL	R3			; DETERMINE BYTE POSITION OF THE DOT
  3567 000023B4 D2E8                <1> 	SHR	AL, CL			; SHIFT TO SET UP THE BITS FOR OUTPUT
  3568 000023B6 20E0                <1> 	AND	AL, AH			; STRIP OFF THE OTHER BITS
  3569 000023B8 8A0E                <1> 	MOV	CL, [eSI]		; GET THE CURRENT BYTE
  3570 000023BA 665B                <1> 	POP	BX			; RECOVER XOR FLAG
  3571 000023BC F6C380              <1> 	TEST	BL, 80H			; IS IT ON
  3572 000023BF 750D                <1> 	JNZ	short R2		; YES, XOR THE DOT
  3573 000023C1 F6D4                <1> 	NOT	AH			; SET MASK TO REMOVE THE INDICATED BITS
  3574 000023C3 20E1                <1> 	AND	CL, AH
  3575 000023C5 08C8                <1> 	OR	AL, CL			; OR IN THE NEW VALUE OF THOSE BITS
  3576                              <1> R1:					; FINISH_DOT
  3577 000023C7 8806                <1> 	MOV	[eSI], AL		; RESTORE THE BYTE IN MEMORY
  3578                              <1> 	;POP	AX
  3579 000023C9 E932F0FFFF          <1> 	JMP	VIDEO_RETURN		; RETURN FROM VIDEO I/O
  3580                              <1> R2:					; XOR_DOT
  3581 000023CE 30C8                <1> 	XOR	AL, CL			; EXCLUSIVE OR THE DOTS
  3582 000023D0 EBF5                <1> 	JMP	short R1		; FINISH UP THE WRITING
  3583                              <1> 
  3584                              <1> ; 01/07/2016 - TRDOS 386 (TRDOS v2.0)
  3585                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  3586                              <1> 
  3587                              <1> ;----------------------------------------------
  3588                              <1> ; THIS SUBROUTINE DETERMINES THE REGEN BYTE LOCATION OF THE
  3589                              <1> ; INDICATED ROW COLUMN VALUE IN GRAPHICS MODE.
  3590                              <1> ; ENTRY --
  3591                              <1> ;  DX = ROW VALUE (0-199)
  3592                              <1> ;  CX = COLUMN VALUE (0-639)
  3593                              <1> ; EXIT --
  3594                              <1> ;  SI = OFFSET INTO REGEN BUFFER FOR BYTE OF INTEREST
  3595                              <1> ;  AH = MASK TO STRIP OFF THE BITS OF INTEREST
  3596                              <1> ;  CL = BITS TO SHIFT TO RIGHT JUSTIFY THE MASK IN AH
  3597                              <1> ;  DH = # BITS IN RESULT
  3598                              <1> ;  BX = MODIFIED
  3599                              <1> ;-----------------------------------------------
  3600                              <1> R3:
  3601                              <1> 
  3602                              <1> ;-----	DETERMINE 1ST BYTE IN INDICATED ROW BY MULTIPLYING ROW VALUE BY 40
  3603                              <1> ;-----	 ( LOW BIT OF ROW DETERMINES EVEN/ODD, 80 BYTES/ROW )
  3604                              <1> 
  3605 000023D2 0FB7F0              <1> 	movzx	esi, ax			; WILL SAVE AL AND AH DURING OPERATION
  3606 000023D5 B028                <1> 	MOV	AL, 40
  3607 000023D7 F6E2                <1> 	MUL	DL			; AX= ADDRESS OF START OF INDICATED ROW
  3608 000023D9 A808                <1> 	TEST	AL, 08H 		; TEST FOR EVEN/ODD ROW CALCULATED
  3609 000023DB 7404                <1> 	JZ	short R4		; JUMP IF EVEN ROW
  3610 000023DD 6605D81F            <1> 	ADD	AX, 2000H-40		; OFFSET TO LOCATION OF ODD ROWS ADJUST
  3611                              <1> R4:					; EVEN_ROW
  3612 000023E1 6696                <1> 	XCHG	SI, AX			; MOVE POINTER TO (SI) AND RECOVER (AX)
  3613 000023E3 81C600800B00        <1> 	add	esi, 0B8000h
  3614 000023E9 6689CA              <1> 	MOV	DX, CX			; COLUMN VALUE TO DX
  3615                              <1> 
  3616                              <1> ;-----	DETERMINE GRAPHICS MODE CURRENTLY IN EFFECT
  3617                              <1> 
  3618                              <1> ; SET UP THE REGISTERS ACCORDING TO THE MODE
  3619                              <1> ; CH = MASK FOR LOW OF COLUMN ADDRESS ( 7/3 FOR HIGH/MED RES )
  3620                              <1> ; CL = # OF ADDRESS BITS IN COLUMN VALUE ( 3/2 FOR H/M )
  3621                              <1> ; BL = MASK TO SELECT BITS FROM POINTED BYTE ( 80H/C0H FOR H/M )
  3622                              <1> ; BH = NUMBER OF VALID BITS IN POINTED BYTE ( 1/2 FOR H/M )
  3623                              <1> 
  3624 000023EC 66BBC002            <1> 	MOV	BX, 2C0H
  3625 000023F0 66B90203            <1> 	MOV	CX, 302H 		; SET PARMS FOR MED RES
  3626 000023F4 803D[E6E80000]06    <1> 	CMP	byte [CRT_MODE], 6
  3627 000023FB 7208                <1> 	JC	short R5		; HANDLE IF MED RES
  3628 000023FD 66BB8001            <1> 	MOV	BX, 180H
  3629 00002401 66B90307            <1> 	MOV	CX, 703H 		; SET PARMS FOR HIGH RES
  3630                              <1> 
  3631                              <1> ;-----	DETERMINE BIT OFFSET IN BYTE FROM COLUMN MASK
  3632                              <1> R5:
  3633 00002405 20D5                <1> 	AND	CH, DL			; ADDRESS OF PEL WITHIN BYTE TO CH
  3634                              <1> 
  3635                              <1> ;-----	DETERMINE BYTE OFFSET FOR THIS LOCATION IN COLUMN
  3636                              <1> 
  3637 00002407 66D3EA              <1> 	SHR	DX, CL			; SHIFT BY CORRECT AMOUNT
  3638 0000240A 6601D6              <1> 	ADD	SI, DX			; INCREMENT THE POINTER
  3639 0000240D 88FE                <1> 	MOV	DH, BH			; GET THE # OF BITS IN RESULT TO DH
  3640                              <1> 
  3641                              <1> ;-----	MULTIPLY BH (VALID BITS IN BYTE) BY CH (BIT OFFSET)
  3642                              <1> 
  3643 0000240F 28C9                <1> 	SUB	CL, CL			; ZERO INTO STORAGE LOCATION
  3644                              <1> R6:
  3645 00002411 D0C8                <1> 	ROR	AL, 1			; LEFT JUSTIFY VALUE IN AL (FOR WRITE)
  3646 00002413 00E9                <1> 	ADD	CL, CH			; ADD IN THE BIT OFFSET VALUE
  3647 00002415 FECF                <1> 	DEC	BH			; LOOP CONTROL
  3648 00002417 75F8                <1> 	JNZ	short R6		; ON EXIT, CL HAS COUNT TO RESTORE BITS
  3649 00002419 88DC                <1> 	MOV	AH, BL			;  GET MASK TO AH
  3650 0000241B D2EC                <1> 	SHR	AH, CL			;  MOVE THE MASK TO CORRECT LOCATION
  3651 0000241D C3                  <1> 	RETn				;  RETURN WITH EVERYTHING SET UP
  3652                              <1> 
  3653                              <1> load_dac_palette:
  3654                              <1> 	; 29/07/2016
  3655                              <1> 	; 23/07/2016
  3656                              <1> 	; 03/07/2016 (TRDOS 386 = TRDOS v2.0)
  3657                              <1> 	; (set_mode_vga)
  3658                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  3659                              <1> 	; vgabios-0.7a (2011)
  3660                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  3661                              <1> 	; 'vgabios.c', 'load_dac_palette'
  3662                              <1> 	;
  3663                              <1> 	; Oracle VirtualBox 5.0.24 VGABios Source Code
  3664                              <1> 	; ('vgabios.c', 'vgatables.h', 'vgafonts.h', 'vgarom.asm')
  3665                              <1> 	;
  3666                              <1> 	; INPUT -> AH = DAC selection number (3, 2 or 1)
  3667                              <1> 	; OUTPUT -> ECX = 0, AX = 0
  3668                              <1> 	; (Modifed registers: EAX, ECX, EDX, ESI)
  3669                              <1> 	;
  3670 0000241E 66BAC803            <1> 	mov	dx, 3C8h  ; VGAREG_DAC_WRITE_ADDRESS
  3671 00002422 28C0                <1> 	sub	al, al ; 0
  3672 00002424 EE                  <1> 	out	dx, al ; 0 ; color index, always 0 at the beginning	
  3673 00002425 6642                <1> 	inc	dx   ; 3C9h ; VGAREG_DAC_DATA
  3674 00002427 B900010000          <1> 	mov	ecx, 256   ; always 256*3 values
  3675                              <1> 	;push	esi
  3676 0000242C 88E0                <1> 	mov	al, ah
  3677 0000242E B43F                <1> 	mov	ah, 3Fh	; 3Fh except DAC selection number 3
  3678 00002430 3C02                <1> 	cmp 	al, 2
  3679 00002432 7414                <1> 	je	short l_dac_p_2
  3680 00002434 7719                <1> 	ja	short l_dac_p_3
  3681 00002436 20C0                <1> 	and	al, al
  3682 00002438 7507                <1> 	jnz	short l_dac_p_1
  3683                              <1> l_dac_p_0:
  3684 0000243A BE[00EF0000]        <1> 	mov	esi, palette0
  3685 0000243F EB15                <1> 	jmp	short l_dac_p_4	
  3686                              <1> l_dac_p_1:
  3687 00002441 BE[C0EF0000]        <1> 	mov	esi, palette1
  3688 00002446 EB0E                <1> 	jmp	short l_dac_p_4
  3689                              <1> l_dac_p_2:
  3690 00002448 BE[80F00000]        <1> 	mov	esi, palette2
  3691 0000244D EB07                <1> 	jmp	short l_dac_p_4
  3692                              <1> l_dac_p_3:
  3693 0000244F B4FF                <1> 	mov	ah, 0FFh ; dac registers
  3694 00002451 BE[40F10000]        <1> 	mov	esi, palette3
  3695                              <1> l_dac_p_4:
  3696 00002456 AC                  <1> 	lodsb
  3697 00002457 EE                  <1> 	out	dx, al  ; Red
  3698 00002458 AC                  <1> 	lodsb
  3699 00002459 EE                  <1> 	out	dx, al	; Green
  3700 0000245A AC                  <1> 	lodsb
  3701 0000245B EE                  <1> 	out	dx, al	; Blue
  3702 0000245C 20E4                <1> 	and	ah, ah
  3703 0000245E 7405                <1> 	jz	short l_dac_p_5	
  3704 00002460 FECC                <1> 	dec	ah
  3705 00002462 E2F2                <1> 	loop	l_dac_p_4
  3706                              <1> 	;pop	esi
  3707 00002464 C3                  <1> 	retn
  3708                              <1> l_dac_p_5:
  3709                              <1> 	; 29/07/2016
  3710 00002465 FEC9                <1> 	dec	cl
  3711 00002467 7407                <1> 	jz	short l_dac_p_7
  3712                              <1> 	;
  3713 00002469 28C0                <1> 	sub	al, al ; 0
  3714                              <1> l_dac_p_6:
  3715 0000246B EE                  <1> 	out	dx, al ; outb(VGAREG_DAC_DATA,0);
  3716 0000246C EE                  <1> 	out	dx, al
  3717 0000246D EE                  <1> 	out	dx, al
  3718 0000246E E2FB                <1> 	loop	l_dac_p_6
  3719                              <1> l_dac_p_7:
  3720                              <1> 	;pop	esi
  3721 00002470 C3                  <1> 	retn
  3722                              <1> 
  3723                              <1> gray_scale_summing:
  3724                              <1> 	; 03/07/2016 (TRDOS 386 = TRDOS v2.0)
  3725                              <1> 	; (set_mode_vga)
  3726                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  3727                              <1> 	; vgabios-0.7a (2011)
  3728                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  3729                              <1> 	; 'vgabios.c', 'biosfn_perform_gray_scale_summing'
  3730                              <1> 	;
  3731                              <1> 	; Oracle VirtualBox 5.0.24 VGABios Source Code
  3732                              <1> 	; ('vgabios.c', 'vgatables.h', 'vgafonts.h', 'vgarom.asm')
  3733                              <1> 	;
  3734                              <1> 
  3735                              <1> 	; INPUT -> EBX = Start address (color index <= 255)
  3736                              <1> 	;	   ECX = Count (<= 256)
  3737                              <1> 	; OUTPUT -> (E)CX = 0
  3738                              <1> 	; (Modifed registers: EAX, ECX, EDX, EBX)
  3739                              <1> 
  3740 00002471 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
  3741 00002475 EC                  <1> 	in	al, dx
  3742 00002476 30C0                <1> 	xor	al, al ; 0
  3743 00002478 66BAC003            <1> 	mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
  3744 0000247C EE                  <1> 	out	dx, al	; clear bit 5
  3745                              <1> 			; (while loading palette registers)
  3746                              <1> 	; set read address and switch to read mode
  3747                              <1> g_s_s_1:
  3748 0000247D 66BAC703            <1> 	mov	dx, 3C7h ; VGAREG_DAC_READ_ADDRESS
  3749 00002481 88D8                <1> 	mov	al, bl
  3750 00002483 EE                  <1> 	out	dx, al
  3751                              <1> 	; get 6-bit wide RGB data values
  3752                              <1>  	; intensity = (0.3*Red)+(0.59*Green)+(0.11*Blue)
  3753                              <1> 	; i = ( ( 77*r + 151*g + 28*b ) + 0x80 ) >> 8;
  3754 00002484 66BAC903            <1> 	mov	dx, 3C9h ; VGAREG_DAC_DATA
  3755 00002488 EC                  <1> 	in	al, dx ; red
  3756 00002489 B44D                <1> 	mov	ah, 77 ; 0.3* Red
  3757 0000248B F6E4                <1> 	mul	ah
  3758 0000248D 6650                <1> 	push	ax
  3759 0000248F EC                  <1> 	in	al, dx ; green
  3760 00002490 B497                <1> 	mov	ah, 151  ; 0.59 * Green
  3761 00002492 F6E4                <1> 	mul	ah
  3762 00002494 6650                <1> 	push	ax
  3763 00002496 EC                  <1> 	in	al, dx ; blue
  3764 00002497 B41C                <1> 	mov	ah, 28 ; 0.11 * Blue
  3765 00002499 F6E4                <1> 	mul	ah
  3766 0000249B 665A                <1> 	pop	dx
  3767 0000249D 6601D0              <1> 	add	ax, dx
  3768 000024A0 665A                <1> 	pop	dx
  3769 000024A2 6601D0              <1> 	add	ax, dx
  3770 000024A5 66058000            <1> 	add	ax, 80h  
  3771 000024A9 B03F                <1> 	mov	al, 3Fh
  3772 000024AB 38C4                <1> 	cmp	ah, al
  3773 000024AD 7602                <1> 	jna	short g_s_s_2
  3774 000024AF 88C4                <1> 	mov	ah, al
  3775                              <1> g_s_s_2:
  3776 000024B1 66BAC803            <1> 	mov	dx, 3C8h  ; VGAREG_DAC_WRITE_ADDRESS
  3777 000024B5 88D8                <1> 	mov	al, bl ; color index
  3778 000024B7 EE                  <1> 	out	dx, al
  3779 000024B8 88E0                <1> 	mov	al, ah ; intensity
  3780 000024BA 6642                <1> 	inc	dx ; 3C9h ; VGAREG_DAC_DATA
  3781 000024BC EE                  <1> 	out	dx, al ; R (R=G=B)
  3782 000024BD 88E0                <1> 	mov	al, ah ; intensity
  3783 000024BF EE                  <1> 	out	dx, al ; G (R=G=B)
  3784 000024C0 88E0                <1>  	mov	al, ah ; intensity
  3785 000024C2 EE                  <1> 	out	dx, al ; B (R=G=B)
  3786 000024C3 6649                <1> 	dec	cx
  3787 000024C5 7404                <1> 	jz	short g_s_s_3
  3788 000024C7 FEC3                <1> 	inc	bl    ; next color index value
  3789 000024C9 EBB2                <1> 	jmp	short g_s_s_1
  3790                              <1> g_s_s_3:
  3791 000024CB 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
  3792 000024CF EC                  <1> 	in	al, dx
  3793 000024D0 B020                <1> 	mov	al, 20h
  3794 000024D2 66BAC003            <1> 	mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
  3795 000024D6 EE                  <1> 	out	dx, al ; 20h -> set bit 5
  3796                              <1> 		        ; (after loading palette regs)	
  3797 000024D7 C3                  <1> 	retn
  3798                              <1> 
  3799                              <1> vga_write_char_attr:
  3800                              <1> vga_write_char_only: 
  3801                              <1> 	; 08/07/2016 (TRDOS 386 = TRDOS v2.0)
  3802                              <1> 	;
  3803                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  3804                              <1> 	; vgabios-0.7a (2011)
  3805                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  3806                              <1> 	; 'vgabios.c', 'biosfn_write_char_attr'
  3807                              <1> 	; 'biosfn_write_char_only'
  3808                              <1> 
  3809                              <1> 	; INPUT ->
  3810                              <1> 	; [CRT_MODE] = current video mode (>7)
  3811                              <1> 	; CX = Count of characters to write
  3812                              <1> 	; AL = Character to write
  3813                              <1> 	; BL = Color of character
  3814                              <1> 	; OUTPUT ->
  3815                              <1> 	; Regen buffer updated
  3816                              <1>  
  3817 000024D8 8A25[E6E80000]      <1> 	mov 	ah, [CRT_MODE]
  3818 000024DE 668B15[C61F0100]    <1> 	mov	dx, [CURSOR_POSN] ; cursor pos for page 0
  3819                              <1> 
  3820 000024E5 BE[02E90000]        <1> 	mov	esi, vga_modes
  3821 000024EA 89F7                <1> 	mov	edi, esi
  3822 000024EC 83C710              <1> 	add	edi, vga_mode_count
  3823                              <1> vga_wca_0:
  3824 000024EF AC                  <1> 	lodsb
  3825 000024F0 38E0                <1> 	cmp	al, ah ; [CRT_MODE]
  3826 000024F2 7405                <1> 	je	short vga_wca_2
  3827 000024F4 39FE                <1> 	cmp	esi, edi
  3828 000024F6 72F7                <1> 	jb	short vga_wca_0
  3829                              <1> vga_wca_1:
  3830 000024F8 C3                  <1> 	retn	; nothing to do
  3831                              <1> vga_wca_2:
  3832 000024F9 83C64F              <1> 	add	esi, vga_memmodel - (vga_modes + 1)  
  3833                              <1> 	; [ESI] = VGA memory model number (LINEAR8, PLANAR4, PLANAR1)
  3834                              <1> 
  3835                              <1> 	; biosfn_write_char_attr (car,page,attr,count) 
  3836                              <1> 	; AL = car, page = 0, BL = attr, CX = count
  3837 000024FC 803E04              <1> 	cmp	byte [esi], PLANAR4
  3838 000024FF 741D                <1> 	je	short vga_wca_planar
  3839 00002501 803E03              <1> 	cmp	byte [esi], PLANAR1
  3840 00002504 7418                <1> 	je	short vga_wca_planar
  3841                              <1> vga_wca_linear8:
  3842                              <1> 	; while((count-->0) && (xcurs<nbcols))
  3843                              <1> 	; CX = count
  3844 00002506 6621C9              <1> 	and	cx, cx
  3845 00002509 74ED                <1> 	jz	short vga_wca_1
  3846 0000250B 3A15[E8E80000]      <1> 	cmp	dl, [CRT_COLS]
  3847 00002511 73E5                <1> 	jnb	short vga_wca_1
  3848                              <1> 	; write_gfx_char_lin(car,attr,xcurs,ycurs,nbcols);
  3849                              <1> 	; AL = car, BL = attr, DL = xcurs, DH = ycurs, 
  3850                              <1> 	; [CRT_COLS]= nbcols
  3851 00002513 E81E000000          <1> 	call	write_gfx_char_lin	 
  3852 00002518 6649                <1> 	dec	cx ; count
  3853 0000251A FEC2                <1> 	inc	dl ; xcurs
  3854 0000251C EBE8                <1> 	jmp	short vga_wca_linear8
  3855                              <1> vga_wca_planar:
  3856                              <1> 	; while((count-->0) && (xcurs<nbcols))
  3857                              <1> 	; CX = count
  3858 0000251E 6621C9              <1> 	and	cx, cx
  3859 00002521 74D5                <1> 	jz	short vga_wca_1
  3860 00002523 3A15[E8E80000]      <1> 	cmp	dl, [CRT_COLS]
  3861 00002529 73CD                <1> 	jnb	short vga_wca_1
  3862                              <1> 	; write_gfx_char_pl4(car,attr,xcurs,ycurs,nbcols,cheight);
  3863                              <1> 	; AL = car, BL = attr, DL = xcurs, DH = ycurs, 
  3864                              <1> 	; [CRT_COLS]= nbcols, [CHAR_HEIGHT] = cheight
  3865 0000252B E873000000          <1> 	call	write_gfx_char_pl4
  3866 00002530 6649                <1> 	dec	cx ; count
  3867 00002532 FEC2                <1> 	inc	dl ; xcurs
  3868 00002534 EBE8                <1> 	jmp	short vga_wca_planar
  3869                              <1> 
  3870                              <1> write_gfx_char_lin:
  3871                              <1> 	; 08/07/2016 (TRDOS 386 = TRDOS v2.0)
  3872                              <1> 	;
  3873                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  3874                              <1> 	; vgabios-0.7a (2011)
  3875                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  3876                              <1> 	; 'vgabios.c', 'write_gfx_char_lin'
  3877                              <1> 
  3878                              <1> 	; write_gfx_char_lin(car,attr,xcurs,ycurs,nbcols)
  3879                              <1> 	; INPUT ->
  3880                              <1> 	; AL = car, BL = attr, DL = xcurs, DH = ycurs, 
  3881                              <1> 	; [CRT_COLS]= nbcols
  3882                              <1> 	; OUTPUT ->
  3883                              <1> 	; Regen buffer updated
  3884                              <1> 
  3885 00002536 51                  <1> 	push	ecx
  3886 00002537 53                  <1> 	push	ebx
  3887 00002538 52                  <1> 	push	edx
  3888 00002539 50                  <1> 	push	eax
  3889 0000253A 0FB6F0              <1> 	movzx	esi, al ; car
  3890                              <1> 	; addr=xcurs*8+ycurs*nbcols*64;
  3891 0000253D 0FB6C6              <1> 	movzx	eax, dh ; ycurs
  3892 00002540 8A25[E8E80000]      <1> 	mov	ah, [CRT_COLS] ; nbcols
  3893 00002546 F6E4                <1> 	mul	ah
  3894 00002548 66C1E006            <1> 	shl	ax, 6 ; * 64
  3895 0000254C 28F6                <1>  	sub	dh, dh ; 0
  3896 0000254E 66C1E203            <1> 	shl	dx, 3 ; ncurs * 8
  3897 00002552 0FB7FA              <1> 	movzx	edi, dx
  3898 00002555 01C7                <1> 	add	edi, eax ; addr
  3899 00002557 81C700000A00        <1> 	add	edi, 0A0000h
  3900 0000255D 66C1E603            <1> 	shl	si, 3 ; car * 8
  3901                              <1> 	; esi = src = car * 8
  3902                              <1> 	; i = 0
  3903 00002561 81C6[40F40000]      <1> 	add	esi, vgafont8 ; fdata [src+i]
  3904 00002567 28FF                <1> 	sub	bh, bh ; i = 0
  3905                              <1> wgfxl_0:
  3906                              <1> 	; for(i=0;i<8;i++)
  3907 00002569 57                  <1> 	push	edi ; addr
  3908 0000256A 0FB605[E8E80000]    <1> 	movzx	eax, byte [CRT_COLS] ; nbcols
  3909 00002571 F6E7                <1> 	mul	bh ; nbcols*i
  3910 00002573 66C1E003            <1> 	shl	ax, 3 ; i*nbcols*8
  3911                              <1>  	; dest=addr+i*nbcols*8;
  3912 00002577 01C7                <1> 	add	edi, eax ; dest + j ; j = 0
  3913 00002579 B580                <1> 	mov	ch, 80h ; mask = 0x80;
  3914                              <1> 	; esi = fdata + src + i
  3915 0000257B AC                  <1> 	lodsb
  3916 0000257C 88C1                <1> 	mov	cl, al ; fdata[src+i]
  3917                              <1> 	;
  3918                              <1> 	; for(j=0;j<8;j++)
  3919 0000257E 29D2                <1> 	sub	edx, edx ; j = 0
  3920                              <1> wfgxl_1:
  3921 00002580 28C0                <1> 	sub	al, al ; data = 0
  3922 00002582 84E9                <1> 	test	cl, ch ; if (fdata[src+i] & mask)
  3923 00002584 7402                <1> 	jz	short wgfxl_2  ; zf = 1
  3924 00002586 88D8                <1> 	mov	al, bl ; data = attr;
  3925                              <1> wgfxl_2:
  3926                              <1> 	; write_byte(0xa000,dest+j,data);		
  3927 00002588 AA                  <1> 	stosb  ; dest + j (+ 0A0000h)
  3928                              <1> 	;inc	dl ; j++
  3929                              <1> 	;cmp	dl, 8
  3930 00002589 80FA07              <1> 	cmp	dl, 7
  3931 0000258C 720A                <1> 	jb	short wgfxl_3
  3932 0000258E 5F                  <1> 	pop	edi
  3933 0000258F 80FF07              <1> 	cmp	bh, 7
  3934 00002592 730A                <1> 	jnb	short wgfxl_4
  3935 00002594 FEC7                <1> 	inc	bh ; i++
  3936 00002596 EBD1                <1> 	jmp	short wgfxl_0
  3937                              <1> wgfxl_3:
  3938 00002598 D0ED                <1> 	shr	ch, 1 ; mask >>= 1;
  3939 0000259A FEC2                <1> 	inc	dl ; j++
  3940 0000259C EBE2                <1> 	jmp	short wfgxl_1
  3941                              <1> wgfxl_4:
  3942 0000259E 58                  <1> 	pop	eax
  3943 0000259F 5A                  <1> 	pop	edx
  3944 000025A0 5B                  <1> 	pop	ebx
  3945 000025A1 59                  <1> 	pop	ecx
  3946 000025A2 C3                  <1> 	retn
  3947                              <1> 
  3948                              <1> write_gfx_char_pl4:
  3949                              <1> 	; 08/07/2016 (TRDOS 386 = TRDOS v2.0)
  3950                              <1> 	;
  3951                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  3952                              <1> 	; vgabios-0.7a (2011)
  3953                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  3954                              <1> 	; 'vgabios.c', 'write_gfx_char_pl4'
  3955                              <1> 
  3956                              <1> 	; write_gfx_char_pl4(car,attr,xcurs,ycurs,nbcols,cheight)
  3957                              <1> 	; INPUT ->
  3958                              <1> 	; AL = car, BL = attr, DL = xcurs, DH = ycurs, 
  3959                              <1> 	; [CRT_COLS]= nbcols, [CHAR_HEIGHT] = cheight
  3960                              <1> 	; OUTPUT ->
  3961                              <1> 	; Regen buffer updated
  3962                              <1> 
  3963 000025A3 51                  <1> 	push	ecx
  3964 000025A4 53                  <1> 	push	ebx
  3965 000025A5 52                  <1> 	push	edx
  3966 000025A6 50                  <1> 	push	eax
  3967                              <1> wgfxpl_f0:
  3968                              <1> 	; switch(cheight)
  3969 000025A7 8A25[EAE80000]      <1> 	mov	ah, [CHAR_HEIGHT]
  3970 000025AD 80FC10              <1> 	cmp	ah, 16 ; case 16:
  3971 000025B0 7507                <1> 	jne	short wgfxpl_f1
  3972                              <1> 	; fdata = &vgafont16;
  3973 000025B2 BE[400A0100]        <1> 	mov	esi, vgafont16
  3974 000025B7 EB13                <1> 	jmp	short wgfxpl_f3
  3975                              <1> wgfxpl_f1:
  3976 000025B9 80FC0E              <1> 	cmp	ah, 14 ; case 14:
  3977 000025BC 7507                <1> 	jne	short wgfxpl_f2
  3978 000025BE BE[40FC0000]        <1> 	mov	esi, vgafont14
  3979 000025C3 EB07                <1> 	jmp	short wgfxpl_f3
  3980                              <1> wgfxpl_f2:
  3981                              <1> 	; default:
  3982                              <1> 	;  fdata = &vgafont8;
  3983 000025C5 BE[40F40000]        <1> 	mov	esi, vgafont8
  3984 000025CA B408                <1> 	mov	ah, 8	
  3985                              <1> wgfxpl_f3:
  3986                              <1> 	; al = car
  3987 000025CC F6E4                <1> 	mul	ah ; ah = cheight
  3988 000025CE 25FFFF0000          <1> 	and	eax, 0FFFFh ; car * cheight
  3989                              <1> 	; src = car * cheight;
  3990 000025D3 01C6                <1> 	add	esi, eax ; esi = fdata[src+i]
  3991                              <1> 	; addr=xcurs*8+ycurs*nbcols*64;
  3992 000025D5 0FB6C6              <1> 	movzx	eax, dh ; ycurs
  3993 000025D8 8A25[E8E80000]      <1> 	mov	ah, [CRT_COLS] ; nbcols
  3994 000025DE F6E4                <1> 	mul	ah
  3995 000025E0 66C1E006            <1> 	shl	ax, 6 ; * 64
  3996 000025E4 28F6                <1>  	sub	dh, dh ; 0
  3997 000025E6 66C1E203            <1> 	shl	dx, 3 ; ncurs * 8
  3998 000025EA 0FB7FA              <1> 	movzx	edi, dx
  3999 000025ED 01C7                <1> 	add	edi, eax ; addr
  4000 000025EF 81C700000A00        <1> 	add	edi, 0A0000h
  4001                              <1> 	;
  4002                              <1> 	; outw(VGAREG_SEQU_ADDRESS, 0x0f02);
  4003                              <1> 	; outw(VGAREG_GRDC_ADDRESS, 0x0205);
  4004 000025F5 66BAC403            <1> 	mov	dx, 3C4h ; VGAREG_SEQU_ADDRESS
  4005 000025F9 66B8020F            <1> 	mov	ax, 0F02h
  4006 000025FD 66EF                <1> 	out	dx, ax
  4007 000025FF 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  4008 00002603 66B80502            <1> 	mov	ax, 0205h
  4009 00002607 66EF                <1> 	out	dx, ax
  4010                              <1> 	;
  4011 00002609 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  4012 0000260D F6C380              <1> 	test	bl, 80h ; if(attr&0x80)
  4013 00002610 7406                <1> 	jz	short wgfxpl_f4 ; else
  4014                              <1> 	; outw(VGAREG_GRDC_ADDRESS, 0x1803);
  4015 00002612 66B80318            <1> 	mov	ax, 1803h
  4016 00002616 EB04                <1> 	jmp	short wgfxpl_f5
  4017                              <1> wgfxpl_f4:
  4018                              <1> 	; outw(VGAREG_GRDC_ADDRESS, 0x0003);
  4019 00002618 66B80300            <1> 	mov	ax, 0003h	
  4020                              <1> wgfxpl_f5:
  4021 0000261C 66EF                <1> 	out	dx, ax
  4022                              <1> 	;	
  4023 0000261E 28FF                <1> 	sub	bh, bh ; i = 0
  4024                              <1> wgfxpl_0:
  4025                              <1> 	; for(i=0;i<cheight;i++)
  4026 00002620 57                  <1> 	push	edi ; addr
  4027 00002621 0FB605[E8E80000]    <1> 	movzx	eax, byte [CRT_COLS] ; nbcols
  4028 00002628 F6E7                <1> 	mul	bh ; nbcols*i
  4029                              <1> 	; dest=addr+i*nbcols
  4030 0000262A 01C7                <1> 	add	edi, eax ; dest
  4031 0000262C B580                <1> 	mov	ch, 80h ; mask = 0x80;
  4032                              <1> 	; for(j=0;j<8;j++)
  4033 0000262E 28C9                <1> 	sub	cl, cl ; j = 0
  4034                              <1> wgfxpl_1:
  4035 00002630 D2ED                <1> 	shr	ch, cl ; mask=0x80>>j;
  4036                              <1> 	;
  4037                              <1> 	; outw(VGAREG_GRDC_ADDRESS, (mask << 8) | 0x08);
  4038                              <1>      	; read_byte(0xa000,dest);
  4039                              <1> 	;mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  4040 00002632 88EC                <1> 	mov	ah, ch
  4041 00002634 B008                <1> 	mov	al, 8
  4042 00002636 66EF                <1> 	out	dx, ax
  4043 00002638 8A07                <1> 	mov	al, [edi] ; ? (io delay?)
  4044                              <1> 	;
  4045 0000263A 28C0                <1> 	sub	al, al ; attr = 0
  4046                              <1> 	; if (fdata[src+i] & mask)
  4047 0000263C 842E                <1> 	test	byte [esi], ch
  4048 0000263E 7404                <1> 	jz	short wgfxpl_2  ; zf = 1
  4049                              <1> 	; write_byte(0xa000,dest,attr&0x0f);
  4050 00002640 88D8                <1> 	mov	al, bl ; attr;
  4051 00002642 240F                <1> 	and	al, 0Fh	; attr&0x0f
  4052                              <1> wgfxpl_2:
  4053                              <1> 	; write_byte(0xa000,dest,0x00);		
  4054 00002644 8807                <1> 	mov	[edi], al ; dest (+ 0A0000h)
  4055 00002646 FEC1                <1> 	inc	cl ; j++
  4056 00002648 80F908              <1> 	cmp	cl, 8
  4057 0000264B 72E3                <1> 	jb	short wgfxpl_1
  4058 0000264D 5F                  <1> 	pop	edi
  4059 0000264E 80FF07              <1> 	cmp	bh, 7
  4060 00002651 7305                <1> 	jnb	short wgfxpl_3
  4061 00002653 FEC7                <1> 	inc	bh ; i++
  4062 00002655 46                  <1> 	inc	esi
  4063 00002656 EBC8                <1> 	jmp	short wgfxpl_0
  4064                              <1> wgfxpl_3:
  4065                              <1> 	;mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  4066 00002658 66B808FF            <1>   	mov	ax, 0FF08h
  4067 0000265C 66EF                <1> 	out	dx, ax
  4068 0000265E 66B80500            <1> 	mov	ax, 0005h
  4069 00002662 66EF                <1> 	out	dx, ax
  4070 00002664 66B80300            <1> 	mov	ax, 0003h
  4071 00002668 66EF                <1> 	out	dx, ax
  4072                              <1> 	;
  4073 0000266A 58                  <1> 	pop	eax
  4074 0000266B 5A                  <1> 	pop	edx
  4075 0000266C 5B                  <1> 	pop	ebx
  4076 0000266D 59                  <1> 	pop	ecx
  4077 0000266E C3                  <1> 	retn
  4078                              <1> 
  4079                              <1> vga_write_pixel: 
  4080                              <1> 	; 09/07/2016 (TRDOS 386 = TRDOS v2.0)
  4081                              <1> 	;
  4082                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  4083                              <1> 	; vgabios-0.7a (2011)
  4084                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  4085                              <1> 	; 'vgabios.c', 'biosfn_write_pixel'
  4086                              <1> 
  4087                              <1> 	; INPUT ->
  4088                              <1> 	; 	DX = row (0-239)
  4089                              <1> 	; 	CX = column (0-799)
  4090                              <1> 	; 	AL = pixel value
  4091                              <1> 	;	(AH = [CRT_MODE])
  4092                              <1> 	; OUTPUT ->
  4093                              <1> 	; 	none
  4094                              <1>  
  4095 0000266F 88C3                <1> 	mov	bl, al ; pixel value
  4096                              <1> 	;mov 	ah, [CRT_MODE]
  4097 00002671 BE[02E90000]        <1> 	mov	esi, vga_modes
  4098 00002676 89F7                <1> 	mov	edi, esi
  4099 00002678 83C710              <1> 	add	edi, vga_mode_count
  4100                              <1> vga_wp_0:
  4101 0000267B AC                  <1> 	lodsb
  4102 0000267C 38E0                <1> 	cmp	al, ah ; [CRT_MODE]
  4103 0000267E 7405                <1> 	je	short vga_wp_1
  4104 00002680 39FE                <1> 	cmp	esi, edi
  4105 00002682 72F7                <1> 	jb	short vga_wp_0
  4106 00002684 C3                  <1> 	retn	; nothing to do
  4107                              <1> vga_wp_1:
  4108 00002685 83C64F              <1> 	add	esi, vga_memmodel - (vga_modes + 1)  
  4109                              <1> 	; [ESI] = VGA memory model number (LINEAR8, PLANAR4, PLANAR1)
  4110 00002688 BF00000A00          <1> 	mov	edi, 0A0000h
  4111                              <1> 	;
  4112 0000268D 803E04              <1> 	cmp	byte [esi], PLANAR4
  4113 00002690 741D                <1> 	je	short vga_wp_planar
  4114 00002692 803E03              <1> 	cmp	byte [esi], PLANAR1
  4115 00002695 7418                <1> 	je	short vga_wp_planar
  4116                              <1> vga_wp_linear8:
  4117                              <1> 	; addr=CX+DX*(read_word(BIOSMEM_SEG,BIOSMEM_NB_COLS)*8);
  4118 00002697 0FB605[E8E80000]    <1> 	movzx	eax, byte [CRT_COLS] ; = [VGA_COLS] ; nbcols
  4119 0000269E 66C1E003            <1>      	shl	ax, 3 ; * 8
  4120 000026A2 66F7E2              <1> 	mul	dx
  4121 000026A5 50                  <1> 	push	eax
  4122                              <1> 	;mov	edi, 0A0000h
  4123 000026A6 6601CF              <1> 	add	di, cx
  4124 000026A9 58                  <1> 	pop	eax
  4125 000026AA 01C7                <1> 	add	edi, eax ; addr
  4126                              <1> 	; write_byte(0xa000,addr,AL);
  4127 000026AC 881F                <1> 	mov	[edi], bl
  4128 000026AE C3                  <1> 	retn    
  4129                              <1> vga_wp_planar:
  4130                              <1> 	; addr = CX/8+DX*read_word(BIOSMEM_SEG,BIOSMEM_NB_COLS);
  4131 000026AF 0FB7C1              <1> 	movzx	eax, cx
  4132 000026B2 66C1E803            <1> 	shr	ax, 3 ; CX/8
  4133 000026B6 50                  <1> 	push	eax
  4134 000026B7 28E4                <1> 	sub	ah, ah ; 0
  4135 000026B9 A0[E8E80000]        <1> 	mov	al, [CRT_COLS] ; = [VGA_COLS] ; nbcols
  4136 000026BE 66F7E2              <1> 	mul	dx
  4137                              <1> 	;mov	edi, 0A0000h
  4138 000026C1 6601C7              <1>         add     di, ax
  4139 000026C4 58                  <1> 	pop	eax
  4140 000026C5 01C7                <1> 	add	edi, eax ; addr
  4141 000026C7 80E107              <1> 	and	cl, 7
  4142 000026CA B580                <1> 	mov	ch, 80h ; mask
  4143 000026CC D2ED                <1> 	shr	ch, cl 	; mask = 0x80 >> (CX & 0x07);
  4144                              <1> 	
  4145                              <1> 	; outw(VGAREG_GRDC_ADDRESS, (mask << 8) | 0x08);
  4146 000026CE 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  4147 000026D2 88EC                <1> 	mov	ah, ch
  4148 000026D4 B008                <1> 	mov	al, 8
  4149 000026D6 66EF                <1> 	out	dx, ax
  4150                              <1> 	; outw(VGAREG_GRDC_ADDRESS, 0x0205);
  4151 000026D8 66B80502            <1> 	mov	ax, 0205h
  4152 000026DC 66EF                <1> 	out	dx, ax
  4153                              <1> 	; data = read_byte(0xa000,addr);
  4154 000026DE 8A07                <1> 	mov	al, [edi] ; (delay?)	
  4155                              <1> 	; if (AL & 0x80)
  4156                              <1> 	; {
  4157                              <1> 	;  outw(VGAREG_GRDC_ADDRESS, 0x1803);
  4158                              <1> 	; }
  4159 000026E0 F6C380              <1> 	test	bl, 80h
  4160 000026E3 7406                <1> 	jz	short vga_wp_2
  4161 000026E5 66B80318            <1> 	mov	ax, 1803h
  4162 000026E9 66EF                <1> 	out	dx, ax
  4163                              <1> vga_wp_2:	
  4164                              <1> 	; write_byte(0xa000,addr,AL);
  4165 000026EB 881F                <1> 	mov	[edi], bl
  4166                              <1> 	;
  4167                              <1> 	;mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  4168 000026ED 66B808FF            <1>   	mov	ax, 0FF08h
  4169 000026F1 66EF                <1> 	out	dx, ax
  4170 000026F3 66B80500            <1> 	mov	ax, 0005h
  4171 000026F7 66EF                <1> 	out	dx, ax
  4172 000026F9 66B80300            <1> 	mov	ax, 0003h
  4173 000026FD 66EF                <1> 	out	dx, ax
  4174                              <1> 	;
  4175 000026FF C3                  <1> 	retn
  4176                              <1> 
  4177                              <1> vga_read_pixel: 
  4178                              <1> 	; 09/07/2016 (TRDOS 386 = TRDOS v2.0)
  4179                              <1> 	;
  4180                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  4181                              <1> 	; vgabios-0.7a (2011)
  4182                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  4183                              <1> 	; 'vgabios.c', 'biosfn_read_pixel'
  4184                              <1> 
  4185                              <1> 	; INPUT ->
  4186                              <1> 	; 	DX = row (0-239)
  4187                              <1> 	; 	CX = column (0-799)
  4188                              <1> 	;	(AH = [CRT_MODE])
  4189                              <1> 	; OUTPUT ->
  4190                              <1> 	; 	AL = pixel value
  4191                              <1> 	 
  4192                              <1> 	;mov 	ah, [CRT_MODE]
  4193 00002700 BE[02E90000]        <1> 	mov	esi, vga_modes
  4194 00002705 89F7                <1> 	mov	edi, esi
  4195 00002707 83C710              <1> 	add	edi, vga_mode_count
  4196                              <1> vga_rp_0:
  4197 0000270A AC                  <1> 	lodsb
  4198 0000270B 38E0                <1> 	cmp	al, ah ; [CRT_MODE]
  4199 0000270D 7405                <1> 	je	short vga_rp_1
  4200 0000270F 39FE                <1> 	cmp	esi, edi
  4201 00002711 72F7                <1> 	jb	short vga_rp_0
  4202 00002713 C3                  <1> 	retn	; nothing to do
  4203                              <1> vga_rp_1:
  4204 00002714 83C64F              <1> 	add	esi, vga_memmodel - (vga_modes + 1)  
  4205                              <1> 	; [ESI] = VGA memory model number (LINEAR8, PLANAR4, PLANAR1)
  4206 00002717 BF00000A00          <1> 	mov	edi, 0A0000h
  4207                              <1> 	;
  4208 0000271C 803E04              <1> 	cmp	byte [esi], PLANAR4
  4209 0000271F 741D                <1> 	je	short vga_rp_planar
  4210 00002721 803E03              <1> 	cmp	byte [esi], PLANAR1
  4211 00002724 7418                <1> 	je	short vga_rp_planar
  4212                              <1> vga_rp_linear8:
  4213                              <1> 	; addr=CX+DX*(read_word(BIOSMEM_SEG,BIOSMEM_NB_COLS)*8);
  4214 00002726 0FB605[E8E80000]    <1> 	movzx	eax, byte [CRT_COLS] ; = [VGA_COLS] ; nbcols
  4215 0000272D 66C1E003            <1>      	shl	ax, 3 ; * 8
  4216 00002731 66F7E2              <1> 	mul	dx
  4217 00002734 50                  <1> 	push	eax
  4218                              <1> 	;mov	edi, 0A0000h
  4219 00002735 6601CF              <1> 	add	di, cx
  4220 00002738 58                  <1> 	pop	eax
  4221 00002739 01C7                <1> 	add	edi, eax ; addr
  4222                              <1> 	; attr=read_byte(0xa000,addr);
  4223 0000273B 8A07                <1> 	mov	al, [edi] ; pixel value
  4224 0000273D C3                  <1> 	retn    
  4225                              <1> vga_rp_planar:
  4226                              <1> 	; addr = CX/8+DX*read_word(BIOSMEM_SEG,BIOSMEM_NB_COLS);
  4227 0000273E 0FB7C1              <1> 	movzx	eax, cx
  4228 00002741 66C1E803            <1> 	shr	ax, 3 ; CX/8
  4229 00002745 50                  <1> 	push	eax
  4230 00002746 28E4                <1> 	sub	ah, ah ; 0
  4231 00002748 A0[E8E80000]        <1> 	mov	al, [CRT_COLS] ; = [VGA_COLS] ; nbcols
  4232 0000274D 66F7E2              <1> 	mul	dx
  4233                              <1> 	;mov	edi, 0A0000h
  4234 00002750 6601C7              <1>         add     di, ax
  4235 00002753 58                  <1> 	pop	eax
  4236 00002754 01C7                <1> 	add	edi, eax ; addr
  4237 00002756 80E107              <1> 	and	cl, 7
  4238 00002759 B580                <1> 	mov	ch, 80h ; mask
  4239 0000275B D2ED                <1> 	shr	ch, cl 	; mask = 0x80 >> (CX & 0x07);
  4240                              <1> 	; attr = 0x00;
  4241 0000275D 30DB                <1> 	xor	bl, bl ; attr = bl = 0, 
  4242 0000275F 30C9                <1> 	xor	cl, cl ; i = cl = 0
  4243                              <1> 	; for(i=0;i<4;i++)
  4244                              <1>       	; {
  4245                              <1>        	;  outw(VGAREG_GRDC_ADDRESS, (i << 8) | 0x04);
  4246                              <1>        	;  data = read_byte(0xa000,addr) & mask;
  4247                              <1>        	;  if (data > 0) attr |= (0x01 << i);
  4248                              <1>       	; }
  4249                              <1> vga_rp_2:
  4250 00002761 88CC                <1> 	mov	ah, cl ; i << 8
  4251 00002763 B004                <1> 	mov	al, 4  ; | 0x04
  4252 00002765 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  4253 00002769 66EF                <1> 	out	dx, ax
  4254                              <1> 	; data = read_byte(0xa000,addr) & mask;
  4255 0000276B 8A07                <1> 	mov	al, [edi]
  4256 0000276D 20E8                <1> 	and	al, ch ; & mask
  4257                              <1> 	; if (data > 0) attr |= (0x01 << i);
  4258 0000276F 08C0                <1> 	or	al, al
  4259 00002771 7408                <1> 	jz	short vga_rp_3 ; al = 0 
  4260 00002773 B701                <1> 	mov	bh, 1
  4261 00002775 D2E7                <1> 	shl	bh, cl ; (0x01 << i)
  4262 00002777 08FB                <1> 	or	bl, bh ; attr |= (0x01 << i)
  4263 00002779 88D8                <1> 	mov	al, bl ; pixel value	
  4264                              <1> vga_rp_3:	
  4265 0000277B C3                  <1> 	retn
  4266                              <1> 
  4267                              <1> vga_write_teletype:
  4268                              <1> 	; 09/07/2016 (TRDOS 386 = TRDOS v2.0)
  4269                              <1> 	;
  4270                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  4271                              <1> 	; vgabios-0.7a (2011)
  4272                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  4273                              <1> 	; 'vgabios.c', 'biosfn_write_teletype'
  4274                              <1> 	; 'biosfn_write_char_only'
  4275                              <1> 
  4276                              <1> 	; INPUT ->
  4277                              <1> 	; [CRT_MODE] = current video mode (>7)
  4278                              <1> 	; AL = Character to write
  4279                              <1> 	; BL = Color of character
  4280                              <1> 	; OUTPUT ->
  4281                              <1> 	; Regen buffer updated
  4282                              <1> 
  4283                              <1> 	; biosfn_write_teletype (car, page, attr, flag) 
  4284                              <1> 	; car = character (AL)
  4285                              <1> 	; page = 0
  4286                              <1> 	; attr = color (BL)
  4287                              <1> 	; 'flag' not used
  4288                              <1> 
  4289 0000277C 8A25[E6E80000]      <1> 	mov 	ah, [CRT_MODE]
  4290 00002782 88C7                <1> 	mov	bh, al ; character
  4291 00002784 668B15[C61F0100]    <1> 	mov	dx, [CURSOR_POSN] ; cursor pos for page 0
  4292                              <1> 
  4293 0000278B BE[02E90000]        <1> 	mov	esi, vga_modes
  4294 00002790 89F7                <1> 	mov	edi, esi
  4295 00002792 83C710              <1> 	add	edi, vga_mode_count
  4296                              <1> vga_wtty_0:
  4297 00002795 AC                  <1> 	lodsb
  4298 00002796 38E0                <1> 	cmp	al, ah ; [CRT_MODE]
  4299 00002798 7405                <1> 	je	short vga_wtty_2
  4300 0000279A 39FE                <1> 	cmp	esi, edi
  4301 0000279C 72F7                <1> 	jb	short vga_wtty_0
  4302                              <1> vga_wtty_1:
  4303 0000279E C3                  <1> 	retn	; nothing to do
  4304                              <1> vga_wtty_2:
  4305 0000279F 80FF07              <1> 	cmp	bh, 07h ; bell (beep)
  4306 000027A2 0F8454F4FFFF        <1> 	je	beeper  ; u11
  4307 000027A8 80FF08              <1> 	cmp	bh, 08h ; backspace
  4308 000027AB 750B                <1> 	jne	short vga_wtty_3
  4309                              <1> 	; if(xcurs>0)xcurs--;
  4310 000027AD 08D2                <1> 	or	dl, dl ; xcurs (column)
  4311 000027AF 74ED                <1> 	jz	short vga_wtty_1
  4312 000027B1 FECA                <1> 	dec	dl ; xcurs--;
  4313 000027B3 E99B000000          <1>         jmp     vga_wtty_12 
  4314                              <1> vga_wtty_3:			
  4315 000027B8 3C0D                <1> 	cmp	al, 0Dh ; carriage return (\r)
  4316 000027BA 7507                <1> 	jne	short vga_wtty_4
  4317                              <1> 	; xcurs=0;
  4318 000027BC 28D2                <1> 	sub	dl, dl ; 0
  4319 000027BE E990000000          <1>         jmp     vga_wtty_12 
  4320                              <1> vga_wtty_4:	
  4321 000027C3 3C0A                <1> 	cmp	al, 0Ah ; new line (\n)
  4322 000027C5 7504                <1> 	jne	short vga_wtty_5
  4323                              <1> 	; ycurs++;
  4324 000027C7 FEC6                <1> 	inc	dh ; next row
  4325 000027C9 EB4D                <1>         jmp     short vga_wtty_10
  4326                              <1> vga_wtty_5:
  4327 000027CB 3C09                <1> 	cmp 	al, 09h ; tab stop
  4328 000027CD 7527                <1> 	jne	short vga_wtty_8
  4329 000027CF 88D0                <1> 	mov	al, dl
  4330 000027D1 6698                <1> 	cbw
  4331 000027D3 B108                <1> 	mov	cl, 8
  4332 000027D5 F6F1                <1> 	div	cl
  4333 000027D7 28E1                <1> 	sub	cl, ah
  4334                              <1> 	;
  4335 000027D9 B720                <1> 	mov	bh, 20h ; space
  4336                              <1> vga_wtty_6: ; tab stop loop
  4337 000027DB 6651                <1> 	push	cx
  4338 000027DD 6653                <1> 	push	bx
  4339 000027DF E812000000          <1> 	call	vga_wtty_8
  4340 000027E4 665B                <1> 	pop	bx  ; bh = character, bl = color
  4341 000027E6 6659                <1> 	pop	cx
  4342 000027E8 FEC9                <1> 	dec	cl
  4343 000027EA 7409                <1> 	jz	short vga_wtty_7
  4344 000027EC 668B15[C61F0100]    <1> 	mov	dx, [CURSOR_POSN] ; new cursor position (pg 0)
  4345 000027F3 EBE6                <1> 	jmp	short vga_wtty_6
  4346                              <1> vga_wtty_7:
  4347 000027F5 C3                  <1> 	retn
  4348                              <1> 	;
  4349                              <1> vga_wtty_8:
  4350 000027F6 83C64F              <1> 	add	esi, vga_memmodel - (vga_modes + 1)  
  4351                              <1> 	; [ESI] = VGA memory model number (LINEAR8, PLANAR4, PLANAR1)
  4352 000027F9 BF00000A00          <1> 	mov	edi, 0A0000h
  4353                              <1> 	;
  4354 000027FE 88F8                <1> 	mov	al, bh ; character
  4355                              <1> 	;
  4356 00002800 803E04              <1> 	cmp	byte [esi], PLANAR4
  4357 00002803 740C                <1> 	je	short vga_wtty_planar
  4358 00002805 803E03              <1> 	cmp	byte [esi], PLANAR1
  4359 00002808 7407                <1> 	je	short vga_wtty_planar
  4360                              <1> vga_wtty_linear8:
  4361                              <1> 	; write_gfx_char_lin(car,attr,xcurs,ycurs,nbcols);
  4362                              <1> 	; AL = car, BL = attr (color), DL = xcurs, DH = ycurs, 
  4363                              <1> 	; [CRT_COLS]= nbcols
  4364 0000280A E827FDFFFF          <1> 	call	write_gfx_char_lin
  4365 0000280F EB05                <1> 	jmp	short vga_wtty_9
  4366                              <1> vga_wtty_planar:
  4367                              <1> 	; write_gfx_char_pl4(car,attr,xcurs,ycurs,nbcols,cheight);
  4368                              <1> 	; AL = car, BL = attr (color), DL = xcurs, DH = ycurs, 
  4369                              <1> 	; [CRT_COLS]= nbcols, [CHAR_HEIGHT] = cheight
  4370 00002811 E88DFDFFFF          <1> 	call	write_gfx_char_pl4
  4371                              <1> vga_wtty_9:
  4372 00002816 FEC2                <1> 	inc	dl ; xcurs++;
  4373                              <1> vga_wtty_10:
  4374                              <1> 	; Do we need to wrap ?
  4375                              <1> 	; if(xcurs==nbcols)
  4376 00002818 3A15[E8E80000]      <1> 	cmp	dl, [CRT_COLS] ; [VGA_COLS]
  4377 0000281E 7233                <1> 	jb	short vga_wtty_12 ; no
  4378 00002820 28D2                <1> 	sub	dl, dl ; xcurs=0;
  4379 00002822 FEC6                <1> 	inc	dh ;  ycurs++;
  4380                              <1> vga_wtty_11:
  4381                              <1> 	; Do we need to scroll ?
  4382                              <1> 	; if(ycurs==nbrows)
  4383 00002824 3A35[EEE80000]      <1> 	cmp	dh, [VGA_ROWS]
  4384 0000282A 7227                <1> 	jb	short vga_wtty_12 ; no
  4385                              <1> 	;
  4386                              <1> 	; biosfn_scroll (nblines,attr,rul,cul,rlr,clr,page,dir)
  4387                              <1> 	; al = nblines = 1, bl = attr (color) = 0
  4388                              <1> 	; ch = rul, cl = cul, dh = rlr, dl = clr, page = 0
  4389                              <1> 	; dir = SCROLL_UP
  4390                              <1> 	
  4391 0000282C B001                <1> 	mov	al, 1
  4392                              <1> 	;sub	bl, bl ; 0 ; blank/black line (attr=0) will be used
  4393 0000282E 6629C9              <1> 	sub	cx, cx
  4394 00002831 8A15[E8E80000]      <1> 	mov	dl, [CRT_COLS]
  4395 00002837 FECA                <1> 	dec	dl ; nbcols -1
  4396 00002839 8A35[EEE80000]      <1> 	mov	dh, [VGA_ROWS]
  4397 0000283F FECE                <1> 	dec	dh ; nbrows -1
  4398                              <1> 
  4399 00002841 8A25[E6E80000]      <1> 	mov	ah, [CRT_MODE]
  4400                              <1> 
  4401                              <1> 	; biosfn_scroll(0x01,0x00,0,0,nbrows-1,nbcols-1,page,SCROLL_UP);
  4402 00002847 E85EF5FFFF          <1> 	call	vga_graphics_up
  4403 0000284C FE0D[C71F0100]      <1> 	dec	byte [CURSOR_POSN+1] ; ycurs-=1;
  4404 00002852 C3                  <1> 	retn
  4405                              <1> 	
  4406                              <1> vga_wtty_12:
  4407                              <1> 	; 09/07/2016
  4408                              <1> 	; set cursor position
  4409                              <1> 	; NOTE: Hardware cursor position will not be set
  4410                              <1> 	;   in any VGA modes (>7)
  4411                              <1> 	;   But, cursor position will be saved into
  4412                              <1> 	;   [CURSOR_POSN].
  4413                              <1> 	;   TRDOS 386 (TRDOS v2.0) uses only one page
  4414                              <1> 	;   (page 0) for all graphics modes.
  4415                              <1> 
  4416 00002853 668915[C61F0100]    <1> 	mov	[CURSOR_POSN], dx ; save cursor pos for pg 0
  4417 0000285A C3                  <1> 	retn
  4418                              <1> 
  4419                              <1> font_setup:
  4420                              <1> 	; 09/07/2016
  4421                              <1> 	; character generator (font loading) functions
  4422                              <1> 	;
  4423                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  4424                              <1> 	; vgabios-0.7a (2011)
  4425                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  4426                              <1> 	; 'vgabios.c', 'int10_func'
  4427                              <1> 
  4428                              <1> 	; AX = 1100H ; Load User-Defined Font (EGA/VGA)
  4429                              <1> 	;
  4430                              <1>         ; BH    height of each character (bytes per character definition)
  4431                              <1>         ; (BL   font block to load (EGA: 0-3; VGA: 0-7))
  4432                              <1> 	; CX    number of characters to redefine (<=256)
  4433                              <1>         ; DX    ASCII code of the first character defined at ES:BP
  4434                              <1>         ; EBP	address of font-definition information
  4435                              <1> 	;	(in user's memory space)
  4436                              <1> 
  4437                              <1> 	; case 0x11:
  4438                              <1>      	; switch(GET_AL())
  4439                              <1>       	; {
  4440                              <1> 	; case 0x00:
  4441                              <1>         ; case 0x10:
  4442                              <1>         ; biosfn_load_text_user_pat(GET_AL(),ES,BP,CX,DX,GET_BL(),GET_BH());
  4443                              <1>         ; break;
  4444                              <1> 
  4445                              <1> 	; AX = 1110H ; Load and Activate User-Defined Font (EGA/VGA)
  4446 0000285B 08C0                <1> 	or	al, al ; 0
  4447 0000285D 7404                <1> 	jz	short font_setup_0
  4448 0000285F 3C10                <1> 	cmp	al, 10h
  4449 00002861 7511                <1> 	jne	short font_setup_1	
  4450                              <1> font_setup_0:
  4451 00002863 E8B7000000          <1> 	call	transfer_user_fonts
  4452 00002868 721C                <1> 	jc	short font_setup_error
  4453 0000286A E8C2000000          <1> 	call	load_text_user_pat
  4454 0000286F E98CEBFFFF          <1>         jmp     VIDEO_RETURN 
  4455                              <1> font_setup_1:
  4456                              <1> 	; AX = 1101H ; Load ROM 8x14 Character Set (EGA/VGA)
  4457                              <1> 	; case 0x01:
  4458                              <1>         ; case 0x11:
  4459                              <1>         ; biosfn_load_text_8_14_pat(GET_AL(),GET_BL());
  4460                              <1>         ; break;
  4461 00002874 3C01                <1> 	cmp	al, 1
  4462 00002876 7404                <1> 	je	short font_setup_2
  4463 00002878 3C11                <1> 	cmp	al, 11h
  4464 0000287A 7511                <1> 	jne	short font_setup_3	
  4465                              <1> font_setup_2:
  4466                              <1> 	; AX = 1111H ; Load and Activate ROM 8x14 Character Set (EGA/VGA)
  4467                              <1> 	; (BL = font block to load (EGA: 0-3; VGA: 0-7))
  4468 0000287C E8EE010000          <1> 	call	load_text_8_14_pat
  4469 00002881 E97AEBFFFF          <1>         jmp     VIDEO_RETURN
  4470                              <1> font_setup_error:
  4471 00002886 29C0                <1> 	sub	eax, eax ; 0 -> fonts could not be loaded
  4472 00002888 E978EBFFFF          <1> 	jmp	_video_return
  4473                              <1> font_setup_3:
  4474                              <1> 	; AX = 1102H ; Load ROM 8x8 Character Set (EGA/VGA)
  4475                              <1> 	; case 0x02:
  4476                              <1>         ; case 0x12:
  4477                              <1>         ; biosfn_load_text_8_8_pat(GET_AL(),GET_BL());
  4478                              <1>         ; break;
  4479 0000288D 3C02                <1> 	cmp	al, 2
  4480 0000288F 7404                <1> 	je	short font_setup_4
  4481 00002891 3C12                <1> 	cmp	al, 12h
  4482 00002893 750A                <1> 	jne	short font_setup_5	
  4483                              <1> font_setup_4:
  4484                              <1> 	; AX = 1112H ; Load and Activate ROM 8x8 Character Set (EGA/VGA)
  4485                              <1> 	; (BL = font block to load (EGA: 0-3; VGA: 0-7))
  4486 00002895 E805020000          <1> 	call	load_text_8_8_pat
  4487 0000289A E961EBFFFF          <1>         jmp     VIDEO_RETURN
  4488                              <1> font_setup_5:
  4489                              <1> 	; AX = 1104H ; Load ROM 8x16 Character Set (EGA/VGA)
  4490                              <1> 	; case 0x04:
  4491                              <1>         ; case 0x14:
  4492                              <1>         ; biosfn_load_text_8_16_pat(GET_AL(),GET_BL());
  4493                              <1>         ; break;
  4494 0000289F 3C04                <1> 	cmp	al, 4
  4495 000028A1 7404                <1> 	je	short font_setup_6
  4496 000028A3 3C14                <1> 	cmp	al, 14h
  4497 000028A5 750A                <1> 	jne	short font_setup_7	
  4498                              <1> font_setup_6:
  4499                              <1> 	; AX = 1114H ; Load and Activate ROM 8x16 Character Set (EGA/VGA)
  4500                              <1> 	; (BL = font block to load (EGA: 0-3; VGA: 0-7))
  4501 000028A7 E823020000          <1> 	call	load_text_8_16_pat
  4502 000028AC E94FEBFFFF          <1>         jmp     VIDEO_RETURN
  4503                              <1> font_setup_7:
  4504                              <1> 	; Note: AX=1120h (Setup INT 1Fh, EXT_PTR) is not needed
  4505                              <1> 	; for TRDOS 386 (TRDIOS v2.0) video functionality;
  4506                              <1> 	; because, originally EXT_PTR (font address) was used for
  4507                              <1> 	; chars 80h to 0FFh (after the first 128 ASCII char fonts), for
  4508                              <1> 	; CGA graphics mode; currenty, 'vgafont8' address has 256 chars!
  4509                              <1> 	; 
  4510                              <1> 	; case 0x20:
  4511                              <1>         ; biosfn_load_gfx_8_8_chars(ES,BP);
  4512                              <1>         ; break; 
  4513                              <1> 	; case 0x21:
  4514                              <1>         ; biosfn_load_gfx_user_chars(ES,BP,CX,GET_BL(),GET_DL());
  4515                              <1>         ; break;
  4516                              <1> 	; AX = 1121H ; Setup User-Defined Font for Graphics Mode (VGA)
  4517                              <1> 	; BL   screen rows code: 00H = user-specified (in DL)
  4518                              <1>         ;                        01H = 14 rows
  4519                              <1>         ;                        02H = 25 rows
  4520                              <1>         ;                        03H = 43 rows
  4521                              <1>         ; CX   bytes per character definition
  4522                              <1>         ; DL   (when BL=0) custom number of character rows on screen
  4523                              <1>         ; EBP  address of font-definition information (user's mem space)
  4524                              <1> 
  4525 000028B1 3C21                <1> 	cmp	al, 21h
  4526 000028B3 751A                <1> 	jne	short font_setup_9
  4527                              <1> 
  4528                              <1> 	; TRDOS 386 modification !
  4529                              <1> 	; dh = 0 -> 256 characters
  4530                              <1> 	; dh = 80h -> 128 characters
  4531                              <1> 	; (If DH <> 0 and DH <> 80h -> invalid)     
  4532 000028B5 20F6                <1> 	and	dh, dh
  4533 000028B7 7405                <1> 	jz	short font_setup_8 ; 256 characters
  4534 000028B9 80FE80              <1> 	cmp	dh, 80h ; 128 characters
  4535 000028BC 75C8                <1> 	jne	short font_setup_error ; invalid !
  4536                              <1> font_setup_8:
  4537 000028BE E85C000000          <1> 	call	transfer_user_fonts
  4538 000028C3 72C1                <1> 	jc	short font_setup_error
  4539                              <1> 	; ebp = user's font data address in system's memory space
  4540 000028C5 E836020000          <1> 	call	load_gfx_user_chars
  4541 000028CA E931EBFFFF          <1>         jmp     VIDEO_RETURN 
  4542                              <1> font_setup_9:
  4543                              <1> 	; case 0x22:
  4544                              <1>         ; biosfn_load_gfx_8_14_chars(GET_BL());
  4545                              <1>         ; break;
  4546 000028CF 3C22                <1> 	cmp	al, 22h
  4547 000028D1 750A                <1> 	jne	short font_setup_10
  4548 000028D3 E87E020000          <1> 	call	load_gfx_8_14_chars	
  4549 000028D8 E923EBFFFF          <1>         jmp     VIDEO_RETURN 
  4550                              <1> font_setup_10:	
  4551                              <1> 	; case 0x23:
  4552                              <1>         ; biosfn_load_gfx_8_8_dd_chars(GET_BL());
  4553                              <1>         ; break;
  4554 000028DD 3C23                <1> 	cmp	al, 23h
  4555 000028DF 750A                <1> 	jne	short font_setup_11
  4556 000028E1 E8B8020000          <1> 	call	load_gfx_8_8_chars	
  4557 000028E6 E915EBFFFF          <1>         jmp     VIDEO_RETURN 
  4558                              <1> font_setup_11:	
  4559                              <1> 	; case 0x24:
  4560                              <1>         ; biosfn_load_gfx_8_16_chars(GET_BL());
  4561                              <1>         ; break;
  4562 000028EB 3C24                <1> 	cmp	al, 24h
  4563 000028ED 750A                <1> 	jne	short font_setup_12
  4564 000028EF E8F2020000          <1> 	call	load_gfx_8_16_chars	
  4565 000028F4 E907EBFFFF          <1>         jmp     VIDEO_RETURN 
  4566                              <1> font_setup_12:
  4567                              <1>  	; case 0x30:
  4568                              <1>         ; biosfn_get_font_info(GET_BH(),&ES,&BP,&CX,&DX);
  4569                              <1>         ; break;
  4570 000028F9 3C30                <1> 	cmp	al, 30h
  4571 000028FB 750A                <1> 	jne	short font_setup_13			
  4572 000028FD E82C030000          <1> 	call	get_font_info
  4573                              <1> 	; eax = return value (info: 4 bytes for 4 parms)
  4574                              <1> 	; eax = 0 -> invalid function (input)
  4575 00002902 E9FEEAFFFF          <1>         jmp     _video_return
  4576                              <1> font_setup_13:
  4577 00002907 3C03                <1> 	cmp	al, 03h ; AX = 1103h	
  4578 00002909 750D                <1> 	jne	short font_setup_14
  4579                              <1> 	; biosfn_set_text_block_specifier:
  4580                              <1> 	; BL = font block selector code	
  4581                              <1> 	; NOTE: TRDOS 386 only uses and sets font block 0
  4582                              <1> 	; (It is as BL = 0 for TRDOS 386)
  4583 0000290B 66BAC403            <1> 	mov	dx, 3C4h ; VGAREG_SEQU_ADDRESS
  4584                              <1> 	;mov	ah, bl
  4585 0000290F 28E4                <1> 	sub	ah, ah ; 0
  4586                              <1> 	;mov	al, 03h
  4587 00002911 66EF                <1> 	out	dx, ax
  4588 00002913 E9E8EAFFFF          <1> 	jmp     VIDEO_RETURN 
  4589                              <1> 	
  4590                              <1> font_setup_14:
  4591 00002918 29C0                <1> 	sub	eax, eax ; 0 = invalid function
  4592 0000291A E9E6EAFFFF          <1>         jmp     _video_return
  4593                              <1> 
  4594                              <1> transfer_user_fonts:
  4595                              <1> 	; 09/07/2016
  4596                              <1> 	;and	ecx, 0FFFFh
  4597                              <1> 	; ECX = byte count
  4598                              <1> 	;push	ecx
  4599 0000291F 89EE                <1> 	mov	esi, ebp ; user buffer
  4600 00002921 BF00000700          <1> 	mov	edi, Cluster_Buffer  ; system buffer
  4601 00002926 E86FB00000          <1> 	call	transfer_from_user_buffer
  4602                              <1> 	;pop	ecx
  4603                              <1> 	; ecx = transfer (byte) count = character count
  4604 0000292B BD00000700          <1> 	mov	ebp, Cluster_Buffer
  4605                              <1> 	; jc	VIDEO_RETURN -> failed
  4606 00002930 C3                  <1> 	retn
  4607                              <1> 
  4608                              <1> load_text_user_pat:
  4609                              <1> 	; 26/07/2016
  4610                              <1> 	; 09/07/2016
  4611                              <1> 	; load user defined (EGA/VGA) text fonts
  4612                              <1> 	;
  4613                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  4614                              <1> 	; vgabios-0.7a (2011)
  4615                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  4616                              <1> 	; 'vgabios.c', 'biosfn_load_text_user_pat'
  4617                              <1> 
  4618                              <1> 	; biosfn_load_text_user_pat (AL,ES,BP,CX,DX,BL,BH)
  4619                              <1> 
  4620                              <1> 	; get_font_access();
  4621                              <1> 	; blockaddr = ((BL & 0x03) << 14) + ((BL & 0x04) << 11);
  4622                              <1> 	; for(i=0;i<CX;i++)
  4623                              <1> 	; {
  4624                              <1> 	;  src = BP + i * BH;
  4625                              <1> 	;  dest = blockaddr + (DX + i) * 32;
  4626                              <1> 	;  memcpyb(0xA000, dest, ES, src, BH);
  4627                              <1> 	; }
  4628                              <1> 	; release_font_access();
  4629                              <1> 	; if(AL>=0x10)
  4630                              <1> 	; {
  4631                              <1> 	; set_scan_lines(BH);
  4632                              <1> 	; }
  4633                              <1> 
  4634 00002931 50                  <1> 	push	eax
  4635 00002932 E83C000000          <1> 	call	get_font_access
  4636 00002937 28DB                <1> 	sub	bl, bl ; i = 0	
  4637                              <1> ltup_1:
  4638 00002939 88D8                <1> 	mov	al, bl
  4639 0000293B F6E7                <1> 	mul	bh
  4640 0000293D 0FB7F0              <1> 	movzx	esi, ax
  4641 00002940 01EE                <1> 	add	esi, ebp
  4642 00002942 88D8                <1> 	mov	al, bl
  4643 00002944 28E4                <1> 	sub	ah, ah
  4644 00002946 6601D0              <1> 	add	ax, dx ; (DX + i)
  4645 00002949 66C1E005            <1> 	shl	ax, 5  ; * 32
  4646 0000294D 0FB7F8              <1> 	movzx	edi, ax
  4647 00002950 81C700000A00        <1> 	add	edi, 0A0000h
  4648 00002956 51                  <1> 	push	ecx
  4649 00002957 0FB6CF              <1> 	movzx	ecx, bh 		
  4650 0000295A F3A4                <1> 	rep	movsb
  4651 0000295C 59                  <1> 	pop	ecx	
  4652 0000295D FEC3                <1> 	inc	bl
  4653 0000295F 38CB                <1> 	cmp	bl, cl
  4654 00002961 75D6                <1> 	jne	short ltup_1	
  4655                              <1> 	;
  4656 00002963 E840000000          <1> 	call	release_font_access
  4657                              <1> 	;
  4658 00002968 58                  <1> 	pop	eax
  4659                              <1> 	; if(AL>=0x10)
  4660 00002969 3C10                <1> 	cmp	al, 10h
  4661 0000296B 7205                <1> 	jb	short ltup_2
  4662                              <1>    	; set_scan_lines(BH);
  4663 0000296D E875000000          <1> 	call	set_scan_lines
  4664                              <1> ltup_2:
  4665 00002972 C3                  <1> 	retn
  4666                              <1> 
  4667                              <1> get_font_access:
  4668                              <1> 	; 09/07/2016
  4669                              <1> 	;
  4670                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  4671                              <1> 	; vgabios-0.7a (2011)
  4672                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  4673                              <1> 	; 'vgabios.c', 'get_font_access'
  4674                              <1> 
  4675                              <1> 	; get_font_access()
  4676 00002973 52                  <1> 	push	edx
  4677 00002974 66BAC403            <1> 	mov	dx, 3C4h ; VGAREG_SEQU_ADDRESS
  4678 00002978 66B80001            <1> 	mov	ax, 0100h
  4679 0000297C 66EF                <1> 	out	dx, ax
  4680 0000297E 66B80204            <1> 	mov	ax, 0402h
  4681 00002982 66EF                <1> 	out	dx, ax
  4682 00002984 66B80407            <1> 	mov	ax, 0704h
  4683 00002988 66EF                <1> 	out	dx, ax
  4684 0000298A 66B80003            <1> 	mov	ax, 0300h
  4685 0000298E 66EF                <1> 	out	dx, ax
  4686 00002990 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  4687 00002994 66B80402            <1> 	mov	ax, 0204h
  4688 00002998 66EF                <1> 	out	dx, ax
  4689 0000299A 66B80500            <1> 	mov	ax, 0005h
  4690 0000299E 66EF                <1> 	out	dx, ax
  4691 000029A0 66B80604            <1> 	mov	ax, 0406h
  4692 000029A4 66EF                <1> 	out	dx, ax
  4693 000029A6 5A                  <1> 	pop	edx
  4694 000029A7 C3                  <1> 	retn
  4695                              <1> 
  4696                              <1> release_font_access:
  4697                              <1> 	; 29/07/2016
  4698                              <1> 	; 09/07/2016
  4699                              <1> 	;
  4700                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  4701                              <1> 	; vgabios-0.7a (2011)
  4702                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  4703                              <1> 	; 'vgabios.c', 'release_font_access'
  4704                              <1> 
  4705 000029A8 66BAC403            <1> 	mov	dx, 3C4h ; VGAREG_SEQU_ADDRESS
  4706 000029AC 66B80001            <1> 	mov	ax, 0100h
  4707 000029B0 66EF                <1> 	out	dx, ax
  4708 000029B2 66B80203            <1> 	mov	ax, 0302h
  4709 000029B6 66EF                <1> 	out	dx, ax
  4710 000029B8 66B80403            <1> 	mov	ax, 0304h
  4711 000029BC 66EF                <1> 	out	dx, ax
  4712 000029BE 66B80003            <1> 	mov	ax, 0300h
  4713 000029C2 66EF                <1> 	out	dx, ax
  4714 000029C4 66BACC03            <1> 	mov	dx, 3CCh ; VGAREG_READ_MISC_OUTPUT
  4715 000029C8 EC                  <1>  	in	al, dx
  4716 000029C9 2401                <1> 	and	al, 01h
  4717 000029CB C0E002              <1> 	shl	al, 2
  4718 000029CE 0C0A                <1> 	or	al, 0Ah
  4719 000029D0 88C4                <1> 	mov	ah, al
  4720 000029D2 B006                <1> 	mov	al, 06h
  4721 000029D4 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  4722 000029D8 66EF                <1> 	out	dx, ax
  4723 000029DA 66B80400            <1> 	mov	ax, 0004h
  4724 000029DE 66EF                <1> 	out	dx, ax
  4725 000029E0 66B80510            <1> 	mov	ax, 1005h
  4726 000029E4 66EF                <1> 	out	dx, ax
  4727 000029E6 C3                  <1> 	retn
  4728                              <1> 
  4729                              <1> set_scan_lines:
  4730                              <1> 	; 09/07/2016
  4731                              <1> 	;
  4732                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  4733                              <1> 	; vgabios-0.7a (2011)
  4734                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  4735                              <1> 	; 'vgabios.c', 'set_scan_lines'
  4736                              <1> 
  4737                              <1> 	; set_scan_lines(lines)
  4738                              <1> 	; BH = lines
  4739                              <1> 
  4740                              <1> 	; outb(crtc_addr, 0x09);
  4741 000029E7 66BAD403            <1> 	mov	dx, 3D4h ; CRTC_ADDRESS = 3D4h (always)
  4742 000029EB B009                <1> 	mov	al, 09h
  4743 000029ED EE                  <1> 	out	dx, al
  4744                              <1> 	; crtc_r9 = inb(crtc_addr+1);
  4745 000029EE 6642                <1> 	inc	dx ; 3D5h
  4746 000029F0 EC                  <1> 	in	al, dx
  4747                              <1> 	; crtc_r9 = (crtc_r9 & 0xe0) | (lines - 1);
  4748 000029F1 24E0                <1> 	and	al, 0E0h
  4749 000029F3 FECF                <1> 	dec	bh ; lines - 1
  4750 000029F5 08F8                <1> 	or	al, bh
  4751                              <1> 	; outb(crtc_addr+1, crtc_r9);
  4752 000029F7 EE                  <1> 	out	dx, al
  4753                              <1> 	;inc	bh 
  4754                              <1> 	; if(lines==8)
  4755                              <1> 	;cmp	bh, 8
  4756 000029F8 80FF07              <1> 	cmp	bh, 7
  4757 000029FB 7506                <1> 	jne	short ssl_1
  4758                              <1> 	; biosfn_set_cursor_shape(0x06,0x07);
  4759 000029FD 66B90706            <1> 	mov	cx, 0607h
  4760 00002A01 EB06                <1> 	jmp	short ssl_2
  4761                              <1> ssl_1:
  4762                              <1> 	; biosfn_set_cursor_shape(lines-4,lines-3);
  4763 00002A03 88F9                <1> 	mov	cl, bh ; lines - 1
  4764 00002A05 88CD                <1> 	mov	ch, cl ; lines - 1 (16 -> 15)
  4765 00002A07 FECD                <1> 	dec	ch  ; lines - 2 (16 -> 14)
  4766                              <1> ssl_2:
  4767                              <1> 	; CH = start line, CL = stop line
  4768 00002A09 B40A                <1> 	mov	ah, 10	; 6845 register for cursor set
  4769 00002A0B 66890D[FFE80000]    <1> 	mov	[CURSOR_MODE], cx ; save in data area
  4770 00002A12 E8C6F1FFFF          <1> 	call	m16	; output cx register
  4771                              <1> 	; write_word(BIOSMEM_SEG,BIOSMEM_CHAR_HEIGHT, lines);
  4772 00002A17 FEC7                <1> 	inc	bh ; lines
  4773 00002A19 883D[EAE80000]      <1> 	mov	[CHAR_HEIGHT], bh
  4774                              <1> 	;  outb(crtc_addr, 0x12);
  4775 00002A1F 66BAD403            <1> 	mov	dx, 3D4h ; CRTC_ADDRESS
  4776 00002A23 B012                <1> 	mov	al, 12h
  4777 00002A25 EE                  <1> 	out	dx, al
  4778                              <1> 	; vde = inb(crtc_addr+1);
  4779 00002A26 6642                <1> 	inc	dx
  4780 00002A28 EC                  <1> 	in	al, dx
  4781 00002A29 88C4                <1> 	mov	ah, al
  4782                              <1> 	; outb(crtc_addr, 0x07);
  4783 00002A2B 664A                <1> 	dec	dx
  4784 00002A2D B007                <1> 	mov	al, 07h
  4785 00002A2F EE                  <1> 	out	dx, al
  4786                              <1> 	; ovl = inb(crtc_addr+1);
  4787 00002A30 6642                <1> 	inc	dx
  4788 00002A32 EC                  <1> 	in	al, dx
  4789                              <1> 	; vde += (((ovl & 0x02) << 7) + ((ovl & 0x40) << 3) + 1);
  4790 00002A33 88E2                <1> 	mov	dl, ah ; vde
  4791 00002A35 88C6                <1> 	mov	dh, al ; ovl
  4792 00002A37 6683E002            <1> 	and	ax, 02h
  4793 00002A3B 66C1E007            <1> 	shl	ax, 7
  4794 00002A3F 6689C1              <1> 	mov	cx, ax ; (ovl & 0x02) << 7)	
  4795 00002A42 88F0                <1> 	mov	al, dh ; ovl
  4796 00002A44 6683E040            <1> 	and	ax, 40h			
  4797 00002A48 66C1E003            <1> 	shl	ax, 3  ; (ovl & 0x40) << 3)
  4798 00002A4C 6640                <1> 	inc	ax ; + 1 
  4799 00002A4E 6601C8              <1> 	add	ax, cx
  4800 00002A51 30F6                <1> 	xor	dh, dh
  4801 00002A53 6601D0              <1> 	add	ax, dx ; + vde
  4802                              <1> 	; rows = vde / lines;
  4803 00002A56 F6F7                <1> 	div	bh
  4804                              <1> 	;dec	al ; rows -1
  4805                              <1> 	; write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, rows-1);
  4806 00002A58 A2[EEE80000]        <1> 	mov	[VGA_ROWS], al ; rows (not 'rows-1' !)
  4807                              <1> 	; write_word(BIOSMEM_SEG,BIOSMEM_PAGE_SIZE, rows * cols * 2);
  4808 00002A5D 8A25[E8E80000]      <1> 	mov	ah, [CRT_COLS]
  4809 00002A63 F6E4                <1> 	mul	ah
  4810 00002A65 66D1E0              <1> 	shl	ax, 1
  4811 00002A68 66A3[342D0100]      <1> 	mov 	[CRT_LEN], ax	
  4812 00002A6E C3                  <1> 	retn
  4813                              <1> 
  4814                              <1> load_text_8_14_pat:
  4815                              <1> 	; 26/07/2016
  4816                              <1> 	; 25/07/2016
  4817                              <1> 	; 23/07/2016
  4818                              <1> 	; 09/07/2016
  4819                              <1> 	; load user defined (EGA/VGA) text fonts
  4820                              <1> 	;
  4821                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  4822                              <1> 	; vgabios-0.7a (2011)
  4823                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  4824                              <1> 	; 'vgabios.c', 'biosfn_load_text_8_14_pat'
  4825                              <1> 
  4826                              <1> 	; biosfn_load_text_8_14_pat (AL,BL)
  4827                              <1> 
  4828                              <1> 	; get_font_access();
  4829                              <1> 	; blockaddr = ((BL & 0x03) << 14) + ((BL & 0x04) << 11);
  4830                              <1> 	; for(i=0;i<0x100;i++)
  4831                              <1> 	; {
  4832                              <1> 	;  src = i * 14;
  4833                              <1> 	;  dest = blockaddr + i * 32;
  4834                              <1> 	;  memcpyb(0xA000, dest, 0xC000, vgafont14+src, 14);
  4835                              <1> 	; }
  4836                              <1> 	; release_font_access();
  4837                              <1> 	; if(AL>=0x10)
  4838                              <1> 	; {
  4839                              <1> 	; set_scan_lines(14);
  4840                              <1> 	; }
  4841                              <1> 
  4842 00002A6F 50                  <1> 	push	eax
  4843 00002A70 E8FEFEFFFF          <1> 	call	get_font_access
  4844                              <1> 
  4845                              <1> 	; blockaddr = ((BL & 0x03) << 14) + ((BL & 0x04) << 11);
  4846                              <1> 	;mov	dl, bl
  4847                              <1> 	;and	dl, 3
  4848                              <1> 	;shl	dx, 14
  4849                              <1> 	;xchg	dx, bx
  4850                              <1> 	;and	dl, 4
  4851                              <1> 	;shl	dx, 11
  4852                              <1> 	;add	dx, bx 	
  4853                              <1>  
  4854                              <1> 	;xor	dx, dx  ; blockaddr = 0
  4855                              <1> 	; Always block 0 for TRDOS 386 ! (blockaddr=0(
  4856                              <1> 
  4857 00002A75 28DB                <1> 	sub	bl, bl ; i = 0
  4858 00002A77 B70E                <1> 	mov	bh, 14
  4859 00002A79 BE[40FC0000]        <1> 	mov	esi, vgafont14
  4860 00002A7E BF00000A00          <1> 	mov	edi, 0A0000h		
  4861                              <1> lt8_14_1:
  4862                              <1> 	;mov	al, bl
  4863                              <1> 	;mul	bh
  4864                              <1> 	;movzx	esi, ax
  4865                              <1> 	;add	esi, vgafont14
  4866                              <1> 	;mov	al, bl
  4867                              <1> 	;sub	ah, ah
  4868                              <1> 	;shl	ax, 5 ; * 32
  4869                              <1> 	;;add	ax, dx ; blockaddr + i * 32;
  4870                              <1> 	;movzx	edi, ax ; dest
  4871                              <1> 	;add	edi, 0A0000h
  4872 00002A83 0FB6CF              <1> 	movzx	ecx, bh 		
  4873 00002A86 F3A4                <1> 	rep	movsb
  4874 00002A88 83C712              <1> 	add	edi, 18 ; 32 - 14
  4875 00002A8B FEC3                <1> 	inc	bl
  4876 00002A8D 75F4                <1> 	jnz	short lt8_14_1	
  4877                              <1> 	;
  4878 00002A8F E814FFFFFF          <1> 	call	release_font_access
  4879                              <1> 	;
  4880 00002A94 58                  <1> 	pop	eax
  4881                              <1> 	; if(AL>=0x10)
  4882 00002A95 3C10                <1> 	cmp	al, 10h
  4883 00002A97 7205                <1> 	jb	short lt8_14_4
  4884                              <1> 	; BH = 14
  4885                              <1>    	; set_scan_lines(14);
  4886 00002A99 E849FFFFFF          <1> 	call	set_scan_lines
  4887                              <1> lt8_14_4:
  4888 00002A9E C3                  <1> 	retn
  4889                              <1> 
  4890                              <1> load_text_8_8_pat:
  4891                              <1> 	; 26/07/2016
  4892                              <1> 	; 25/07/2016
  4893                              <1> 	; 23/07/2016
  4894                              <1> 	; 09/07/2016
  4895                              <1> 	; load user defined (EGA/VGA) text fonts
  4896                              <1> 	;
  4897                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  4898                              <1> 	; vgabios-0.7a (2011)
  4899                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  4900                              <1> 	; 'vgabios.c', 'biosfn_load_text_8_8_pat'
  4901                              <1> 
  4902                              <1> 	; biosfn_load_text_8_8_pat (AL,BL)
  4903                              <1> 
  4904                              <1> 	; get_font_access();
  4905                              <1> 	; blockaddr = ((BL & 0x03) << 14) + ((BL & 0x04) << 11);
  4906                              <1> 	; for(i=0;i<0x100;i++)
  4907                              <1> 	; {
  4908                              <1> 	;  src = i * 8;
  4909                              <1> 	;  dest = blockaddr + i * 32;
  4910                              <1> 	;  memcpyb(0xA000, dest, 0xC000, vgafont8+src, 8);
  4911                              <1> 	; }
  4912                              <1> 	; release_font_access();
  4913                              <1> 	; if(AL>=0x10)
  4914                              <1> 	; {
  4915                              <1> 	; set_scan_lines(8);
  4916                              <1> 	; }
  4917                              <1> 
  4918 00002A9F 50                  <1> 	push	eax
  4919 00002AA0 E8CEFEFFFF          <1> 	call	get_font_access
  4920                              <1> 
  4921                              <1> 	; blockaddr = ((BL & 0x03) << 14) + ((BL & 0x04) << 11);
  4922                              <1> 	;mov	dl, bl
  4923                              <1> 	;and	dl, 3
  4924                              <1> 	;shl	dx, 14
  4925                              <1> 	;xchg	dx, bx
  4926                              <1> 	;and	dl, 4
  4927                              <1> 	;shl	dx, 11
  4928                              <1> 	;add	dx, bx 	
  4929                              <1>  
  4930                              <1> 	;xor	dx, dx  ; blockaddr = 0
  4931                              <1> 	; Always block 0 for TRDOS 386 ! (blockaddr=0(
  4932                              <1> 
  4933 00002AA5 28DB                <1> 	sub	bl, bl ; i = 0
  4934 00002AA7 B708                <1> 	mov	bh, 8
  4935 00002AA9 BE[40F40000]        <1> 	mov	esi, vgafont8
  4936 00002AAE BF00000A00          <1> 	mov	edi, 0A0000h		
  4937                              <1> lt8_8_1:
  4938                              <1> 	;mov	al, bl
  4939                              <1> 	;mul	bh
  4940                              <1> 	;movzx	esi, ax
  4941                              <1> 	;add	esi, vgafont8
  4942                              <1> 	;mov	al, bl
  4943                              <1> 	;sub	ah, ah
  4944                              <1> 	;shl	ax, 5 ; * 32
  4945                              <1> 	;;add	ax, dx ; blockaddr + i * 32;
  4946                              <1> 	;movzx	edi, ax ; dest
  4947                              <1> 	;add	edi, 0A0000h
  4948 00002AB3 0FB6CF              <1> 	movzx	ecx, bh 		
  4949 00002AB6 F3A4                <1> 	rep	movsb
  4950 00002AB8 83C718              <1> 	add	edi, 24 ; 32 - 8
  4951 00002ABB FEC3                <1> 	inc	bl
  4952 00002ABD 75F4                <1> 	jnz	short lt8_8_1	
  4953                              <1> 	;
  4954 00002ABF E8E4FEFFFF          <1> 	call	release_font_access
  4955                              <1> 	;
  4956 00002AC4 58                  <1> 	pop	eax
  4957                              <1> 	; if(AL>=0x10)
  4958 00002AC5 3C10                <1> 	cmp	al, 10h
  4959 00002AC7 7205                <1> 	jb	short lt8_8_2
  4960                              <1> 	; BH = 8
  4961                              <1>    	; set_scan_lines(8);
  4962 00002AC9 E819FFFFFF          <1> 	call	set_scan_lines
  4963                              <1> lt8_8_2:
  4964 00002ACE C3                  <1> 	retn
  4965                              <1> 
  4966                              <1> load_text_8_16_pat:
  4967                              <1> 	; 26/07/2016
  4968                              <1> 	; 25/07/2016
  4969                              <1> 	; 23/07/2016
  4970                              <1> 	; 09/07/2016
  4971                              <1> 	; load user defined (EGA/VGA) text fonts
  4972                              <1> 	;
  4973                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  4974                              <1> 	; vgabios-0.7a (2011)
  4975                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  4976                              <1> 	; 'vgabios.c', 'biosfn_load_text_8_16_pat'
  4977                              <1> 
  4978                              <1> 	; biosfn_load_text_8_16_pat (AL,BL)
  4979                              <1> 
  4980                              <1> 	; get_font_access();
  4981                              <1> 	; blockaddr = ((BL & 0x03) << 14) + ((BL & 0x04) << 11);
  4982                              <1> 	; for(i=0;i<0x100;i++)
  4983                              <1> 	; {
  4984                              <1> 	;  src = i * 16;
  4985                              <1> 	;  dest = blockaddr + i * 32;
  4986                              <1> 	;  memcpyb(0xA000, dest, 0xC000, vgafont16+src, 16);
  4987                              <1> 	; }
  4988                              <1> 	; release_font_access();
  4989                              <1> 	; if(AL>=0x10)
  4990                              <1> 	; {
  4991                              <1> 	; set_scan_lines(16);
  4992                              <1> 	; }
  4993                              <1> 
  4994 00002ACF 50                  <1> 	push	eax
  4995 00002AD0 E89EFEFFFF          <1> 	call	get_font_access
  4996                              <1> 
  4997                              <1> 	; blockaddr = ((BL & 0x03) << 14) + ((BL & 0x04) << 11);
  4998                              <1> 	;mov	dl, bl
  4999                              <1> 	;and	dl, 3
  5000                              <1> 	;shl	dx, 14
  5001                              <1> 	;xchg	dx, bx
  5002                              <1> 	;and	dl, 4
  5003                              <1> 	;shl	dx, 11
  5004                              <1> 	;add	dx, bx 	
  5005                              <1>  
  5006                              <1> 	;xor	dx, dx  ; blockaddr = 0
  5007                              <1> 	; Always block 0 for TRDOS 386 ! (blockaddr=0(
  5008                              <1> 
  5009 00002AD5 28DB                <1> 	sub	bl, bl ; i = 0
  5010 00002AD7 B710                <1> 	mov	bh, 16
  5011 00002AD9 BE[400A0100]        <1> 	mov	esi, vgafont16
  5012 00002ADE BF00000A00          <1> 	mov	edi, 0A0000h
  5013 00002AE3 0FB6C7              <1> 	movzx	eax, bh	
  5014                              <1> lt8_16_1:
  5015                              <1> 	;mov	al, bl
  5016                              <1> 	;mul	bh
  5017                              <1> 	;movzx	esi, ax
  5018                              <1> 	;add	esi, vgafont16
  5019                              <1> 	;mov	al, bl ; i
  5020                              <1> 	;sub	ah, ah
  5021                              <1> 	;shl	ax, 5 ; * 32
  5022                              <1> 	;;add	ax, dx ; blockaddr + i * 32;
  5023                              <1> 	;movzx	edi, ax ; dest
  5024                              <1> 	;add	edi, 0A0000h
  5025                              <1> 	;movzx	ecx, bh
  5026 00002AE6 89C1                <1> 	mov	ecx, eax ; 16	
  5027 00002AE8 F3A4                <1> 	rep	movsb
  5028 00002AEA 01C7                <1> 	add	edi, eax ; add edi, 16
  5029 00002AEC FEC3                <1> 	inc	bl
  5030 00002AEE 75F6                <1> 	jnz	short lt8_16_1
  5031                              <1> 	;
  5032 00002AF0 E8B3FEFFFF          <1> 	call	release_font_access
  5033                              <1> 	;
  5034 00002AF5 58                  <1> 	pop	eax
  5035                              <1> 	; if(AL>=0x10)
  5036 00002AF6 3C10                <1> 	cmp	al, 10h
  5037 00002AF8 7205                <1> 	jb	short lt8_16_2
  5038                              <1> 	; BH = 16
  5039                              <1>    	; set_scan_lines(16);
  5040 00002AFA E8E8FEFFFF          <1> 	call	set_scan_lines
  5041                              <1> lt8_16_2:
  5042 00002AFF C3                  <1> 	retn
  5043                              <1> 
  5044                              <1> load_gfx_user_chars:
  5045                              <1> 	; 10/07/2016
  5046                              <1> 	; Setup User-Defined Font for Graphics Mode (VGA)
  5047                              <1> 	;
  5048                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  5049                              <1> 	; vgabios-0.7a (2011)
  5050                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  5051                              <1> 	; 'vgabios.c', 'biosfn_load_gfx_user_chars'
  5052                              <1> 
  5053                              <1> 	; biosfn_load_gfx_user_chars (ES,BP,CX,BL,DL)
  5054                              <1> 	; /* set 0x43 INT pointer */
  5055                              <1>     	; write_word(0x0, 0x43*4, BP);
  5056                              <1>     	; write_word(0x0, 0x43*4+2, ES);
  5057 00002B00 31C0                <1> 	xor	eax, eax
  5058 00002B02 48                  <1> 	dec	eax ; 0FFFFFFFFh (user defined fonts)
  5059 00002B03 A3[462D0100]        <1> 	mov	[VGA_INT43H], eax
  5060                              <1> 		
  5061                              <1> 	; BL   screen rows code: 00H = user-specified (in DL)
  5062                              <1>         ;                        01H = 14 rows
  5063                              <1>         ;                        02H = 25 rows
  5064                              <1>         ;                        03H = 43 rows
  5065                              <1>         ; CX   bytes per character definition
  5066                              <1>         ; DL   (when BL=0) custom number of character rows on screen
  5067                              <1> 	; dh = 0 -> 256 characters
  5068                              <1> 	; dh = 80h -> 128 characters
  5069                              <1> 	; (If DH <> 0 and DH <> 80h -> invalid)     	 
  5070                              <1>         ; EBP  address of font-definition information (user's mem space)
  5071                              <1> 
  5072                              <1> 	; switch (BL) {
  5073                              <1> 	; case 0:
  5074                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, DL-1);
  5075                              <1> 	;    break;
  5076 00002B08 20DB                <1> 	and	bl, bl
  5077 00002B0A 7508                <1> 	jnz	short l_gfx_uc_1
  5078 00002B0C 8815[EEE80000]      <1> 	mov	[VGA_ROWS], dl  ; not DL-1 !
  5079 00002B12 EB23                <1> 	jmp	short l_gfx_uc_4 	
  5080                              <1> l_gfx_uc_1:
  5081                              <1> 	; case 1:
  5082                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 13);
  5083                              <1> 	;    break;
  5084 00002B14 FECB                <1> 	dec	bl
  5085 00002B16 7509                <1> 	jnz	short l_gfx_uc_2
  5086                              <1> 	; bl = 1
  5087 00002B18 C605[EEE80000]0E    <1> 	mov	byte [VGA_ROWS], 14  ; not 13 !
  5088 00002B1F EB16                <1> 	jmp	short l_gfx_uc_4 	
  5089                              <1> l_gfx_uc_2:
  5090 00002B21 FECB                <1> 	dec	bl
  5091 00002B23 740B                <1> 	jz	short l_gfx_uc_3 ; bl = 2
  5092 00002B25 FECB                <1> 	dec	bl
  5093 00002B27 750E                <1> 	jnz	short l_gfx_uc_4 ; bl > 3
  5094                              <1> 	; bl = 3
  5095                              <1> 	; case 3:
  5096                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 42);
  5097                              <1> 	;    break;
  5098 00002B29 C605[EEE80000]2B    <1> 	mov	byte [VGA_ROWS], 43  ; not 42 !
  5099                              <1> l_gfx_uc_3:
  5100                              <1>     	; case 2:
  5101                              <1>     	; default:
  5102                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 24);
  5103                              <1> 	;    break;
  5104                              <1> 	; bl = 2 or bl > 3
  5105 00002B30 C605[EEE80000]19    <1> 	mov	byte [VGA_ROWS], 25  ; not 24 !	
  5106                              <1>     	; }
  5107                              <1> l_gfx_uc_4:
  5108                              <1>     	; write_byte(BIOSMEM_SEG, BIOSMEM_CHAR_HEIGHT, CX);
  5109 00002B37 880D[EAE80000]      <1> 	mov	[CHAR_HEIGHT], cl
  5110                              <1> 	; }
  5111                              <1> 
  5112                              <1> 	; TRDOS 386 (TRDOS v2.0) modification on
  5113                              <1> 	; 'biosfn_load_gfx_user_chars'
  5114                              <1> 	; (User fonts will be activated; but,
  5115                              <1> 	; user's font data address will not be readable or
  5116                              <1> 	; or usable by user, later. 
  5117                              <1> 	; So, 0FFFFFFFFh is put in [VGA_INT13H] to indicate
  5118                              <1> 	; that user's font are activated by there is not
  5119                              <1> 	; an address to read fonts directly at memory.)
  5120                              <1> 
  5121                              <1>  	; BH    height of each character
  5122 00002B3D 88CF                <1> 	mov	bh, cl ; bytes per character
  5123                              <1> 		       ; width = 8 pixels (1 byte, always)
  5124                              <1> 		       ; height = bytes per character
  5125                              <1> 	; CX    number of characters to redefine (<=256)
  5126 00002B3F 66B90001            <1> 	mov	cx, 256 ; 256 characters
  5127 00002B43 80FE80              <1> 	cmp	dh, 80h ; 128
  5128 00002B46 7503                <1> 	jne	short l_gfx_uc_5
  5129 00002B48 66D1E9              <1> 	shr	cx, 1	; 128 characters 
  5130                              <1> l_gfx_uc_5:
  5131                              <1>         ; DX    ASCII code of the first charr defined at EBP
  5132 00002B4B 6631D2              <1>         xor	dx, dx ; 0
  5133                              <1> 	; EBP	address of font-definition information
  5134 00002B4E B021                <1> 	mov	al, 21h ; > 10h
  5135 00002B50 E8DCFDFFFF          <1> 	call	load_text_user_pat
  5136 00002B55 C3                  <1> 	retn	
  5137                              <1> 
  5138                              <1> load_gfx_8_14_chars:
  5139                              <1> 	; 10/07/2016
  5140                              <1> 	; Setup ROM 8x14 Font for Graphics Mode (VGA)
  5141                              <1> 	;
  5142                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  5143                              <1> 	; vgabios-0.7a (2011)
  5144                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  5145                              <1> 	; 'vgabios.c', 'biosfn_load_gfx_8_14_chars'
  5146                              <1> 
  5147                              <1> 	; biosfn_load_gfx_8_14_chars (BL)
  5148                              <1> 	; /* set 0x43 INT pointer */
  5149                              <1>     	; write_word(0x0, 0x43*4, &vgafont14);
  5150                              <1>     	; write_word(0x0, 0x43*4+2, 0xC000);
  5151 00002B56 C705[462D0100]-     <1> 	mov	dword [VGA_INT43H], vgafont14
  5151 00002B5C [40FC0000]          <1>
  5152                              <1> 		
  5153                              <1> 	; BL    screen rows code: 00H = user-specified (in DL)
  5154                              <1>         ;                         01H = 14 rows
  5155                              <1>         ;                         02H = 25 rows
  5156                              <1>         ;                         03H = 43 rows
  5157                              <1>         ; DL    (when BL=0) custom number of char rows on screen
  5158                              <1> 
  5159                              <1> 	; switch (BL) {
  5160                              <1> 	; case 0:
  5161                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, DL-1);
  5162                              <1> 	;    break;
  5163 00002B60 20DB                <1> 	and	bl, bl
  5164 00002B62 7508                <1> 	jnz	short l_gfx_8_14c_1
  5165 00002B64 8815[EEE80000]      <1> 	mov	[VGA_ROWS], dl  ; not DL-1 !
  5166 00002B6A EB23                <1> 	jmp	short l_gfx_8_14c_4 	
  5167                              <1> l_gfx_8_14c_1:
  5168                              <1> 	; case 1:
  5169                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 13);
  5170                              <1> 	;    break;
  5171 00002B6C FECB                <1> 	dec	bl
  5172 00002B6E 7509                <1> 	jnz	short l_gfx_8_14c_2
  5173                              <1> 	; bl = 1
  5174 00002B70 C605[EEE80000]0E    <1> 	mov	byte [VGA_ROWS], 14  ; not 13 !
  5175 00002B77 EB16                <1> 	jmp	short l_gfx_8_14c_4 	
  5176                              <1> l_gfx_8_14c_2:
  5177 00002B79 FECB                <1> 	dec	bl
  5178 00002B7B 740B                <1> 	jz	short l_gfx_8_14c_3 ; bl = 2
  5179 00002B7D FECB                <1> 	dec	bl
  5180 00002B7F 750E                <1> 	jnz	short l_gfx_8_14c_4 ; bl > 3
  5181                              <1> 	; bl = 3
  5182                              <1> 	; case 3:
  5183                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 42);
  5184                              <1> 	;    break;
  5185 00002B81 C605[EEE80000]2B    <1> 	mov	byte [VGA_ROWS], 43  ; not 42 !
  5186                              <1> l_gfx_8_14c_3:
  5187                              <1>     	; case 2:
  5188                              <1>     	; default:
  5189                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 24);
  5190                              <1> 	;    break;
  5191                              <1> 	; bl = 2 or bl > 3
  5192 00002B88 C605[EEE80000]19    <1> 	mov	byte [VGA_ROWS], 25  ; not 24 !	
  5193                              <1>     	; }
  5194                              <1> l_gfx_8_14c_4:
  5195                              <1>     	; write_byte(BIOSMEM_SEG, BIOSMEM_CHAR_HEIGHT, 14);
  5196 00002B8F C605[EAE80000]0E    <1>         mov     byte [CHAR_HEIGHT], 14
  5197                              <1> 	; }
  5198                              <1> 
  5199                              <1> 	; TRDOS 386 (TRDOS v2.0) modification on
  5200                              <1> 	; 'biosfn_load_gfx_8_14_chars'
  5201                              <1> 	; (vgafont14 fonts will be activated)
  5202                              <1> 
  5203 00002B96 B022                <1>  	mov	al, 22h ; > 10h
  5204 00002B98 E8D2FEFFFF          <1> 	call	load_text_8_14_pat
  5205 00002B9D C3                  <1> 	retn	
  5206                              <1> 
  5207                              <1> load_gfx_8_8_chars:
  5208                              <1> 	; 10/07/2016
  5209                              <1> 	; Setup ROM 8x14 Font for Graphics Mode (VGA)
  5210                              <1> 	;
  5211                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  5212                              <1> 	; vgabios-0.7a (2011)
  5213                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  5214                              <1> 	; 'vgabios.c', 'biosfn_load_gfx_8_8_dd_chars'
  5215                              <1> 
  5216                              <1> 	; biosfn_load_gfx_8_8_dd_chars (BL)
  5217                              <1> 	; /* set 0x43 INT pointer */
  5218                              <1>     	; write_word(0x0, 0x43*4, &vgafont8);
  5219                              <1>     	; write_word(0x0, 0x43*4+2, 0xC000);
  5220 00002B9E C705[462D0100]-     <1> 	mov	dword [VGA_INT43H], vgafont8
  5220 00002BA4 [40F40000]          <1>
  5221                              <1> 		
  5222                              <1> 	; BL    screen rows code: 00H = user-specified (in DL)
  5223                              <1>         ;                         01H = 14 rows
  5224                              <1>         ;                         02H = 25 rows
  5225                              <1>         ;                         03H = 43 rows
  5226                              <1>         ; DL    (when BL=0) custom number of char rows on screen
  5227                              <1> 
  5228                              <1> 	; switch (BL) {
  5229                              <1> 	; case 0:
  5230                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, DL-1);
  5231                              <1> 	;    break;
  5232 00002BA8 20DB                <1> 	and	bl, bl
  5233 00002BAA 7508                <1> 	jnz	short l_gfx_8_8c_1
  5234 00002BAC 8815[EEE80000]      <1> 	mov	[VGA_ROWS], dl  ; not DL-1 !
  5235 00002BB2 EB23                <1> 	jmp	short l_gfx_8_8c_4 	
  5236                              <1> l_gfx_8_8c_1:
  5237                              <1> 	; case 1:
  5238                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 13);
  5239                              <1> 	;    break;
  5240 00002BB4 FECB                <1> 	dec	bl
  5241 00002BB6 7509                <1> 	jnz	short l_gfx_8_8c_2
  5242                              <1> 	; bl = 1
  5243 00002BB8 C605[EEE80000]0E    <1> 	mov	byte [VGA_ROWS], 14  ; not 13 !
  5244 00002BBF EB16                <1> 	jmp	short l_gfx_8_8c_4 	
  5245                              <1> l_gfx_8_8c_2:
  5246 00002BC1 FECB                <1> 	dec	bl
  5247 00002BC3 740B                <1> 	jz	short l_gfx_8_8c_3 ; bl = 2
  5248 00002BC5 FECB                <1> 	dec	bl
  5249 00002BC7 750E                <1> 	jnz	short l_gfx_8_8c_4 ; bl > 3
  5250                              <1> 	; bl = 3
  5251                              <1> 	; case 3:
  5252                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 42);
  5253                              <1> 	;    break;
  5254 00002BC9 C605[EEE80000]2B    <1> 	mov	byte [VGA_ROWS], 43  ; not 42 !
  5255                              <1> l_gfx_8_8c_3:
  5256                              <1>     	; case 2:
  5257                              <1>     	; default:
  5258                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 24);
  5259                              <1> 	;    break;
  5260                              <1> 	; bl = 2 or bl > 3
  5261 00002BD0 C605[EEE80000]19    <1> 	mov	byte [VGA_ROWS], 25  ; not 24 !	
  5262                              <1>     	; }
  5263                              <1> l_gfx_8_8c_4:
  5264                              <1>     	; write_byte(BIOSMEM_SEG, BIOSMEM_CHAR_HEIGHT, 8);
  5265 00002BD7 C605[EAE80000]08    <1>         mov     byte [CHAR_HEIGHT], 8
  5266                              <1> 	; }
  5267                              <1> 
  5268                              <1> 	; TRDOS 386 (TRDOS v2.0) modification on
  5269                              <1> 	; 'biosfn_load_gfx_8_8_dd_chars'
  5270                              <1> 	; (vgafont8 fonts will be activated)
  5271                              <1> 
  5272 00002BDE B023                <1>  	mov	al, 23h ; > 10h
  5273 00002BE0 E8BAFEFFFF          <1> 	call	load_text_8_8_pat
  5274 00002BE5 C3                  <1> 	retn
  5275                              <1> 
  5276                              <1> load_gfx_8_16_chars:
  5277                              <1> 	; 10/07/2016
  5278                              <1> 	; Setup ROM 8x14 Font for Graphics Mode (VGA)
  5279                              <1> 	;
  5280                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  5281                              <1> 	; vgabios-0.7a (2011)
  5282                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  5283                              <1> 	; 'vgabios.c', 'biosfn_load_gfx_8_16_chars'
  5284                              <1> 
  5285                              <1> 	; biosfn_load_gfx_8_16_chars (BL)
  5286                              <1> 	; /* set 0x43 INT pointer */
  5287                              <1>     	; write_word(0x0, 0x43*4, &vgafont16);
  5288                              <1>     	; write_word(0x0, 0x43*4+2, 0xC000);
  5289 00002BE6 C705[462D0100]-     <1> 	mov	dword [VGA_INT43H], vgafont16
  5289 00002BEC [400A0100]          <1>
  5290                              <1> 		
  5291                              <1> 	; BL    screen rows code: 00H = user-specified (in DL)
  5292                              <1>         ;                         01H = 14 rows
  5293                              <1>         ;                         02H = 25 rows
  5294                              <1>         ;                         03H = 43 rows
  5295                              <1>         ; DL    (when BL=0) custom number of char rows on screen
  5296                              <1> 
  5297                              <1> 	; switch (BL) {
  5298                              <1> 	; case 0:
  5299                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, DL-1);
  5300                              <1> 	;    break;
  5301 00002BF0 20DB                <1> 	and	bl, bl
  5302 00002BF2 7508                <1> 	jnz	short l_gfx_8_16c_1
  5303 00002BF4 8815[EEE80000]      <1> 	mov	[VGA_ROWS], dl  ; not DL-1 !
  5304 00002BFA EB23                <1> 	jmp	short l_gfx_8_16c_4 	
  5305                              <1> l_gfx_8_16c_1:
  5306                              <1> 	; case 1:
  5307                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 13);
  5308                              <1> 	;    break;
  5309 00002BFC FECB                <1> 	dec	bl
  5310 00002BFE 7509                <1> 	jnz	short l_gfx_8_16c_2
  5311                              <1> 	; bl = 1
  5312 00002C00 C605[EEE80000]0E    <1> 	mov	byte [VGA_ROWS], 14  ; not 13 !
  5313 00002C07 EB16                <1> 	jmp	short l_gfx_8_16c_4 	
  5314                              <1> l_gfx_8_16c_2:
  5315 00002C09 FECB                <1> 	dec	bl
  5316 00002C0B 740B                <1> 	jz	short l_gfx_8_16c_3 ; bl = 2
  5317 00002C0D FECB                <1> 	dec	bl
  5318 00002C0F 750E                <1> 	jnz	short l_gfx_8_16c_4 ; bl > 3
  5319                              <1> 	; bl = 3
  5320                              <1> 	; case 3:
  5321                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 42);
  5322                              <1> 	;    break;
  5323 00002C11 C605[EEE80000]2B    <1> 	mov	byte [VGA_ROWS], 43  ; not 42 !
  5324                              <1> l_gfx_8_16c_3:
  5325                              <1>     	; case 2:
  5326                              <1>     	; default:
  5327                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 24);
  5328                              <1> 	;    break;
  5329                              <1> 	; bl = 2 or bl > 3
  5330 00002C18 C605[EEE80000]19    <1> 	mov	byte [VGA_ROWS], 25  ; not 24 !	
  5331                              <1>     	; }
  5332                              <1> l_gfx_8_16c_4:
  5333                              <1>     	; write_byte(BIOSMEM_SEG, BIOSMEM_CHAR_HEIGHT, 16);
  5334 00002C1F C605[EAE80000]10    <1>         mov     byte [CHAR_HEIGHT], 16
  5335                              <1> 	; }
  5336                              <1> 
  5337                              <1> 	; TRDOS 386 (TRDOS v2.0) modification on
  5338                              <1> 	; 'biosfn_load_gfx_8_16_chars'
  5339                              <1> 	; (vgafont14 fonts will be activated)
  5340                              <1> 
  5341 00002C26 B024                <1>  	mov	al, 24h ; > 10h
  5342 00002C28 E8A2FEFFFF          <1> 	call	load_text_8_16_pat
  5343 00002C2D C3                  <1> 	retn
  5344                              <1> 			
  5345                              <1> get_font_info:
  5346                              <1> 	; 10/07/2016
  5347                              <1> 	; Get Current Character Generator Info (VGA)
  5348                              <1> 	;
  5349                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  5350                              <1> 	; vgabios-0.7a (2011)
  5351                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  5352                              <1> 	; 'vgabios.c', 'biosfn_get_font_info'
  5353                              <1> 
  5354                              <1> 	; Modified for TRDOS 386 !
  5355                              <1> 	;
  5356                              <1> 	; INPUT ->
  5357                              <1> 	;    AX = 1130h
  5358                              <1> 	;    BL = 0 -> Get info for current VGA font
  5359                              <1> 	;	       (BH = unused)
  5360                              <1> 	;    BL > 0 -> Invalid function (for now!)
  5361                              <1> 	; OUTPUT ->
  5362                              <1> 	;    AL = height (scanlines), bytes per character
  5363                              <1> 	;    AH = screen rows
  5364                              <1> 	;    Byte 16-23 of EAX = number of columns
  5365                              <1> 	;    Byte 24-31 of EAX = 
  5366                              <1> 	;	  0 -> default font (not configured yet)
  5367                              <1> 	;	  0FFh -> user defined font
  5368                              <1> 	;	  14 = vgafont14
  5369                              <1> 	;	   8 = vgafont8
  5370                              <1> 	;	  16 = vgafont16
  5371                              <1> 	;
  5372 00002C2E 20DB                <1> 	and	bl, bl
  5373 00002C30 7403                <1> 	jz	short gfi_0
  5374                              <1> 	; invalid function (input)
  5375 00002C32 31C0                <1> 	xor	eax, eax ; 0
  5376 00002C34 C3                  <1> 	retn
  5377                              <1> gfi_0:
  5378 00002C35 A0[EAE80000]        <1> 	mov	al, [CHAR_HEIGHT]
  5379 00002C3A 8A25[EEE80000]      <1> 	mov	ah, [VGA_ROWS]
  5380 00002C40 C1E010              <1> 	shl	eax, 16
  5381 00002C43 A0[E8E80000]        <1> 	mov	al, [CRT_COLS]
  5382 00002C48 8B0D[462D0100]      <1> 	mov	ecx, [VGA_INT43H]
  5383 00002C4E 21C9                <1> 	and	ecx, ecx
  5384 00002C50 741D                <1> 	jz	short gfi_2 ; 0 = default font
  5385 00002C52 41                  <1> 	inc	ecx ; 0FFFFFFFFh -> 0 (user defined font)
  5386 00002C53 7504                <1> 	jnz	short gfi_1
  5387 00002C55 FECC                <1> 	dec	ah ; 0FFh
  5388 00002C57 EB16                <1> 	jmp	short gfi_2
  5389                              <1> gfi_1:
  5390 00002C59 B40E                <1> 	mov	ah, 14
  5391 00002C5B 81F9[40FC0000]      <1> 	cmp	ecx, vgafont14
  5392 00002C61 740C                <1> 	je	short gfi_2
  5393 00002C63 B408                <1> 	mov	ah, 8
  5394 00002C65 81F9[40F40000]      <1> 	cmp	ecx, vgafont8
  5395 00002C6B 7402                <1> 	je	short gfi_2
  5396                              <1> 	; vgafont16
  5397 00002C6D D0E4                <1> 	shl	ah, 1 ; ah = 16
  5398                              <1> gfi_2:
  5399 00002C6F C1C010              <1> 	rol	eax, 16
  5400                              <1> gfi_3:
  5401 00002C72 C3                  <1> 	retn
  5402                              <1> 
  5403                              <1> ; % include 'vidata.s' ; VIDEO DATA
  5404                              <1> 
  5405                              <1> ; /// End Of VIDEO FUNCTIONS ///
  1697                                  
  1698                                  setup_rtc_int:
  1699                                  ; source: http://wiki.osdev.org/RTC
  1700 00002C73 FA                      	cli		; disable interrupts
  1701                                  	; default int frequency is 1024 Hz (Lower 4 bits of register A is 0110b or 6)
  1702                                  	; in order to change this ...
  1703                                  	; frequency  = 32768 >> (rate-1) --> 32768 >> 5 = 1024
  1704                                  	; (rate must be above 2 and not over 15)
  1705                                  	; new rate = 15 --> 32768 >> (15-1) = 2 Hz
  1706 00002C74 B08A                    	mov	al, 8Ah 
  1707 00002C76 E670                    	out	70h, al ; set index to register A, disable NMI
  1708 00002C78 90                      	nop
  1709 00002C79 E471                    	in	al, 71h ; get initial value of register A
  1710 00002C7B 88C4                    	mov 	ah, al
  1711 00002C7D 80E4F0                  	and	ah, 0F0h
  1712 00002C80 B08A                    	mov	al, 8Ah 
  1713 00002C82 E670                    	out	70h, al ; reset index to register A
  1714 00002C84 88E0                    	mov	al, ah
  1715 00002C86 0C0F                    	or	al, 0Fh	; new rate (0Fh -> 15)
  1716 00002C88 E671                    	out	71h, al ; write only our rate to A. Note, rate is the bottom 4 bits. 
  1717                                  	; enable RTC interrupt
  1718 00002C8A B08B                    	mov	al, 8Bh ;
  1719 00002C8C E670                    	out	70h, al ; select register B and disable NMI
  1720 00002C8E 90                      	nop
  1721 00002C8F E471                    	in	al, 71h ; read the current value of register B
  1722 00002C91 88C4                    	mov	ah, al  ;
  1723 00002C93 B08B                    	mov 	al, 8Bh ;
  1724 00002C95 E670                    	out	70h, al ; set the index again (a read will reset the index to register B)	
  1725 00002C97 88E0                    	mov	al, ah  ;
  1726 00002C99 0C40                    	or	al, 40h ;
  1727 00002C9B E671                    	out	71h, al ; write the previous value ORed with 0x40. This turns on bit 6 of register B
  1728 00002C9D FB                      	sti
  1729 00002C9E C3                      	retn
  1730                                  
  1731                                  ; Write memory information
  1732                                  ; 29/01/2016
  1733                                  ; 06/11/2014
  1734                                  ; 14/08/2015 
  1735                                  memory_info:	
  1736 00002C9F A1[AC1F0100]            	mov	eax, [memory_size] ; in pages
  1737 00002CA4 50                      	push	eax
  1738 00002CA5 C1E00C                  	shl	eax, 12		   ; in bytes
  1739 00002CA8 BB0A000000              	mov	ebx, 10
  1740 00002CAD 89D9                    	mov	ecx, ebx	   ; 10
  1741 00002CAF BE[FCED0000]            	mov	esi, mem_total_b_str	
  1742 00002CB4 E8BD000000              	call	bintdstr
  1743 00002CB9 58                      	pop	eax
  1744 00002CBA B107                    	mov	cl, 7
  1745 00002CBC BE[20EE0000]            	mov	esi, mem_total_p_str
  1746 00002CC1 E8B0000000              	call	bintdstr	
  1747                                  	; 14/08/2015
  1748 00002CC6 E8C8000000              	call	calc_free_mem
  1749                                  	; edx = calculated free pages
  1750                                  	; ecx = 0
  1751 00002CCB A1[B01F0100]            	mov 	eax, [free_pages]
  1752 00002CD0 39D0                    	cmp	eax, edx ; calculated free mem value 
  1753                                  		; and initial free mem value are same or not?
  1754 00002CD2 751D                    	jne 	short pmim ; print mem info with '?' if not
  1755 00002CD4 52                      	push 	edx ; free memory in pages	
  1756                                  	;mov 	eax, edx
  1757 00002CD5 C1E00C                  	shl	eax, 12 ; convert page count
  1758                                  			; to byte count
  1759 00002CD8 B10A                    	mov	cl, 10
  1760 00002CDA BE[40EE0000]            	mov	esi, free_mem_b_str
  1761 00002CDF E892000000              	call	bintdstr
  1762 00002CE4 58                      	pop	eax
  1763 00002CE5 B107                    	mov	cl, 7
  1764 00002CE7 BE[64EE0000]            	mov	esi, free_mem_p_str
  1765 00002CEC E885000000              	call	bintdstr
  1766                                  pmim:
  1767 00002CF1 BE[EAED0000]            	mov	esi, msg_memory_info
  1768                                  	;
  1769 00002CF6 B407                    	mov	ah, 07h ; Black background, 
  1770                                  			; light gray forecolor
  1771                                  print_kmsg: ; 29/01/2016
  1772 00002CF8 8825[D71F0100]          	mov	[ccolor], ah
  1773                                  pkmsg_loop:
  1774 00002CFE AC                      	lodsb
  1775 00002CFF 08C0                    	or	al, al
  1776 00002D01 7410                    	jz	short pkmsg_ok
  1777 00002D03 56                      	push	esi
  1778                                  	; 13/05/2016
  1779 00002D04 0FB61D[D71F0100]        	movzx	ebx, byte [ccolor]
  1780                                  			; Video page 0 (bh=0)
  1781 00002D0B E80CEEFFFF              	call	_write_tty
  1782 00002D10 5E                      	pop	esi
  1783 00002D11 EBEB                    	jmp	short pkmsg_loop
  1784                                  pkmsg_ok:
  1785 00002D13 C3                      	retn
  1786                                  
  1787                                  ; Convert binary number to hexadecimal string
  1788                                  ; 10/05/2015  
  1789                                  ; dsectpm.s (28/02/2015)
  1790                                  ; Retro UNIX 386 v1 - Kernel v0.2.0.6  
  1791                                  ; 01/12/2014
  1792                                  ; 25/11/2014
  1793                                  ;
  1794                                  bytetohex:
  1795                                  	; INPUT ->
  1796                                  	; 	AL = byte (binary number)
  1797                                  	; OUTPUT ->
  1798                                  	;	AX = hexadecimal string
  1799                                  	;
  1800 00002D14 53                      	push	ebx
  1801 00002D15 31DB                    	xor	ebx, ebx
  1802 00002D17 88C3                    	mov	bl, al
  1803 00002D19 C0EB04                  	shr	bl, 4
  1804 00002D1C 8A9B[662D0000]          	mov	bl, [ebx+hexchrs] 	 	
  1805 00002D22 86D8                    	xchg	bl, al
  1806 00002D24 80E30F                  	and	bl, 0Fh
  1807 00002D27 8AA3[662D0000]          	mov	ah, [ebx+hexchrs] 
  1808 00002D2D 5B                      	pop	ebx	
  1809 00002D2E C3                      	retn
  1810                                  
  1811                                  wordtohex:
  1812                                  	; INPUT ->
  1813                                  	; 	AX = word (binary number)
  1814                                  	; OUTPUT ->
  1815                                  	;	EAX = hexadecimal string
  1816                                  	;
  1817 00002D2F 53                      	push	ebx
  1818 00002D30 31DB                    	xor	ebx, ebx
  1819 00002D32 86E0                    	xchg	ah, al
  1820 00002D34 6650                    	push	ax
  1821 00002D36 88E3                    	mov	bl, ah
  1822 00002D38 C0EB04                  	shr	bl, 4
  1823 00002D3B 8A83[662D0000]          	mov	al, [ebx+hexchrs] 	 	
  1824 00002D41 88E3                    	mov	bl, ah
  1825 00002D43 80E30F                  	and	bl, 0Fh
  1826 00002D46 8AA3[662D0000]          	mov	ah, [ebx+hexchrs]
  1827 00002D4C C1E010                  	shl	eax, 16
  1828 00002D4F 6658                    	pop	ax
  1829 00002D51 5B                      	pop	ebx
  1830 00002D52 EBC0                    	jmp	short bytetohex
  1831                                  	;mov	bl, al
  1832                                  	;shr	bl, 4
  1833                                  	;mov	bl, [ebx+hexchrs] 	 	
  1834                                  	;xchg	bl, al	 	
  1835                                  	;and	bl, 0Fh
  1836                                  	;mov	ah, [ebx+hexchrs] 
  1837                                  	;pop	ebx	
  1838                                  	;retn
  1839                                  
  1840                                  dwordtohex:
  1841                                  	; INPUT ->
  1842                                  	; 	EAX = dword (binary number)
  1843                                  	; OUTPUT ->
  1844                                  	;	EDX:EAX = hexadecimal string
  1845                                  	;
  1846 00002D54 50                      	push	eax
  1847 00002D55 C1E810                  	shr	eax, 16
  1848 00002D58 E8D2FFFFFF              	call	wordtohex
  1849 00002D5D 89C2                    	mov	edx, eax
  1850 00002D5F 58                      	pop	eax
  1851 00002D60 E8CAFFFFFF              	call	wordtohex
  1852 00002D65 C3                      	retn
  1853                                  
  1854                                  ; 10/05/2015
  1855                                  hex_digits:
  1856                                  hexchrs:
  1857 00002D66 303132333435363738-     	db '0123456789ABCDEF'
  1857 00002D6F 39414243444546     
  1858                                  
  1859                                  ; Convert binary number to decimal/numeric string
  1860                                  ; 06/11/2014
  1861                                  ; Temporary Code
  1862                                  ;
  1863                                  
  1864                                  bintdstr:
  1865                                  	; EAX = binary number
  1866                                  	; ESI = decimal/numeric string address
  1867                                  	; EBX = divisor (10)
  1868                                  	; ECX = string length (<=10)
  1869 00002D76 01CE                    	add	esi, ecx
  1870                                  btdstr0:
  1871 00002D78 4E                      	dec	esi
  1872 00002D79 31D2                    	xor	edx, edx
  1873 00002D7B F7F3                    	div	ebx
  1874 00002D7D 80C230                  	add	dl, 30h
  1875 00002D80 8816                    	mov	[esi], dl
  1876 00002D82 FEC9                    	dec	cl
  1877 00002D84 740C                    	jz	btdstr2
  1878 00002D86 09C0                    	or	eax, eax
  1879 00002D88 75EE                    	jnz	short btdstr0
  1880                                  btdstr1:
  1881 00002D8A 4E                      	dec	esi
  1882 00002D8B C60620                          mov     byte [esi], 20h ; blank space
  1883 00002D8E FEC9                    	dec	cl
  1884 00002D90 75F8                    	jnz	short btdstr1
  1885                                  btdstr2:
  1886 00002D92 C3                      	retn
  1887                                  
  1888                                  ; Calculate free memory pages on M.A.T.
  1889                                  ; 06/11/2014
  1890                                  ; Temporary Code
  1891                                  ;
  1892                                  
  1893                                  calc_free_mem:
  1894 00002D93 31D2                    	xor	edx, edx
  1895                                  	;xor	ecx, ecx
  1896 00002D95 668B0D[C01F0100]        	mov	cx, [mat_size] ; in pages
  1897 00002D9C C1E10A                  	shl	ecx, 10	; 1024 dwords per page
  1898 00002D9F BE00001000              	mov	esi, MEM_ALLOC_TBL
  1899                                  cfm0:
  1900 00002DA4 AD                      	lodsd
  1901 00002DA5 51                      	push	ecx
  1902 00002DA6 B920000000              	mov	ecx, 32
  1903                                  cfm1:
  1904 00002DAB D1E8                    	shr	eax, 1
  1905 00002DAD 7301                    	jnc	short cfm2
  1906 00002DAF 42                      	inc	edx
  1907                                  cfm2:
  1908 00002DB0 E2F9                    	loop	cfm1
  1909 00002DB2 59                      	pop	ecx
  1910 00002DB3 E2EF                    	loop	cfm0
  1911 00002DB5 C3                      	retn
  1912                                  
  1913                                  %include 'diskio.s'  ; 07/03/2015
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.0 - diskio.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 01/06/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> ; 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 00002DB6 9C                  <1> 	pushfd
    31 00002DB7 0E                  <1> 	push 	cs
    32 00002DB8 E809000000          <1> 	call 	DISKETTE_IO_1
    33 00002DBD C3                  <1> 	retn
    34                              <1> 	
    35                              <1> ;;;;;; DISKETTE I/O ;;;;;;;;;;;;;;;;;;;; 06/02/2015 ;;;
    36                              <1> ;//////////////////////////////////////////////////////
    37                              <1> 
    38                              <1> ; DISKETTE I/O - Erdogan Tan (Retro UNIX 386 v1 project)
    39                              <1> ; 20/02/2015
    40                              <1> ; 06/02/2015 (unix386.s)
    41                              <1> ; 16/12/2014 - 02/01/2015 (dsectrm2.s)
    42                              <1> ;
    43                              <1> ; Code (DELAY) modifications - AWARD BIOS 1999 (ADISK.EQU, COMMON.MAC)
    44                              <1> ;
    45                              <1> ; ADISK.EQU
    46                              <1> 
    47                              <1> ;----- Wait control constants 
    48                              <1> 
    49                              <1> ;amount of time to wait while RESET is active.
    50                              <1> 
    51                              <1> WAITCPU_RESET_ON	EQU	21		;Reset on must last at least 14us
    52                              <1> 						;at 250 KBS xfer rate.
    53                              <1> 						;see INTEL MCS, 1985, pg. 5-456
    54                              <1> 
    55                              <1> WAITCPU_FOR_STATUS	EQU	100		;allow 30 microseconds for
    56                              <1> 						;status register to become valid
    57                              <1> 						;before re-reading.
    58                              <1> 
    59                              <1> ;After sending a byte to NEC, status register may remain
    60                              <1> ;incorrectly set for 24 us.
    61                              <1> 
    62                              <1> WAITCPU_RQM_LOW		EQU	24		;number of loops to check for
    63                              <1> 						;RQM low.
    64                              <1> 
    65                              <1> ; COMMON.MAC
    66                              <1> ;
    67                              <1> ;	Timing macros
    68                              <1> ;
    69                              <1> 
    70                              <1> %macro 		SIODELAY 0 			; SHORT IODELAY
    71                              <1> 		jmp short $+2
    72                              <1> %endmacro		
    73                              <1> 
    74                              <1> %macro		IODELAY  0			; NORMAL IODELAY
    75                              <1> 		jmp short $+2
    76                              <1> 		jmp short $+2
    77                              <1> %endmacro
    78                              <1> 
    79                              <1> %macro		NEWIODELAY 0
    80                              <1> 		out	0ebh,al
    81                              <1> %endmacro 
    82                              <1> 
    83                              <1> ; (According to) AWARD BIOS 1999 - ATORGS.ASM (dw -> equ, db -> equ)
    84                              <1> ;;; WAIT_FOR_MEM
    85                              <1> ;WAIT_FDU_INT_LO	equ	017798		; 2.5 secs in 30 micro units.
    86                              <1> ;WAIT_FDU_INT_HI	equ	1
    87                              <1> WAIT_FDU_INT_LH		equ	83334		; 27/02/2015 (2.5 seconds waiting)
    88                              <1> ;;; WAIT_FOR_PORT
    89                              <1> ;WAIT_FDU_SEND_LO	equ	16667		; .5 secons in 30 us units.
    90                              <1> ;WAIT_FDU_SEND_HI	equ	0
    91                              <1> WAIT_FDU_SEND_LH	equ 	16667		; 27/02/2015	
    92                              <1> ;Time to wait while waiting for each byte of NEC results = .5
    93                              <1> ;seconds.  .5 seconds = 500,000 micros.  500,000/30 = 16,667.
    94                              <1> ;WAIT_FDU_RESULTS_LO	equ	16667		; .5 seconds in 30 micro units.
    95                              <1> ;WAIT_FDU_RESULTS_HI	equ	0
    96                              <1> WAIT_FDU_RESULTS_LH	equ	16667  ; 27/02/2015
    97                              <1> ;;; WAIT_REFRESH
    98                              <1> ;amount of time to wait for head settle, per unit in parameter
    99                              <1> ;table = 1 ms.
   100                              <1> WAIT_FDU_HEAD_SETTLE	equ	33		; 1 ms in 30 micro units.
   101                              <1> 
   102                              <1> 
   103                              <1> ; //////////////// DISKETTE I/O ////////////////
   104                              <1> 
   105                              <1> ; 11/12/2014 (copy from IBM PC-XT Model 286 BIOS - POSTEQU.INC)
   106                              <1> 
   107                              <1> ;----------------------------------------
   108                              <1> ;	EQUATES USED BY POST AND BIOS	:
   109                              <1> ;----------------------------------------
   110                              <1> 
   111                              <1> ;--------- 8042 KEYBOARD INTERFACE AND DIAGNOSTIC CONTROL REGISTERS ------------
   112                              <1> ;PORT_A		EQU	060H		; 8042 KEYBOARD SCAN CODE/CONTROL PORT
   113                              <1> ;PORT_B		EQU	061H		; PORT B READ/WRITE DIAGNOSTIC REGISTER
   114                              <1> ;REFRESH_BIT	EQU	00010000B	; REFRESH TEST BIT
   115                              <1> 
   116                              <1> ;----------------------------------------
   117                              <1> ;	CMOS EQUATES FOR THIS SYSTEM	:
   118                              <1> ;-------------------------------------------------------------------------------
   119                              <1> ;CMOS_PORT	EQU	070H		; I/O ADDRESS OF CMOS ADDRESS PORT
   120                              <1> ;CMOS_DATA	EQU	071H		; I/O ADDRESS OF CMOS DATA PORT
   121                              <1> ;NMI		EQU	10000000B	; DISABLE NMI INTERRUPTS MASK -
   122                              <1> 					;  HIGH BIT OF CMOS LOCATION ADDRESS
   123                              <1> 
   124                              <1> ;---------- CMOS TABLE LOCATION ADDRESS'S ## -----------------------------------
   125                              <1> CMOS_DISKETTE	EQU	010H		; DISKETTE DRIVE TYPE BYTE	      ;
   126                              <1> ;		EQU	011H		; - RESERVED			      ;C
   127                              <1> CMOS_DISK	EQU	012H		; FIXED DISK TYPE BYTE		      ;H
   128                              <1> ;		EQU	013H		; - RESERVED			      ;E
   129                              <1> CMOS_EQUIP	EQU	014H		; EQUIPMENT WORD LOW BYTE	      ;C
   130                              <1> 
   131                              <1> ;---------- DISKETTE EQUATES ---------------------------------------------------
   132                              <1> INT_FLAG	EQU	10000000B	; INTERRUPT OCCURRENCE FLAG
   133                              <1> DSK_CHG 	EQU	10000000B	; DISKETTE CHANGE FLAG MASK BIT
   134                              <1> DETERMINED	EQU	00010000B	; SET STATE DETERMINED IN STATE BITS
   135                              <1> HOME		EQU	00010000B	; TRACK 0 MASK
   136                              <1> SENSE_DRV_ST	EQU	00000100B	; SENSE DRIVE STATUS COMMAND
   137                              <1> TRK_SLAP	EQU	030H		; CRASH STOP (48 TPI DRIVES)
   138                              <1> QUIET_SEEK	EQU	00AH		; SEEK TO TRACK 10
   139                              <1> ;MAX_DRV 	EQU	2		; MAX NUMBER OF DRIVES
   140                              <1> HD12_SETTLE	EQU	15		; 1.2 M HEAD SETTLE TIME
   141                              <1> HD320_SETTLE	EQU	20		; 320 K HEAD SETTLE TIME
   142                              <1> MOTOR_WAIT	EQU	37		; 2 SECONDS OF COUNTS FOR MOTOR TURN OFF
   143                              <1> 
   144                              <1> ;---------- DISKETTE ERRORS ----------------------------------------------------
   145                              <1> ;TIME_OUT	EQU	080H		; ATTACHMENT FAILED TO RESPOND
   146                              <1> ;BAD_SEEK	EQU	040H		; SEEK OPERATION FAILED
   147                              <1> BAD_NEC 	EQU	020H		; DISKETTE CONTROLLER HAS FAILED
   148                              <1> BAD_CRC 	EQU	010H		; BAD CRC ON DISKETTE READ
   149                              <1> MED_NOT_FND	EQU	00CH		; MEDIA TYPE NOT FOUND
   150                              <1> DMA_BOUNDARY	EQU	009H		; ATTEMPT TO DMA ACROSS 64K BOUNDARY
   151                              <1> BAD_DMA 	EQU	008H		; DMA OVERRUN ON OPERATION
   152                              <1> MEDIA_CHANGE	EQU	006H		; MEDIA REMOVED ON DUAL ATTACH CARD
   153                              <1> RECORD_NOT_FND	EQU	004H		; REQUESTED SECTOR NOT FOUND
   154                              <1> WRITE_PROTECT	EQU	003H		; WRITE ATTEMPTED ON WRITE PROTECT DISK
   155                              <1> BAD_ADDR_MARK	EQU	002H		; ADDRESS MARK NOT FOUND
   156                              <1> BAD_CMD 	EQU	001H		; BAD COMMAND PASSED TO DISKETTE I/O
   157                              <1> 
   158                              <1> ;---------- DISK CHANGE LINE EQUATES -------------------------------------------
   159                              <1> NOCHGLN 	EQU	001H		; NO DISK CHANGE LINE AVAILABLE
   160                              <1> CHGLN		EQU	002H		; DISK CHANGE LINE AVAILABLE
   161                              <1> 
   162                              <1> ;---------- MEDIA/DRIVE STATE INDICATORS ---------------------------------------
   163                              <1> TRK_CAPA	EQU	00000001B	; 80 TRACK CAPABILITY
   164                              <1> FMT_CAPA	EQU	00000010B	; MULTIPLE FORMAT CAPABILITY (1.2M)
   165                              <1> DRV_DET 	EQU	00000100B	; DRIVE DETERMINED
   166                              <1> MED_DET 	EQU	00010000B	; MEDIA DETERMINED BIT
   167                              <1> DBL_STEP	EQU	00100000B	; DOUBLE STEP BIT
   168                              <1> RATE_MSK	EQU	11000000B	; MASK FOR CLEARING ALL BUT RATE
   169                              <1> RATE_500	EQU	00000000B	; 500 KBS DATA RATE
   170                              <1> RATE_300	EQU	01000000B	; 300 KBS DATA RATE
   171                              <1> RATE_250	EQU	10000000B	; 250 KBS DATA RATE
   172                              <1> STRT_MSK	EQU	00001100B	; OPERATION START RATE MASK
   173                              <1> SEND_MSK	EQU	11000000B	; MASK FOR SEND RATE BITS
   174                              <1> 
   175                              <1> ;---------- MEDIA/DRIVE STATE INDICATORS COMPATIBILITY -------------------------
   176                              <1> M3D3U		EQU	00000000B	; 360 MEDIA/DRIVE NOT ESTABLISHED
   177                              <1> M3D1U		EQU	00000001B	; 360 MEDIA,1.2DRIVE NOT ESTABLISHED
   178                              <1> M1D1U		EQU	00000010B	; 1.2 MEDIA/DRIVE NOT ESTABLISHED
   179                              <1> MED_UNK 	EQU	00000111B	; NONE OF THE ABOVE
   180                              <1> 
   181                              <1> ;---------- INTERRUPT EQUATES --------------------------------------------------
   182                              <1> ;EOI		EQU	020H		; END OF INTERRUPT COMMAND TO 8259
   183                              <1> ;INTA00		EQU	020H		; 8259 PORT
   184                              <1> INTA01		EQU	021H		; 8259 PORT
   185                              <1> INTB00		EQU	0A0H		; 2ND 8259
   186                              <1> INTB01		EQU	0A1H		;
   187                              <1> 
   188                              <1> ;-------------------------------------------------------------------------------
   189                              <1> DMA08		EQU	008H		; DMA STATUS REGISTER PORT ADDRESS
   190                              <1> DMA		EQU	000H		; DMA CH.0 ADDRESS REGISTER PORT ADDRESS
   191                              <1> DMA18		EQU	0D0H		; 2ND DMA STATUS PORT ADDRESS
   192                              <1> DMA1		EQU	0C0H		; 2ND DMA CH.0 ADDRESS REGISTER ADDRESS
   193                              <1> ;-------------------------------------------------------------------------------
   194                              <1> ;TIMER		EQU	040H		; 8254 TIMER - BASE ADDRESS
   195                              <1> 
   196                              <1> ;-------------------------------------------------------------------------------
   197                              <1> DMA_PAGE	EQU	081H		; START OF DMA PAGE REGISTERS
   198                              <1> 
   199                              <1> ; 06/02/2015 (unix386.s, protected mode modifications)
   200                              <1> ; (unix386.s <-- dsectrm2.s)
   201                              <1> ; 11/12/2014 (copy from IBM PC-XT Model 286 BIOS - DSEG.INC)
   202                              <1> 
   203                              <1> ; 27/05/2016 - TRDOS 386 (TRDOS v2.0)
   204                              <1> ; 10/12/2014
   205                              <1> ;
   206                              <1> ;int40h:
   207                              <1> ;	pushf
   208                              <1> ;	push 	cs
   209                              <1> ;	;cli
   210                              <1> ;	call 	DISKETTE_IO_1
   211                              <1> ;	retn
   212                              <1> 
   213                              <1> ; DSKETTE ----- 04/21/86 DISKETTE BIOS
   214                              <1> ; (IBM PC XT Model 286 System BIOS Source Code, 04-21-86)
   215                              <1> ;
   216                              <1> 
   217                              <1> ;-- INT13H ---------------------------------------------------------------------
   218                              <1> ; DISKETTE I/O
   219                              <1> ;	THIS INTERFACE PROVIDES ACCESS TO THE 5 1/4 INCH 360 KB,
   220                              <1> ;	1.2 MB, 720 KB AND 1.44 MB DISKETTE DRIVES.
   221                              <1> ; INPUT
   222                              <1> ;	(AH) =  00H RESET DISKETTE SYSTEM
   223                              <1> ;		HARD RESET TO NEC, PREPARE COMMAND, RECALIBRATE REQUIRED
   224                              <1> ;		ON ALL DRIVES
   225                              <1> ;------------------------------------------------------------------------------- 
   226                              <1> ;	(AH)= 01H  READ THE STATUS OF THE SYSTEM INTO (AH)
   227                              <1> ;		@DISKETTE_STATUS FROM LAST OPERATION IS USED
   228                              <1> ;-------------------------------------------------------------------------------
   229                              <1> ;	REGISTERS FOR READ/WRITE/VERIFY/FORMAT
   230                              <1> ;	(DL) - DRIVE NUMBER (0-1 ALLOWED, VALUE CHECKED)
   231                              <1> ;	(DH) - HEAD NUMBER (0-1 ALLOWED, NOT VALUE CHECKED)
   232                              <1> ;	(CH) - TRACK NUMBER (NOT VALUE CHECKED)
   233                              <1> ;		MEDIA	DRIVE	TRACK NUMBER
   234                              <1> ;		320/360	320/360	    0-39
   235                              <1> ;		320/360	1.2M	    0-39
   236                              <1> ;		1.2M	1.2M	    0-79
   237                              <1> ;		720K	720K	    0-79
   238                              <1> ;		1.44M	1.44M	    0-79	
   239                              <1> ;	(CL) - 	SECTOR NUMBER (NOT VALUE CHECKED, NOT USED FOR FORMAT)
   240                              <1> ;		MEDIA	DRIVE	SECTOR NUMBER
   241                              <1> ;		320/360	320/360	     1-8/9
   242                              <1> ;		320/360	1.2M	     1-8/9
   243                              <1> ;		1.2M	1.2M	     1-15
   244                              <1> ;		720K	720K	     1-9
   245                              <1> ;		1.44M	1.44M	     1-18		
   246                              <1> ;	(AL)	NUMBER OF SECTORS (NOT VALUE CHECKED)
   247                              <1> ;		MEDIA	DRIVE	MAX NUMBER OF SECTORS
   248                              <1> ;		320/360	320/360	        8/9
   249                              <1> ;		320/360	1.2M	        8/9
   250                              <1> ;		1.2M	1.2M		15
   251                              <1> ;		720K	720K		9
   252                              <1> ;		1.44M	1.44M		18
   253                              <1> ;
   254                              <1> ;	(ES:BX) - ADDRESS OF BUFFER (NOT REQUIRED FOR VERIFY)
   255                              <1> ;
   256                              <1> ;-------------------------------------------------------------------------------
   257                              <1> ;	(AH)= 02H  READ THE DESIRED SECTORS INTO MEMORY
   258                              <1> ;-------------------------------------------------------------------------------
   259                              <1> ;	(AH)= 03H  WRITE THE DESIRED SECTORS FROM MEMORY
   260                              <1> ;-------------------------------------------------------------------------------
   261                              <1> ;	(AH)= 04H  VERIFY THE DESIRED SECTORS
   262                              <1> ;-------------------------------------------------------------------------------
   263                              <1> ;	(AH)= 05H  FORMAT THE DESIRED TRACK
   264                              <1> ;		(ES,BX) MUST POINT TO THE COLLECTION OF DESIRED ADDRESS FIELDS
   265                              <1> ;		FOR THE	TRACK. EACH FIELD IS COMPOSED OF 4 BYTES, (C,H,R,N),
   266                              <1> ;		WHERE C = TRACK NUMBER, H=HEAD NUMBER, R = SECTOR NUMBER, 
   267                              <1> ;		N= NUMBER OF BYTES PER SECTOR (00=128,01=256,02=512,03=1024),
   268                              <1> ;		THERE MUST BE ONE ENTRY FOR EVERY SECTOR ON THE TRACK.
   269                              <1> ;		THIS INFORMATION IS USED TO FIND THE REQUESTED SECTOR DURING 
   270                              <1> ;		READ/WRITE ACCESS.
   271                              <1> ;		PRIOR TO FORMATTING A DISKETTE, IF THERE EXISTS MORE THAN
   272                              <1> ;		ONE SUPPORTED MEDIA FORMAT TYPE WITHIN THE DRIVE IN QUESTION,
   273                              <1> ;		THEN "SET DASD TYPE" (INT 13H, AH = 17H) OR 'SET MEDIA TYPE'
   274                              <1> ;		(INT 13H, AH =  18H) MUST BE CALLED TO SET THE DISKETTE TYPE
   275                              <1> ;		THAT IS TO BE FORMATTED. IF "SET DASD TYPE" OR "SET MEDIA TYPE"
   276                              <1> ;		IS NOT CALLED, THE FORMAT ROUTINE WILL ASSUME THE 
   277                              <1> ;		MEDIA FORMAT TO BE THE MAXIMUM CAPACITY OF THE DRIVE.
   278                              <1> ;
   279                              <1> ;		THESE PARAMETERS OF DISK BASE MUST BE CHANGED IN ORDER TO
   280                              <1> ;		FORMAT THE FOLLOWING MEDIAS:
   281                              <1> ;		---------------------------------------------
   282                              <1> ;		: MEDIA  :     DRIVE      : PARM 1 : PARM 2 :
   283                              <1> ;		---------------------------------------------
   284                              <1> ;		: 320K	 : 320K/360K/1.2M :  50H   :   8    :
   285                              <1> ;		: 360K	 : 320K/360K/1.2M :  50H   :   9    :
   286                              <1> ;		: 1.2M	 : 1.2M           :  54H   :  15    :
   287                              <1> ;		: 720K	 : 720K/1.44M     :  50H   :   9    :
   288                              <1> ;		: 1.44M	 : 1.44M          :  6CH   :  18    :		  	
   289                              <1> ;		---------------------------------------------
   290                              <1> ;		NOTES: - PARM 1 = GAP LENGTH FOR FORMAT
   291                              <1> ;		       - PARM 2 = EOT (LAST SECTOR ON TRACK)
   292                              <1> ;		       - DISK BASE IS POINTED BY DISK POINTER LOCATED
   293                              <1> ;			 AT ABSOLUTE ADDRESS 0:78.
   294                              <1> ;		       - WHEN FORMAT OPERATIONS ARE COMPLETE, THE PARAMETERS
   295                              <1> ;			 SHOULD BE RESTORED TO THEIR RESPECTIVE INITIAL VALUES.			
   296                              <1> ;-------------------------------------------------------------------------------
   297                              <1> ;	(AH) = 08H READ DRIVE PARAMETERS
   298                              <1> ;	REGISTERS
   299                              <1> ;	  INPUT
   300                              <1> ;	    (DL) - DRIVE NUMBER (0-1 ALLOWED, VALUE CHECKED)
   301                              <1> ;	     ** 27/05/2016 - TRDOS 386 (TRDOS v2.0) **	
   302                              <1> ;            ** EBX = Buffer address for floppy disk parameters table **
   303                              <1> ;	  OUTPUT
   304                              <1> ;	    (ES:DI) POINTS TO DRIVE PARAMETER TABLE
   305                              <1> ; 	    *** TRDOS 386 note: floppy disk parameter table (16 bytes)
   306                              <1> ;	    will be returned to user in EBX, buffer address *** 27/05/2016 ***		
   307                              <1> ;					
   308                              <1> ;	    (CH) - LOW ORDER 8 OF 10 BITS MAXIMUM NUMBER OF TRACKS
   309                              <1> ;	    (CL) - BITS 7 & 6 - HIGH ORDER TWO BITS OF MAXIMUM TRACKS
   310                              <1> ;	           BITS 5 THRU 0 - MAXIMUM SECTORS PER TRACK
   311                              <1> ;	    (DH) - MAXIMUM HEAD NUMBER
   312                              <1> ;	    (DL) - NUMBER OF DISKETTE DRIVES INSTALLED
   313                              <1> ;	    (BH) - 0
   314                              <1> ;	    (BL) - BITS 7 THRU 4 - 0
   315                              <1> ;	           BITS 3 THRU 0 - VALID DRIVE TYPE VALUE IN CMOS
   316                              <1> ;	    (AX) - 0
   317                              <1> ;	 UNDER THE FOLLOWING CIRCUMSTANCES:
   318                              <1> ;	    (1) THE DRIVE NUMBER IS INVALID,
   319                              <1> ;	    (2) THE DRIVE TYPE IS UNKNOWN AND CMOS IS NOT PRESENT, 
   320                              <1> ;	    (3) THE DRIVE TYPE IS UNKNOWN AND CMOS IS BAD,
   321                              <1> ;	    (4) OR THE DRIVE TYPE IS UNKNOWN AND THE CMOS DRIVE TYPE IS INVALID
   322                              <1> ;	    THEN ES,AX,BX,CX,DH,DI=0 ; DL=NUMBER OF DRIVES. 
   323                              <1> ;	    IF NO DRIVES ARE PRESENT THEN: ES,AX,BX,CX,DX,DI=0.
   324                              <1> ;	    @DISKETTE_STATUS = 0 AND CY IS RESET.
   325                              <1> ;-------------------------------------------------------------------------------
   326                              <1> ;	(AH)= 15H  READ DASD TYPE
   327                              <1> ;	OUTPUT REGISTERS
   328                              <1> ;	(AH) - ON RETURN IF CARRY FLAG NOT SET, OTHERWISE ERROR	
   329                              <1> ;		00 - DRIVE NOT PRESENT	
   330                              <1> ;		01 - DISKETTE, NO CHANGE LINE AVAILABLE
   331                              <1> ;		02 - DISKETTE, CHANGE LINE AVAILABLE	
   332                              <1> ;		03 - RESERVED (FIXED DISK)
   333                              <1> ;	(DL) - DRIVE NUMBER (0-1 ALLOWED, VALUE CHECKED)
   334                              <1> ;-------------------------------------------------------------------------------
   335                              <1> ;	(AH)= 16H  DISK CHANGE LINE STATUS
   336                              <1> ;	OUTPUT REGISTERS
   337                              <1> ;	(AH) - 00 - DISK CHANGE LINE NOT ACTIVE	
   338                              <1> ;	       06 - DISK CHANGE LINE ACTIVE & CARRY BIT ON
   339                              <1> ;	(DL) - DRIVE NUMBER (0-1 ALLOWED, VALUE CHECKED)
   340                              <1> ;-------------------------------------------------------------------------------
   341                              <1> ;	(AH)= 17H  SET DASD TYPE FOR FORMAT
   342                              <1> ;	INPUT REGISTERS
   343                              <1> ;	(AL) -	00 - NOT USED	
   344                              <1> ;		01 - DISKETTE 320/360K IN 360K DRIVE	
   345                              <1> ;		02 - DISKETTE 360K IN 1.2M DRIVE
   346                              <1> ;		03 - DISKETTE 1.2M IN 1.2M DRIVE
   347                              <1> ;		04 - DISKETTE 720K IN 720K DRIVE
   348                              <1> ;	(DL) - DRIVE NUMBER (0-1 ALLOWED, VALUE CHECKED:
   349                              <1> ;	       (DO NOT USE WHEN DISKETTE ATTACH CARD USED)
   350                              <1> ;-------------------------------------------------------------------------------
   351                              <1> ;	(AH)= 18H  SET MEDIA TYPE FOR FORMAT
   352                              <1> ;	INPUT REGISTERS
   353                              <1> ;	(CH) - LOW ORDER 8 OF 10 BITS MAXIMUM TRACKS
   354                              <1> ;	(CL) - BITS 7 & 6 - HIGH ORDER TWO BITS OF MAXIMUM TRACKS
   355                              <1> ;	       BITS 5 THRU 0 - MAXIMUM SECTORS PER TRACK
   356                              <1> ;	(DL) - DRIVE NUMBER (0-1 ALLOWED, VALUE CHACKED)
   357                              <1> ;	OUTPUT REGISTERS:
   358                              <1> ;	(ES:DI) - POINTER TO DRIVE PARAMETERS TABLE FOR THIS MEDIA TYPE,
   359                              <1> ;		  UNCHANGED IF (AH) IS NON-ZERO
   360                              <1> ;	(AH) - 00H, CY = 0, TRACK AND SECTORS/TRACK COMBINATION IS SUPPORTED
   361                              <1> ;	     - 01H, CY = 1, FUNCTION IS NOT AVAILABLE
   362                              <1> ;	     - 0CH, CY = 1, TRACK AND SECTORS/TRACK COMBINATION IS NOT SUPPORTED
   363                              <1> ;	     - 80H, CY = 1, TIME OUT (DISKETTE NOT PRESENT)		
   364                              <1> ;-------------------------------------------------------------------------------
   365                              <1> ;	DISK CHANGE STATUS IS ONLY CHECKED WHEN A MEDIA SPECIFIED IS OTHER
   366                              <1> ;	THAN 360 KB DRIVE. IF THE DISK CHANGE LINE IS FOUND TO BE
   367                              <1> ;	ACTIVE THE FOLLOWING ACTIONS TAKE PLACE:
   368                              <1> ;		ATTEMPT TO RESET DISK CHANGE LINE TO INACTIVE STATE. 
   369                              <1> ;		IF ATTEMPT SUCCEEDS SET DASD TYPE FOR FORMAT AND RETURN DISK 
   370                              <1> ;		CHANGE ERROR CODE
   371                              <1> ;		IF ATTEMPT FAILS RETURN TIMEOUT ERROR CODE AND SET DASD TYPE 
   372                              <1> ;		TO A PREDETERMINED STATE INDICATING MEDIA TYPE UNKNOWN.
   373                              <1> ;	IF THE DISK CHANGE LINE IN INACTIVE PERFORM SET DASD TYPE FOR FORMAT.
   374                              <1> ;
   375                              <1> ; DATA VARIABLE -- @DISK_POINTER
   376                              <1> ;	DOUBLE WORD POINTER TO THE CURRENT SET OF DISKETTE PARAMETERS
   377                              <1> ;-------------------------------------------------------------------------------
   378                              <1> ; OUTPUT FOR ALL FUNCTIONS
   379                              <1> ;	AH = STATUS OF OPERATION
   380                              <1> ;		STATUS BITS ARE DEFINED IN THE EQUATES FOR @DISKETTE_STATUS
   381                              <1> ;		VARIABLE IN THE DATA SEGMENT OF THIS MODULE
   382                              <1> ;	CY = 0	SUCCESSFUL OPERATION (AH=0 ON RETURN, EXCEPT FOR READ DASD
   383                              <1> ;		TYPE AH=(15)).
   384                              <1> ;	CY = 1	FAILED OPERATION (AH HAS ERROR REASON)
   385                              <1> ;	FOR READ/WRITE/VERIFY
   386                              <1> ;		DS,BX,DX,CX PRESERVED
   387                              <1> ;	NOTE: IF AN ERROR IS REPORTED BY THE DISKETTE CODE, THE APPROPRIATE 
   388                              <1> ;		ACTION IS TO RESET THE DISKETTE, THEN RETRY THE OPERATION.
   389                              <1> ;		ON READ ACCESSES, NO MOTOR START DELAY IS TAKEN, SO THAT 
   390                              <1> ;		THREE RETRIES ARE REQUIRED ON READS TO ENSURE THAT THE 
   391                              <1> ;		PROBLEM IS NOT DUE TO MOTOR START-UP.
   392                              <1> ;-------------------------------------------------------------------------------
   393                              <1> ;
   394                              <1> ; DISKETTE STATE MACHINE - ABSOLUTE ADDRESS 40:90 (DRIVE A) & 91 (DRIVE B)
   395                              <1> ;
   396                              <1> ;   -----------------------------------------------------------------
   397                              <1> ;   |       |       |       |       |       |       |       |       |
   398                              <1> ;   |   7   |   6   |   5   |   4   |   3   |   2   |   1   |   0   |
   399                              <1> ;   |       |       |       |       |       |       |       |       |
   400                              <1> ;   -----------------------------------------------------------------
   401                              <1> ;	|	|	|	|	|	|	|	|
   402                              <1> ;	|	|	|	|	|	-----------------
   403                              <1> ;	|	|	|	|	|		|
   404                              <1> ;	|	|	|	|    RESERVED		|
   405                              <1> ;	|	|	|	|		  PRESENT STATE
   406                              <1> ;	|	|	|	|	000: 360K IN 360K DRIVE UNESTABLISHED
   407                              <1> ;	|	|	|	|	001: 360K IN 1.2M DRIVE UNESTABLISHED
   408                              <1> ;	|	|	|	|	010: 1.2M IN 1.2M DRIVE UNESTABLISHED
   409                              <1> ;	|	|	|	|	011: 360K IN 360K DRIVE ESTABLISHED
   410                              <1> ;	|	|	|	|	100: 360K IN 1.2M DRIVE ESTABLISHED
   411                              <1> ;	|	|	|	|	101: 1.2M IN 1.2M DRIVE ESTABLISHED
   412                              <1> ;	|	|	|	|	110: RESERVED
   413                              <1> ;	|	|	|	|	111: NONE OF THE ABOVE
   414                              <1> ;	|	|	|	|
   415                              <1> ;	|	|	|	------>	MEDIA/DRIVE ESTABLISHED
   416                              <1> ;	|	|	|
   417                              <1> ;	|	|	-------------->	DOUBLE STEPPING REQUIRED (360K IN 1.2M
   418                              <1> ;	|	|			DRIVE)
   419                              <1> ;	|	|
   420                              <1> ;	------------------------------>	DATA TRANSFER RATE FOR THIS DRIVE:
   421                              <1> ;
   422                              <1> ;						00: 500 KBS
   423                              <1> ;						01: 300 KBS
   424                              <1> ;						10: 250 KBS
   425                              <1> ;						11: RESERVED
   426                              <1> ;
   427                              <1> ;
   428                              <1> ;-------------------------------------------------------------------------------
   429                              <1> ; STATE OPERATION STARTED - ABSOLUTE ADDRESS 40:92 (DRIVE A) & 93 (DRIVE B)
   430                              <1> ;-------------------------------------------------------------------------------
   431                              <1> ; PRESENT CYLINDER NUMBER - ABSOLUTE ADDRESS 40:94 (DRIVE A) & 95 (DRIVE B)
   432                              <1> ;-------------------------------------------------------------------------------
   433                              <1> 
   434                              <1> struc MD
   435 00000000 <res 00000001>      <1> 	.SPEC1		resb	1	; SRT=D, HD UNLOAD=0F - 1ST SPECIFY BYTE
   436 00000001 <res 00000001>      <1> 	.SPEC2		resb	1	; HD LOAD=1, MODE=DMA - 2ND SPECIFY BYTE
   437 00000002 <res 00000001>      <1> 	.OFF_TIM	resb	1	; WAIT TIME AFTER OPERATION TILL MOTOR OFF
   438 00000003 <res 00000001>      <1> 	.BYT_SEC	resb	1	; 512 BYTES/SECTOR
   439 00000004 <res 00000001>      <1> 	.SEC_TRK	resb	1	; EOT (LAST SECTOR ON TRACK)
   440 00000005 <res 00000001>      <1> 	.GAP		resb	1	; GAP LENGTH
   441 00000006 <res 00000001>      <1> 	.DTL		resb	1	; DTL
   442 00000007 <res 00000001>      <1> 	.GAP3		resb	1	; GAP LENGTH FOR FORMAT
   443 00000008 <res 00000001>      <1> 	.FIL_BYT	resb	1	; FILL BYTE FOR FORMAT
   444 00000009 <res 00000001>      <1> 	.HD_TIM		resb	1	; HEAD SETTLE TIME (MILLISECONDS)
   445 0000000A <res 00000001>      <1> 	.STR_TIM	resb	1	; MOTOR START TIME (1/8 SECONDS)
   446 0000000B <res 00000001>      <1> 	.MAX_TRK	resb	1	; MAX. TRACK NUMBER
   447 0000000C <res 00000001>      <1> 	.RATE		resb	1	; DATA TRANSFER RATE
   448                              <1> endstruc
   449                              <1> 
   450                              <1> BIT7OFF	EQU	7FH
   451                              <1> BIT7ON	EQU	80H
   452                              <1> 
   453                              <1> ;;int13h: ; 16/02/2015
   454                              <1> ;; 16/02/2015 - 21/02/2015
   455                              <1> int40h:
   456 00002DBE 9C                  <1> 	pushfd
   457 00002DBF 0E                  <1> 	push 	cs
   458 00002DC0 E801000000          <1> 	call 	DISKETTE_IO_1
   459 00002DC5 C3                  <1> 	retn	
   460                              <1> 
   461                              <1> DISKETTE_IO_1:
   462                              <1> 
   463 00002DC6 FB                  <1> 	STI				; INTERRUPTS BACK ON
   464 00002DC7 55                  <1> 	PUSH	eBP			; USER REGISTER
   465 00002DC8 57                  <1> 	PUSH	eDI			; USER REGISTER
   466 00002DC9 52                  <1> 	PUSH	eDX			; HEAD #, DRIVE # OR USER REGISTER
   467 00002DCA 53                  <1> 	PUSH	eBX			; BUFFER OFFSET PARAMETER OR REGISTER
   468 00002DCB 51                  <1> 	PUSH	eCX			; TRACK #-SECTOR # OR USER REGISTER
   469 00002DCC 89E5                <1> 	MOV	eBP,eSP			; BP     => PARAMETER LIST DEP. ON AH
   470                              <1> 					; [BP]   = SECTOR #
   471                              <1> 					; [BP+1] = TRACK #
   472                              <1> 					; [BP+2] = BUFFER OFFSET
   473                              <1> 					; FOR RETURN OF DRIVE PARAMETERS:
   474                              <1> 					; CL/[BP] = BITS 7&6 HI BITS OF MAX CYL
   475                              <1> 					; 	    BITS 0-5 MAX SECTORS/TRACK
   476                              <1> 					; CH/[BP+1] = LOW 8 BITS OF MAX CYL.
   477                              <1> 					; BL/[BP+2] = BITS 7-4 = 0
   478                              <1> 					;	      BITS 3-0 = VALID CMOS TYPE
   479                              <1> 					; BH/[BP+3] = 0
   480                              <1> 					; DL/[BP+4] = # DRIVES INSTALLED
   481                              <1> 					; DH/[BP+5] = MAX HEAD #
   482                              <1> 					; DI/[BP+6] = OFFSET TO DISK BASE
   483 00002DCE 06                  <1> 	push	es ; 06/02/2015	
   484 00002DCF 1E                  <1> 	PUSH	DS			; BUFFER SEGMENT PARM OR USER REGISTER
   485 00002DD0 56                  <1> 	PUSH	eSI			; USER REGISTERS
   486                              <1> 	;CALL	DDS			; SEGMENT OF BIOS DATA AREA TO DS
   487                              <1> 	;mov	cx, cs
   488                              <1> 	;mov	ds, cx
   489 00002DD1 66B91000            <1> 	mov	cx, KDATA
   490 00002DD5 8ED9                <1>         mov     ds, cx
   491 00002DD7 8EC1                <1>         mov     es, cx
   492                              <1> 
   493                              <1> 	;CMP	AH,(FNC_TAE-FNC_TAB)/2	; CHECK FOR > LARGEST FUNCTION
   494 00002DD9 80FC19              <1> 	cmp	ah,(FNC_TAE-FNC_TAB)/4  ; 18/02/2015
   495 00002DDC 7202                <1> 	JB	short OK_FUNC		; FUNCTION OK
   496 00002DDE B414                <1> 	MOV	AH,14H			; REPLACE WITH KNOWN INVALID FUNCTION
   497                              <1> OK_FUNC:
   498 00002DE0 80FC01              <1> 	CMP	AH,1			; RESET OR STATUS ?
   499 00002DE3 760C                <1> 	JBE	short OK_DRV		; IF RESET OR STATUS DRIVE ALWAYS OK
   500 00002DE5 80FC08              <1> 	CMP	AH,8			; READ DRIVE PARMS ?
   501 00002DE8 7407                <1> 	JZ	short OK_DRV		; IF SO DRIVE CHECKED LATER
   502 00002DEA 80FA01              <1> 	CMP	DL,1			; DRIVES 0 AND 1 OK
   503 00002DED 7602                <1> 	JBE	short OK_DRV		; IF 0 OR 1 THEN JUMP
   504 00002DEF B414                <1> 	MOV	AH,14H			; REPLACE WITH KNOWN INVALID FUNCTION
   505                              <1> OK_DRV:
   506 00002DF1 31C9                <1> 	xor	ecx, ecx
   507                              <1> 	;mov	esi, ecx ; 08/02/2015
   508 00002DF3 89CF                <1> 	mov	edi, ecx ; 08/02/2015
   509 00002DF5 88E1                <1> 	MOV	CL,AH			; CL = FUNCTION
   510                              <1> 	;XOR	CH,CH			; CX = FUNCTION
   511                              <1> 	;SHL	CL, 1			; FUNCTION TIMES 2
   512 00002DF7 C0E102              <1> 	SHL	CL, 2 ; 20/02/2015	; FUNCTION TIMES 4 (for 32 bit offset)
   513 00002DFA BB[322E0000]        <1> 	MOV	eBX,FNC_TAB		; LOAD START OF FUNCTION TABLE
   514 00002DFF 01CB                <1> 	ADD	eBX,eCX			; ADD OFFSET INTO TABLE => ROUTINE
   515 00002E01 88F4                <1> 	MOV	AH,DH			; AX = HEAD #,# OF SECTORS OR DASD TYPE
   516 00002E03 30F6                <1> 	XOR	DH,DH			; DX = DRIVE #
   517 00002E05 6689C6              <1> 	MOV	SI,AX			; SI = HEAD #,# OF SECTORS OR DASD TYPE
   518 00002E08 6689D7              <1> 	MOV     DI,DX                   ; DI = DRIVE #
   519                              <1> 	;
   520                              <1> 	; 11/12/2014
   521 00002E0B 8815[EBEC0000]      <1>         mov     [cfd], dl               ; current floppy drive (for 'GET_PARM')        
   522                              <1> 	;
   523 00002E11 8A25[30200100]      <1> 	MOV	AH, [DSKETTE_STATUS]	; LOAD STATUS TO AH FOR STATUS FUNCTION
   524 00002E17 C605[30200100]00    <1> 	MOV	byte [DSKETTE_STATUS],0	; INITIALIZE FOR ALL OTHERS
   525                              <1> 
   526                              <1> ;	THROUGHOUT THE DISKETTE BIOS, THE FOLLOWING INFORMATION IS CONTAINED IN
   527                              <1> ;	THE FOLLOWING MEMORY LOCATIONS AND REGISTERS. NOT ALL DISKETTE BIOS
   528                              <1> ;	FUNCTIONS REQUIRE ALL OF THESE PARAMETERS.
   529                              <1> ;
   530                              <1> ;		DI	: DRIVE #
   531                              <1> ;		SI-HI	: HEAD #
   532                              <1> ;		SI-LOW	: # OF SECTORS OR DASD TYPE FOR FORMAT
   533                              <1> ;		ES	: BUFFER SEGMENT
   534                              <1> ;		[BP]	: SECTOR #
   535                              <1> ;		[BP+1]	: TRACK #
   536                              <1> ;		[BP+2]	: BUFFER OFFSET
   537                              <1> ;
   538                              <1> ;	ACROSS CALLS TO SUBROUTINES THE CARRY FLAG (CY=1), WHERE INDICATED IN 
   539                              <1> ;	SUBROUTINE PROLOGUES, REPRESENTS AN EXCEPTION RETURN (NORMALLY AN ERROR 
   540                              <1> ;	CONDITION). IN MOST CASES, WHEN CY = 1, @DSKETTE_STATUS CONTAINS THE 
   541                              <1> ;	SPECIFIC ERROR CODE.
   542                              <1> ;
   543                              <1> 					; (AH) = @DSKETTE_STATUS
   544 00002E1E FF13                <1> 	CALL	dWORD [eBX]		; CALL THE REQUESTED FUNCTION
   545 00002E20 5E                  <1> 	POP	eSI			; RESTORE ALL REGISTERS
   546 00002E21 1F                  <1> 	POP	DS
   547 00002E22 07                  <1> 	pop	es	; 06/02/2015
   548 00002E23 59                  <1> 	POP	eCX
   549 00002E24 5B                  <1> 	POP	eBX
   550 00002E25 5A                  <1> 	POP	eDX
   551 00002E26 5F                  <1> 	POP	eDI
   552 00002E27 89E5                <1> 	MOV	eBP, eSP
   553 00002E29 50                  <1> 	PUSH	eAX
   554 00002E2A 9C                  <1> 	PUSHFd
   555 00002E2B 58                  <1> 	POP	eAX
   556                              <1> 	;MOV	[BP+6], AX
   557 00002E2C 89450C              <1> 	mov	[ebp+12], eax  ; 18/02/2015, flags
   558 00002E2F 58                  <1> 	POP	eAX
   559 00002E30 5D                  <1> 	POP	eBP
   560 00002E31 CF                  <1> 	IRETd
   561                              <1> 
   562                              <1> ;-------------------------------------------------------------------------------
   563                              <1> ; DW --> dd (06/02/2015)
   564 00002E32 [962E0000]          <1> FNC_TAB	dd	DSK_RESET		; AH = 00H; RESET
   565 00002E36 [0F2F0000]          <1> 	dd	DSK_STATUS		; AH = 01H; STATUS
   566 00002E3A [202F0000]          <1> 	dd	DSK_READ		; AH = 02H; READ
   567 00002E3E [312F0000]          <1> 	dd	DSK_WRITE		; AH = 03H; WRITE
   568 00002E42 [422F0000]          <1> 	dd	DSK_VERF		; AH = 04H; VERIFY
   569 00002E46 [532F0000]          <1> 	dd	DSK_FORMAT		; AH = 05H; FORMAT
   570 00002E4A [D82F0000]          <1> 	dd	FNC_ERR			; AH = 06H; INVALID
   571 00002E4E [D82F0000]          <1> 	dd	FNC_ERR			; AH = 07H; INVALID
   572 00002E52 [E52F0000]          <1> 	dd	DSK_PARMS		; AH = 08H; READ DRIVE PARAMETERS
   573 00002E56 [D82F0000]          <1> 	dd	FNC_ERR			; AH = 09H; INVALID
   574 00002E5A [D82F0000]          <1> 	dd	FNC_ERR			; AH = 0AH; INVALID
   575 00002E5E [D82F0000]          <1> 	dd	FNC_ERR			; AH = 0BH; INVALID
   576 00002E62 [D82F0000]          <1> 	dd	FNC_ERR			; AH = 0CH; INVALID
   577 00002E66 [D82F0000]          <1> 	dd	FNC_ERR			; AH = 0DH; INVALID
   578 00002E6A [D82F0000]          <1> 	dd	FNC_ERR			; AH = 0EH; INVALID
   579 00002E6E [D82F0000]          <1> 	dd	FNC_ERR			; AH = 0FH; INVALID
   580 00002E72 [D82F0000]          <1> 	dd	FNC_ERR			; AH = 10H; INVALID
   581 00002E76 [D82F0000]          <1> 	dd	FNC_ERR			; AH = 11H; INVALID
   582 00002E7A [D82F0000]          <1> 	dd	FNC_ERR			; AH = 12H; INVALID
   583 00002E7E [D82F0000]          <1> 	dd	FNC_ERR			; AH = 13H; INVALID
   584 00002E82 [D82F0000]          <1> 	dd	FNC_ERR			; AH = 14H; INVALID
   585 00002E86 [BD300000]          <1> 	dd	DSK_TYPE		; AH = 15H; READ DASD TYPE
   586 00002E8A [E8300000]          <1> 	dd	DSK_CHANGE		; AH = 16H; CHANGE STATUS
   587 00002E8E [22310000]          <1> 	dd	FORMAT_SET		; AH = 17H; SET DASD TYPE
   588 00002E92 [A5310000]          <1> 	dd	SET_MEDIA		; AH = 18H; SET MEDIA TYPE	
   589                              <1> FNC_TAE EQU     $                       ; END
   590                              <1> 
   591                              <1> ;-------------------------------------------------------------------------------
   592                              <1> ; DISK_RESET	(AH = 00H)	
   593                              <1> ;		RESET THE DISKETTE SYSTEM.
   594                              <1> ;
   595                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
   596                              <1> ;-------------------------------------------------------------------------------
   597                              <1> DSK_RESET:
   598 00002E96 66BAF203            <1> 	MOV	DX,03F2H		; ADAPTER CONTROL PORT
   599 00002E9A FA                  <1> 	CLI				; NO INTERRUPTS
   600 00002E9B A0[2E200100]        <1> 	MOV	AL,[MOTOR_STATUS]	; GET DIGITAL OUTPUT REGISTER REFLECTION
   601 00002EA0 243F                <1> 	AND	AL,00111111B		; KEEP SELECTED AND MOTOR ON BITS
   602 00002EA2 C0C004              <1> 	ROL	AL,4			; MOTOR VALUE TO HIGH NIBBLE
   603                              <1> 					; DRIVE SELECT TO LOW NIBBLE
   604 00002EA5 0C08                <1> 	OR	AL,00001000B		; TURN ON INTERRUPT ENABLE
   605 00002EA7 EE                  <1> 	OUT	DX,AL			; RESET THE ADAPTER
   606 00002EA8 C605[2D200100]00    <1> 	MOV	byte [SEEK_STATUS],0	; SET RECALIBRATE REQUIRED ON ALL DRIVES
   607                              <1> 	;JMP	$+2			; WAIT FOR I/O
   608                              <1> 	;JMP	$+2			; WAIT FOR I/O (TO INSURE MINIMUM
   609                              <1> 					;      PULSE WIDTH)
   610                              <1> 	; 19/12/2014
   611                              <1> 	NEWIODELAY
   611 00002EAF E6EB                <2>  out 0ebh,al
   612                              <1> 
   613                              <1> 	; 17/12/2014 
   614                              <1> 	; AWARD BIOS 1999 - RESETDRIVES (ADISK.ASM)
   615 00002EB1 B915000000          <1> 	mov	ecx, WAITCPU_RESET_ON	; cx = 21 -- Min. 14 micro seconds !?
   616                              <1> wdw1:
   617                              <1> 	NEWIODELAY   ; 27/02/2015
   617 00002EB6 E6EB                <2>  out 0ebh,al
   618 00002EB8 E2FC                <1> 	loop	wdw1
   619                              <1> 	;
   620 00002EBA 0C04                <1> 	OR	AL,00000100B		; TURN OFF RESET BIT
   621 00002EBC EE                  <1> 	OUT	DX,AL			; RESET THE ADAPTER
   622                              <1> 	; 16/12/2014
   623                              <1> 	IODELAY
   623 00002EBD EB00                <2>  jmp short $+2
   623 00002EBF EB00                <2>  jmp short $+2
   624                              <1> 	;
   625                              <1> 	;STI				; ENABLE THE INTERRUPTS
   626 00002EC1 E83C0C0000          <1> 	CALL	WAIT_INT		; WAIT FOR THE INTERRUPT
   627 00002EC6 723E                <1> 	JC	short DR_ERR		; IF ERROR, RETURN IT
   628 00002EC8 66B9C000            <1> 	MOV	CX,11000000B		; CL = EXPECTED @NEC_STATUS
   629                              <1> NXT_DRV:
   630 00002ECC 6651                <1> 	PUSH	CX			; SAVE FOR CALL
   631 00002ECE B8[042F0000]        <1> 	MOV	eAX, DR_POP_ERR 	; LOAD NEC_OUTPUT ERROR ADDRESS
   632 00002ED3 50                  <1> 	PUSH	eAX			; "
   633 00002ED4 B408                <1> 	MOV	AH,08H			; SENSE INTERRUPT STATUS COMMAND
   634 00002ED6 E81A0B0000          <1> 	CALL	NEC_OUTPUT
   635 00002EDB 58                  <1> 	POP	eAX			; THROW AWAY ERROR RETURN
   636 00002EDC E8510C0000          <1> 	CALL	RESULTS			; READ IN THE RESULTS
   637 00002EE1 6659                <1> 	POP	CX			; RESTORE AFTER CALL
   638 00002EE3 7221                <1> 	JC	short DR_ERR		; ERROR RETURN
   639 00002EE5 3A0D[31200100]      <1> 	CMP	CL, [NEC_STATUS]	; TEST FOR DRIVE READY TRANSITION
   640 00002EEB 7519                <1> 	JNZ	short DR_ERR		; EVERYTHING OK
   641 00002EED FEC1                <1> 	INC	CL			; NEXT EXPECTED @NEC_STATUS
   642 00002EEF 80F9C3              <1> 	CMP	CL,11000011B		; ALL POSSIBLE DRIVES CLEARED
   643 00002EF2 76D8                <1> 	JBE	short NXT_DRV		; FALL THRU IF 11000100B OR >
   644                              <1> 	;
   645 00002EF4 E869030000          <1> 	CALL	SEND_SPEC		; SEND SPECIFY COMMAND TO NEC
   646                              <1> RESBAC:
   647 00002EF9 E81D090000          <1> 	CALL	SETUP_END		; VARIOUS CLEANUPS
   648 00002EFE 6689F3              <1> 	MOV	BX,SI			; GET SAVED AL TO BL
   649 00002F01 88D8                <1> 	MOV	AL,BL			; PUT BACK FOR RETURN
   650 00002F03 C3                  <1> 	RETn		
   651                              <1> DR_POP_ERR:
   652 00002F04 6659                <1> 	POP	CX			; CLEAR STACK
   653                              <1> DR_ERR:
   654 00002F06 800D[30200100]20    <1> 	OR	byte [DSKETTE_STATUS],BAD_NEC ; SET ERROR CODE
   655 00002F0D EBEA                <1> 	JMP	SHORT RESBAC		; RETURN FROM RESET
   656                              <1> 
   657                              <1> ;-------------------------------------------------------------------------------
   658                              <1> ; DISK_STATUS	(AH = 01H)
   659                              <1> ;	DISKETTE STATUS.
   660                              <1> ;
   661                              <1> ; ON ENTRY:	AH : STATUS OF PREVIOUS OPERATION
   662                              <1> ;
   663                              <1> ; ON EXIT:	AH, @DSKETTE_STATUS, CY REFLECT STATUS OF PREVIOUS OPERATION.
   664                              <1> ;-------------------------------------------------------------------------------
   665                              <1> DSK_STATUS:
   666 00002F0F 8825[30200100]      <1> 	MOV	[DSKETTE_STATUS],AH	; PUT BACK FOR SETUP END
   667 00002F15 E801090000          <1> 	CALL	SETUP_END		; VARIOUS CLEANUPS
   668 00002F1A 6689F3              <1> 	MOV	BX,SI			; GET SAVED AL TO BL
   669 00002F1D 88D8                <1> 	MOV	AL,BL			; PUT BACK FOR RETURN
   670 00002F1F C3                  <1> 	RETn		
   671                              <1> 
   672                              <1> ;-------------------------------------------------------------------------------
   673                              <1> ; DISK_READ	(AH = 02H)	
   674                              <1> ;	DISKETTE READ.
   675                              <1> ;
   676                              <1> ; ON ENTRY:	DI	: DRIVE #
   677                              <1> ;		SI-HI	: HEAD #
   678                              <1> ;		SI-LOW	: # OF SECTORS
   679                              <1> ;		ES	: BUFFER SEGMENT
   680                              <1> ;		[BP]	: SECTOR #
   681                              <1> ;		[BP+1]	: TRACK #
   682                              <1> ;		[BP+2]	: BUFFER OFFSET
   683                              <1> ;
   684                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
   685                              <1> ;-------------------------------------------------------------------------------
   686                              <1> 
   687                              <1> ; 06/02/2015, ES:BX -> EBX (unix386.s)
   688                              <1> 
   689                              <1> DSK_READ:
   690 00002F20 8025[2E200100]7F    <1> 	AND	byte [MOTOR_STATUS],01111111B ; INDICATE A READ OPERATION
   691 00002F27 66B846E6            <1> 	MOV	AX,0E646H		; AX = NEC COMMAND, DMA COMMAND
   692 00002F2B E83C040000          <1> 	CALL	RD_WR_VF		; COMMON READ/WRITE/VERIFY
   693 00002F30 C3                  <1> 	RETn
   694                              <1> 
   695                              <1> ;-------------------------------------------------------------------------------
   696                              <1> ; DISK_WRITE	(AH = 03H)
   697                              <1> ;	DISKETTE WRITE.
   698                              <1> ;
   699                              <1> ; ON ENTRY:	DI	: DRIVE #
   700                              <1> ;		SI-HI	: HEAD #
   701                              <1> ;		SI-LOW	: # OF SECTORS
   702                              <1> ;		ES	: BUFFER SEGMENT
   703                              <1> ;		[BP]	: SECTOR #
   704                              <1> ;		[BP+1]	: TRACK #
   705                              <1> ;		[BP+2]	: BUFFER OFFSET
   706                              <1> ;
   707                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
   708                              <1> ;-------------------------------------------------------------------------------
   709                              <1> 
   710                              <1> ; 06/02/2015, ES:BX -> EBX (unix386.s)
   711                              <1> 
   712                              <1> DSK_WRITE:
   713 00002F31 66B84AC5            <1> 	MOV	AX,0C54AH		; AX = NEC COMMAND, DMA COMMAND
   714 00002F35 800D[2E200100]80    <1>         OR      byte [MOTOR_STATUS],10000000B ; INDICATE WRITE OPERATION
   715 00002F3C E82B040000          <1> 	CALL	RD_WR_VF		; COMMON READ/WRITE/VERIFY
   716 00002F41 C3                  <1> 	RETn
   717                              <1> 
   718                              <1> ;-------------------------------------------------------------------------------
   719                              <1> ; DISK_VERF	(AH = 04H)
   720                              <1> ;	DISKETTE VERIFY.
   721                              <1> ;
   722                              <1> ; ON ENTRY:	DI	: DRIVE #
   723                              <1> ;		SI-HI	: HEAD #
   724                              <1> ;		SI-LOW	: # OF SECTORS
   725                              <1> ;		ES	: BUFFER SEGMENT
   726                              <1> ;		[BP]	: SECTOR #
   727                              <1> ;		[BP+1]	: TRACK #
   728                              <1> ;		[BP+2]	: BUFFER OFFSET
   729                              <1> ;
   730                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
   731                              <1> ;-------------------------------------------------------------------------------
   732                              <1> DSK_VERF:
   733 00002F42 8025[2E200100]7F    <1> 	AND	byte [MOTOR_STATUS],01111111B ; INDICATE A READ OPERATION
   734 00002F49 66B842E6            <1> 	MOV	AX,0E642H		; AX = NEC COMMAND, DMA COMMAND
   735 00002F4D E81A040000          <1> 	CALL	RD_WR_VF		; COMMON READ/WRITE/VERIFY
   736 00002F52 C3                  <1> 	RETn
   737                              <1> 
   738                              <1> ;-------------------------------------------------------------------------------
   739                              <1> ; DISK_FORMAT	(AH = 05H)
   740                              <1> ;	DISKETTE FORMAT.
   741                              <1> ;
   742                              <1> ; ON ENTRY:	DI	: DRIVE #
   743                              <1> ;		SI-HI	: HEAD #
   744                              <1> ;		SI-LOW	: # OF SECTORS
   745                              <1> ;		ES	: BUFFER SEGMENT
   746                              <1> ;		[BP]	: SECTOR #
   747                              <1> ;		[BP+1]	: TRACK #
   748                              <1> ;		[BP+2]	: BUFFER OFFSET
   749                              <1> ;		@DISK_POINTER POINTS TO THE PARAMETER TABLE OF THIS DRIVE
   750                              <1> ;
   751                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
   752                              <1> ;-------------------------------------------------------------------------------
   753                              <1> DSK_FORMAT:
   754 00002F53 E853030000          <1> 	CALL	XLAT_NEW		; TRANSLATE STATE TO PRESENT ARCH.
   755 00002F58 E84F050000          <1> 	CALL	FMT_INIT		; ESTABLISH STATE IF UNESTABLISHED
   756 00002F5D 800D[2E200100]80    <1>         OR      byte [MOTOR_STATUS], 10000000B ; INDICATE WRITE OPERATION
   757 00002F64 E897050000          <1> 	CALL	MED_CHANGE		; CHECK MEDIA CHANGE AND RESET IF SO
   758 00002F69 725D                <1>         JC      short FM_DON            ; MEDIA CHANGED, SKIP
   759 00002F6B E8F2020000          <1> 	CALL	SEND_SPEC		; SEND SPECIFY COMMAND TO NEC
   760 00002F70 E8FD050000          <1> 	CALL	CHK_LASTRATE		; ZF=1 ATTEMPT RATE IS SAME AS LAST RATE
   761 00002F75 7405                <1>         JZ      short FM_WR             ; YES, SKIP SPECIFY COMMAND
   762 00002F77 E8D4050000          <1> 	CALL	SEND_RATE		; SEND DATA RATE TO CONTROLLER
   763                              <1> FM_WR:
   764 00002F7C E88A060000          <1> 	CALL	FMTDMA_SET		; SET UP THE DMA FOR FORMAT
   765 00002F81 7245                <1>         JC      short FM_DON            ; RETURN WITH ERROR
   766 00002F83 B44D                <1> 	MOV	AH,04DH			; ESTABLISH THE FORMAT COMMAND
   767 00002F85 E8E7060000          <1> 	CALL	NEC_INIT		; INITIALIZE THE NEC
   768 00002F8A 723C                <1>         JC      short FM_DON            ; ERROR - EXIT
   769 00002F8C B8[C82F0000]        <1>         MOV     eAX, FM_DON             ; LOAD ERROR ADDRESS
   770 00002F91 50                  <1> 	PUSH	eAX			; PUSH NEC_OUT ERROR RETURN
   771 00002F92 B203                <1> 	MOV	DL,3			; BYTES/SECTOR VALUE TO NEC
   772 00002F94 E856090000          <1> 	CALL	GET_PARM
   773 00002F99 E8570A0000          <1> 	CALL	NEC_OUTPUT
   774 00002F9E B204                <1> 	MOV	DL,4			; SECTORS/TRACK VALUE TO NEC
   775 00002FA0 E84A090000          <1> 	CALL	GET_PARM
   776 00002FA5 E84B0A0000          <1> 	CALL	NEC_OUTPUT
   777 00002FAA B207                <1> 	MOV	DL,7			; GAP LENGTH VALUE TO NEC
   778 00002FAC E83E090000          <1> 	CALL	GET_PARM
   779 00002FB1 E83F0A0000          <1> 	CALL	NEC_OUTPUT
   780 00002FB6 B208                <1> 	MOV	DL,8			; FILLER BYTE TO NEC
   781 00002FB8 E832090000          <1> 	CALL	GET_PARM
   782 00002FBD E8330A0000          <1> 	CALL	NEC_OUTPUT
   783 00002FC2 58                  <1> 	POP	eAX			; THROW AWAY ERROR
   784 00002FC3 E827070000          <1> 	CALL	NEC_TERM		; TERMINATE, RECEIVE STATUS, ETC,
   785                              <1> FM_DON:
   786 00002FC8 E80F030000          <1> 	CALL	XLAT_OLD		; TRANSLATE STATE TO COMPATIBLE MODE
   787 00002FCD E849080000          <1> 	CALL	SETUP_END		; VARIOUS CLEANUPS
   788 00002FD2 6689F3              <1> 	MOV	BX,SI			; GET SAVED AL TO BL
   789 00002FD5 88D8                <1> 	MOV	AL,BL			; PUT BACK FOR RETURN
   790 00002FD7 C3                  <1> 	RETn
   791                              <1> 
   792                              <1> ;-------------------------------------------------------------------------------
   793                              <1> ; FNC_ERR
   794                              <1> ;	INVALID FUNCTION REQUESTED OR INVALID DRIVE: 
   795                              <1> ;	SET BAD COMMAND IN STATUS.
   796                              <1> ;
   797                              <1> ; ON EXIT: 	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
   798                              <1> ;-------------------------------------------------------------------------------
   799                              <1> FNC_ERR:				; INVALID FUNCTION REQUEST
   800 00002FD8 6689F0              <1> 	MOV	AX,SI			; RESTORE AL
   801 00002FDB B401                <1> 	MOV	AH,BAD_CMD		; SET BAD COMMAND ERROR
   802 00002FDD 8825[30200100]      <1> 	MOV	[DSKETTE_STATUS],AH	; STORE IN DATA AREA
   803 00002FE3 F9                  <1> 	STC				; SET CARRY INDICATING ERROR
   804 00002FE4 C3                  <1> 	RETn
   805                              <1> 
   806                              <1> ; 01/06/2016
   807                              <1> ; 28/05/2016
   808                              <1> ; 27/05/2016 - TRDOS 386 (TRDOS v.2.0)
   809                              <1> ;-------------------------------------------------------------------------------
   810                              <1> ; DISK_PARMS	(AH = 08H)	
   811                              <1> ;	READ DRIVE PARAMETERS.
   812                              <1> ;
   813                              <1> ; ON ENTRY:	DI : DRIVE #
   814                              <1> ;		; 27/05/2016
   815                              <1> ;		EBX = Buffer Address for floppy disk parameters table (16 bytes)
   816                              <1> ;
   817                              <1> ; ON EXIT:	CL/[BP]   = BITS 7 & 6 HI 2 BITS OF MAX CYLINDER
   818                              <1> ;		            BITS 0-5 MAX SECTORS/TRACK
   819                              <1> ;		CH/[BP+1] = LOW 8 BITS OF MAX CYLINDER
   820                              <1> ;		BL/[BP+2] = BITS 7-4 = 0
   821                              <1> ;		            BITS 3-0 = VALID CMOS DRIVE TYPE
   822                              <1> ;		BH/[BP+3] = 0
   823                              <1> ;		DL/[BP+4] = # DRIVES INSTALLED (VALUE CHECKED)
   824                              <1> ;		DH/[BP+5] = MAX HEAD #
   825                              <1> ;	     ** 27/05/2016 - TRDOS 386 (TRDOS v2.0) **	
   826                              <1> ;            ** EBX = Buffer address for floppy disk parameters table **
   827                              <1> ;		;DI/[BP+6] = OFFSET TO DISK_BASE
   828                              <1> ;		;ES        = SEGMENT OF DISK_BASE
   829                              <1> ;
   830                              <1> ;		AX        = 0
   831                              <1> ;
   832                              <1> ;		NOTE : THE ABOVE INFORMATION IS STORED IN THE USERS STACK AT
   833                              <1> ;		       THE LOCATIONS WHERE THE MAIN ROUTINE WILL POP THEM
   834                              <1> ;		       INTO THE APPROPRIATE REGISTERS BEFORE RETURNING TO THE
   835                              <1> ;		       CALLER.
   836                              <1> ;-------------------------------------------------------------------------------
   837                              <1> DSK_PARMS:
   838 00002FE5 E8C1020000          <1> 	CALL	XLAT_NEW		; TRANSLATE STATE TO PRESENT ARCH,
   839                              <1>      ;	MOV	WORD [BP+2],0		; DRIVE TYPE = 0
   840                              <1>      ;  MOV     AX, [EQUIP_FLAG]        ; LOAD EQUIPMENT FLAG FOR # DISKETTES
   841                              <1>      ;  AND     AL,11000001B            ; KEEP DISKETTE DRIVE BITS
   842                              <1>      ;  MOV     DL,2                    ; DISKETTE DRIVES = 2
   843                              <1>      ;  CMP     AL,01000001B            ; 2 DRIVES INSTALLED ?
   844                              <1>      ;  JZ      short STO_DL            ; IF YES JUMP
   845                              <1>      ;  DEC     DL                      ; DISKETTE DRIVES = 1
   846                              <1>      ;  CMP     AL,00000001B            ; 1 DRIVE INSTALLED ?
   847                              <1>      ;  JNZ     short NON_DRV           ; IF NO JUMP
   848 00002FEA 29D2                <1> 	sub	edx, edx
   849 00002FEC 66A1[F8EC0000]      <1> 	mov     ax, [fd0_type]
   850 00002FF2 6621C0              <1> 	and     ax, ax
   851 00002FF5 0F848A000000        <1>         jz      NON_DRV
   852 00002FFB FEC2                <1> 	inc     dl
   853 00002FFD 20E4                <1> 	and     ah, ah
   854 00002FFF 7402                <1> 	jz      short STO_DL
   855 00003001 FEC2                <1> 	inc     dl
   856                              <1> STO_DL:
   857                              <1> 	;MOV	[BP+4],DL		; STORE NUMBER OF DRIVES
   858 00003003 895508              <1> 	mov	[ebp+8], edx ; 20/02/2015	 	
   859 00003006 6683FF01            <1> 	CMP	DI,1			; CHECK FOR VALID DRIVE
   860 0000300A 777C                <1> 	JA	short NON_DRV1		; DRIVE INVALID
   861                              <1> 	;MOV	BYTE [BP+5],1		; MAXIMUM HEAD NUMBER =	1
   862 0000300C C6450901            <1> 	mov	byte [ebp+9], 1  ; 20/02/2015	
   863 00003010 E8D1080000          <1> 	CALL	CMOS_TYPE		; RETURN DRIVE TYPE IN AL
   864                              <1> 	;;20/02/2015
   865                              <1> 	;;JC	short CHK_EST		; IF CMOS BAD CHECKSUM ESTABLISHED
   866                              <1> 	;;OR	AL,AL			; TEST FOR NO DRIVE TYPE
   867 00003015 740F                <1> 	JZ	short CHK_EST		; JUMP IF SO
   868 00003017 E81B020000          <1> 	CALL	DR_TYPE_CHECK		; RTN CS:BX = MEDIA/DRIVE PARAM TBL
   869 0000301C 7208                <1> 	JC	short CHK_EST		; TYPE NOT IN TABLE (POSSIBLE BAD CMOS)
   870                              <1> 	;MOV	[BP+2],AL		; STORE VALID CMOS DRIVE TYPE
   871                              <1>         ;mov	[ebp+4], al ; 06/02/2015
   872 0000301E 8A4B04              <1> 	MOV     CL, [eBX+MD.SEC_TRK]     ; GET SECTOR/TRACK
   873 00003021 8A6B0B              <1>         MOV     CH, [eBX+MD.MAX_TRK]     ; GET MAX. TRACK NUMBER
   874 00003024 EB36                <1> 	JMP	SHORT STO_CX		; CMOS GOOD, USE CMOS
   875                              <1> CHK_EST:
   876 00003026 8AA7[3D200100]      <1> 	MOV	AH, [DSK_STATE+eDI]	; LOAD STATE FOR THIS DRIVE
   877 0000302C F6C410              <1> 	TEST	AH,MED_DET		; CHECK FOR ESTABLISHED STATE
   878 0000302F 7457                <1> 	JZ	short NON_DRV1		; CMOS BAD/INVALID OR UNESTABLISHED
   879                              <1> USE_EST:
   880 00003031 80E4C0              <1> 	AND	AH,RATE_MSK		; ISOLATE STATE
   881 00003034 80FC80              <1> 	CMP	AH,RATE_250		; RATE 250 ?
   882 00003037 7570                <1> 	JNE	short USE_EST2		; NO, GO CHECK OTHER RATE
   883                              <1> 
   884                              <1> ;-----	DATA RATE IS 250 KBS, TRY 360 KB TABLE FIRST
   885                              <1> 
   886 00003039 B001                <1> 	MOV	AL,01			; DRIVE TYPE 1 (360KB)
   887 0000303B E8F7010000          <1> 	CALL	DR_TYPE_CHECK		; RTN CS:BX = MEDIA/DRIVE PARAM TBL
   888 00003040 8A4B04              <1>         MOV     CL, [eBX+MD.SEC_TRK]    ; GET SECTOR/TRACK
   889 00003043 8A6B0B              <1>         MOV     CH, [eBX+MD.MAX_TRK]    ; GET MAX. TRACK NUMBER
   890 00003046 F687[3D200100]01    <1> 	TEST	byte [DSK_STATE+eDI],TRK_CAPA ; 80 TRACK ?
   891 0000304D 740D                <1> 	JZ	short STO_CX		; MUST BE 360KB DRIVE 
   892                              <1> 
   893                              <1> ;-----	IT IS 1.44 MB DRIVE
   894                              <1> 
   895                              <1> PARM144:
   896 0000304F B004                <1> 	MOV	AL,04			; DRIVE TYPE 4 (1.44MB)
   897 00003051 E8E1010000          <1> 	CALL	DR_TYPE_CHECK		; RTN CS:BX = MEDIA/DRIVE PARAM TBL
   898 00003056 8A4B04              <1>         MOV     CL, [eBX+MD.SEC_TRK]    ; GET SECTOR/TRACK
   899 00003059 8A6B0B              <1>         MOV     CH, [eBX+MD.MAX_TRK]    ; GET MAX. TRACK NUMBER
   900                              <1> STO_CX:
   901 0000305C 894D00              <1> 	MOV	[eBP],eCX		; SAVE POINTER IN STACK FOR RETURN
   902                              <1> ES_DI:
   903                              <1> 	;MOV	[BP+6],BX		; ADDRESS OF MEDIA/DRIVE PARM TABLE 
   904                              <1> 	;mov	[ebp+12], ebx ; 06/02/2015
   905                              <1> 	;MOV	AX,CS			; SEGMENT MEDIA/DRIVE PARAMETER TABLE
   906                              <1> 	;MOV	ES,AX			; ES IS SEGMENT OF TABLE
   907                              <1> 	;
   908                              <1> 	; 28/05/2016
   909                              <1> 	; 27/05/2016
   910                              <1> 	; return floppy disk parameters table to user
   911                              <1> 	; in user's buffer, which is pointed by EBX
   912                              <1> 	;
   913 0000305F 57                  <1> 	push	edi
   914 00003060 8B7D04              <1> 	mov	edi, [ebp+4]  		; ebx (input), user's buffer address
   915 00003063 0FB6C0              <1> 	movzx	eax, al
   916 00003066 894504              <1>         mov	[ebp+4], eax   ; ebx	; drive type (for floppy drives)
   917                              <1> 	; 01/06/2016 (INT 33h, disk type return for floppy disks, in BL)
   918 00003069 A3[282D0100]        <1> 	mov	[user_buffer], eax	; 01/06/2016 (overwrite ebx return value)
   919                              <1> 	;(INT 33h, Function 08h will replace user's buffer addr with disk type!)
   920                              <1> 	;
   921 0000306E 89DE                <1> 	mov	esi, ebx 		; floppy disk parameter table (16 bytes)
   922 00003070 B910000000          <1> 	mov	ecx, 16 ; 16 bytes
   923 00003075 E8D6A80000          <1>         call    transfer_to_user_buffer ; trdosk6.s (16/05/2016)
   924 0000307A 5F                  <1> 	pop	edi	
   925                              <1> DP_OUT:
   926 0000307B E85C020000          <1> 	CALL	XLAT_OLD		; TRANSLATE STATE TO COMPATIBLE MODE
   927 00003080 6631C0              <1> 	XOR	AX,AX			; CLEAR
   928 00003083 F8                  <1> 	CLC
   929 00003084 C3                  <1> 	RETn
   930                              <1> 
   931                              <1> ;-----	NO DRIYE PRESENT HANDLER
   932                              <1> 
   933                              <1> NON_DRV:
   934                              <1> 	;MOV	BYTE [BP+4],0		; CLEAR NUMBER OF DRIVES
   935 00003085 895508              <1> 	mov	[ebp+8], edx ; 0 ; 20/02/2015
   936                              <1> NON_DRV1:
   937 00003088 6681FF8000          <1> 	CMP	DI,80H			; CHECK FOR FIXED MEDIA TYPE REQUEST
   938 0000308D 720C                <1> 	JB	short NON_DRV2		; CONTINUE IF NOT REQUEST FALL THROUGH
   939                              <1> 
   940                              <1> ;-----	FIXED DISK REQUEST FALL THROUGH ERROR
   941                              <1> 	
   942 0000308F E848020000          <1> 	CALL	XLAT_OLD		; ELSE TRANSLATE TO COMPATIBLE MODE
   943 00003094 6689F0              <1> 	MOV	AX,SI			; RESTORE AL
   944 00003097 B401                <1> 	MOV	AH,BAD_CMD		; SET BAD COMMAND ERROR
   945 00003099 F9                  <1> 	STC
   946 0000309A C3                  <1> 	RETn
   947                              <1> 
   948                              <1> NON_DRV2:
   949                              <1> 	;XOR	AX,AX			; CLEAR PARMS IF NO DRIVES OR CMOS BAD
   950 0000309B 31C0                <1> 	xor	eax, eax	
   951 0000309D 66894500            <1> 	MOV	[eBP],AX		; TRACKS, SECTORS/TRACK = 0
   952                              <1> 	;MOV	[BP+5],AH		; HEAD = 0
   953 000030A1 886509              <1> 	mov	[ebp+9], ah ; 06/02/2015
   954                              <1> 	;MOV	[BP+6],AX		; OFFSET TO DISK_BASE = 0
   955 000030A4 89450C              <1> 	mov	[ebp+12], eax
   956                              <1> 	;MOV	ES,AX			; ES IS SEGMENT OF TABLE
   957 000030A7 EBD2                <1> 	JMP	SHORT DP_OUT
   958                              <1> 
   959                              <1> ;-----	DATA RATE IS EITHER 300 KBS OR 500 KBS, TRY 1.2 MB TABLE FIRST
   960                              <1> 
   961                              <1> USE_EST2:
   962 000030A9 B002                <1> 	MOV	AL,02			; DRIVE TYPE 2 (1.2MB)
   963 000030AB E887010000          <1> 	CALL	DR_TYPE_CHECK		; RTN CS:BX = MEDIA/DRIVE PARAM TBL
   964 000030B0 8A4B04              <1>         MOV     CL, [eBX+MD.SEC_TRK]    ; GET SECTOR/TRACK
   965 000030B3 8A6B0B              <1>         MOV     CH, [eBX+MD.MAX_TRK]    ; GET MAX. TRACK NUMBER
   966 000030B6 80FC40              <1> 	CMP	AH,RATE_300		; RATE 300 ?
   967 000030B9 74A1                <1> 	JZ	short STO_CX		; MUST BE 1.2MB DRIVE
   968 000030BB EB92                <1> 	JMP	SHORT PARM144		; ELSE, IT IS 1.44MB DRIVE 
   969                              <1> 
   970                              <1> ;-------------------------------------------------------------------------------
   971                              <1> ; DISK_TYPE (AH = 15H)	
   972                              <1> ;	THIS ROUTINE RETURNS THE TYPE OF MEDIA INSTALLED.
   973                              <1> ;
   974                              <1> ;  ON ENTRY:	DI = DRIVE #
   975                              <1> ;
   976                              <1> ;  ON EXIT:	AH = DRIVE TYPE, CY=0
   977                              <1> ;-------------------------------------------------------------------------------
   978                              <1> DSK_TYPE:
   979 000030BD E8E9010000          <1> 	CALL	XLAT_NEW		; TRANSLATE STATE TO PRESENT ARCH.
   980 000030C2 8A87[3D200100]      <1> 	MOV	AL, [DSK_STATE+eDI]	; GET PRESENT STATE INFORMATION
   981 000030C8 08C0                <1> 	OR	AL,AL			; CHECK FOR NO DRIVE
   982 000030CA 7418                <1> 	JZ	short NO_DRV
   983 000030CC B401                <1> 	MOV	AH,NOCHGLN		; NO CHANGE LINE FOR 40 TRACK DRIVE
   984 000030CE A801                <1> 	TEST	AL,TRK_CAPA		; IS THIS DRIVE AN 80 TRACK DRIVE?
   985 000030D0 7402                <1> 	JZ	short DT_BACK			; IF NO JUMP
   986 000030D2 B402                <1> 	MOV	AH,CHGLN		; CHANGE LINE FOR 80 TRACK DRIVE
   987                              <1> DT_BACK:
   988 000030D4 6650                <1> 	PUSH	AX			; SAVE RETURN VALUE
   989 000030D6 E801020000          <1> 	CALL	XLAT_OLD		; TRANSLATE STATE TO COMPATIBLE MODE
   990 000030DB 6658                <1> 	POP	AX			; RESTORE RETURN VALUE
   991 000030DD F8                  <1> 	CLC				; NO ERROR
   992 000030DE 6689F3              <1> 	MOV	BX,SI			; GET SAVED AL TO BL
   993 000030E1 88D8                <1> 	MOV	AL,BL			; PUT BACK FOR RETURN
   994 000030E3 C3                  <1> 	RETn
   995                              <1> NO_DRV:	
   996 000030E4 30E4                <1> 	XOR	AH,AH			; NO DRIVE PRESENT OR UNKNOWN
   997 000030E6 EBEC                <1> 	JMP	SHORT DT_BACK
   998                              <1> 
   999                              <1> ;-------------------------------------------------------------------------------
  1000                              <1> ; DISK_CHANGE	(AH = 16H)
  1001                              <1> ;	THIS ROUTINE RETURNS THE STATE OF THE DISK CHANGE LINE.
  1002                              <1> ;
  1003                              <1> ; ON ENTRY:	DI = DRIVE #
  1004                              <1> ;
  1005                              <1> ; ON EXIT:	AH = @DSKETTE_STATUS
  1006                              <1> ;		     00 - DISK CHANGE LINE INACTIVE, CY = 0
  1007                              <1> ;		     06 - DISK CHANGE LINE ACTIVE, CY = 1
  1008                              <1> ;-------------------------------------------------------------------------------
  1009                              <1> DSK_CHANGE:
  1010 000030E8 E8BE010000          <1> 	CALL	XLAT_NEW		; TRANSLATE STATE TO PRESENT ARCH.
  1011 000030ED 8A87[3D200100]      <1> 	MOV	AL, [DSK_STATE+eDI]	; GET MEDIA STATE INFORMATION
  1012 000030F3 08C0                <1> 	OR	AL,AL			; DRIVE PRESENT ?
  1013 000030F5 7422                <1> 	JZ	short DC_NON		; JUMP IF NO DRIVE
  1014 000030F7 A801                <1> 	TEST	AL,TRK_CAPA		; 80 TRACK DRIVE ?
  1015 000030F9 7407                <1> 	JZ	short SETIT		; IF SO , CHECK CHANGE LINE
  1016                              <1> DC0:
  1017 000030FB E88D0A0000          <1>         CALL    READ_DSKCHNG            ; GO CHECK STATE OF DISK CHANGE LINE
  1018 00003100 7407                <1> 	JZ	short FINIS		; CHANGE LINE NOT ACTIVE
  1019                              <1> 
  1020 00003102 C605[30200100]06    <1> SETIT:	MOV	byte [DSKETTE_STATUS], MEDIA_CHANGE ; INDICATE MEDIA REMOVED
  1021                              <1> 
  1022 00003109 E8CE010000          <1> FINIS:	CALL	XLAT_OLD		; TRANSLATE STATE TO COMPATIBLE MODE
  1023 0000310E E808070000          <1> 	CALL	SETUP_END		; VARIOUS CLEANUPS
  1024 00003113 6689F3              <1> 	MOV	BX,SI			; GET SAVED AL TO BL
  1025 00003116 88D8                <1> 	MOV	AL,BL			; PUT BACK FOR RETURN
  1026 00003118 C3                  <1> 	RETn
  1027                              <1> DC_NON:
  1028 00003119 800D[30200100]80    <1> 	OR	byte [DSKETTE_STATUS], TIME_OUT ; SET TIMEOUT, NO DRIVE
  1029 00003120 EBE7                <1> 	JMP	SHORT FINIS
  1030                              <1> 
  1031                              <1> ;-------------------------------------------------------------------------------
  1032                              <1> ; FORMAT_SET	(AH = 17H)
  1033                              <1> ;	THIS ROUTINE IS USED TO ESTABLISH THE TYPE OF MEDIA TO BE USED
  1034                              <1> ;	FOR THE FOLLOWING FORMAT OPERATION.
  1035                              <1> ;
  1036                              <1> ; ON ENTRY:	SI LOW = DASD TYPE FOR FORMAT
  1037                              <1> ;		DI     = DRIVE #
  1038                              <1> ;
  1039                              <1> ; ON EXIT:	@DSKETTE_STATUS REFLECTS STATUS
  1040                              <1> ;		AH = @DSKETTE_STATUS
  1041                              <1> ;		CY = 1 IF ERROR
  1042                              <1> ;-------------------------------------------------------------------------------
  1043                              <1> FORMAT_SET:
  1044 00003122 E884010000          <1> 	CALL	XLAT_NEW		; TRANSLATE STATE TO PRESENT ARCH.
  1045 00003127 6656                <1> 	PUSH	SI			; SAVE DASD TYPE
  1046 00003129 6689F0              <1> 	MOV	AX,SI			; AH = ? , AL , DASD TYPE
  1047 0000312C 30E4                <1> 	XOR	AH,AH			; AH , 0 , AL , DASD TYPE
  1048 0000312E 6689C6              <1> 	MOV	SI,AX			; SI = DASD TYPE
  1049 00003131 80A7[3D200100]0F    <1> 	AND	byte [DSK_STATE+eDI], ~(MED_DET+DBL_STEP+RATE_MSK) ; CLEAR STATE
  1050 00003138 664E                <1> 	DEC	SI			; CHECK FOR 320/360K MEDIA & DRIVE
  1051 0000313A 7509                <1> 	JNZ	short NOT_320		; BYPASS IF NOT
  1052 0000313C 808F[3D200100]90    <1> 	OR	byte [DSK_STATE+eDI], MED_DET+RATE_250 ; SET TO 320/360
  1053 00003143 EB48                <1> 	JMP	SHORT S0
  1054                              <1> 
  1055                              <1> NOT_320:
  1056 00003145 E8B6030000          <1> 	CALL	MED_CHANGE		; CHECK FOR TIME_OUT
  1057 0000314A 803D[30200100]80    <1> 	CMP	byte [DSKETTE_STATUS], TIME_OUT
  1058 00003151 743A                <1> 	JZ	short S0		; IF TIME OUT TELL CALLER
  1059                              <1> S3:
  1060 00003153 664E                <1> 	DEC	SI			; CHECK FOR 320/360K IN 1.2M DRIVE
  1061 00003155 7509                <1> 	JNZ	short NOT_320_12	; BYPASS IF NOT
  1062 00003157 808F[3D200100]70    <1> 	OR	byte [DSK_STATE+eDI], MED_DET+DBL_STEP+RATE_300 ; SET STATE
  1063 0000315E EB2D                <1> 	JMP	SHORT S0
  1064                              <1> 
  1065                              <1> NOT_320_12:
  1066 00003160 664E                <1> 	DEC	SI			; CHECK FOR 1.2M MEDIA IN 1.2M DRIVE
  1067 00003162 7509                <1> 	JNZ	short NOT_12		; BYPASS IF NOT
  1068 00003164 808F[3D200100]10    <1> 	OR	byte [DSK_STATE+eDI], MED_DET+RATE_500 ; SET STATE VARIABLE
  1069 0000316B EB20                <1> 	JMP	SHORT S0		; RETURN TO CALLER
  1070                              <1> 
  1071                              <1> NOT_12:	
  1072 0000316D 664E                <1> 	DEC	SI			; CHECK FOR SET DASD TYPE 04
  1073 0000316F 752B                <1> 	JNZ	short FS_ERR		; BAD COMMAND EXIT IF NOT VALID TYPE
  1074                              <1> 
  1075 00003171 F687[3D200100]04    <1> 	TEST	byte [DSK_STATE+eDI], DRV_DET ; DRIVE DETERMINED ?
  1076 00003178 740B                <1> 	JZ	short ASSUME		; IF STILL NOT DETERMINED ASSUME
  1077 0000317A B050                <1> 	MOV	AL,MED_DET+RATE_300
  1078 0000317C F687[3D200100]02    <1>         TEST    byte [DSK_STATE+eDI], FMT_CAPA ; MULTIPLE FORMAT CAPABILITY ?
  1079 00003183 7502                <1> 	JNZ	short OR_IT_IN		; IF 1.2 M THEN DATA RATE 300
  1080                              <1> 
  1081                              <1> ASSUME:
  1082 00003185 B090                <1> 	MOV	AL,MED_DET+RATE_250	; SET UP
  1083                              <1> 
  1084                              <1> OR_IT_IN:
  1085 00003187 0887[3D200100]      <1> 	OR	[DSK_STATE+eDI], AL	; OR IN THE CORRECT STATE
  1086                              <1> S0:
  1087 0000318D E84A010000          <1> 	CALL	XLAT_OLD		; TRANSLATE STATE TO COMPATIBLE MODE
  1088 00003192 E884060000          <1> 	CALL	SETUP_END		; VARIOUS CLEANUPS
  1089 00003197 665B                <1> 	POP	BX			; GET SAVED AL TO BL
  1090 00003199 88D8                <1> 	MOV	AL,BL			; PUT BACK FOR RETURN
  1091 0000319B C3                  <1> 	RETn
  1092                              <1> 
  1093                              <1> FS_ERR:
  1094 0000319C C605[30200100]01    <1> 	MOV	byte [DSKETTE_STATUS], BAD_CMD ; UNKNOWN STATE,BAD COMMAND
  1095 000031A3 EBE8                <1> 	JMP	SHORT S0
  1096                              <1> 
  1097                              <1> ;-------------------------------------------------------------------------------
  1098                              <1> ; SET_MEDIA	(AH = 18H)
  1099                              <1> ;	THIS ROUTINE SETS THE TYPE OF MEDIA AND DATA RATE 
  1100                              <1> ;	TO BE USED FOR THE FOLLOWING FORMAT OPERATION.
  1101                              <1> ;
  1102                              <1> ; ON ENTRY:
  1103                              <1> ;	[BP]	= SECTOR PER TRACK
  1104                              <1> ;	[BP+1]	= TRACK #
  1105                              <1> ;	DI	= DRIVE #
  1106                              <1> ;
  1107                              <1> ; ON EXIT:
  1108                              <1> ;	@DSKETTE_STATUS REFLECTS STATUS
  1109                              <1> ;	IF NO ERROR:
  1110                              <1> ;		AH = 0
  1111                              <1> ;		CY = 0
  1112                              <1> ;		ES = SEGMENT OF MEDIA/DRIVE PARAMETER TABLE
  1113                              <1> ;		DI/[BP+6] = OFFSET OF MEDIA/DRIVE PARAMETER TABLE
  1114                              <1> ;	IF ERROR:	
  1115                              <1> ;		AH = @DSKETTE_STATUS
  1116                              <1> ;		CY = 1
  1117                              <1> ;-------------------------------------------------------------------------------
  1118                              <1> SET_MEDIA:
  1119 000031A5 E801010000          <1> 	CALL	XLAT_NEW		; TRANSLATE STATE TO PRESENT ARCH.
  1120 000031AA F687[3D200100]01    <1>         TEST    byte [DSK_STATE+eDI], TRK_CAPA ; CHECK FOR CHANGE LINE AVAILABLE
  1121 000031B1 7415                <1> 	JZ	short SM_CMOS		; JUMP IF 40 TRACK DRIVE
  1122 000031B3 E848030000          <1> 	CALL	MED_CHANGE		; RESET CHANGE LINE
  1123 000031B8 803D[30200100]80    <1> 	CMP	byte [DSKETTE_STATUS], TIME_OUT ; IF TIME OUT TELL CALLER
  1124 000031BF 746B                <1> 	JE	short SM_RTN
  1125 000031C1 C605[30200100]00    <1> 	MOV	byte [DSKETTE_STATUS], 0 ; CLEAR STATUS
  1126                              <1> SM_CMOS:
  1127 000031C8 E819070000          <1> 	CALL	CMOS_TYPE		; RETURN DRIVE TYPE IN (AL)
  1128                              <1> 	;;20/02/2015
  1129                              <1> 	;;JC	short MD_NOT_FND	; ERROR IN CMOS
  1130                              <1> 	;;OR	AL,AL			; TEST FOR NO DRIVE
  1131 000031CD 745D                <1> 	JZ	short SM_RTN		; RETURN IF SO
  1132 000031CF E863000000          <1> 	CALL	DR_TYPE_CHECK		; RTN CS:BX = MEDIA/DRIVE PARAM TBL
  1133 000031D4 7231                <1> 	JC	short MD_NOT_FND	; TYPE NOT IN TABLE (BAD CMOS)
  1134 000031D6 57                  <1> 	PUSH	eDI			; SAVE REG.
  1135 000031D7 31DB                <1> 	XOR	eBX,eBX			; BX = INDEX TO DR. TYPE TABLE
  1136 000031D9 B906000000          <1> 	MOV	eCX,DR_CNT		; CX = LOOP COUNT
  1137                              <1> DR_SEARCH:
  1138 000031DE 8AA3[76EC0000]      <1> 	MOV	AH, [DR_TYPE+eBX]	; GET DRIVE TYPE
  1139 000031E4 80E47F              <1> 	AND	AH,BIT7OFF		; MASK OUT MSB
  1140 000031E7 38E0                <1> 	CMP	AL,AH			; DRIVE TYPE MATCH ?
  1141 000031E9 7516                <1> 	JNE	short NXT_MD		; NO, CHECK NEXT DRIVE TYPE
  1142                              <1> DR_FND:
  1143 000031EB 8BBB[77EC0000]      <1> 	MOV	eDI, [DR_TYPE+eBX+1] 	; DI = MEDIA/DRIVE PARAM TABLE
  1144                              <1> MD_SEARCH:
  1145 000031F1 8A6704              <1>         MOV     AH, [eDI+MD.SEC_TRK]    ; GET SECTOR/TRACK
  1146 000031F4 386500              <1> 	CMP	[eBP],AH		; MATCH?
  1147 000031F7 7508                <1> 	JNE	short NXT_MD		; NO, CHECK NEXT MEDIA
  1148 000031F9 8A670B              <1>         MOV     AH, [eDI+MD.MAX_TRK]    ; GET MAX. TRACK #
  1149 000031FC 386501              <1> 	CMP 	[eBP+1],AH		; MATCH?
  1150 000031FF 740F                <1> 	JE	short MD_FND		; YES, GO GET RATE
  1151                              <1> NXT_MD:
  1152                              <1> 	;ADD	BX,3			; CHECK NEXT DRIVE TYPE
  1153 00003201 83C305              <1>         add	ebx, 5 ; 18/02/2015
  1154 00003204 E2D8                <1> 	LOOP    DR_SEARCH
  1155 00003206 5F                  <1> 	POP	eDI			; RESTORE REG.
  1156                              <1> MD_NOT_FND:
  1157 00003207 C605[30200100]0C    <1> 	MOV	byte [DSKETTE_STATUS], MED_NOT_FND ; ERROR, MEDIA TYPE NOT FOUND
  1158 0000320E EB1C                <1> 	JMP	SHORT SM_RTN		; RETURN
  1159                              <1> MD_FND:
  1160 00003210 8A470C              <1>         MOV     AL, [eDI+MD.RATE]       ; GET RATE
  1161 00003213 3C40                <1> 	CMP	AL,RATE_300		; DOUBLE STEP REQUIRED FOR RATE 300
  1162 00003215 7502                <1> 	JNE	short MD_SET
  1163 00003217 0C20                <1> 	OR	AL,DBL_STEP
  1164                              <1> MD_SET:
  1165                              <1> 	;MOV	[BP+6],DI		; SAVE TABLE POINTER IN STACK
  1166 00003219 897D0C              <1> 	mov	[ebp+12], edi ; 18/02/2015
  1167 0000321C 0C10                <1> 	OR	AL,MED_DET		; SET MEDIA ESTABLISHED
  1168 0000321E 5F                  <1> 	POP	eDI
  1169 0000321F 80A7[3D200100]0F    <1> 	AND	byte [DSK_STATE+eDI], ~(MED_DET+DBL_STEP+RATE_MSK) ; CLEAR STATE
  1170 00003226 0887[3D200100]      <1> 	OR	[DSK_STATE+eDI], AL
  1171                              <1> 	;MOV	AX, CS			; SEGMENT OF MEDIA/DRIVE PARAMETER TABLE
  1172                              <1> 	;MOV	ES, AX			; ES IS SEGMENT OF TABLE
  1173                              <1> SM_RTN:
  1174 0000322C E8AB000000          <1> 	CALL	XLAT_OLD		; TRANSLATE STATE TO COMPATIBLE MODE
  1175 00003231 E8E5050000          <1> 	CALL	SETUP_END		; VARIOUS CLEANUPS
  1176 00003236 C3                  <1> 	RETn
  1177                              <1> 
  1178                              <1> ;----------------------------------------------------------------
  1179                              <1> ; DR_TYPE_CHECK							:
  1180                              <1> ;	CHECK IF THE GIVEN DRIVE TYPE IN REGISTER (AL)		:
  1181                              <1> ;	IS SUPPORTED IN BIOS DRIVE TYPE TABLE			:
  1182                              <1> ; ON ENTRY:							:
  1183                              <1> ;	AL = DRIVE TYPE						:
  1184                              <1> ; ON EXIT:							:
  1185                              <1> ;	CS = SEGMENT MEDIA/DRIVE PARAMETER TABLE (CODE)		:
  1186                              <1> ;	CY = 0 	DRIVE TYPE SUPPORTED				:
  1187                              <1> ;	     BX = OFFSET TO MEDIA/DRIVE PARAMETER TABLE		:
  1188                              <1> ;	CY = 1	DRIVE TYPE NOT SUPPORTED 			:
  1189                              <1> ; REGISTERS ALTERED: eBX						:
  1190                              <1> ;----------------------------------------------------------------		
  1191                              <1> DR_TYPE_CHECK:
  1192 00003237 6650                <1> 	PUSH	AX			
  1193 00003239 51                  <1> 	PUSH	eCX
  1194 0000323A 31DB                <1> 	XOR	eBX,eBX			; BX = INDEX TO DR_TYPE TABLE
  1195 0000323C B906000000          <1> 	MOV	eCX,DR_CNT		; CX = LOOP COUNT
  1196                              <1> TYPE_CHK:	
  1197 00003241 8AA3[76EC0000]      <1> 	MOV	AH,[DR_TYPE+eBX]	; GET DRIVE TYPE
  1198 00003247 38E0                <1> 	CMP	AL,AH			; DRIVE TYPE MATCH?
  1199 00003249 740D                <1> 	JE	short DR_TYPE_VALID	; YES, RETURN WITH CARRY RESET
  1200                              <1> 	;ADD	BX,3			; CHECK NEXT DRIVE TYPE
  1201 0000324B 83C305              <1>         add	ebx, 5	; 16/02/2015 (32 bit address modification)
  1202 0000324E E2F1                <1> 	LOOP    TYPE_CHK
  1203                              <1> 	;
  1204 00003250 BB[D5EC0000]        <1> 	mov	ebx, MD_TBL6		; 1.44MB fd parameter table
  1205                              <1> 					; Default for GET_PARM (11/12/2014)
  1206                              <1> 	;
  1207 00003255 F9                  <1> 	STC				; DRIVE TYPE NOT FOUND IN TABLE
  1208 00003256 EB06                <1> 	JMP	SHORT TYPE_RTN
  1209                              <1> DR_TYPE_VALID:
  1210 00003258 8B9B[77EC0000]      <1> 	MOV	eBX,[DR_TYPE+eBX+1] 	; BX = MEDIA TABLE
  1211                              <1> TYPE_RTN:
  1212 0000325E 59                  <1> 	POP	eCX
  1213 0000325F 6658                <1> 	POP	AX
  1214 00003261 C3                  <1> 	RETn	
  1215                              <1> 		
  1216                              <1> ;----------------------------------------------------------------
  1217                              <1> ; SEND_SPEC							:
  1218                              <1> ;	SEND THE SPECIFY COMMAND TO CONTROLLER USING DATA FROM	:
  1219                              <1> ;	THE DRIVE PARAMETER TABLE POINTED BY @DISK_POINTER	:
  1220                              <1> ; ON ENTRY:	@DISK_POINTER = DRIVE PARAMETER TABLE		:
  1221                              <1> ; ON EXIT:	NONE						:	
  1222                              <1> ; REGISTERS ALTERED: CX, DX					:
  1223                              <1> ;----------------------------------------------------------------		
  1224                              <1> SEND_SPEC:
  1225 00003262 50                  <1> 	PUSH	eAX			; SAVE AX
  1226 00003263 B8[89320000]        <1> 	MOV	eAX, SPECBAC		; LOAD ERROR ADDRESS
  1227 00003268 50                  <1> 	PUSH	eAX			; PUSH NEC_OUT ERROR RETURN
  1228 00003269 B403                <1> 	MOV	AH,03H			; SPECIFY COMMAND
  1229 0000326B E885070000          <1> 	CALL	NEC_OUTPUT		; OUTPUT THE COMMAND
  1230 00003270 28D2                <1> 	SUB	DL,DL			; FIRST SPECIFY BYTE
  1231 00003272 E878060000          <1> 	CALL	GET_PARM		; GET PARAMETER TO AH
  1232 00003277 E879070000          <1> 	CALL	NEC_OUTPUT		; OUTPUT THE COMMAND
  1233 0000327C B201                <1> 	MOV	DL,1			; SECOND SPECIFY BYTE
  1234 0000327E E86C060000          <1> 	CALL	GET_PARM		; GET PARAMETER TO AH
  1235 00003283 E86D070000          <1> 	CALL	NEC_OUTPUT		; OUTPUT THE COMMAND
  1236 00003288 58                  <1> 	POP	eAX			; POP ERROR RETURN
  1237                              <1> SPECBAC:
  1238 00003289 58                  <1> 	POP	eAX			; RESTORE ORIGINAL AX VALUE
  1239 0000328A C3                  <1> 	RETn
  1240                              <1> 
  1241                              <1> ;----------------------------------------------------------------
  1242                              <1> ; SEND_SPEC_MD							:
  1243                              <1> ;	SEND THE SPECIFY COMMAND TO CONTROLLER USING DATA FROM	:
  1244                              <1> ;	THE MEDIA/DRIVE PARAMETER TABLE POINTED BY (CS:BX)	:
  1245                              <1> ; ON ENTRY:	CS:BX = MEDIA/DRIVE PARAMETER TABLE		:
  1246                              <1> ; ON EXIT:	NONE						:	
  1247                              <1> ; REGISTERS ALTERED: AX						:
  1248                              <1> ;----------------------------------------------------------------		
  1249                              <1> SEND_SPEC_MD:
  1250 0000328B 50                  <1> 	PUSH	eAX			; SAVE RATE DATA
  1251 0000328C B8[A9320000]        <1> 	MOV	eAX, SPEC_ESBAC		; LOAD ERROR ADDRESS
  1252 00003291 50                  <1> 	PUSH	eAX			; PUSH NEC_OUT ERROR RETURN
  1253 00003292 B403                <1> 	MOV	AH,03H			; SPECIFY COMMAND
  1254 00003294 E85C070000          <1> 	CALL	NEC_OUTPUT		; OUTPUT THE COMMAND
  1255 00003299 8A23                <1>         MOV     AH, [eBX+MD.SPEC1]      ; GET 1ST SPECIFY BYTE
  1256 0000329B E855070000          <1> 	CALL	NEC_OUTPUT		; OUTPUT THE COMMAND
  1257 000032A0 8A6301              <1>         MOV     AH, [eBX+MD.SPEC2]      ; GET SECOND SPECIFY BYTE
  1258 000032A3 E84D070000          <1> 	CALL	NEC_OUTPUT		; OUTPUT THE COMMAND
  1259 000032A8 58                  <1> 	POP	eAX			; POP ERROR RETURN
  1260                              <1> SPEC_ESBAC:
  1261 000032A9 58                  <1> 	POP	eAX			; RESTORE ORIGINAL AX VALUE
  1262 000032AA C3                  <1> 	RETn
  1263                              <1> 
  1264                              <1> ;-------------------------------------------------------------------------------
  1265                              <1> ; XLAT_NEW  
  1266                              <1> ;	TRANSLATES DISKETTE STATE LOCATIONS FROM COMPATIBLE
  1267                              <1> ;	MODE TO NEW ARCHITECTURE.
  1268                              <1> ;
  1269                              <1> ; ON ENTRY:	DI = DRIVE #
  1270                              <1> ;-------------------------------------------------------------------------------
  1271                              <1> XLAT_NEW:
  1272 000032AB 83FF01              <1> 	CMP	eDI,1				; VALID DRIVE
  1273 000032AE 7725                <1> 	JA	short XN_OUT			; IF INVALID BACK
  1274 000032B0 80BF[3D200100]00    <1> 	CMP	byte [DSK_STATE+eDI], 0		; NO DRIVE ?
  1275 000032B7 741D                <1> 	JZ	short DO_DET			; IF NO DRIVE ATTEMPT DETERMINE
  1276 000032B9 6689F9              <1> 	MOV	CX,DI				; CX = DRIVE NUMBER
  1277 000032BC C0E102              <1> 	SHL	CL,2				; CL = SHIFT COUNT, A=0, B=4
  1278 000032BF A0[3C200100]        <1> 	MOV	AL, [HF_CNTRL]			; DRIVE INFORMATION
  1279 000032C4 D2C8                <1> 	ROR	AL,CL				; TO LOW NIBBLE
  1280 000032C6 2407                <1> 	AND	AL,DRV_DET+FMT_CAPA+TRK_CAPA	; KEEP DRIVE BITS
  1281 000032C8 80A7[3D200100]F8    <1>         AND     byte [DSK_STATE+eDI], ~(DRV_DET+FMT_CAPA+TRK_CAPA)
  1282 000032CF 0887[3D200100]      <1> 	OR	[DSK_STATE+eDI], AL		; UPDATE DRIVE STATE
  1283                              <1> XN_OUT:
  1284 000032D5 C3                  <1> 	RETn
  1285                              <1> DO_DET:
  1286 000032D6 E8BF080000          <1> 	CALL	DRIVE_DET			; TRY TO DETERMINE
  1287 000032DB C3                  <1> 	RETn
  1288                              <1> 
  1289                              <1> ;-------------------------------------------------------------------------------
  1290                              <1> ; XLAT_OLD 
  1291                              <1> ;	TRANSLATES DISKETTE STATE LOCATIONS FROM NEW
  1292                              <1> ;	ARCHITECTURE TO COMPATIBLE MODE.
  1293                              <1> ;
  1294                              <1> ; ON ENTRY:	DI = DRIVE
  1295                              <1> ;-------------------------------------------------------------------------------
  1296                              <1> XLAT_OLD:
  1297 000032DC 83FF01              <1> 	CMP	eDI,1			; VALID DRIVE ?
  1298                              <1>         ;JA     short XO_OUT            ; IF INVALID BACK
  1299 000032DF 0F8786000000        <1>         ja      XO_OUT
  1300 000032E5 80BF[3D200100]00    <1>         CMP	byte [DSK_STATE+eDI],0	; NO DRIVE ?
  1301 000032EC 747D                <1> 	JZ	short XO_OUT		; IF NO DRIVE TRANSLATE DONE
  1302                              <1> 
  1303                              <1> ;-----	TEST FOR SAVED DRIVE INFORMATION ALREADY SET
  1304                              <1> 
  1305 000032EE 6689F9              <1> 	MOV	CX,DI			; CX = DRIVE NUMBER
  1306 000032F1 C0E102              <1> 	SHL	CL,2			; CL = SHIFT COUNT, A=0, B=4
  1307 000032F4 B402                <1> 	MOV	AH,FMT_CAPA		; LOAD MULTIPLE DATA RATE BIT MASK
  1308 000032F6 D2CC                <1> 	ROR	AH,CL			; ROTATE BY MASK
  1309 000032F8 8425[3C200100]      <1> 	TEST	[HF_CNTRL], AH		; MULTIPLE-DATA RATE DETERMINED ?
  1310 000032FE 751C                <1> 	JNZ	short SAVE_SET		; IF SO, NO NEED TO RE-SAVE
  1311                              <1> 
  1312                              <1> ;-----	ERASE DRIVE BITS IN @HF_CNTRL FOR THIS DRIVE
  1313                              <1> 
  1314 00003300 B407                <1> 	MOV	AH,DRV_DET+FMT_CAPA+TRK_CAPA ; MASK TO KEEP
  1315 00003302 D2CC                <1> 	ROR	AH,CL			; FIX MASK TO KEEP
  1316 00003304 F6D4                <1> 	NOT	AH			; TRANSLATE MASK
  1317 00003306 2025[3C200100]      <1> 	AND	[HF_CNTRL], AH		; KEEP BITS FROM OTHER DRIVE INTACT
  1318                              <1> 
  1319                              <1> ;-----	ACCESS CURRENT DRIVE BITS AND STORE IN @HF_CNTRL
  1320                              <1> 
  1321 0000330C 8A87[3D200100]      <1> 	MOV	AL, [DSK_STATE+eDI]	; ACCESS STATE
  1322 00003312 2407                <1> 	AND	AL,DRV_DET+FMT_CAPA+TRK_CAPA ; KEEP DRIVE BITS
  1323 00003314 D2C8                <1> 	ROR	AL,CL			; FIX FOR THIS DRIVE
  1324 00003316 0805[3C200100]      <1> 	OR	[HF_CNTRL], AL		; UPDATE SAVED DRIVE STATE
  1325                              <1> 
  1326                              <1> ;-----	TRANSLATE TO COMPATIBILITY MODE
  1327                              <1> 
  1328                              <1> SAVE_SET:
  1329 0000331C 8AA7[3D200100]      <1> 	MOV	AH, [DSK_STATE+eDI]	; ACCESS STATE
  1330 00003322 88E7                <1> 	MOV	BH,AH			; TO BH FOR LATER
  1331 00003324 80E4C0              <1> 	AND	AH,RATE_MSK		; KEEP ONLY RATE
  1332 00003327 80FC00              <1> 	CMP	AH,RATE_500		; RATE 500 ?
  1333 0000332A 7410                <1> 	JZ	short CHK_144		; YES 1.2/1.2 OR 1.44/1.44
  1334 0000332C B001                <1> 	MOV	AL,M3D1U		; AL = 360 IN 1.2 UNESTABLISHED
  1335 0000332E 80FC40              <1> 	CMP	AH,RATE_300		; RATE 300 ?
  1336 00003331 7518                <1> 	JNZ	short CHK_250		; NO, 360/360, 720/720 OR 720/1.44
  1337 00003333 F6C720              <1> 	TEST	BH,DBL_STEP		; CHECK FOR DOUBLE STEP
  1338 00003336 751F                <1> 	JNZ	short TST_DET		; MUST BE 360 IN 1.2
  1339                              <1> UNKNO:
  1340 00003338 B007                <1> 	MOV	AL,MED_UNK		; NONE OF THE ABOVE
  1341 0000333A EB22                <1> 	JMP	SHORT AL_SET		; PROCESS COMPLETE
  1342                              <1> CHK_144:
  1343 0000333C E8A5050000          <1> 	CALL	CMOS_TYPE		; RETURN DRIVE TYPE IN (AL)
  1344                              <1> 	;;20/02/2015
  1345                              <1> 	;;JC	short UNKNO		; ERROR, SET 'NONE OF ABOVE'
  1346 00003341 74F5                <1> 	jz	short UNKNO ;; 20/02/2015
  1347 00003343 3C02                <1> 	CMP	AL,2			; 1.2MB DRIVE ?
  1348 00003345 75F1                <1> 	JNE	short UNKNO		; NO, GO SET 'NONE OF ABOVE'
  1349 00003347 B002                <1> 	MOV	AL,M1D1U		; AL = 1.2 IN 1.2 UNESTABLISHED
  1350 00003349 EB0C                <1> 	JMP	SHORT TST_DET
  1351                              <1> CHK_250:
  1352 0000334B B000                <1> 	MOV	AL,M3D3U		; AL = 360 IN 360 UNESTABLISHED
  1353 0000334D 80FC80              <1> 	CMP	AH,RATE_250		; RATE 250 ?
  1354 00003350 75E6                <1> 	JNZ	short UNKNO		; IF SO FALL IHRU
  1355 00003352 F6C701              <1> 	TEST	BH,TRK_CAPA		; 80 TRACK CAPABILITY ?
  1356 00003355 75E1                <1> 	JNZ	short UNKNO		; IF SO JUMP, FALL THRU TEST DET
  1357                              <1> TST_DET:
  1358 00003357 F6C710              <1> 	TEST	BH,MED_DET		; DETERMINED ?
  1359 0000335A 7402                <1> 	JZ	short AL_SET		; IF NOT THEN SET
  1360 0000335C 0403                <1> 	ADD	AL,3			; MAKE DETERMINED/ESTABLISHED
  1361                              <1> AL_SET:
  1362 0000335E 80A7[3D200100]F8    <1> 	AND	byte [DSK_STATE+eDI], ~(DRV_DET+FMT_CAPA+TRK_CAPA) ; CLEAR DRIVE
  1363 00003365 0887[3D200100]      <1> 	OR	[DSK_STATE+eDI], AL	; REPLACE WITH COMPATIBLE MODE
  1364                              <1> XO_OUT:
  1365 0000336B C3                  <1> 	RETn
  1366                              <1> 
  1367                              <1> ;-------------------------------------------------------------------------------
  1368                              <1> ; RD_WR_VF
  1369                              <1> ;	COMMON READ, WRITE AND VERIFY: 
  1370                              <1> ;	MAIN LOOP FOR STATE RETRIES.
  1371                              <1> ;
  1372                              <1> ; ON ENTRY:	AH = READ/WRITE/VERIFY NEC PARAMETER
  1373                              <1> ;		AL = READ/WRITE/VERIFY DMA PARAMETER
  1374                              <1> ;
  1375                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
  1376                              <1> ;-------------------------------------------------------------------------------
  1377                              <1> RD_WR_VF:
  1378 0000336C 6650                <1> 	PUSH	AX			; SAVE DMA, NEC PARAMETERS
  1379 0000336E E838FFFFFF          <1> 	CALL	XLAT_NEW		; TRANSLATE STATE TO PRESENT ARCH.
  1380 00003373 E8F3000000          <1> 	CALL	SETUP_STATE		; INITIALIZE START AND END RATE
  1381 00003378 6658                <1> 	POP	AX			; RESTORE READ/WRITE/VERIFY
  1382                              <1> DO_AGAIN:
  1383 0000337A 6650                <1> 	PUSH	AX			; SAVE READ/WRITE/VERIFY PARAMETER
  1384 0000337C E87F010000          <1> 	CALL	MED_CHANGE		; MEDIA CHANGE AND RESET IF CHANGED
  1385 00003381 6658                <1> 	POP	AX			; RESTORE READ/WRITE/VERIFY
  1386 00003383 0F82C9000000        <1>         JC      RWV_END                 ; MEDIA CHANGE ERROR OR TIME-OUT
  1387                              <1> RWV:
  1388 00003389 6650                <1> 	PUSH	AX			; SAVE READ/WRITE/VERIFY PARAMETER
  1389 0000338B 8AB7[3D200100]      <1> 	MOV	DH, [DSK_STATE+eDI]	; GET RATE STATE OF THIS DRIVE
  1390 00003391 80E6C0              <1> 	AND	DH,RATE_MSK		; KEEP ONLY RATE
  1391 00003394 E84D050000          <1> 	CALL	CMOS_TYPE		; RETURN DRIVE TYPE IN AL (AL)
  1392                              <1> 	;;20/02/2015
  1393                              <1> 	;;JC	short RWV_ASSUME	; ERROR IN CMOS
  1394 00003399 7451                <1> 	jz	short RWV_ASSUME ; 20/02/2015
  1395 0000339B 3C01                <1> 	CMP	AL,1			; 40 TRACK DRIVE?
  1396 0000339D 750D                <1> 	JNE	short RWV_1		; NO, BYPASS CMOS VALIDITY CHECK
  1397 0000339F F687[3D200100]01    <1> 	TEST	byte [DSK_STATE+eDI], TRK_CAPA ; CHECK FOR 40 TRACK DRIVE
  1398 000033A6 7413                <1> 	JZ	short RWV_2		; YES, CMOS IS CORRECT
  1399 000033A8 B002                <1> 	MOV	AL,2			; CHANGE TO 1.2M
  1400 000033AA EB0F                <1> 	JMP	SHORT RWV_2
  1401                              <1> RWV_1:
  1402 000033AC 720D                <1> 	JB	short RWV_2		; NO DRIVE SPECIFIED, CONTINUE
  1403 000033AE F687[3D200100]01    <1> 	TEST    byte [DSK_STATE+eDI], TRK_CAPA ; IS IT REALLY 40 TRACK?
  1404 000033B5 7504                <1> 	JNZ	short RWV_2		; NO, 80 TRACK
  1405 000033B7 B001                <1> 	MOV	AL,1			; IT IS 40 TRACK, FIX CMOS VALUE
  1406 000033B9 EB04                <1> 	jmp	short rwv_3
  1407                              <1> RWV_2:
  1408 000033BB 08C0                <1> 	OR	AL,AL			; TEST FOR NO DRIVE
  1409 000033BD 742D                <1> 	JZ	short RWV_ASSUME	; ASSUME TYPE, USE MAX TRACK
  1410                              <1> rwv_3:
  1411 000033BF E873FEFFFF          <1> 	CALL	DR_TYPE_CHECK		; RTN CS:BX = MEDIA/DRIVE PARAM TBL.
  1412 000033C4 7226                <1> 	JC	short RWV_ASSUME	; TYPE NOT IN TABLE (BAD CMOS)
  1413                              <1> 
  1414                              <1> ;-----	SEARCH FOR MEDIA/DRIVE PARAMETER TABLE
  1415                              <1> 
  1416 000033C6 57                  <1> 	PUSH	eDI			; SAVE DRIVE #
  1417 000033C7 31DB                <1> 	XOR	eBX,eBX			; BX = INDEX TO DR_TYPE TABLE
  1418 000033C9 B906000000          <1> 	MOV	eCX,DR_CNT		; CX = LOOP COUNT
  1419                              <1> RWV_DR_SEARCH:
  1420 000033CE 8AA3[76EC0000]      <1> 	MOV	AH, [DR_TYPE+eBX]	; GET DRIVE TYPE
  1421 000033D4 80E47F              <1> 	AND	AH,BIT7OFF		; MASK OUT MSB
  1422 000033D7 38E0                <1> 	CMP	AL,AH			; DRIVE TYPE MATCH?
  1423 000033D9 750B                <1> 	JNE	short RWV_NXT_MD	; NO, CHECK NEXT DRIVE TYPE
  1424                              <1> RWV_DR_FND:
  1425 000033DB 8BBB[77EC0000]      <1> 	MOV	eDI, [DR_TYPE+eBX+1] 	; DI = MEDIA/DRIVE PARAMETER TABLE
  1426                              <1> RWV_MD_SEARH:
  1427 000033E1 3A770C              <1>         CMP     DH, [eDI+MD.RATE]       ; MATCH?
  1428 000033E4 741B                <1> 	JE	short RWV_MD_FND	; YES, GO GET 1ST SPECIFY BYTE
  1429                              <1> RWV_NXT_MD:
  1430                              <1> 	;ADD	BX,3			; CHECK NEXT DRIVE TYPE
  1431 000033E6 83C305              <1> 	add	eBX, 5
  1432 000033E9 E2E3                <1> 	LOOP	RWV_DR_SEARCH
  1433 000033EB 5F                  <1> 	POP	eDI			; RESTORE DRIVE #
  1434                              <1> 
  1435                              <1> ;-----	ASSUME PRIMARY DRIVE IS INSTALLED AS SHIPPED
  1436                              <1> 
  1437                              <1> RWV_ASSUME:
  1438 000033EC BB[94EC0000]        <1> 	MOV	eBX, MD_TBL1		; POINT TO 40 TRACK 250 KBS
  1439 000033F1 F687[3D200100]01    <1> 	TEST 	byte [DSK_STATE+eDI], TRK_CAPA ; TEST FOR 80 TRACK
  1440 000033F8 740A                <1> 	JZ	short RWV_MD_FND1	; MUST BE 40 TRACK
  1441 000033FA BB[AEEC0000]        <1> 	MOV	eBX, MD_TBL3		; POINT TO 80 TRACK 500 KBS
  1442 000033FF EB03                <1> 	JMP	short RWV_MD_FND1	; GO SPECIFY PARAMTERS
  1443                              <1> 
  1444                              <1> ;-----	CS:BX POINTS TO MEDIA/DRIVE PARAMETER TABLE
  1445                              <1> 	 			
  1446                              <1> RWV_MD_FND:
  1447 00003401 89FB                <1> 	MOV	eBX,eDI			; BX = MEDIA/DRIVE PARAMETER TABLE
  1448 00003403 5F                  <1> 	POP	eDI			; RESTORE DRIVE #
  1449                              <1> 	
  1450                              <1> ;-----	SEND THE SPECIFY COMMAND TO THE CONTROLLER
  1451                              <1> 
  1452                              <1> RWV_MD_FND1:
  1453 00003404 E882FEFFFF          <1> 	CALL	SEND_SPEC_MD
  1454 00003409 E864010000          <1> 	CALL	CHK_LASTRATE		; ZF=1 ATTEMP RATE IS SAME AS LAST RATE
  1455 0000340E 7405                <1> 	JZ	short RWV_DBL		; YES,SKIP SEND RATE COMMAND
  1456 00003410 E83B010000          <1> 	CALL	SEND_RATE		; SEND DATA RATE TO NEC
  1457                              <1> RWV_DBL:
  1458 00003415 53                  <1> 	PUSH	eBX			; SAVE MEDIA/DRIVE PARAM TBL ADDRESS
  1459 00003416 E822040000          <1> 	CALL	SETUP_DBL		; CHECK FOR DOUBLE STEP
  1460 0000341B 5B                  <1> 	POP	eBX			; RESTORE ADDRESS
  1461 0000341C 7226                <1> 	JC	short CHK_RET		; ERROR FROM READ ID, POSSIBLE RETRY
  1462 0000341E 6658                <1> 	POP	AX			; RESTORE NEC, DMA COMMAND
  1463 00003420 6650                <1> 	PUSH	AX			; SAVE NEC COMMAND
  1464 00003422 53                  <1> 	PUSH	eBX			; SAVE MEDIA/DRIVE PARAM TBL ADDRESS
  1465 00003423 E861010000          <1> 	CALL	DMA_SETUP		; SET UP THE DMA
  1466 00003428 5B                  <1> 	POP	eBX 
  1467 00003429 6658                <1> 	POP	AX			; RESTORE NEC COMMAND
  1468 0000342B 722F                <1> 	JC	short RWV_BAC		; CHECK FOR DMA BOUNDARY ERROR
  1469 0000342D 6650                <1> 	PUSH	AX			; SAVE NEC COMMAND
  1470 0000342F 53                  <1> 	PUSH	eBX			; SAVE MEDIA/DRIVE PARAM TBL ADDRESS
  1471 00003430 E83C020000          <1> 	CALL	NEC_INIT		; INITIALIZE NEC
  1472 00003435 5B                  <1> 	POP	eBX			; RESTORE ADDRESS
  1473 00003436 720C                <1> 	JC	short CHK_RET		; ERROR - EXIT
  1474 00003438 E866020000          <1> 	CALL	RWV_COM			; OP CODE COMMON TO READ/WRITE/VERIFY
  1475 0000343D 7205                <1> 	JC	short CHK_RET		; ERROR - EXIT
  1476 0000343F E8AB020000          <1> 	CALL	NEC_TERM		; TERMINATE, GET STATUS, ETC.
  1477                              <1> CHK_RET:
  1478 00003444 E84A030000          <1> 	CALL	RETRY			; CHECK FOR, SETUP RETRY
  1479 00003449 6658                <1> 	POP	AX			; RESTORE READ/WRITE/VERIFY PARAMETER
  1480 0000344B 7305                <1> 	JNC	short RWV_END		; CY = 0 NO RETRY
  1481 0000344D E928FFFFFF          <1>         JMP     DO_AGAIN                ; CY = 1 MEANS RETRY
  1482                              <1> RWV_END:
  1483 00003452 E8F4020000          <1> 	CALL	DSTATE			; ESTABLISH STATE IF SUCCESSFUL
  1484 00003457 E887030000          <1> 	CALL	NUM_TRANS		; AL = NUMBER TRANSFERRED
  1485                              <1> RWV_BAC:				; BAD DMA ERROR ENTRY
  1486 0000345C 6650                <1> 	PUSH	AX			; SAVE NUMBER TRANSFERRED
  1487 0000345E E879FEFFFF          <1> 	CALL	XLAT_OLD		; TRANSLATE STATE TO COMPATIBLE MODE
  1488 00003463 6658                <1> 	POP	AX			; RESTORE NUMBER TRANSFERRED
  1489 00003465 E8B1030000          <1> 	CALL	SETUP_END		; VARIOUS CLEANUPS
  1490 0000346A C3                  <1> 	RETn
  1491                              <1> 
  1492                              <1> ;-------------------------------------------------------------------------------
  1493                              <1> ; SETUP_STATE:	INITIALIZES START AND END RATES.
  1494                              <1> ;-------------------------------------------------------------------------------
  1495                              <1> SETUP_STATE:
  1496 0000346B F687[3D200100]10    <1> 	TEST	byte [DSK_STATE+eDI], MED_DET ; MEDIA DETERMINED ?
  1497 00003472 7537                <1> 	JNZ	short J1C		; NO STATES IF DETERMINED
  1498 00003474 66B84000            <1>         MOV     AX,(RATE_500*256)+RATE_300  ; AH = START RATE, AL = END RATE
  1499 00003478 F687[3D200100]04    <1> 	TEST	byte [DSK_STATE+eDI],DRV_DET ; DRIVE ?
  1500 0000347F 740D                <1> 	JZ	short AX_SET		; DO NOT KNOW DRIVE
  1501 00003481 F687[3D200100]02    <1> 	TEST	byte [DSK_STATE+eDI], FMT_CAPA ; MULTI-RATE?
  1502 00003488 7504                <1> 	JNZ	short AX_SET		; JUMP IF YES
  1503 0000348A 66B88080            <1>         MOV     AX,RATE_250*257         ; START A END RATE 250 FOR 360 DRIVE
  1504                              <1> AX_SET:	
  1505 0000348E 80A7[3D200100]1F    <1> 	AND	byte [DSK_STATE+eDI], ~(RATE_MSK+DBL_STEP) ; TURN OFF THE RATE
  1506 00003495 08A7[3D200100]      <1> 	OR	[DSK_STATE+eDI], AH	; RATE FIRST TO TRY
  1507 0000349B 8025[38200100]F3    <1> 	AND	byte [LASTRATE], ~STRT_MSK ; ERASE LAST TO TRY RATE BITS
  1508 000034A2 C0C804              <1> 	ROR	AL,4			; TO OPERATION LAST RATE LOCATION
  1509 000034A5 0805[38200100]      <1> 	OR	[LASTRATE], AL		; LAST RATE
  1510                              <1> J1C:	
  1511 000034AB C3                  <1> 	RETn
  1512                              <1> 
  1513                              <1> ;-------------------------------------------------------------------------------
  1514                              <1> ;  FMT_INIT: ESTABLISH STATE IF UNESTABLISHED AT FORMAT TIME.
  1515                              <1> ;-------------------------------------------------------------------------------
  1516                              <1> FMT_INIT:
  1517 000034AC F687[3D200100]10    <1> 	TEST	byte [DSK_STATE+eDI], MED_DET ; IS MEDIA ESTABLISHED
  1518 000034B3 7546                <1> 	JNZ	short F1_OUT		; IF SO RETURN
  1519 000034B5 E82C040000          <1> 	CALL	CMOS_TYPE		; RETURN DRIVE TYPE IN AL
  1520                              <1> 	;; 20/02/2015
  1521                              <1> 	;;JC	short CL_DRV		; ERROR IN CMOS ASSUME NO DRIVE
  1522 000034BA 7440                <1> 	jz	short CL_DRV ;; 20/02/2015
  1523 000034BC FEC8                <1> 	DEC	AL			; MAKE ZERO ORIGIN
  1524                              <1> 	;;JS	short CL_DRV		; NO DRIVE IF AL 0
  1525 000034BE 8AA7[3D200100]      <1> 	MOV	AH, [DSK_STATE+eDI]	; AH = CURRENT STATE
  1526 000034C4 80E40F              <1> 	AND	AH, ~(MED_DET+DBL_STEP+RATE_MSK) ; CLEAR
  1527 000034C7 08C0                <1> 	OR	AL,AL			; CHECK FOR 360
  1528 000034C9 7505                <1> 	JNZ	short N_360		; IF 360 WILL BE 0
  1529 000034CB 80CC90              <1> 	OR	AH,MED_DET+RATE_250	; ESTABLISH MEDIA
  1530 000034CE EB25                <1> 	JMP	SHORT SKP_STATE		; SKIP OTHER STATE PROCESSING
  1531                              <1> N_360:	
  1532 000034D0 FEC8                <1> 	DEC	AL			; 1.2 M DRIVE
  1533 000034D2 7505                <1> 	JNZ	short N_12		; JUMP IF NOT
  1534                              <1> F1_RATE:
  1535 000034D4 80CC10              <1> 	OR	AH,MED_DET+RATE_500	; SET FORMAT RATE
  1536 000034D7 EB1C                <1> 	JMP	SHORT SKP_STATE		; SKIP OTHER STATE PROCESSING
  1537                              <1> N_12:	
  1538 000034D9 FEC8                <1> 	DEC	AL			; CHECK FOR TYPE 3
  1539 000034DB 750F                <1> 	JNZ	short N_720		; JUMP IF NOT
  1540 000034DD F6C404              <1> 	TEST	AH,DRV_DET		; IS DRIVE DETERMINED
  1541 000034E0 7410                <1> 	JZ	short ISNT_12		; TREAT AS NON 1.2 DRIVE
  1542 000034E2 F6C402              <1> 	TEST	AH,FMT_CAPA		; IS 1.2M
  1543 000034E5 740B                <1> 	JZ	short ISNT_12		; JUMP IF NOT
  1544 000034E7 80CC50              <1> 	OR	AH,MED_DET+RATE_300	; RATE 300
  1545 000034EA EB09                <1> 	JMP	SHORT SKP_STATE		; CONTINUE
  1546                              <1> N_720:
  1547 000034EC FEC8                <1> 	DEC	AL			; CHECK FOR TYPE 4
  1548 000034EE 750C                <1> 	JNZ	short CL_DRV		; NO DRIVE, CMOS BAD
  1549 000034F0 EBE2                <1> 	JMP	SHORT F1_RATE
  1550                              <1> ISNT_12: 
  1551 000034F2 80CC90              <1> 	OR	AH,MED_DET+RATE_250	; MUST BE RATE 250
  1552                              <1> 
  1553                              <1> SKP_STATE:
  1554 000034F5 88A7[3D200100]      <1> 	MOV	[DSK_STATE+eDI], AH	; STORE AWAY
  1555                              <1> F1_OUT:
  1556 000034FB C3                  <1> 	RETn
  1557                              <1> CL_DRV:	
  1558 000034FC 30E4                <1> 	XOR	AH,AH			; CLEAR STATE
  1559 000034FE EBF5                <1> 	JMP	SHORT SKP_STATE		; SAVE IT
  1560                              <1> 
  1561                              <1> ;-------------------------------------------------------------------------------
  1562                              <1> ; MED_CHANGE	
  1563                              <1> ;	CHECKS FOR MEDIA CHANGE, RESETS MEDIA CHANGE, 
  1564                              <1> ;	CHECKS MEDIA CHANGE AGAIN.
  1565                              <1> ;
  1566                              <1> ; ON EXIT:	CY = 1 MEANS MEDIA CHANGE OR TIMEOUT
  1567                              <1> ;		@DSKETTE_STATUS = ERROR CODE
  1568                              <1> ;-------------------------------------------------------------------------------
  1569                              <1> MED_CHANGE:
  1570 00003500 E888060000          <1> 	CALL	READ_DSKCHNG		; READ DISK CHANCE LINE STATE
  1571 00003505 7447                <1> 	JZ	short MC_OUT		; BYPASS HANDLING DISK CHANGE LINE
  1572 00003507 80A7[3D200100]EF    <1> 	AND	byte [DSK_STATE+eDI], ~MED_DET ; CLEAR STATE FOR THIS DRIVE
  1573                              <1> 
  1574                              <1> ;	THIS SEQUENCE ENSURES WHENEVER A DISKETTE IS CHANGED THAT
  1575                              <1> ;	ON THE NEXT OPERATION THE REQUIRED MOTOR START UP TIME WILL
  1576                              <1> ;	BE WAITED. (DRIVE MOTOR MAY GO OFF UPON DOOR OPENING).
  1577                              <1> 
  1578 0000350E 6689F9              <1> 	MOV	CX,DI			; CL = DRIVE 0
  1579 00003511 B001                <1> 	MOV	AL,1			; MOTOR ON BIT MASK
  1580 00003513 D2E0                <1> 	SHL	AL,CL			; TO APPROPRIATE POSITION
  1581 00003515 F6D0                <1> 	NOT	AL			; KEEP ALL BUT MOTOR ON
  1582 00003517 FA                  <1> 	CLI				; NO INTERRUPTS
  1583 00003518 2005[2E200100]      <1> 	AND	[MOTOR_STATUS], AL	; TURN MOTOR OFF INDICATOR
  1584 0000351E FB                  <1> 	STI				; INTERRUPTS ENABLED
  1585 0000351F E810040000          <1> 	CALL	MOTOR_ON		; TURN MOTOR ON
  1586                              <1> 
  1587                              <1> ;-----	THIS SEQUENCE OF SEEKS IS USED TO RESET DISKETTE CHANGE SIGNAL
  1588                              <1> 
  1589 00003524 E86DF9FFFF          <1> 	CALL	DSK_RESET		; RESET NEC
  1590 00003529 B501                <1> 	MOV	CH,01H			; MOVE TO CYLINDER 1
  1591 0000352B E8FF040000          <1> 	CALL	SEEK			; ISSUE SEEK
  1592 00003530 30ED                <1> 	XOR	CH,CH			; MOVE TO CYLINDER 0
  1593 00003532 E8F8040000          <1> 	CALL	SEEK			; ISSUE SEEK
  1594 00003537 C605[30200100]06    <1> 	MOV	byte [DSKETTE_STATUS], MEDIA_CHANGE ; STORE IN STATUS
  1595                              <1> OK1:
  1596 0000353E E84A060000          <1> 	CALL	READ_DSKCHNG		; CHECK MEDIA CHANGED AGAIN
  1597 00003543 7407                <1> 	JZ	short OK2		; IF ACTIVE, NO DISKETTE, TIMEOUT
  1598                              <1> OK4:
  1599 00003545 C605[30200100]80    <1> 	MOV	byte [DSKETTE_STATUS], TIME_OUT ; TIMEOUT IF DRIVE EMPTY
  1600                              <1> OK2:		
  1601 0000354C F9                  <1> 	STC				; MEDIA CHANGED, SET CY
  1602 0000354D C3                  <1> 	RETn
  1603                              <1> MC_OUT:
  1604 0000354E F8                  <1> 	CLC				; NO MEDIA CHANGED, CLEAR CY
  1605 0000354F C3                  <1> 	RETn
  1606                              <1> 
  1607                              <1> ;-------------------------------------------------------------------------------
  1608                              <1> ; SEND_RATE
  1609                              <1> ;	SENDS DATA RATE COMMAND TO NEC
  1610                              <1> ; ON ENTRY:	DI = DRIVE #
  1611                              <1> ; ON EXIT:	NONE
  1612                              <1> ; REGISTERS ALTERED: DX
  1613                              <1> ;-------------------------------------------------------------------------------
  1614                              <1> SEND_RATE:
  1615 00003550 6650                <1> 	PUSH	AX			; SAVE REG.
  1616 00003552 8025[38200100]3F    <1> 	AND	byte [LASTRATE], ~SEND_MSK ; ELSE CLEAR LAST RATE ATTEMPTED
  1617 00003559 8A87[3D200100]      <1> 	MOV	AL, [DSK_STATE+eDI]	; GET RATE STATE OF THIS DRIVE
  1618 0000355F 24C0                <1> 	AND	AL,SEND_MSK		; KEEP ONLY RATE BITS
  1619 00003561 0805[38200100]      <1> 	OR	[LASTRATE], AL		; SAVE NEW RATE FOR NEXT CHECK
  1620 00003567 C0C002              <1> 	ROL	AL,2			; MOVE TO BIT OUTPUT POSITIONS
  1621 0000356A 66BAF703            <1> 	MOV	DX,03F7H		; OUTPUT NEW DATA RATE
  1622 0000356E EE                  <1> 	OUT	DX,AL
  1623 0000356F 6658                <1> 	POP	AX			; RESTORE REG.
  1624 00003571 C3                  <1> 	RETn
  1625                              <1> 
  1626                              <1> ;-------------------------------------------------------------------------------
  1627                              <1> ; CHK_LASTRATE
  1628                              <1> ;	CHECK PREVIOUS DATE RATE SNT TO THE CONTROLLER.
  1629                              <1> ; ON ENTRY:
  1630                              <1> ;	DI = DRIVE #
  1631                              <1> ; ON EXIT:
  1632                              <1> ;	ZF =  1 DATA RATE IS THE SAME AS THE LAST RATE SENT TO NEC
  1633                              <1> ;	ZF =  0 DATA RATE IS DIFFERENT FROM LAST RATE
  1634                              <1> ; REGISTERS ALTERED: DX
  1635                              <1> ;-------------------------------------------------------------------------------
  1636                              <1> CHK_LASTRATE:
  1637 00003572 6650                <1> 	PUSH	AX			; SAVE REG
  1638 00003574 2225[38200100]      <1> 	AND	AH, [LASTRATE]		; GET LAST DATA RATE SELECTED
  1639 0000357A 8A87[3D200100]      <1> 	MOV	AL, [DSK_STATE+eDI]	; GET RATE STATE OF THIS DRIVE
  1640 00003580 6625C0C0            <1>         AND     AX, SEND_MSK*257        ; KEEP ONLY RATE BITS OF BOTH
  1641 00003584 38E0                <1> 	CMP	AL, AH			; COMPARE TO PREVIOUSLY TRIED
  1642                              <1> 					; ZF = 1 RATE IS THE SAME
  1643 00003586 6658                <1> 	POP	AX			; RESTORE REG.
  1644 00003588 C3                  <1> 	RETn
  1645                              <1> 
  1646                              <1> ;-------------------------------------------------------------------------------
  1647                              <1> ; DMA_SETUP
  1648                              <1> ;	THIS ROUTINE SETS UP THE DMA FOR READ/WRITE/VERIFY OPERATIONS.
  1649                              <1> ;
  1650                              <1> ; ON ENTRY:	AL = DMA COMMAND
  1651                              <1> ;
  1652                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
  1653                              <1> ;-------------------------------------------------------------------------------
  1654                              <1> 
  1655                              <1> ; SI = Head #, # of Sectors or DASD Type
  1656                              <1> 
  1657                              <1> ; 22/08/2015
  1658                              <1> ; 08/02/2015 - Protected Mode Modification
  1659                              <1> ; 06/02/2015 - 07/02/2015
  1660                              <1> ; NOTE: Buffer address must be in 1st 16MB of Physical Memory (24 bit limit).
  1661                              <1> ; (DMA Addres = Physical Address)
  1662                              <1> ; (Retro UNIX 386 v1 Kernel/System Mode Virtual Address = Physical Address)
  1663                              <1> ;
  1664                              <1> 
  1665                              <1> 
  1666                              <1> ; 04/02/2016 (clc)
  1667                              <1> ; 20/02/2015 modification (source: AWARD BIOS 1999, DMA_SETUP)
  1668                              <1> ; 16/12/2014 (IODELAY)
  1669                              <1> 
  1670                              <1> DMA_SETUP:
  1671                              <1> 
  1672                              <1> ;; 20/02/2015
  1673 00003589 8B5504              <1> 	mov	edx, [ebp+4] 		; Buffer address
  1674 0000358C F7C2000000FF        <1> 	test	edx, 0FF000000h		; 16 MB limit (22/08/2015, bugfix)
  1675 00003592 756E                <1> 	jnz	short dma_bnd_err_stc
  1676                              <1> 	;
  1677 00003594 6650                <1> 	push	ax			; DMA command
  1678 00003596 52                  <1> 	push	edx			; *
  1679 00003597 B203                <1> 	mov	dl, 3			; GET BYTES/SECTOR PARAMETER
  1680 00003599 E851030000          <1> 	call	GET_PARM		; 
  1681 0000359E 88E1                <1> 	mov	cl, ah 			; SHIFT COUNT (0=128, 1=256, 2=512 ETC)
  1682 000035A0 6689F0              <1> 	mov	ax, si			; Sector count
  1683 000035A3 88C4                <1> 	mov	ah, al			; AH =  # OF SECTORS
  1684 000035A5 28C0                <1> 	sub	al, al			; AL = 0, AX = # SECTORS * 256
  1685 000035A7 66D1E8              <1> 	shr	ax, 1			; AX = # SECTORS * 128
  1686 000035AA 66D3E0              <1> 	shl	ax, cl			; SHIFT BY PARAMETER VALUE
  1687 000035AD 6648                <1> 	dec	ax			; -1 FOR DMA VALUE
  1688 000035AF 6689C1              <1> 	mov	cx, ax
  1689 000035B2 5A                  <1> 	pop	edx			; *
  1690 000035B3 6658                <1> 	pop	ax
  1691 000035B5 3C42                <1> 	cmp	al, 42h
  1692 000035B7 7507                <1>         jne     short NOT_VERF
  1693 000035B9 BA0000FF00          <1> 	mov	edx, 0FF0000h
  1694 000035BE EB08                <1> 	jmp	short J33
  1695                              <1> NOT_VERF:
  1696 000035C0 6601CA              <1> 	add	dx, cx			; check for overflow
  1697 000035C3 723E                <1> 	jc	short dma_bnd_err
  1698                              <1> 	;
  1699 000035C5 6629CA              <1> 	sub	dx, cx			; Restore start address
  1700                              <1> J33:
  1701 000035C8 FA                  <1> 	CLI				; DISABLE INTERRUPTS DURING DMA SET-UP
  1702 000035C9 E60C                <1> 	OUT	DMA+12,AL		; SET THE FIRST/LA5T F/F
  1703                              <1> 	IODELAY				; WAIT FOR I/O
  1703 000035CB EB00                <2>  jmp short $+2
  1703 000035CD EB00                <2>  jmp short $+2
  1704 000035CF E60B                <1> 	OUT	DMA+11,AL		; OUTPUT THE MODE BYTE
  1705 000035D1 89D0                <1> 	mov	eax, edx		; Buffer address
  1706 000035D3 E604                <1> 	OUT	DMA+4,AL		; OUTPUT LOW ADDRESS
  1707                              <1> 	IODELAY				; WAIT FOR I/O
  1707 000035D5 EB00                <2>  jmp short $+2
  1707 000035D7 EB00                <2>  jmp short $+2
  1708 000035D9 88E0                <1> 	MOV	AL,AH
  1709 000035DB E604                <1> 	OUT	DMA+4,AL		; OUTPUT HIGH ADDRESS
  1710 000035DD C1E810              <1> 	shr	eax, 16
  1711                              <1> 	IODELAY				; I/O WAIT STATE
  1711 000035E0 EB00                <2>  jmp short $+2
  1711 000035E2 EB00                <2>  jmp short $+2
  1712 000035E4 E681                <1> 	OUT	081H,AL			; OUTPUT highest BITS TO PAGE REGISTER
  1713                              <1> 	IODELAY
  1713 000035E6 EB00                <2>  jmp short $+2
  1713 000035E8 EB00                <2>  jmp short $+2
  1714 000035EA 6689C8              <1> 	mov	ax, cx			; Byte count - 1
  1715 000035ED E605                <1> 	OUT	DMA+5,AL		; LOW BYTE OF COUNT
  1716                              <1> 	IODELAY				; WAIT FOR I/O
  1716 000035EF EB00                <2>  jmp short $+2
  1716 000035F1 EB00                <2>  jmp short $+2
  1717 000035F3 88E0                <1> 	MOV	AL, AH
  1718 000035F5 E605                <1> 	OUT	DMA+5,AL		; HIGH BYTE OF COUNT
  1719                              <1> 	IODELAY
  1719 000035F7 EB00                <2>  jmp short $+2
  1719 000035F9 EB00                <2>  jmp short $+2
  1720 000035FB FB                  <1> 	STI				; RE-ENABLE INTERRUPTS
  1721 000035FC B002                <1> 	MOV	AL, 2			; MODE FOR 8237
  1722 000035FE E60A                <1> 	OUT	DMA+10, AL		; INITIALIZE THE DISKETTE CHANNEL
  1723                              <1> 
  1724 00003600 F8                  <1> 	clc	; 04/02/2016
  1725 00003601 C3                  <1> 	retn
  1726                              <1> 
  1727                              <1> dma_bnd_err_stc:
  1728 00003602 F9                  <1> 	stc
  1729                              <1> dma_bnd_err:
  1730 00003603 C605[30200100]09    <1> 	MOV	byte [DSKETTE_STATUS], DMA_BOUNDARY ; SET ERROR
  1731 0000360A C3                  <1> 	RETn				; CY SET BY ABOVE IF ERROR
  1732                              <1> 
  1733                              <1> ;; 16/12/2014
  1734                              <1> ;;	CLI				; DISABLE INTERRUPTS DURING DMA SET-UP
  1735                              <1> ;;	OUT	DMA+12,AL		; SET THE FIRST/LA5T F/F
  1736                              <1> ;;	;JMP	$+2			; WAIT FOR I/O
  1737                              <1> ;;	IODELAY
  1738                              <1> ;; 	OUT	DMA+11,AL		; OUTPUT THE MODE BYTE
  1739                              <1> ;;	;SIODELAY
  1740                              <1> ;;      ;CMP	AL, 42H			; DMA VERIFY COMMAND
  1741                              <1> ;;      ;JNE	short NOT_VERF		; NO
  1742                              <1> ;;      ;XOR	AX, AX			; START ADDRESS
  1743                              <1> ;;      ;JMP	SHORT J33
  1744                              <1> ;;;NOT_VERF:	
  1745                              <1> ;;	;MOV	AX,ES			; GET THE ES VALUE
  1746                              <1> ;;	;ROL	AX,4			; ROTATE LEFT
  1747                              <1> ;;	;MOV	CH,AL			; GET HIGHEST NIBBLE OF ES TO CH
  1748                              <1> ;;	;AND	AL,11110000B		; ZERO THE LOW NIBBLE FROM SEGMENT
  1749                              <1> ;;	;ADD	AX,[BP+2]		; TEST FOR CARRY FROM ADDITION
  1750                              <1> ;;	mov	eax, [ebp+4] ; 06/02/2015	
  1751                              <1> ;;	;JNC	short J33
  1752                              <1> ;;	;INC	CH			; CARRY MEANS HIGH 4 BITS MUST BE INC
  1753                              <1> ;;;J33:
  1754                              <1> ;;	PUSH	eAX			; SAVE START ADDRESS
  1755                              <1> ;;	OUT	DMA+4,AL		; OUTPUT LOW ADDRESS
  1756                              <1> ;;	;JMP	$+2			; WAIT FOR I/O
  1757                              <1> ;;	IODELAY
  1758                              <1> ;;	MOV	AL,AH
  1759                              <1> ;;	OUT	DMA+4,AL		; OUTPUT HIGH ADDRESS
  1760                              <1> ;;	shr	eax, 16	     ; 07/02/2015
  1761                              <1> ;;	;MOV	AL,CH			; GET HIGH 4 BITS
  1762                              <1> ;;	;JMP	$+2			; I/O WAIT STATE
  1763                              <1> ;;	IODELAY
  1764                              <1> ;;	;AND	AL,00001111B
  1765                              <1> ;;	OUT	081H,AL			; OUTPUT HIGH 4 BITS TO PAGE REGISTER
  1766                              <1> ;;	;SIODELAY
  1767                              <1> ;;
  1768                              <1> ;;;----- DETERMINE COUNT
  1769                              <1> ;;	sub	eax, eax ; 08/02/2015
  1770                              <1> ;;	MOV	AX, SI			; AL =  # OF SECTORS
  1771                              <1> ;;	XCHG	AL, AH			; AH =  # OF SECTORS
  1772                              <1> ;;	SUB	AL, AL			; AL = 0, AX = # SECTORS * 256
  1773                              <1> ;;	SHR	AX, 1			; AX = # SECTORS * 128
  1774                              <1> ;;	PUSH	AX			; SAVE # OF SECTORS * 128
  1775                              <1> ;;	MOV	DL, 3			; GET BYTES/SECTOR PARAMETER
  1776                              <1> ;;	CALL	GET_PARM		; "
  1777                              <1> ;;	MOV	CL,AH			; SHIFT COUNT (0=128, 1=256, 2=512 ETC)
  1778                              <1> ;;	POP	AX			; AX = # SECTORS * 128
  1779                              <1> ;;	SHL	AX,CL			; SHIFT BY PARAMETER VALUE
  1780                              <1> ;;	DEC	AX			; -1 FOR DMA VALUE
  1781                              <1> ;;	PUSH	eAX  ; 08/02/2015	; SAVE COUNT VALUE
  1782                              <1> ;;	OUT	DMA+5,AL		; LOW BYTE OF COUNT
  1783                              <1> ;;	;JMP	$+2			; WAIT FOR I/O
  1784                              <1> ;;	IODELAY
  1785                              <1> ;;	MOV	AL, AH
  1786                              <1> ;;	OUT	DMA+5,AL		; HIGH BYTE OF COUNT
  1787                              <1> ;;	;IODELAY
  1788                              <1> ;;	STI				; RE-ENABLE INTERRUPTS
  1789                              <1> ;;	POP	eCX  ; 08/02/2015 	; RECOVER COUNT VALUE
  1790                              <1> ;;	POP	eAX  ; 08/02/2015	; RECOVER ADDRESS VALUE
  1791                              <1> ;;	;ADD	AX, CX			; ADD, TEST FOR 64K OVERFLOW
  1792                              <1> ;;	add	ecx, eax ; 08/02/2015
  1793                              <1> ;;	MOV	AL, 2			; MODE FOR 8237
  1794                              <1> ;;	;JMP	$+2			; WAIT FOR I/O
  1795                              <1> ;;	SIODELAY
  1796                              <1> ;;	OUT	DMA+10, AL		; INITIALIZE THE DISKETTE CHANNEL
  1797                              <1> ;;	;JNC	short NO_BAD		; CHECK FOR ERROR
  1798                              <1> ;;	jc	short dma_bnd_err ; 08/02/2015
  1799                              <1> ;;	and	ecx, 0FFF00000h ; 16 MB limit
  1800                              <1> ;;	jz	short NO_BAD
  1801                              <1> ;;dma_bnd_err:
  1802                              <1> ;;	MOV	byte [DSKETTE_STATUS], DMA_BOUNDARY ; SET ERROR
  1803                              <1> ;;NO_BAD:
  1804                              <1> ;;	RETn				; CY SET BY ABOVE IF ERROR
  1805                              <1> 
  1806                              <1> ;-------------------------------------------------------------------------------
  1807                              <1> ; FMTDMA_SET
  1808                              <1> ;	THIS ROUTINE SETS UP THE DMA CONTROLLER FOR A FORMAT OPERATION.
  1809                              <1> ;
  1810                              <1> ; ON ENTRY:	NOTHING REQUIRED
  1811                              <1> ;
  1812                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
  1813                              <1> ;-------------------------------------------------------------------------------
  1814                              <1> 
  1815                              <1> FMTDMA_SET:
  1816                              <1> ;; 20/02/2015 modification	
  1817 0000360B 8B5504              <1> 	mov	edx, [ebp+4] 		; Buffer address
  1818 0000360E F7C20000F0FF        <1> 	test	edx, 0FFF00000h		; 16 MB limit
  1819 00003614 75EC                <1> 	jnz	short dma_bnd_err_stc
  1820                              <1> 	;
  1821 00003616 6652                <1> 	push	dx			; *
  1822 00003618 B204                <1> 	mov	DL, 4			; SECTORS/TRACK VALUE IN PARM TABLE
  1823 0000361A E8D0020000          <1> 	call	GET_PARM		; "
  1824 0000361F 88E0                <1> 	mov	al, ah			; AL = SECTORS/TRACK VALUE
  1825 00003621 28E4                <1> 	sub	ah, ah			; AX = SECTORS/TRACK VALUE
  1826 00003623 66C1E002            <1> 	shl	ax, 2			; AX = SEC/TRK * 4 (OFFSET C,H,R,N)
  1827 00003627 6648                <1> 	dec	ax			; -1 FOR DMA VALUE
  1828 00003629 6689C1              <1> 	mov	cx, ax
  1829 0000362C 665A                <1> 	pop	dx			; *
  1830 0000362E 6601CA              <1> 	add	dx, cx			; check for overflow
  1831 00003631 72D0                <1> 	jc	short dma_bnd_err
  1832                              <1> 	;
  1833 00003633 6629CA              <1> 	sub	dx, cx			; Restore start address
  1834                              <1> 	;
  1835 00003636 B04A                <1> 	MOV	AL, 04AH		; WILL WRITE TO THE DISKETTE
  1836 00003638 FA                  <1> 	CLI				; DISABLE INTERRUPTS DURING DMA SET-UP
  1837 00003639 E60C                <1> 	OUT	DMA+12,AL		; SET THE FIRST/LA5T F/F
  1838                              <1> 	IODELAY				; WAIT FOR I/O
  1838 0000363B EB00                <2>  jmp short $+2
  1838 0000363D EB00                <2>  jmp short $+2
  1839 0000363F E60B                <1> 	OUT	DMA+11,AL		; OUTPUT THE MODE BYTE
  1840 00003641 89D0                <1> 	mov	eax, edx		; Buffer address
  1841 00003643 E604                <1> 	OUT	DMA+4,AL		; OUTPUT LOW ADDRESS
  1842                              <1> 	IODELAY				; WAIT FOR I/O
  1842 00003645 EB00                <2>  jmp short $+2
  1842 00003647 EB00                <2>  jmp short $+2
  1843 00003649 88E0                <1> 	MOV	AL,AH
  1844 0000364B E604                <1> 	OUT	DMA+4,AL		; OUTPUT HIGH ADDRESS
  1845 0000364D C1E810              <1> 	shr	eax, 16
  1846                              <1> 	IODELAY				; I/O WAIT STATE
  1846 00003650 EB00                <2>  jmp short $+2
  1846 00003652 EB00                <2>  jmp short $+2
  1847 00003654 E681                <1> 	OUT	081H,AL			; OUTPUT highest BITS TO PAGE REGISTER
  1848                              <1> 	IODELAY
  1848 00003656 EB00                <2>  jmp short $+2
  1848 00003658 EB00                <2>  jmp short $+2
  1849 0000365A 6689C8              <1> 	mov	ax, cx			; Byte count - 1
  1850 0000365D E605                <1> 	OUT	DMA+5,AL		; LOW BYTE OF COUNT
  1851                              <1> 	IODELAY				; WAIT FOR I/O
  1851 0000365F EB00                <2>  jmp short $+2
  1851 00003661 EB00                <2>  jmp short $+2
  1852 00003663 88E0                <1> 	MOV	AL, AH
  1853 00003665 E605                <1> 	OUT	DMA+5,AL		; HIGH BYTE OF COUNT
  1854                              <1> 	IODELAY
  1854 00003667 EB00                <2>  jmp short $+2
  1854 00003669 EB00                <2>  jmp short $+2
  1855 0000366B FB                  <1> 	STI				; RE-ENABLE INTERRUPTS
  1856 0000366C B002                <1> 	MOV	AL, 2			; MODE FOR 8237
  1857 0000366E E60A                <1> 	OUT	DMA+10, AL		; INITIALIZE THE DISKETTE CHANNEL
  1858 00003670 C3                  <1> 	retn
  1859                              <1> 
  1860                              <1> ;; 08/02/2015 - Protected Mode Modification
  1861                              <1> ;;	MOV	AL, 04AH		; WILL WRITE TO THE DISKETTE
  1862                              <1> ;;	CLI				; DISABLE INTERRUPTS DURING DMA SET-UP
  1863                              <1> ;;	OUT	DMA+12,AL		; SET THE FIRST/LA5T F/F
  1864                              <1> ;;	;JMP	$+2			; WAIT FOR I/O
  1865                              <1> ;;	IODELAY
  1866                              <1> ;;	OUT	DMA+11,AL		; OUTPUT THE MODE BYTE
  1867                              <1> ;;	;MOV	AX,ES			; GET THE ES VALUE
  1868                              <1> ;;	;ROL	AX,4			; ROTATE LEFT
  1869                              <1> ;;	;MOV	CH,AL			; GET HIGHEST NIBBLE OF ES TO CH
  1870                              <1> ;;	;AND	AL,11110000B		; ZERO THE LOW NIBBLE FROM SEGMENT
  1871                              <1> ;;	;ADD	AX,[BP+2]		; TEST FOR CARRY FROM ADDITION
  1872                              <1> ;;	;JNC	short J33A
  1873                              <1> ;;	;INC	CH			; CARRY MEANS HIGH 4 BITS MUST BE INC
  1874                              <1> ;;	mov	eax, [ebp+4] ; 08/02/2015
  1875                              <1> ;;;J33A:
  1876                              <1> ;;	PUSH	eAX ; 08/02/2015	; SAVE START ADDRESS
  1877                              <1> ;;	OUT	DMA+4,AL		; OUTPUT LOW ADDRESS
  1878                              <1> ;;	;JMP	$+2			; WAIT FOR I/O
  1879                              <1> ;;	IODELAY
  1880                              <1> ;;	MOV	AL,AH
  1881                              <1> ;;	OUT	DMA+4,AL		; OUTPUT HIGH ADDRESS
  1882                              <1> ;;	shr 	eax, 16 ; 08/02/2015
  1883                              <1> ;;	;MOV	AL,CH			; GET HIGH 4 BITS
  1884                              <1> ;;	;JMP	$+2			; I/O WAIT STATE
  1885                              <1> ;;	IODELAY
  1886                              <1> ;;	;AND	AL,00001111B
  1887                              <1> ;;	OUT	081H,AL			; OUTPUT HIGH 4 BITS TO PAGE REGISTER
  1888                              <1> ;;
  1889                              <1> ;;;----- DETERMINE COUNT
  1890                              <1> ;;	sub	eax, eax ; 08/02/2015
  1891                              <1> ;;	MOV	DL, 4			; SECTORS/TRACK VALUE IN PARM TABLE
  1892                              <1> ;;	CALL	GET_PARM		; "
  1893                              <1> ;;	XCHG	AL, AH			; AL = SECTORS/TRACK VALUE
  1894                              <1> ;;	SUB	AH, AH			; AX = SECTORS/TRACK VALUE
  1895                              <1> ;;	SHL	AX, 2			; AX = SEC/TRK * 4 (OFFSET C,H,R,N)
  1896                              <1> ;;	DEC	AX			; -1 FOR DMA VALUE
  1897                              <1> ;;	PUSH	eAX 	; 08/02/2015	; SAVE # OF BYTES TO BE TRANSFERED
  1898                              <1> ;;	OUT	DMA+5,AL		; LOW BYTE OF COUNT
  1899                              <1> ;;	;JMP	$+2			; WAIT FOR I/O
  1900                              <1> ;;	IODELAY
  1901                              <1> ;;	MOV	AL, AH
  1902                              <1> ;;	OUT	DMA+5,AL		; HIGH BYTE OF COUNT
  1903                              <1> ;;	STI				; RE-ENABLE INTERRUPTS
  1904                              <1> ;;	POP	eCX	; 08/02/2015	; RECOVER COUNT VALUE
  1905                              <1> ;;	POP	eAX	; 08/02/2015	; RECOVER ADDRESS VALUE
  1906                              <1> ;;	;ADD	AX, CX			; ADD, TEST FOR 64K OVERFLOW
  1907                              <1> ;;	add	ecx, eax ; 08/02/2015
  1908                              <1> ;;	MOV	AL, 2			; MODE FOR 8237
  1909                              <1> ;;	;JMP	$+2			; WAIT FOR I/O
  1910                              <1> ;;	SIODELAY
  1911                              <1> ;;	OUT	DMA+10, AL		; INITIALIZE THE DISKETTE CHANNEL
  1912                              <1> ;;	;JNC	short FMTDMA_OK		; CHECK FOR ERROR
  1913                              <1> ;;	jc	short fmtdma_bnd_err ; 08/02/2015
  1914                              <1> ;;	and	ecx, 0FFF00000h  ; 16 MB limit
  1915                              <1> ;;	jz	short FMTDMA_OK
  1916                              <1> ;;	stc	; 20/02/2015
  1917                              <1> ;;fmtdma_bnd_err:
  1918                              <1> ;;	MOV	byte [DSKETTE_STATUS], DMA_BOUNDARY ; SET ERROR
  1919                              <1> ;;FMTDMA_OK:
  1920                              <1> ;;	RETn				; CY SET BY ABOVE IF ERROR
  1921                              <1> 
  1922                              <1> ;-------------------------------------------------------------------------------
  1923                              <1> ; NEC_INIT	
  1924                              <1> ;	THIS ROUTINE SEEKS TO THE REQUESTED TRACK AND INITIALIZES
  1925                              <1> ;	THE NEC FOR THE READ/WRITE/VERIFY/FORMAT OPERATION.
  1926                              <1> ;
  1927                              <1> ; ON ENTRY:	AH = NEC COMMAND TO BE PERFORMED
  1928                              <1> ;
  1929                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
  1930                              <1> ;-------------------------------------------------------------------------------
  1931                              <1> NEC_INIT:
  1932 00003671 6650                <1> 	PUSH	AX			; SAVE NEC COMMAND
  1933 00003673 E8BC020000          <1> 	CALL	MOTOR_ON		; TURN MOTOR ON FOR SPECIFIC DRIVE
  1934                              <1> 
  1935                              <1> ;-----	DO THE SEEK OPERATION
  1936                              <1> 
  1937 00003678 8A6D01              <1> 	MOV	CH,[eBP+1]		; CH = TRACK #
  1938 0000367B E8AF030000          <1> 	CALL	SEEK			; MOVE TO CORRECT TRACK
  1939 00003680 6658                <1> 	POP	AX			; RECOVER COMMAND
  1940 00003682 721E                <1> 	JC	short ER_1		; ERROR ON SEEK
  1941 00003684 BB[A2360000]        <1> 	MOV	eBX, ER_1		; LOAD ERROR ADDRESS
  1942 00003689 53                  <1> 	PUSH	eBX			; PUSH NEC_OUT ERROR RETURN
  1943                              <1> 
  1944                              <1> ;-----	SEND OUT THE PARAMETERS TO THE CONTROLLER
  1945                              <1> 
  1946 0000368A E866030000          <1> 	CALL	NEC_OUTPUT		; OUTPUT THE OPERATION COMMAND
  1947 0000368F 6689F0              <1> 	MOV	AX,SI			; AH = HEAD #
  1948 00003692 89FB                <1> 	MOV	eBX,eDI			; BL = DRIVE #
  1949 00003694 C0E402              <1> 	SAL	AH,2			; MOVE IT TO BIT 2
  1950 00003697 80E404              <1> 	AND	AH,00000100B		; ISOLATE THAT BIT
  1951 0000369A 08DC                <1> 	OR	AH,BL			; OR IN THE DRIVE NUMBER
  1952 0000369C E854030000          <1> 	CALL	NEC_OUTPUT		; FALL THRU CY SET IF ERROR
  1953 000036A1 5B                  <1> 	POP	eBX			; THROW AWAY ERROR RETURN
  1954                              <1> ER_1:
  1955 000036A2 C3                  <1> 	RETn
  1956                              <1> 
  1957                              <1> ;-------------------------------------------------------------------------------
  1958                              <1> ; RWV_COM
  1959                              <1> ;	THIS ROUTINE SENDS PARAMETERS TO THE NEC SPECIFIC TO THE 
  1960                              <1> ;	READ/WRITE/VERIFY OPERATIONS.
  1961                              <1> ;
  1962                              <1> ; ON ENTRY:	CS:BX = ADDRESS OF MEDIA/DRIVE PARAMETER TABLE
  1963                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
  1964                              <1> ;-------------------------------------------------------------------------------
  1965                              <1> RWV_COM:
  1966 000036A3 B8[EE360000]        <1> 	MOV	eAX, ER_2		; LOAD ERROR ADDRESS
  1967 000036A8 50                  <1> 	PUSH	eAX			; PUSH NEC_OUT ERROR RETURN
  1968 000036A9 8A6501              <1> 	MOV	AH,[eBP+1]		; OUTPUT TRACK #
  1969 000036AC E844030000          <1> 	CALL	NEC_OUTPUT
  1970 000036B1 6689F0              <1> 	MOV	AX,SI			; OUTPUT HEAD #
  1971 000036B4 E83C030000          <1> 	CALL	NEC_OUTPUT
  1972 000036B9 8A6500              <1>         MOV     AH,[eBP]                ; OUTPUT SECTOR #
  1973 000036BC E834030000          <1> 	CALL	NEC_OUTPUT
  1974 000036C1 B203                <1> 	MOV	DL,3			; BYTES/SECTOR PARAMETER FROM BLOCK
  1975 000036C3 E827020000          <1> 	CALL	GET_PARM 		; ... TO THE NEC
  1976 000036C8 E828030000          <1> 	CALL	NEC_OUTPUT		; OUTPUT TO CONTROLLER
  1977 000036CD B204                <1> 	MOV	DL,4			; EOT PARAMETER FROM BLOCK
  1978 000036CF E81B020000          <1> 	CALL	GET_PARM 		; ... TO THE NEC
  1979 000036D4 E81C030000          <1> 	CALL	NEC_OUTPUT		; OUTPUT TO CONTROLLER
  1980 000036D9 8A6305              <1>         MOV     AH, [eBX+MD.GAP]        ; GET GAP LENGTH
  1981                              <1> _R15:
  1982 000036DC E814030000          <1> 	CALL	NEC_OUTPUT
  1983 000036E1 B206                <1> 	MOV	DL,6			; DTL PARAMETER PROM BLOCK
  1984 000036E3 E807020000          <1> 	CALL	GET_PARM		;  TO THE NEC
  1985 000036E8 E808030000          <1> 	CALL	NEC_OUTPUT		; OUTPUT TO CONTROLLER
  1986 000036ED 58                  <1> 	POP	eAX			; THROW AWAY ERROR EXIT
  1987                              <1> ER_2:
  1988 000036EE C3                  <1> 	RETn
  1989                              <1> 
  1990                              <1> ;-------------------------------------------------------------------------------
  1991                              <1> ; NEC_TERM
  1992                              <1> ;	THIS ROUTINE WAITS FOR THE OPERATION THEN ACCEPTS THE STATUS 
  1993                              <1> ;	FROM THE NEC FOR THE READ/WRITE/VERIFY/FORWAT OPERATION.
  1994                              <1> ;
  1995                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
  1996                              <1> ;-------------------------------------------------------------------------------
  1997                              <1> NEC_TERM:
  1998                              <1> 
  1999                              <1> ;-----	LET THE OPERATION HAPPEN
  2000                              <1> 
  2001 000036EF 56                  <1> 	PUSH	eSI			; SAVE HEAD #, # OF SECTORS
  2002 000036F0 E80D040000          <1> 	CALL	WAIT_INT		; WAIT FOR THE INTERRUPT
  2003 000036F5 9C                  <1> 	PUSHF
  2004 000036F6 E837040000          <1> 	CALL	RESULTS			; GET THE NEC STATUS
  2005 000036FB 724B                <1> 	JC	short SET_END_POP
  2006 000036FD 9D                  <1> 	POPF
  2007 000036FE 723E                <1> 	JC	short SET_END		; LOOK FOR ERROR
  2008                              <1> 
  2009                              <1> ;-----	CHECK THE RESULTS RETURNED BY THE CONTROLLER
  2010                              <1> 
  2011 00003700 FC                  <1> 	CLD				; SET THE CORRECT DIRECTION
  2012 00003701 BE[31200100]        <1> 	MOV	eSI, NEC_STATUS		; POINT TO STATUS FIELD
  2013 00003706 AC                  <1> 	lodsb				; GET ST0
  2014 00003707 24C0                <1> 	AND	AL,11000000B		; TEST FOR NORMAL TERMINATION
  2015 00003709 7433                <1> 	JZ	short SET_END
  2016 0000370B 3C40                <1> 	CMP	AL,01000000B		; TEST FOR ABNORMAL TERMINATION
  2017 0000370D 7527                <1> 	JNZ	short J18		; NOT ABNORMAL, BAD NEC
  2018                              <1> 
  2019                              <1> ;-----	ABNORMAL TERMINATION, FIND OUT WHY
  2020                              <1> 
  2021 0000370F AC                  <1> 	lodsb				; GET ST1
  2022 00003710 D0E0                <1> 	SAL	AL,1			; TEST FOR EDT FOUND
  2023 00003712 B404                <1> 	MOV	AH,RECORD_NOT_FND
  2024 00003714 7222                <1> 	JC	short J19
  2025 00003716 C0E002              <1> 	SAL	AL,2
  2026 00003719 B410                <1> 	MOV	AH,BAD_CRC
  2027 0000371B 721B                <1> 	JC	short J19
  2028 0000371D D0E0                <1> 	SAL	AL,1			; TEST FOR DMA OVERRUN
  2029 0000371F B408                <1> 	MOV	AH,BAD_DMA
  2030 00003721 7215                <1> 	JC	short J19
  2031 00003723 C0E002              <1> 	SAL	AL,2			; TEST FOR RECORD NOT FOUND
  2032 00003726 B404                <1> 	MOV	AH,RECORD_NOT_FND
  2033 00003728 720E                <1> 	JC	short J19
  2034 0000372A D0E0                <1> 	SAL	AL,1
  2035 0000372C B403                <1> 	MOV	AH,WRITE_PROTECT	; TEST FOR WRITE_PROTECT
  2036 0000372E 7208                <1> 	JC	short J19
  2037 00003730 D0E0                <1> 	SAL	AL,1			; TEST MISSING ADDRESS MARK
  2038 00003732 B402                <1> 	MOV	AH,BAD_ADDR_MARK
  2039 00003734 7202                <1> 	JC	short J19
  2040                              <1> 
  2041                              <1> ;----- 	NEC MUST HAVE FAILED
  2042                              <1> J18:
  2043 00003736 B420                <1> 	MOV	AH,BAD_NEC
  2044                              <1> J19:
  2045 00003738 0825[30200100]      <1> 	OR	[DSKETTE_STATUS], AH
  2046                              <1> SET_END:
  2047 0000373E 803D[30200100]01    <1> 	CMP	byte [DSKETTE_STATUS], 1 ; SET ERROR CONDITION
  2048 00003745 F5                  <1> 	CMC
  2049 00003746 5E                  <1> 	POP	eSI
  2050 00003747 C3                  <1> 	RETn				; RESTORE HEAD #, # OF SECTORS
  2051                              <1> 
  2052                              <1> SET_END_POP:
  2053 00003748 9D                  <1> 	POPF
  2054 00003749 EBF3                <1> 	JMP	SHORT SET_END
  2055                              <1> 
  2056                              <1> ;-------------------------------------------------------------------------------
  2057                              <1> ; DSTATE:	ESTABLISH STATE UPON SUCCESSFUL OPERATION.
  2058                              <1> ;-------------------------------------------------------------------------------
  2059                              <1> DSTATE:
  2060 0000374B 803D[30200100]00    <1> 	CMP	byte [DSKETTE_STATUS],0	; CHECK FOR ERROR
  2061 00003752 753E                <1> 	JNZ	short SETBAC		    ; IF ERROR JUMP
  2062 00003754 808F[3D200100]10    <1> 	OR	byte [DSK_STATE+eDI],MED_DET ; NO ERROR, MARK MEDIA AS DETERMINED
  2063 0000375B F687[3D200100]04    <1> 	TEST	byte [DSK_STATE+eDI],DRV_DET ; DRIVE DETERMINED ?
  2064 00003762 752E                <1> 	JNZ	short SETBAC		; IF DETERMINED NO TRY TO DETERMINE
  2065 00003764 8A87[3D200100]      <1> 	MOV	AL,[DSK_STATE+eDI]	; LOAD STATE
  2066 0000376A 24C0                <1> 	AND	AL,RATE_MSK		; KEEP ONLY RATE
  2067 0000376C 3C80                <1> 	CMP	AL,RATE_250		; RATE 250 ?
  2068 0000376E 751B                <1> 	JNE	short M_12		; NO, MUST BE 1.2M OR 1.44M DRIVE
  2069                              <1> 
  2070                              <1> ;----- 	CHECK IF IT IS 1.44M
  2071                              <1> 
  2072 00003770 E871010000          <1> 	CALL	CMOS_TYPE		; RETURN DRIVE TYPE IN (AL)
  2073                              <1> 	;;20/02/2015
  2074                              <1> 	;;JC	short M_12		; CMOS BAD
  2075 00003775 7414                <1> 	jz	short M_12 ;; 20/02/2015
  2076 00003777 3C04                <1> 	CMP	AL, 4			; 1.44MB DRIVE ?
  2077 00003779 7410                <1> 	JE	short M_12		; YES
  2078                              <1> M_720:
  2079 0000377B 80A7[3D200100]FD    <1> 	AND	byte [DSK_STATE+eDI], ~FMT_CAPA ; TURN OFF FORMAT CAPABILITY
  2080 00003782 808F[3D200100]04    <1> 	OR	byte [DSK_STATE+eDI],DRV_DET  ; MARK DRIVE DETERMINED
  2081 00003789 EB07                <1> 	JMP	SHORT SETBAC		; BACK
  2082                              <1> M_12:	
  2083 0000378B 808F[3D200100]06    <1> 	OR	byte [DSK_STATE+eDI],DRV_DET+FMT_CAPA 
  2084                              <1> 					; TURN ON DETERMINED & FMT CAPA
  2085                              <1> SETBAC:
  2086 00003792 C3                  <1> 	RETn
  2087                              <1> 
  2088                              <1> ;-------------------------------------------------------------------------------
  2089                              <1> ; RETRY	
  2090                              <1> ;	DETERMINES WHETHER A RETRY IS NECESSARY. 
  2091                              <1> ;	IF RETRY IS REQUIRED THEN STATE INFORMATION IS UPDATED FOR RETRY.
  2092                              <1> ;
  2093                              <1> ; ON EXIT:	CY = 1 FOR RETRY, CY = 0 FOR NO RETRY
  2094                              <1> ;-------------------------------------------------------------------------------
  2095                              <1> RETRY:
  2096 00003793 803D[30200100]00    <1> 	CMP	byte [DSKETTE_STATUS],0	; GET STATUS OF OPERATION
  2097 0000379A 7445                <1> 	JZ	short NO_RETRY		; SUCCESSFUL OPERATION
  2098 0000379C 803D[30200100]80    <1> 	CMP	byte [DSKETTE_STATUS],TIME_OUT ; IF TIME OUT NO RETRY
  2099 000037A3 743C                <1> 	JZ	short NO_RETRY
  2100 000037A5 8AA7[3D200100]      <1> 	MOV	AH,[DSK_STATE+eDI]	; GET MEDIA STATE OF DRIVE
  2101 000037AB F6C410              <1> 	TEST	AH,MED_DET		; ESTABLISHED/DETERMINED ?
  2102 000037AE 7531                <1> 	JNZ	short NO_RETRY		; IF ESTABLISHED STATE THEN TRUE ERROR
  2103 000037B0 80E4C0              <1> 	AND	AH,RATE_MSK		; ISOLATE RATE
  2104 000037B3 8A2D[38200100]      <1> 	MOV	CH,[LASTRATE]		; GET START OPERATION STATE
  2105 000037B9 C0C504              <1> 	ROL	CH,4			; TO CORRESPONDING BITS
  2106 000037BC 80E5C0              <1> 	AND	CH,RATE_MSK		; ISOLATE RATE BITS
  2107 000037BF 38E5                <1> 	CMP	CH,AH			; ALL RATES TRIED
  2108 000037C1 741E                <1> 	JE	short NO_RETRY		; IF YES, THEN TRUE ERROR
  2109                              <1> 
  2110                              <1> ;	SETUP STATE INDICATOR FOR RETRY ATTEMPT TO NEXT RATE
  2111                              <1> ;	 00000000B (500) -> 10000000B	(250)
  2112                              <1> ;	 10000000B (250) -> 01000000B	(300)
  2113                              <1> ;	 01000000B (300) -> 00000000B	(500)
  2114                              <1> 
  2115 000037C3 80FC01              <1> 	CMP	AH,RATE_500+1		; SET CY FOR RATE 500
  2116 000037C6 D0DC                <1> 	RCR	AH,1			; TO NEXT STATE
  2117 000037C8 80E4C0              <1> 	AND	AH,RATE_MSK		; KEEP ONLY RATE BITS
  2118 000037CB 80A7[3D200100]1F    <1> 	AND	byte [DSK_STATE+eDI], ~(RATE_MSK+DBL_STEP)
  2119                              <1> 					; RATE, DBL STEP OFF
  2120 000037D2 08A7[3D200100]      <1> 	OR	[DSK_STATE+eDI],AH	; TURN ON NEW RATE
  2121 000037D8 C605[30200100]00    <1> 	MOV	byte [DSKETTE_STATUS],0	; RESET STATUS FOR RETRY
  2122 000037DF F9                  <1> 	STC				; SET CARRY FOR RETRY
  2123 000037E0 C3                  <1> 	RETn				; RETRY RETURN
  2124                              <1> 
  2125                              <1> NO_RETRY:
  2126 000037E1 F8                  <1> 	CLC				; CLEAR CARRY NO RETRY
  2127 000037E2 C3                  <1> 	RETn				; NO RETRY RETURN
  2128                              <1> 
  2129                              <1> ;-------------------------------------------------------------------------------
  2130                              <1> ; NUM_TRANS
  2131                              <1> ;	THIS ROUTINE CALCULATES THE NUMBER OF SECTORS THAT WERE
  2132                              <1> ;	ACTUALLY TRANSFERRED TO/FROM THE DISKETTE.
  2133                              <1> ;
  2134                              <1> ; ON ENTRY:	[BP+1] = TRACK
  2135                              <1> ;		SI-HI  = HEAD
  2136                              <1> ;		[BP]   = START SECTOR
  2137                              <1> ;
  2138                              <1> ; ON EXIT:	AL = NUMBER ACTUALLY TRANSFERRED
  2139                              <1> ;-------------------------------------------------------------------------------
  2140                              <1> NUM_TRANS:
  2141 000037E3 30C0                <1> 	XOR	AL,AL			; CLEAR FOR ERROR
  2142 000037E5 803D[30200100]00    <1> 	CMP	byte [DSKETTE_STATUS],0	; CHECK FOR ERROR
  2143 000037EC 752C                <1> 	JNZ	NT_OUT			; IF ERROR 0 TRANSFERRED
  2144 000037EE B204                <1> 	MOV	DL,4			; SECTORS/TRACK OFFSET TO DL
  2145 000037F0 E8FA000000          <1> 	CALL	GET_PARM		; AH = SECTORS/TRACK
  2146 000037F5 8A1D[36200100]      <1> 	MOV	BL, [NEC_STATUS+5]	; GET ENDING SECTOR
  2147 000037FB 6689F1              <1> 	MOV	CX,SI			; CH = HEAD # STARTED
  2148 000037FE 3A2D[35200100]      <1> 	CMP	CH, [NEC_STATUS+4]	; GET HEAD ENDED UP ON
  2149 00003804 750D                <1> 	JNZ	DIF_HD			; IF ON SAME HEAD, THEN NO ADJUST
  2150 00003806 8A2D[34200100]      <1> 	MOV	CH, [NEC_STATUS+3]	; GET TRACK ENDED UP ON
  2151 0000380C 3A6D01              <1> 	CMP	CH,[eBP+1]		; IS IT ASKED FOR TRACK
  2152 0000380F 7404                <1> 	JZ	short SAME_TRK		; IF SAME TRACK NO INCREASE
  2153 00003811 00E3                <1> 	ADD	BL,AH			; ADD SECTORS/TRACK
  2154                              <1> DIF_HD:
  2155 00003813 00E3                <1> 	ADD	BL,AH			; ADD SECTORS/TRACK
  2156                              <1> SAME_TRK:
  2157 00003815 2A5D00              <1> 	SUB	BL,[eBP]		; SUBTRACT START FROM END
  2158 00003818 88D8                <1> 	MOV	AL,BL			; TO AL
  2159                              <1> NT_OUT:
  2160 0000381A C3                  <1> 	RETn
  2161                              <1> 
  2162                              <1> ;-------------------------------------------------------------------------------
  2163                              <1> ; SETUP_END
  2164                              <1> ;	RESTORES @MOTOR_COUNT TO PARAMETER PROVIDED IN TABLE 
  2165                              <1> ;	AND LOADS @DSKETTE_STATUS TO AH, AND SETS CY.
  2166                              <1> ;
  2167                              <1> ; ON EXIT:
  2168                              <1> ;	AH, @DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
  2169                              <1> ;-------------------------------------------------------------------------------
  2170                              <1> SETUP_END:
  2171 0000381B B202                <1> 	MOV	DL,2			; GET THE MOTOR WAIT PARAMETER
  2172 0000381D 6650                <1> 	PUSH	AX			; SAVE NUMBER TRANSFERRED
  2173 0000381F E8CB000000          <1> 	CALL	GET_PARM
  2174 00003824 8825[2F200100]      <1> 	MOV	[MOTOR_COUNT],AH	; STORE UPON RETURN
  2175 0000382A 6658                <1> 	POP	AX			; RESTORE NUMBER TRANSFERRED
  2176 0000382C 8A25[30200100]      <1> 	MOV	AH, [DSKETTE_STATUS]	; GET STATUS OF OPERATION
  2177 00003832 08E4                <1> 	OR	AH,AH			; CHECK FOR ERROR
  2178 00003834 7402                <1> 	JZ	short NUN_ERR		; NO ERROR
  2179 00003836 30C0                <1> 	XOR	AL,AL			; CLEAR NUMBER RETURNED
  2180                              <1> NUN_ERR: 
  2181 00003838 80FC01              <1> 	CMP	AH,1			; SET THE CARRY FLAG TO INDICATE
  2182 0000383B F5                  <1> 	CMC				; SUCCESS OR FAILURE
  2183 0000383C C3                  <1> 	RETn
  2184                              <1> 
  2185                              <1> ;-------------------------------------------------------------------------------
  2186                              <1> ; SETUP_DBL
  2187                              <1> ;	CHECK DOUBLE STEP.
  2188                              <1> ;
  2189                              <1> ; ON ENTRY :	DI = DRIVE
  2190                              <1> ;
  2191                              <1> ; ON EXIT :	CY = 1 MEANS ERROR
  2192                              <1> ;-------------------------------------------------------------------------------
  2193                              <1> SETUP_DBL:
  2194 0000383D 8AA7[3D200100]      <1> 	MOV	AH, [DSK_STATE+eDI]	; ACCESS STATE
  2195 00003843 F6C410              <1> 	TEST	AH,MED_DET		; ESTABLISHED STATE ?
  2196 00003846 757E                <1> 	JNZ	short NO_DBL			; IF ESTABLISHED THEN DOUBLE DONE
  2197                              <1> 
  2198                              <1> ;-----	CHECK FOR TRACK 0 TO SPEED UP ACKNOWLEDGE OF UNFORMATTED DISKETTE
  2199                              <1> 
  2200 00003848 C605[2D200100]00    <1> 	MOV	byte [SEEK_STATUS],0	; SET RECALIBRATE REQUIRED ON ALL DRIVES
  2201 0000384F E8E0000000          <1> 	CALL	MOTOR_ON		; ENSURE MOTOR STAY ON
  2202 00003854 B500                <1> 	MOV	CH,0			; LOAD TRACK 0
  2203 00003856 E8D4010000          <1> 	CALL	SEEK			; SEEK TO TRACK 0
  2204 0000385B E868000000          <1> 	CALL	READ_ID			; READ ID FUNCTION
  2205 00003860 7249                <1> 	JC	short SD_ERR		; IF ERROR NO TRACK 0
  2206                              <1> 
  2207                              <1> ;-----	INITIALIZE START AND MAX TRACKS (TIMES 2 FOR BOTH HEADS)
  2208                              <1> 
  2209 00003862 66B95004            <1> 	MOV	CX,0450H 		; START, MAX TRACKS
  2210 00003866 F687[3D200100]01    <1> 	TEST	byte [DSK_STATE+eDI],TRK_CAPA ; TEST FOR 80 TRACK CAPABILITY
  2211 0000386D 7402                <1> 	JZ	short CNT_OK		; IF NOT COUNT IS SETUP
  2212 0000386F B1A0                <1> 	MOV	CL,0A0H			; MAXIMUM TRACK 1.2 MB
  2213                              <1> 
  2214                              <1> ;	ATTEMPT READ ID OF ALL TRACKS, ALL HEADS UNTIL SUCCESS; UPON SUCCESS,
  2215                              <1> ;	MUST SEE IF ASKED FOR TRACK IN SINGLE STEP MODE = TRACK ID READ; IF NOT
  2216                              <1> ;	THEN SET DOUBLE STEP ON.
  2217                              <1> 
  2218                              <1> CNT_OK:
  2219 00003871 C605[2F200100]FF    <1>         MOV     byte [MOTOR_COUNT], 0FFH ; ENSURE MOTOR STAYS ON FOR OPERATION 
  2220 00003878 6651                <1> 	PUSH	CX			; SAVE TRACK, COUNT
  2221 0000387A C605[30200100]00    <1> 	MOV	byte [DSKETTE_STATUS],0	; CLEAR STATUS, EXPECT ERRORS
  2222 00003881 6631C0              <1> 	XOR	AX,AX			; CLEAR AX
  2223 00003884 D0ED                <1> 	SHR	CH,1			; HALVE TRACK, CY = HEAD
  2224 00003886 C0D003              <1> 	RCL	AL,3			; AX = HEAD IN CORRECT BIT
  2225 00003889 6650                <1> 	PUSH	AX			; SAVE HEAD
  2226 0000388B E89F010000          <1> 	CALL	SEEK			; SEEK TO TRACK
  2227 00003890 6658                <1> 	POP	AX			; RESTORE HEAD
  2228 00003892 6609C7              <1> 	OR	DI,AX			; DI = HEAD OR'ED DRIVE
  2229 00003895 E82E000000          <1> 	CALL	READ_ID			; READ ID HEAD 0
  2230 0000389A 9C                  <1> 	PUSHF				; SAVE RETURN FROM READ_ID
  2231 0000389B 6681E7FB00          <1> 	AND	DI,11111011B		; TURN OFF HEAD 1 BIT
  2232 000038A0 9D                  <1> 	POPF				; RESTORE ERROR RETURN
  2233 000038A1 6659                <1> 	POP	CX			; RESTORE COUNT
  2234 000038A3 7308                <1> 	JNC	short DO_CHK		; IF OK, ASKED = RETURNED TRACK ?
  2235 000038A5 FEC5                <1> 	INC	CH			; INC FOR NEXT TRACK
  2236 000038A7 38CD                <1> 	CMP	CH,CL			; REACHED MAXIMUM YET
  2237 000038A9 75C6                <1> 	JNZ	short CNT_OK		; CONTINUE TILL ALL TRIED
  2238                              <1> 
  2239                              <1> ;-----	FALL THRU, READ ID FAILED FOR ALL TRACKS
  2240                              <1> 
  2241                              <1> SD_ERR:	
  2242 000038AB F9                  <1> 	STC				; SET CARRY FOR ERROR
  2243 000038AC C3                  <1> 	RETn				; SETUP_DBL ERROR EXIT
  2244                              <1> 
  2245                              <1> DO_CHK:
  2246 000038AD 8A0D[34200100]      <1> 	MOV	CL, [NEC_STATUS+3]	; LOAD RETURNED TRACK
  2247 000038B3 888F[41200100]      <1> 	MOV	[DSK_TRK+eDI], CL	; STORE TRACK NUMBER
  2248 000038B9 D0ED                <1> 	SHR	CH,1			; HALVE TRACK
  2249 000038BB 38CD                <1> 	CMP	CH,CL			; IS IT THE SAME AS ASKED FOR TRACK
  2250 000038BD 7407                <1> 	JZ	short NO_DBL		; IF SAME THEN NO DOUBLE STEP
  2251 000038BF 808F[3D200100]20    <1> 	OR	byte [DSK_STATE+eDI],DBL_STEP ; TURN ON DOUBLE STEP REQUIRED
  2252                              <1> NO_DBL:
  2253 000038C6 F8                  <1> 	CLC				; CLEAR ERROR FLAG
  2254 000038C7 C3                  <1> 	RETn
  2255                              <1> 
  2256                              <1> ;-------------------------------------------------------------------------------
  2257                              <1> ; READ_ID
  2258                              <1> ;	READ ID FUNCTION.
  2259                              <1> ;
  2260                              <1> ; ON ENTRY:	DI : BIT 2 = HEAD; BITS 1,0 = DRIVE
  2261                              <1> ;
  2262                              <1> ; ON EXIT: 	DI : BIT 2 IS RESET, BITS 1,0 = DRIVE
  2263                              <1> ;		@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
  2264                              <1> ;-------------------------------------------------------------------------------
  2265                              <1> READ_ID:
  2266 000038C8 B8[E5380000]        <1> 	MOV	eAX, ER_3		; MOVE NEC OUTPUT ERROR ADDRESS
  2267 000038CD 50                  <1> 	PUSH	eAX
  2268 000038CE B44A                <1> 	MOV	AH,4AH			; READ ID COMMAND
  2269 000038D0 E820010000          <1> 	CALL	NEC_OUTPUT		; TO CONTROLLER
  2270 000038D5 6689F8              <1> 	MOV	AX,DI			; DRIVE # TO AH, HEAD 0
  2271 000038D8 88C4                <1> 	MOV	AH,AL
  2272 000038DA E816010000          <1> 	CALL	NEC_OUTPUT		; TO CONTROLLER
  2273 000038DF E80BFEFFFF          <1> 	CALL	NEC_TERM		; WAIT FOR OPERATION, GET STATUS
  2274 000038E4 58                  <1> 	POP	eAX			; THROW AWAY ERROR ADDRESS
  2275                              <1> ER_3:
  2276 000038E5 C3                  <1> 	RETn
  2277                              <1> 
  2278                              <1> ;-------------------------------------------------------------------------------
  2279                              <1> ; CMOS_TYPE
  2280                              <1> ;	RETURNS DISKETTE TYPE FROM CMOS
  2281                              <1> ;
  2282                              <1> ; ON ENTRY:	DI = DRIVE #
  2283                              <1> ;
  2284                              <1> ; ON EXIT:	AL = TYPE; CY REFLECTS STATUS
  2285                              <1> ;-------------------------------------------------------------------------------
  2286                              <1> 
  2287                              <1> CMOS_TYPE: ; 11/12/2014
  2288 000038E6 8A87[F8EC0000]      <1> mov	al, [eDI+fd0_type]
  2289 000038EC 20C0                <1> and 	al, al ; 18/12/2014
  2290 000038EE C3                  <1> retn
  2291                              <1> 
  2292                              <1> ;CMOS_TYPE:
  2293                              <1> ;	MOV	AL, CMOS_DIAG		; CMOS DIAGNOSTIC STATUS BYTE ADDRESS
  2294                              <1> ;	CALL	CMOS_READ		; GET CMOS STATUS
  2295                              <1> ;	TEST	AL,BAD_BAT+BAD_CKSUM	; BATTERY GOOD AND CHECKSUM VALID
  2296                              <1> ;	STC				; SET CY = 1 INDICATING ERROR FOR RETURN
  2297                              <1> ;	JNZ	short BAD_CM		; ERROR IF EITHER BIT ON
  2298                              <1> ;	MOV	AL,CMOS_DISKETTE	; ADDRESS OF DISKETTE BYTE IN CMOS
  2299                              <1> ;	CALL	CMOS_READ		; GET DISKETTE BYTE
  2300                              <1> ;	OR	DI,DI			; SEE WHICH DRIVE IN QUESTION
  2301                              <1> ;	JNZ	short TB		; IF DRIVE 1, DATA IN LOW NIBBLE
  2302                              <1> ;	ROR	AL,4			; EXCHANGE NIBBLES IF SECOND DRIVE
  2303                              <1> ;TB:
  2304                              <1> ;	AND	AL,0FH			; KEEP ONLY DRIVE DATA, RESET CY, 0
  2305                              <1> ;BAD_CM:
  2306                              <1> ;	RETn				; CY, STATUS OF READ
  2307                              <1> 
  2308                              <1> ;-------------------------------------------------------------------------------
  2309                              <1> ; GET_PARM
  2310                              <1> ;	THIS ROUTINE FETCHES THE INDEXED POINTER FROM THE DISK_BASE
  2311                              <1> ;	BLOCK POINTED TO BY THE DATA VARIABLE @DISK_POINTER. A BYTE FROM
  2312                              <1> ;	THAT TABLE IS THEN MOVED INTO AH, THE INDEX OF THAT BYTE BEING
  2313                              <1> ;	THE PARAMETER IN DL.
  2314                              <1> ;
  2315                              <1> ; ON ENTRY:	DL = INDEX OF BYTE TO BE FETCHED
  2316                              <1> ;
  2317                              <1> ; ON EXIT:	AH = THAT BYTE FROM BLOCK
  2318                              <1> ;		AL,DH DESTROYED
  2319                              <1> ;-------------------------------------------------------------------------------
  2320                              <1> GET_PARM:
  2321                              <1> 	;PUSH	DS
  2322 000038EF 56                  <1> 	PUSH	eSI
  2323                              <1>     	;SUB	AX,AX			; DS = 0, BIOS DATA AREA
  2324                              <1>     	;MOV	DS,AX
  2325                              <1> 	;;mov	ax, cs
  2326                              <1> 	;;mov	ds, ax
  2327                              <1> 	; 08/02/2015 (protected mode modifications, bx -> ebx)
  2328 000038F0 87D3                <1> 	XCHG	eDX,eBX			; BL = INDEX
  2329                              <1> 	;SUB	BH,BH			; BX = INDEX
  2330 000038F2 81E3FF000000        <1> 	and	ebx, 0FFh
  2331                              <1>     	;LDS	SI, [DISK_POINTER]	; POINT TO BLOCK
  2332                              <1> 	;
  2333                              <1> 	; 17/12/2014
  2334 000038F8 66A1[EBEC0000]      <1> 	mov	ax, [cfd] ; current (AL) and previous fd (AH)
  2335 000038FE 38E0                <1> 	cmp	al, ah
  2336 00003900 7425                <1> 	je	short gpndc
  2337 00003902 A2[ECEC0000]        <1> 	mov	[pfd], al ; current drive -> previous drive
  2338 00003907 53                  <1> 	push	ebx ; 08/02/2015
  2339 00003908 88C3                <1> 	mov	bl, al 
  2340                              <1> 	; 11/12/2014
  2341 0000390A 8A83[F8EC0000]      <1> 	mov	al, [eBX+fd0_type]	; Drive type (0,1,2,3,4)
  2342                              <1> 	; 18/12/2014
  2343 00003910 20C0                <1> 	and	al, al
  2344 00003912 7507                <1> 	jnz	short gpdtc
  2345 00003914 BB[D5EC0000]        <1> 	mov	ebx, MD_TBL6		; 1.44 MB param. tbl. (default)
  2346 00003919 EB05                <1>         jmp     short gpdpu
  2347                              <1> gpdtc:	
  2348 0000391B E817F9FFFF          <1> 	call	DR_TYPE_CHECK
  2349                              <1> 	; cf = 1 -> eBX points to 1.44MB fd parameter table (default)
  2350                              <1> gpdpu:
  2351 00003920 891D[72EC0000]      <1> 	mov	[DISK_POINTER], ebx
  2352 00003926 5B                  <1> 	pop	ebx
  2353                              <1> gpndc:
  2354 00003927 8B35[72EC0000]      <1> 	mov	esi, [DISK_POINTER] ; 08/02/2015, si -> esi
  2355 0000392D 8A241E              <1> 	MOV	AH, [eSI+eBX]		; GET THE WORD
  2356 00003930 87D3                <1> 	XCHG	eDX,eBX			; RESTORE BX
  2357 00003932 5E                  <1> 	POP	eSI
  2358                              <1> 	;POP	DS
  2359 00003933 C3                  <1> 	RETn
  2360                              <1> 
  2361                              <1> ;-------------------------------------------------------------------------------
  2362                              <1> ; MOTOR_ON
  2363                              <1> ;	TURN MOTOR ON AND WAIT FOR MOTOR START UP TIME. THE @MOTOR_COUNT
  2364                              <1> ;	IS REPLACED WITH A SUFFICIENTLY HIGH NUMBER (0FFH) TO ENSURE
  2365                              <1> ;	THAT THE MOTOR DOES NOT GO OFF DURING THE OPERATION. IF THE
  2366                              <1> ;	MOTOR NEEDED TO BE TURNED ON, THE MULTI-TASKING HOOK FUNCTION
  2367                              <1> ;	(AX=90FDH, INT 15) IS CALLED TELLING THE OPERATING SYSTEM
  2368                              <1> ;	THAT THE BIOS IS ABOUT TO WAIT FOR MOTOR START UP. IF THIS
  2369                              <1> ;	FUNCTION RETURNS WITH CY = 1, IT MEANS THAT THE MINIMUM WAIT
  2370                              <1> ;	HAS BEEN COMPLETED. AT THIS POINT A CHECK IS MADE TO ENSURE
  2371                              <1> ;	THAT THE MOTOR WASN'T TURNED OFF BY THE TIMER. IF THE HOOK DID
  2372                              <1> ;	NOT WAIT, THE WAIT FUNCTION (AH=086H) IS CALLED TO WAIT THE
  2373                              <1> ;	PRESCRIBED AMOUNT OF TIME. IF THE CARRY FLAG IS SET ON RETURN,
  2374                              <1> ;	IT MEANS THAT THE FUNCTION IS IN USE AND DID NOT PERFORM THE
  2375                              <1> ;	WAIT. A TIMER 1 WAIT LOOP WILL THEN DO THE WAIT.
  2376                              <1> ;
  2377                              <1> ; ON ENTRY:	DI = DRIVE #
  2378                              <1> ; ON EXIT:	AX,CX,DX DESTROYED
  2379                              <1> ;-------------------------------------------------------------------------------
  2380                              <1> MOTOR_ON:
  2381 00003934 53                  <1> 	PUSH	eBX			; SAVE REG.
  2382 00003935 E82A000000          <1> 	CALL	TURN_ON			; TURN ON MOTOR
  2383 0000393A 7226                <1> 	JC	short MOT_IS_ON		; IF CY=1 NO WAIT
  2384 0000393C E89BF9FFFF          <1> 	CALL	XLAT_OLD		; TRANSLATE STATE TO COMPATIBLE MODE
  2385 00003941 E865F9FFFF          <1> 	CALL	XLAT_NEW		; TRANSLATE STATE TO PRESENT ARCH,
  2386                              <1> 	;CALL	TURN_ON 		; CHECK AGAIN IF MOTOR ON
  2387                              <1> 	;JC	MOT_IS_ON		; IF NO WAIT MEANS IT IS ON
  2388                              <1> M_WAIT:
  2389 00003946 B20A                <1> 	MOV	DL,10			; GET THE MOTOR WAIT PARAMETER
  2390 00003948 E8A2FFFFFF          <1> 	CALL	GET_PARM
  2391                              <1> 	;MOV	AL,AH			; AL = MOTOR WAIT PARAMETER
  2392                              <1> 	;XOR	AH,AH			; AX = MOTOR WAIT PARAMETER
  2393                              <1> 	;CMP	AL,8			; SEE IF AT LEAST A SECOND IS SPECIFIED
  2394 0000394D 80FC08              <1> 	cmp	ah, 8
  2395                              <1> 	;JAE	short GP2		; IF YES, CONTINUE
  2396 00003950 7702                <1> 	ja	short J13
  2397                              <1> 	;MOV	AL,8			; ONE SECOND WAIT FOR MOTOR START UP
  2398 00003952 B408                <1> 	mov	ah, 8
  2399                              <1> 
  2400                              <1> ;-----	AS CONTAINS NUMBER OF 1/8 SECONDS (125000 MICROSECONDS) TO WAIT
  2401                              <1> GP2:	
  2402                              <1> ;----- 	FOLLOWING LOOPS REQUIRED WHEN RTC WAIT FUNCTION IS ALREADY IN USE
  2403                              <1> J13:					; WAIT FOR 1/8 SECOND PER (AL)
  2404 00003954 B95E200000          <1> 	MOV	eCX,8286		; COUNT FOR 1/8 SECOND AT 15.085737 US
  2405 00003959 E8F9E2FFFF          <1> 	CALL	WAITF			; GO TO FIXED WAIT ROUTINE
  2406                              <1> 	;DEC	AL			; DECREMENT TIME VALUE
  2407 0000395E FECC                <1> 	dec	ah
  2408 00003960 75F2                <1> 	JNZ	short J13		; ARE WE DONE YET
  2409                              <1> MOT_IS_ON:
  2410 00003962 5B                  <1> 	POP	eBX			; RESTORE REG.
  2411 00003963 C3                  <1> 	RETn
  2412                              <1> 
  2413                              <1> ;-------------------------------------------------------------------------------
  2414                              <1> ; TURN_ON
  2415                              <1> ;	TURN MOTOR ON AND RETURN WAIT STATE.
  2416                              <1> ;
  2417                              <1> ; ON ENTRY:	DI = DRIVE #
  2418                              <1> ;
  2419                              <1> ; ON EXIT:	CY = 0 MEANS WAIT REQUIRED
  2420                              <1> ;		CY = 1 MEANS NO WAIT REQUIRED
  2421                              <1> ;		AX,BX,CX,DX DESTROYED
  2422                              <1> ;-------------------------------------------------------------------------------
  2423                              <1> TURN_ON:
  2424 00003964 89FB                <1> 	MOV	eBX,eDI			; BX = DRIVE #
  2425 00003966 88D9                <1> 	MOV	CL,BL			; CL = DRIVE #
  2426 00003968 C0C304              <1> 	ROL	BL,4			; BL = DRIVE SELECT
  2427 0000396B FA                  <1> 	CLI				; NO INTERRUPTS WHILE DETERMINING STATUS
  2428 0000396C C605[2F200100]FF    <1> 	MOV	byte [MOTOR_COUNT],0FFH	; ENSURE MOTOR STAYS ON FOR OPERATION
  2429 00003973 A0[2E200100]        <1> 	MOV	AL, [MOTOR_STATUS]	; GET DIGITAL OUTPUT REGISTER REFLECTION
  2430 00003978 2430                <1> 	AND	AL,00110000B		; KEEP ONLY DRIVE SELECT BITS
  2431 0000397A B401                <1> 	MOV	AH,1			; MASK FOR DETERMINING MOTOR BIT
  2432 0000397C D2E4                <1> 	SHL	AH,CL			; AH = MOTOR ON, A=00000001, B=00000010
  2433                              <1> 
  2434                              <1> ;  AL = DRIVE SELECT FROM @MOTOR_STATUS
  2435                              <1> ;  BL = DRIVE SELECT DESIRED
  2436                              <1> ;  AH = MOTOR ON MASK DESIRED
  2437                              <1> 
  2438 0000397E 38D8                <1> 	CMP	AL,BL			; REQUESTED DRIVE ALREADY SELECTED ?
  2439 00003980 7508                <1> 	JNZ	short TURN_IT_ON	; IF NOT SELECTED JUMP
  2440 00003982 8425[2E200100]      <1> 	TEST	AH, [MOTOR_STATUS]	; TEST MOTOR ON BIT
  2441 00003988 7535                <1> 	JNZ	short NO_MOT_WAIT	; JUMP IF MOTOR ON AND SELECTED
  2442                              <1> 
  2443                              <1> TURN_IT_ON:
  2444 0000398A 08DC                <1> 	OR	AH,BL			; AH = DRIVE SELECT AND MOTOR ON
  2445 0000398C 8A3D[2E200100]      <1> 	MOV	BH,[MOTOR_STATUS]	; SAVE COPY OF @MOTOR_STATUS BEFORE
  2446 00003992 80E70F              <1> 	AND	BH,00001111B		; KEEP ONLY MOTOR BITS
  2447 00003995 8025[2E200100]CF    <1> 	AND	byte [MOTOR_STATUS],11001111B ; CLEAR OUT DRIVE SELECT
  2448 0000399C 0825[2E200100]      <1> 	OR	[MOTOR_STATUS],AH	; OR IN DRIVE SELECTED AND MOTOR ON
  2449 000039A2 A0[2E200100]        <1> 	MOV	AL,[MOTOR_STATUS]	; GET DIGITAL OUTPUT REGISTER REFLECTION
  2450 000039A7 88C3                <1> 	MOV	BL,AL			; BL=@MOTOR_STATUS AFTER, BH=BEFORE
  2451 000039A9 80E30F              <1> 	AND	BL,00001111B		; KEEP ONLY MOTOR BITS
  2452 000039AC FB                  <1> 	STI				; ENABLE INTERRUPTS AGAIN
  2453 000039AD 243F                <1> 	AND	AL,00111111B		; STRIP AWAY UNWANTED BITS
  2454 000039AF C0C004              <1> 	ROL	AL,4			; PUT BITS IN DESIRED POSITIONS
  2455 000039B2 0C0C                <1> 	OR	AL,00001100B		; NO RESET, ENABLE DMA/INTERRUPT
  2456 000039B4 66BAF203            <1> 	MOV	DX,03F2H		; SELECT DRIVE AND TURN ON MOTOR
  2457 000039B8 EE                  <1> 	OUT	DX,AL
  2458 000039B9 38FB                <1> 	CMP	BL,BH			; NEW MOTOR TURNED ON ?
  2459                              <1> 	;JZ	short NO_MOT_WAIT	; NO WAIT REQUIRED IF JUST SELECT
  2460 000039BB 7403                <1> 	je	short no_mot_w1 ; 27/02/2015 
  2461 000039BD F8                  <1> 	CLC				; (re)SET CARRY MEANING WAIT
  2462 000039BE C3                  <1> 	RETn
  2463                              <1> 
  2464                              <1> NO_MOT_WAIT:
  2465 000039BF FB                  <1> 	sti
  2466                              <1> no_mot_w1: ; 27/02/2015
  2467 000039C0 F9                  <1> 	STC				; SET NO WAIT REQUIRED
  2468                              <1> 	;STI				; INTERRUPTS BACK ON
  2469 000039C1 C3                  <1> 	RETn
  2470                              <1> 
  2471                              <1> ;-------------------------------------------------------------------------------
  2472                              <1> ; HD_WAIT
  2473                              <1> ;	WAIT FOR HEAD SETTLE TIME.
  2474                              <1> ;
  2475                              <1> ; ON ENTRY:	DI = DRIVE #
  2476                              <1> ;
  2477                              <1> ; ON EXIT:	AX,BX,CX,DX DESTROYED
  2478                              <1> ;-------------------------------------------------------------------------------
  2479                              <1> HD_WAIT:
  2480 000039C2 B209                <1> 	MOV	DL,9			; GET HEAD SETTLE PARAMETER
  2481 000039C4 E826FFFFFF          <1> 	CALL	GET_PARM
  2482 000039C9 08E4                <1> 	or	ah, ah	; 17/12/2014
  2483 000039CB 7519                <1> 	jnz	short DO_WAT
  2484 000039CD F605[2E200100]80    <1>         TEST    byte [MOTOR_STATUS],10000000B ; SEE IF A WRITE OPERATION
  2485                              <1> 	;JZ	short ISNT_WRITE	; IF NOT, DO NOT ENFORCE ANY VALUES
  2486                              <1> 	;OR	AH,AH			; CHECK FOR ANY WAIT?
  2487                              <1> 	;JNZ	short DO_WAT		; IF THERE DO NOT ENFORCE
  2488 000039D4 741E                <1> 	jz	short HW_DONE
  2489 000039D6 B40F                <1> 	MOV	AH,HD12_SETTLE		; LOAD 1.2M HEAD SETTLE MINIMUM
  2490 000039D8 8A87[3D200100]      <1> 	MOV	AL,[DSK_STATE+eDI]	; LOAD STATE
  2491 000039DE 24C0                <1> 	AND	AL,RATE_MSK		; KEEP ONLY RATE
  2492 000039E0 3C80                <1> 	CMP	AL,RATE_250		; 1.2 M DRIVE ?
  2493 000039E2 7502                <1> 	JNZ	short DO_WAT		; DEFAULT HEAD SETTLE LOADED
  2494                              <1> ;GP3:
  2495 000039E4 B414                <1> 	MOV	AH,HD320_SETTLE		; USE 320/360 HEAD SETTLE
  2496                              <1> ;	JMP	SHORT DO_WAT
  2497                              <1> 
  2498                              <1> ;ISNT_WRITE:
  2499                              <1> ;	OR	AH,AH			; CHECK FOR NO WAIT
  2500                              <1> ;	JZ	short HW_DONE		; IF NOT WRITE AND 0 ITS OK
  2501                              <1> 
  2502                              <1> ;-----	AH CONTAINS NUMBER OF MILLISECONDS TO WAIT
  2503                              <1> DO_WAT:
  2504                              <1> ;	MOV	AL,AH			; AL = # MILLISECONDS
  2505                              <1> ;	;XOR	AH,AH			; AX = # MILLISECONDS
  2506                              <1> J29:					; 	1 MILLISECOND LOOP
  2507                              <1> 	;mov	cx, WAIT_FDU_HEAD_SETTLE ; 33 ; 1 ms in 30 micro units.
  2508 000039E6 B942000000          <1> 	MOV	eCX,66			; COUNT AT 15.085737 US PER COUNT
  2509 000039EB E867E2FFFF          <1> 	CALL	WAITF			; DELAY FOR 1 MILLISECOND
  2510                              <1> 	;DEC	AL			; DECREMENT THE COUNT
  2511 000039F0 FECC                <1> 	dec	ah
  2512 000039F2 75F2                <1> 	JNZ	short J29		; DO AL MILLISECOND # OF TIMES
  2513                              <1> HW_DONE:
  2514 000039F4 C3                  <1> 	RETn
  2515                              <1> 
  2516                              <1> ;-------------------------------------------------------------------------------
  2517                              <1> ; NEC_OUTPUT
  2518                              <1> ;	THIS ROUTINE SENDS A BYTE TO THE NEC CONTROLLER AFTER TESTING
  2519                              <1> ;	FOR CORRECT DIRECTION AND CONTROLLER READY THIS ROUTINE WILL
  2520                              <1> ;	TIME OUT IF THE BYTE IS NOT ACCEPTED WITHIN A REASONABLE AMOUNT
  2521                              <1> ;	OF TIME, SETTING THE DISKETTE STATUS ON COMPLETION.
  2522                              <1> ; 
  2523                              <1> ; ON ENTRY: 	AH = BYTE TO BE OUTPUT
  2524                              <1> ;
  2525                              <1> ; ON EXIT:	CY = 0  SUCCESS
  2526                              <1> ;		CY = 1  FAILURE -- DISKETTE STATUS UPDATED
  2527                              <1> ;		        IF A FAILURE HAS OCCURRED, THE RETURN IS MADE ONE LEVEL
  2528                              <1> ;		        HIGHER THAN THE CALLER OF NEC OUTPUT. THIS REMOVES THE
  2529                              <1> ;		        REQUIREMENT OF TESTING AFTER EVERY CALL OF NEC_OUTPUT.
  2530                              <1> ;		AX,CX,DX DESTROYED
  2531                              <1> ;-------------------------------------------------------------------------------
  2532                              <1> 
  2533                              <1> ; 09/12/2014 [Erdogan Tan] 
  2534                              <1> ;	(from 'PS2 Hardware Interface Tech. Ref. May 88', Page 09-05.)
  2535                              <1> ; Diskette Drive Controller Status Register (3F4h)
  2536                              <1> ;	This read only register facilitates the transfer of data between
  2537                              <1> ;	the system microprocessor and the controller.
  2538                              <1> ; Bit 7 - When set to 1, the Data register is ready to transfer data 
  2539                              <1> ;	  with the system micrprocessor.
  2540                              <1> ; Bit 6 - The direction of data transfer. If this bit is set to 0,
  2541                              <1> ;	  the transfer is to the controller.
  2542                              <1> ; Bit 5 - When this bit is set to 1, the controller is in the non-DMA mode.
  2543                              <1> ; Bit 4 - When this bit is set to 1, a Read or Write command is being executed.
  2544                              <1> ; Bit 3 - Reserved.
  2545                              <1> ; Bit 2 - Reserved.
  2546                              <1> ; Bit 1 - When this bit is set to 1, dskette drive 1 is in the seek mode.
  2547                              <1> ; Bit 0 - When this bit is set to 1, dskette drive 1 is in the seek mode.
  2548                              <1> 
  2549                              <1> ; Data Register (3F5h)
  2550                              <1> ; This read/write register passes data, commands and parameters, and provides
  2551                              <1> ; diskette status information.
  2552                              <1>   		
  2553                              <1> NEC_OUTPUT:
  2554                              <1> 	;PUSH	BX			; SAVE REG.
  2555 000039F5 66BAF403            <1> 	MOV	DX,03F4H		; STATUS PORT
  2556                              <1> 	;MOV	BL,2			; HIGH ORDER COUNTER
  2557                              <1> 	;XOR	CX,CX			; COUNT FOR TIME OUT
  2558                              <1> 	; 16/12/2014
  2559                              <1> 	; waiting for (max.) 0.5 seconds
  2560                              <1>         ;;mov     byte [wait_count], 0 ;; 27/02/2015
  2561                              <1> 	;
  2562                              <1> 	; 17/12/2014
  2563                              <1> 	; Modified from AWARD BIOS 1999 - ADISK.ASM - SEND_COMMAND
  2564                              <1> 	;
  2565                              <1> 	;WAIT_FOR_PORT:	Waits for a bit at a port pointed to by DX to
  2566                              <1> 	;		go on.
  2567                              <1> 	;INPUT:
  2568                              <1> 	;	AH=Mask for isolation bits.
  2569                              <1> 	;	AL=pattern to look for.
  2570                              <1> 	;	DX=Port to test for
  2571                              <1> 	;	BH:CX=Number of memory refresh periods to delay.
  2572                              <1> 	;	     (normally 30 microseconds per period.)
  2573                              <1> 	;
  2574                              <1> 	;WFP_SHORT:  
  2575                              <1> 	;	Wait for port if refresh cycle is short (15-80 Us range).
  2576                              <1> 	;
  2577                              <1> 
  2578                              <1> ;	mov	bl, WAIT_FDU_SEND_HI+1	; 0+1
  2579                              <1> ;	mov	cx, WAIT_FDU_SEND_LO	; 16667
  2580 000039F9 B91B410000          <1> 	mov	ecx, WAIT_FDU_SEND_LH   ; 16667 (27/02/2015)
  2581                              <1> ;
  2582                              <1> ;WFPS_OUTER_LP:
  2583                              <1> ;	;
  2584                              <1> ;WFPS_CHECK_PORT:
  2585                              <1> J23:
  2586 000039FE EC                  <1> 	IN	AL,DX			; GET STATUS
  2587 000039FF 24C0                <1> 	AND	AL,11000000B		; KEEP STATUS AND DIRECTION
  2588 00003A01 3C80                <1> 	CMP	AL,10000000B		; STATUS 1 AND DIRECTION 0 ?
  2589 00003A03 7418                <1> 	JZ	short J27		; STATUS AND DIRECTION OK
  2590                              <1> WFPS_HI:
  2591 00003A05 E461                <1> 	IN	AL, PORT_B	;061h	; SYS1	; wait for hi to lo
  2592 00003A07 A810                <1> 	TEST	AL,010H			; transition on memory
  2593 00003A09 75FA                <1> 	JNZ	SHORT WFPS_HI		; refresh.
  2594                              <1> WFPS_LO:
  2595 00003A0B E461                <1> 	IN	AL, PORT_B		; SYS1
  2596 00003A0D A810                <1> 	TEST	AL,010H
  2597 00003A0F 74FA                <1> 	JZ	SHORT WFPS_LO
  2598                              <1> 	;LOOP	SHORT WFPS_CHECK_PORT
  2599 00003A11 E2EB                <1> 	loop	J23	; 27/02/2015
  2600                              <1> ;	;
  2601                              <1> ;	dec	bl
  2602                              <1> ;	jnz	short WFPS_OUTER_LP
  2603                              <1> ;	jmp	short WFPS_TIMEOUT	; fail
  2604                              <1> ;J23:
  2605                              <1> ;	IN	AL,DX			; GET STATUS
  2606                              <1> ;	AND	AL,11000000B		; KEEP STATUS AND DIRECTION
  2607                              <1> ;	CMP	AL,10000000B		; STATUS 1 AND DIRECTION 0 ?
  2608                              <1> ;	JZ	short J27		; STATUS AND DIRECTION OK
  2609                              <1> 	;LOOP	J23			; CONTINUE TILL CX EXHAUSTED
  2610                              <1> 	;DEC	BL			; DECREMENT COUNTER
  2611                              <1> 	;JNZ	short J23		; REPEAT TILL DELAY FINISHED, CX = 0
  2612                              <1>    
  2613                              <1> 	;;27/02/2015
  2614                              <1> 	;16/12/2014
  2615                              <1>         ;;cmp     byte [wait_count], 10   ; (10/18.2 seconds)
  2616                              <1> 	;;jb	short J23
  2617                              <1> 
  2618                              <1> ;WFPS_TIMEOUT:
  2619                              <1> 
  2620                              <1> ;-----	FALL THRU TO ERROR RETURN
  2621                              <1> 
  2622 00003A13 800D[30200100]80    <1> 	OR	byte [DSKETTE_STATUS],TIME_OUT
  2623                              <1> 	;POP	BX			; RESTORE REG.
  2624 00003A1A 58                  <1> 	POP	eAX ; 08/02/2015	; DISCARD THE RETURN ADDRESS
  2625 00003A1B F9                  <1> 	STC				; INDICATE ERROR TO CALLER
  2626 00003A1C C3                  <1> 	RETn
  2627                              <1> 
  2628                              <1> ;-----	DIRECTION AND STATUS OK; OUTPUT BYTE
  2629                              <1> 
  2630                              <1> J27:	
  2631 00003A1D 88E0                <1> 	MOV	AL,AH			; GET BYTE TO OUTPUT
  2632 00003A1F 6642                <1> 	INC	DX			; DATA PORT = STATUS PORT + 1
  2633 00003A21 EE                  <1> 	OUT	DX,AL			; OUTPUT THE BYTE
  2634                              <1> 	;;NEWIODELAY  ;; 27/02/2015
  2635                              <1> 	; 27/02/2015
  2636 00003A22 9C                  <1> 	PUSHF				; SAVE FLAGS
  2637 00003A23 B903000000          <1> 	MOV	eCX, 3			; 30 TO 45 MICROSECONDS WAIT FOR
  2638 00003A28 E82AE2FFFF          <1> 	CALL 	WAITF			; NEC FLAGS UPDATE CYCLE
  2639 00003A2D 9D                  <1> 	POPF				; RESTORE FLAGS FOR EXIT
  2640                              <1> 	;POP	BX			; RESTORE REG
  2641 00003A2E C3                  <1> 	RETn				; CY = 0 FROM TEST INSTRUCTION
  2642                              <1> 
  2643                              <1> ;-------------------------------------------------------------------------------
  2644                              <1> ; SEEK
  2645                              <1> ;	THIS ROUTINE WILL MOVE THE HEAD ON THE NAMED DRIVE TO THE NAMED
  2646                              <1> ;	TRACK. IF THE DRIVE HAS NOT BEEN ACCESSED SINCE THE DRIVE
  2647                              <1> ;	RESET COMMAND WAS ISSUED, THE DRIVE WILL BE RECALIBRATED.
  2648                              <1> ;
  2649                              <1> ; ON ENTRY:	DI = DRIVE #
  2650                              <1> ;		CH = TRACK #
  2651                              <1> ;
  2652                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION.
  2653                              <1> ;		AX,BX,CX DX DESTROYED
  2654                              <1> ;-------------------------------------------------------------------------------
  2655                              <1> SEEK:
  2656 00003A2F 89FB                <1> 	MOV	eBX,eDI			; BX = DRIVE #
  2657 00003A31 B001                <1> 	MOV	AL,1			; ESTABLISH MASK FOR RECALIBRATE TEST
  2658 00003A33 86CB                <1> 	XCHG	CL,BL			; SET DRIVE VALULE INTO CL
  2659 00003A35 D2C0                <1> 	ROL	AL,CL			; SHIFT MASK BY THE DRIVE VALUE
  2660 00003A37 86CB                <1> 	XCHG	CL,BL			; RECOVER TRACK VALUE
  2661 00003A39 8405[2D200100]      <1> 	TEST	AL,[SEEK_STATUS]	; TEST FOR RECALIBRATE REQUIRED
  2662 00003A3F 7526                <1> 	JNZ	short J28A		; JUMP IF RECALIBRATE NOT REQUIRED
  2663                              <1> 
  2664 00003A41 0805[2D200100]      <1> 	OR	[SEEK_STATUS],AL	; TURN ON THE NO RECALIBRATE BIT IN FLAG
  2665 00003A47 E862000000          <1> 	CALL	RECAL			; RECALIBRATE DRIVE
  2666 00003A4C 730E                <1> 	JNC	short AFT_RECAL		; RECALIBRATE DONE
  2667                              <1> 
  2668                              <1> ;-----	ISSUE RECALIBRATE FOR 80 TRACK DISKETTES
  2669                              <1> 
  2670 00003A4E C605[30200100]00    <1> 	MOV	byte [DSKETTE_STATUS],0	; CLEAR OUT INVALID STATUS
  2671 00003A55 E854000000          <1> 	CALL	RECAL			; RECALIBRATE DRIVE
  2672 00003A5A 7251                <1> 	JC	short RB		; IF RECALIBRATE FAILS TWICE THEN ERROR
  2673                              <1> 
  2674                              <1> AFT_RECAL:
  2675 00003A5C C687[41200100]00    <1>         MOV     byte [DSK_TRK+eDI],0    ; SAVE NEW CYLINDER AS PRESENT POSITION
  2676 00003A63 08ED                <1> 	OR	CH,CH			; CHECK FOR SEEK TO TRACK 0
  2677 00003A65 743F                <1> 	JZ	short DO_WAIT		; HEAD SETTLE, CY = 0 IF JUMP
  2678                              <1> 
  2679                              <1> ;-----	DRIVE IS IN SYNCHRONIZATION WITH CONTROLLER, SEEK TO TRACK
  2680                              <1> 
  2681 00003A67 F687[3D200100]20    <1> J28A:	TEST	byte [DSK_STATE+eDI],DBL_STEP ; CHECK FOR DOUBLE STEP REQUIRED
  2682 00003A6E 7402                <1> 	JZ	short _R7		; SINGLE STEP REQUIRED BYPASS DOUBLE
  2683 00003A70 D0E5                <1> 	SHL	CH,1			; DOUBLE NUMBER OF STEP TO TAKE
  2684                              <1> 
  2685 00003A72 3AAF[41200100]      <1> _R7:	CMP	CH, [DSK_TRK+eDI]	; SEE IF ALREADY AT THE DESIRED TRACK
  2686 00003A78 7433                <1> 	JE	short RB		; IF YES, DO NOT NEED TO SEEK
  2687                              <1> 
  2688 00003A7A BA[AD3A0000]        <1> 	MOV	eDX, NEC_ERR		; LOAD RETURN ADDRESS
  2689 00003A7F 52                  <1> 	PUSH	eDX ; (*)		; ON STACK FOR NEC OUTPUT ERROR
  2690 00003A80 88AF[41200100]      <1> 	MOV	[DSK_TRK+eDI],CH	; SAVE NEW CYLINDER AS PRESENT POSITION
  2691 00003A86 B40F                <1> 	MOV	AH,0FH			; SEEK COMMAND TO NEC
  2692 00003A88 E868FFFFFF          <1> 	CALL	NEC_OUTPUT
  2693 00003A8D 89FB                <1> 	MOV	eBX,eDI			; BX = DRIVE #
  2694 00003A8F 88DC                <1> 	MOV	AH,BL			; OUTPUT DRIVE NUMBER
  2695 00003A91 E85FFFFFFF          <1> 	CALL	NEC_OUTPUT
  2696 00003A96 8AA7[41200100]      <1> 	MOV	AH, [DSK_TRK+eDI]	; GET CYLINDER NUMBER
  2697 00003A9C E854FFFFFF          <1> 	CALL	NEC_OUTPUT
  2698 00003AA1 E829000000          <1> 	CALL	CHK_STAT_2		; ENDING INTERRUPT AND SENSE STATUS
  2699                              <1> 
  2700                              <1> ;-----	WAIT FOR HEAD SETTLE
  2701                              <1> 
  2702                              <1> DO_WAIT:
  2703 00003AA6 9C                  <1> 	PUSHF				; SAVE STATUS
  2704 00003AA7 E816FFFFFF          <1> 	CALL	HD_WAIT			; WAIT FOR HEAD SETTLE TIME
  2705 00003AAC 9D                  <1> 	POPF				; RESTORE STATUS
  2706                              <1> RB:
  2707                              <1> NEC_ERR:
  2708                              <1> 	; 08/02/2015 (code trick here from original IBM PC/AT DISKETTE.ASM)
  2709                              <1> 	; (*) nec_err -> retn (push edx -> pop edx) -> nec_err -> retn
  2710 00003AAD C3                  <1> 	RETn				; RETURN TO CALLER
  2711                              <1> 
  2712                              <1> ;-------------------------------------------------------------------------------
  2713                              <1> ; RECAL
  2714                              <1> ;	RECALIBRATE DRIVE
  2715                              <1> ;
  2716                              <1> ; ON ENTRY:	DI = DRIVE #
  2717                              <1> ;
  2718                              <1> ; ON EXIT:	CY REFLECTS STATUS OF OPERATION.
  2719                              <1> ;-------------------------------------------------------------------------------
  2720                              <1> RECAL:
  2721 00003AAE 6651                <1> 	PUSH	CX
  2722 00003AB0 B8[CC3A0000]        <1> 	MOV	eAX, RC_BACK		; LOAD NEC_OUTPUT ERROR
  2723 00003AB5 50                  <1> 	PUSH	eAX
  2724 00003AB6 B407                <1> 	MOV	AH,07H			; RECALIBRATE COMMAND
  2725 00003AB8 E838FFFFFF          <1> 	CALL	NEC_OUTPUT
  2726 00003ABD 89FB                <1> 	MOV	eBX,eDI			; BX = DRIVE #
  2727 00003ABF 88DC                <1> 	MOV	AH,BL
  2728 00003AC1 E82FFFFFFF          <1> 	CALL	NEC_OUTPUT		; OUTPUT THE DRIVE NUMBER
  2729 00003AC6 E804000000          <1> 	CALL	CHK_STAT_2		; GET THE INTERRUPT AND SENSE INT STATUS
  2730 00003ACB 58                  <1> 	POP	eAX			; THROW AWAY ERROR
  2731                              <1> RC_BACK:
  2732 00003ACC 6659                <1> 	POP	CX
  2733 00003ACE C3                  <1> 	RETn
  2734                              <1> 
  2735                              <1> ;-------------------------------------------------------------------------------
  2736                              <1> ; CHK_STAT_2
  2737                              <1> ;	THIS ROUTINE HANDLES THE INTERRUPT RECEIVED AFTER RECALIBRATE,
  2738                              <1> ;	OR SEEK TO THE ADAPTER. THE INTERRUPT IS WAITED FOR, THE
  2739                              <1> ;	INTERRUPT STATUS SENSED, AND THE RESULT RETURNED TO THE CALLER.
  2740                              <1> ;
  2741                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION.
  2742                              <1> ;-------------------------------------------------------------------------------
  2743                              <1> CHK_STAT_2:
  2744 00003ACF B8[F73A0000]        <1>         MOV     eAX, CS_BACK            ; LOAD NEC_OUTPUT ERROR ADDRESS
  2745 00003AD4 50                  <1> 	PUSH	eAX
  2746 00003AD5 E828000000          <1> 	CALL	WAIT_INT		; WAIT FOR THE INTERRUPT
  2747 00003ADA 721A                <1> 	JC	short J34		; IF ERROR, RETURN IT
  2748 00003ADC B408                <1> 	MOV	AH,08H			; SENSE INTERRUPT STATUS COMMAND
  2749 00003ADE E812FFFFFF          <1> 	CALL	NEC_OUTPUT
  2750 00003AE3 E84A000000          <1> 	CALL	RESULTS			; READ IN THE RESULTS
  2751 00003AE8 720C                <1> 	JC	short J34
  2752 00003AEA A0[31200100]        <1> 	MOV	AL,[NEC_STATUS]		; GET THE FIRST STATUS BYTE
  2753 00003AEF 2460                <1> 	AND	AL,01100000B		; ISOLATE THE BITS
  2754 00003AF1 3C60                <1> 	CMP	AL,01100000B		; TEST FOR CORRECT VALUE
  2755 00003AF3 7403                <1> 	JZ	short J35		; IF ERROR, GO MARK IT
  2756 00003AF5 F8                  <1> 	CLC				; GOOD RETURN
  2757                              <1> J34:
  2758 00003AF6 58                  <1> 	POP	eAX			; THROW AWAY ERROR RETURN
  2759                              <1> CS_BACK:
  2760 00003AF7 C3                  <1> 	RETn
  2761                              <1> J35:
  2762 00003AF8 800D[30200100]40    <1> 	OR	byte [DSKETTE_STATUS], BAD_SEEK
  2763 00003AFF F9                  <1> 	STC				; ERROR RETURN CODE
  2764 00003B00 EBF4                <1> 	JMP	SHORT J34
  2765                              <1> 
  2766                              <1> ;-------------------------------------------------------------------------------
  2767                              <1> ; WAIT_INT
  2768                              <1> ;	THIS ROUTINE WAITS FOR AN INTERRUPT TO OCCUR A TIME OUT ROUTINE
  2769                              <1> ;	TAKES PLACE DURING THE WAIT, SO THAT AN ERROR MAY BE RETURNED
  2770                              <1> ;	IF THE DRIVE IS NOT READY.
  2771                              <1> ;
  2772                              <1> ; ON EXIT: 	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION.
  2773                              <1> ;-------------------------------------------------------------------------------
  2774                              <1> 
  2775                              <1> ; 17/12/2014
  2776                              <1> ; 2.5 seconds waiting !
  2777                              <1> ;(AWARD BIOS - 1999, WAIT_FDU_INT_LOW, WAIT_FDU_INT_HI)
  2778                              <1> ; amount of time to wait for completion interrupt from NEC.
  2779                              <1> 
  2780                              <1> 
  2781                              <1> WAIT_INT:
  2782 00003B02 FB                  <1> 	STI				; TURN ON INTERRUPTS, JUST IN CASE
  2783 00003B03 F8                  <1> 	CLC				; CLEAR TIMEOUT INDICATOR
  2784                              <1>        ;MOV	BL,10			; CLEAR THE COUNTERS
  2785                              <1>        ;XOR	CX,CX			; FOR 2 SECOND WAIT
  2786                              <1> 
  2787                              <1> 	; Modification from AWARD BIOS - 1999 (ATORGS.ASM, WAIT
  2788                              <1> 	;
  2789                              <1> 	;WAIT_FOR_MEM:	
  2790                              <1> 	;	Waits for a bit at a specified memory location pointed
  2791                              <1> 	;	to by ES:[DI] to become set.
  2792                              <1> 	;INPUT:
  2793                              <1> 	;	AH=Mask to test with.
  2794                              <1> 	;	ES:[DI] = memory location to watch.
  2795                              <1> 	;	BH:CX=Number of memory refresh periods to delay.
  2796                              <1> 	;	     (normally 30 microseconds per period.)
  2797                              <1> 
  2798                              <1> 	; waiting for (max.) 2.5 secs in 30 micro units.
  2799                              <1> ;	mov 	cx, WAIT_FDU_INT_LO		; 017798
  2800                              <1> ;;	mov 	bl, WAIT_FDU_INT_HI
  2801                              <1> ;	mov 	bl, WAIT_FDU_INT_HI + 1
  2802                              <1> 	; 27/02/2015
  2803 00003B04 B986450100          <1> 	mov 	ecx, WAIT_FDU_INT_LH	; 83334 (2.5 seconds)		
  2804                              <1> WFMS_CHECK_MEM:
  2805 00003B09 F605[2D200100]80    <1> 	test	byte [SEEK_STATUS],INT_FLAG ; TEST FOR INTERRUPT OCCURRING
  2806 00003B10 7516                <1>         jnz     short J37
  2807                              <1> WFMS_HI:
  2808 00003B12 E461                <1> 	IN	AL,PORT_B  ; 061h	; SYS1, wait for lo to hi
  2809 00003B14 A810                <1> 	TEST	AL,010H			; transition on memory
  2810 00003B16 75FA                <1> 	JNZ	SHORT WFMS_HI		; refresh.
  2811                              <1> WFMS_LO:
  2812 00003B18 E461                <1> 	IN	AL,PORT_B		;SYS1
  2813 00003B1A A810                <1> 	TEST	AL,010H
  2814 00003B1C 74FA                <1> 	JZ	SHORT WFMS_LO
  2815 00003B1E E2E9                <1>         LOOP    WFMS_CHECK_MEM
  2816                              <1> ;WFMS_OUTER_LP:
  2817                              <1> ;;	or	bl, bl			; check outer counter
  2818                              <1> ;;	jz	short J36A		; WFMS_TIMEOUT
  2819                              <1> ;	dec	bl
  2820                              <1> ;	jz	short J36A	
  2821                              <1> ;	jmp	short WFMS_CHECK_MEM
  2822                              <1> 
  2823                              <1> 	;17/12/2014
  2824                              <1> 	;16/12/2014
  2825                              <1> ;        mov     byte [wait_count], 0    ; Reset (INT 08H) counter
  2826                              <1> ;J36:
  2827                              <1> ;	TEST	byte [SEEK_STATUS],INT_FLAG ; TEST FOR INTERRUPT OCCURRING
  2828                              <1> ;	JNZ	short J37
  2829                              <1> 	;16/12/2014
  2830                              <1> 	;LOOP	J36			; COUNT DOWN WHILE WAITING
  2831                              <1> 	;DEC	BL			; SECOND LEVEL COUNTER
  2832                              <1> 	;JNZ	short J36
  2833                              <1> ;       cmp     byte [wait_count], 46   ; (46/18.2 seconds)
  2834                              <1> ;	jb	short J36
  2835                              <1> 
  2836                              <1> ;WFMS_TIMEOUT:
  2837                              <1> ;J36A:
  2838 00003B20 800D[30200100]80    <1> 	OR	byte [DSKETTE_STATUS], TIME_OUT ; NOTHING HAPPENED
  2839 00003B27 F9                  <1> 	STC				; ERROR RETURN
  2840                              <1> J37:
  2841 00003B28 9C                  <1> 	PUSHF				; SAVE CURRENT CARRY
  2842 00003B29 8025[2D200100]7F    <1> 	AND	byte [SEEK_STATUS], ~INT_FLAG ; TURN OFF INTERRUPT FLAG
  2843 00003B30 9D                  <1> 	POPF				; RECOVER CARRY
  2844 00003B31 C3                  <1> 	RETn				; GOOD RETURN CODE
  2845                              <1> 
  2846                              <1> ;-------------------------------------------------------------------------------
  2847                              <1> ; RESULTS
  2848                              <1> ;	THIS ROUTINE WILL READ ANYTHING THAT THE NEC CONTROLLER RETURNS 
  2849                              <1> ;	FOLLOWING AN INTERRUPT.
  2850                              <1> ;
  2851                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION.
  2852                              <1> ;		AX,BX,CX,DX DESTROYED
  2853                              <1> ;-------------------------------------------------------------------------------
  2854                              <1> RESULTS:
  2855 00003B32 57                  <1> 	PUSH	eDI
  2856 00003B33 BF[31200100]        <1> 	MOV	eDI, NEC_STATUS		; POINTER TO DATA AREA
  2857 00003B38 B307                <1> 	MOV	BL,7			; MAX STATUS BYTES
  2858 00003B3A 66BAF403            <1> 	MOV	DX,03F4H		; STATUS PORT
  2859                              <1> 
  2860                              <1> ;-----	WAIT FOR REQUEST FOR MASTER
  2861                              <1> 
  2862                              <1> _R10: 
  2863                              <1> 	; 16/12/2014
  2864                              <1> 	; wait for (max) 0.5 seconds
  2865                              <1> 	;MOV	BH,2			; HIGH ORDER COUNTER
  2866                              <1> 	;XOR	CX,CX			; COUNTER
  2867                              <1> 
  2868                              <1> 	;Time to wait while waiting for each byte of NEC results = .5
  2869                              <1> 	;seconds.  .5 seconds = 500,000 micros.  500,000/30 = 16,667.
  2870                              <1> 	; 27/02/2015
  2871 00003B3E B91B410000          <1> 	mov 	ecx, WAIT_FDU_RESULTS_LH ; 16667  
  2872                              <1> 	;mov	cx, WAIT_FDU_RESULTS_LO  ; 16667
  2873                              <1> 	;mov	bh, WAIT_FDU_RESULTS_HI+1 ; 0+1
  2874                              <1> 
  2875                              <1> WFPSR_OUTER_LP:
  2876                              <1> 	;
  2877                              <1> WFPSR_CHECK_PORT:
  2878                              <1> J39:					; WAIT FOR MASTER
  2879 00003B43 EC                  <1> 	IN	AL,DX			; GET STATUS
  2880 00003B44 24C0                <1> 	AND	AL,11000000B		; KEEP ONLY STATUS AND DIRECTION
  2881 00003B46 3CC0                <1> 	CMP	AL,11000000B		; STATUS 1 AND DIRECTION 1 ?
  2882 00003B48 7418                <1> 	JZ	short J42		; STATUS AND DIRECTION OK
  2883                              <1> WFPSR_HI:
  2884 00003B4A E461                <1> 	IN	AL, PORT_B	;061h	; SYS1	; wait for hi to lo
  2885 00003B4C A810                <1> 	TEST	AL,010H			; transition on memory
  2886 00003B4E 75FA                <1> 	JNZ	SHORT WFPSR_HI		; refresh.
  2887                              <1> WFPSR_LO:
  2888 00003B50 E461                <1> 	IN	AL, PORT_B		; SYS1
  2889 00003B52 A810                <1> 	TEST	AL,010H
  2890 00003B54 74FA                <1> 	JZ	SHORT WFPSR_LO
  2891 00003B56 E2EB                <1>         LOOP    WFPSR_CHECK_PORT
  2892                              <1> 	;; 27/02/2015
  2893                              <1> 	;;dec	bh
  2894                              <1> 	;;jnz	short WFPSR_OUTER_LP
  2895                              <1> 	;jmp	short WFPSR_TIMEOUT	; fail
  2896                              <1> 
  2897                              <1> 	;;mov	byte [wait_count], 0
  2898                              <1> ;J39:					; WAIT FOR MASTER
  2899                              <1> ;	IN	AL,DX			; GET STATUS
  2900                              <1> ;	AND	AL,11000000B		; KEEP ONLY STATUS AND DIRECTION
  2901                              <1> ;	CMP	AL,11000000B		; STATUS 1 AND DIRECTION 1 ?
  2902                              <1> ;	JZ	short J42		; STATUS AND DIRECTION OK
  2903                              <1> 	;LOOP	J39			; LOOP TILL TIMEOUT
  2904                              <1> 	;DEC	BH			; DECREMENT HIGH ORDER COUNTER
  2905                              <1> 	;JNZ	short J39		; REPEAT TILL DELAY DONE
  2906                              <1> 	;
  2907                              <1> 	;;cmp	byte [wait_count], 10  ; (10/18.2 seconds)
  2908                              <1> 	;;jb	short J39	
  2909                              <1> 
  2910                              <1> ;WFPSR_TIMEOUT:
  2911 00003B58 800D[30200100]80    <1> 	OR	byte [DSKETTE_STATUS],TIME_OUT
  2912 00003B5F F9                  <1> 	STC				; SET ERROR RETURN
  2913 00003B60 EB29                <1> 	JMP	SHORT POPRES		; POP REGISTERS AND RETURN
  2914                              <1> 
  2915                              <1> ;-----	READ IN THE STATUS
  2916                              <1> 
  2917                              <1> J42:
  2918 00003B62 EB00                <1> 	JMP	$+2			; I/O DELAY
  2919 00003B64 6642                <1> 	INC	DX			; POINT AT DATA PORT
  2920 00003B66 EC                  <1> 	IN	AL,DX			; GET THE DATA
  2921                              <1> 	; 16/12/2014
  2922                              <1> 	NEWIODELAY
  2922 00003B67 E6EB                <2>  out 0ebh,al
  2923 00003B69 8807                <1>         MOV     [eDI],AL                ; STORE THE BYTE
  2924 00003B6B 47                  <1> 	INC	eDI			; INCREMENT THE POINTER
  2925                              <1> 	; 16/12/2014
  2926                              <1> ;	push	cx
  2927                              <1> ;	mov	cx, 30
  2928                              <1> ;wdw2:
  2929                              <1> ;	NEWIODELAY
  2930                              <1> ;	loop	wdw2
  2931                              <1> ;	pop	cx
  2932                              <1> 
  2933 00003B6C B903000000          <1> 	MOV	eCX,3			; MINIMUM 24 MICROSECONDS FOR NEC
  2934 00003B71 E8E1E0FFFF          <1> 	CALL	WAITF			; WAIT 30 TO 45 MICROSECONDS
  2935 00003B76 664A                <1> 	DEC	DX			; POINT AT STATUS PORT
  2936 00003B78 EC                  <1> 	IN	AL,DX			; GET STATUS
  2937                              <1> 	; 16/12/2014
  2938                              <1> 	NEWIODELAY
  2938 00003B79 E6EB                <2>  out 0ebh,al
  2939                              <1> 	;
  2940 00003B7B A810                <1> 	TEST	AL,00010000B		; TEST FOR NEC STILL BUSY
  2941 00003B7D 740C                <1> 	JZ	short POPRES		; RESULTS DONE ?
  2942                              <1> 
  2943 00003B7F FECB                <1> 	DEC	BL			; DECREMENT THE STATUS COUNTER
  2944 00003B81 75BB                <1>         JNZ     short _R10              ; GO BACK FOR MORE
  2945 00003B83 800D[30200100]20    <1> 	OR	byte [DSKETTE_STATUS],BAD_NEC ; TOO MANY STATUS BYTES
  2946 00003B8A F9                  <1> 	STC				; SET ERROR FLAG
  2947                              <1> 
  2948                              <1> ;-----	RESULT OPERATION IS DONE
  2949                              <1> POPRES:
  2950 00003B8B 5F                  <1> 	POP	eDI
  2951 00003B8C C3                  <1> 	RETn				; RETURN WITH CARRY SET
  2952                              <1> 
  2953                              <1> ;-------------------------------------------------------------------------------
  2954                              <1> ; READ_DSKCHNG
  2955                              <1> ;	READS THE STATE OF THE DISK CHANGE LINE.
  2956                              <1> ;
  2957                              <1> ; ON ENTRY:	DI = DRIVE #
  2958                              <1> ;
  2959                              <1> ; ON EXIT:	DI = DRIVE #
  2960                              <1> ;		ZF = 0 : DISK CHANGE LINE INACTIVE
  2961                              <1> ;		ZF = 1 : DISK CHANGE LINE ACTIVE
  2962                              <1> ;		AX,CX,DX DESTROYED
  2963                              <1> ;-------------------------------------------------------------------------------
  2964                              <1> READ_DSKCHNG:
  2965 00003B8D E8A2FDFFFF          <1> 	CALL	MOTOR_ON		; TURN ON THE MOTOR IF OFF
  2966 00003B92 66BAF703            <1> 	MOV	DX,03F7H		; ADDRESS DIGITAL INPUT REGISTER
  2967 00003B96 EC                  <1> 	IN	AL,DX			; INPUT DIGITAL INPUT REGISTER
  2968 00003B97 A880                <1> 	TEST	AL,DSK_CHG		; CHECK FOR DISK CHANGE LINE ACTIVE
  2969 00003B99 C3                  <1> 	RETn				; RETURN TO CALLER WITH ZERO FLAG SET
  2970                              <1> 
  2971                              <1> ;-------------------------------------------------------------------------------
  2972                              <1> ; DRIVE_DET
  2973                              <1> ;	DETERMINES WHETHER DRIVE IS 80 OR 40 TRACKS AND
  2974                              <1> ;	UPDATES STATE INFORMATION ACCORDINGLY.
  2975                              <1> ; ON ENTRY:	DI = DRIVE #
  2976                              <1> ;-------------------------------------------------------------------------------
  2977                              <1> DRIVE_DET:
  2978 00003B9A E895FDFFFF          <1> 	CALL	MOTOR_ON		; TURN ON MOTOR IF NOT ALREADY ON
  2979 00003B9F E80AFFFFFF          <1> 	CALL	RECAL			; RECALIBRATE DRIVE
  2980 00003BA4 7251                <1> 	JC	short DD_BAC		; ASSUME NO DRIVE PRESENT
  2981 00003BA6 B530                <1> 	MOV	CH,TRK_SLAP		; SEEK TO TRACK 48
  2982 00003BA8 E882FEFFFF          <1> 	CALL	SEEK
  2983 00003BAD 7248                <1> 	JC	short DD_BAC		; ERROR NO DRIVE
  2984 00003BAF B50B                <1> 	MOV	CH,QUIET_SEEK+1		; SEEK TO TRACK 10
  2985                              <1> SK_GIN:
  2986 00003BB1 FECD                <1> 	DEC	CH			; DECREMENT TO NEXT TRACK
  2987 00003BB3 6651                <1> 	PUSH	CX			; SAVE TRACK
  2988 00003BB5 E875FEFFFF          <1> 	CALL	SEEK
  2989 00003BBA 723C                <1> 	JC	short POP_BAC		; POP AND RETURN
  2990 00003BBC B8[F83B0000]        <1> 	MOV	eAX, POP_BAC		; LOAD NEC OUTPUT ERROR ADDRESS
  2991 00003BC1 50                  <1> 	PUSH	eAX
  2992 00003BC2 B404                <1> 	MOV	AH,SENSE_DRV_ST		; SENSE DRIVE STATUS COMMAND BYTE
  2993 00003BC4 E82CFEFFFF          <1> 	CALL	NEC_OUTPUT		; OUTPUT TO NEC
  2994 00003BC9 6689F8              <1> 	MOV	AX,DI			; AL = DRIVE
  2995 00003BCC 88C4                <1> 	MOV	AH,AL			; AH = DRIVE
  2996 00003BCE E822FEFFFF          <1> 	CALL	NEC_OUTPUT		; OUTPUT TO NEC
  2997 00003BD3 E85AFFFFFF          <1> 	CALL	RESULTS			; GO GET STATUS
  2998 00003BD8 58                  <1> 	POP	eAX			; THROW AWAY ERROR ADDRESS
  2999 00003BD9 6659                <1> 	POP	CX			; RESTORE TRACK
  3000 00003BDB F605[31200100]10    <1> 	TEST	byte [NEC_STATUS], HOME	; TRACK 0 ?
  3001 00003BE2 74CD                <1> 	JZ	short SK_GIN		; GO TILL TRACK 0
  3002 00003BE4 08ED                <1> 	OR	CH,CH			; IS HOME AT TRACK 0
  3003 00003BE6 7408                <1> 	JZ	short IS_80		; MUST BE 80 TRACK DRIVE
  3004                              <1> 
  3005                              <1> ;	DRIVE IS A 360; SET DRIVE TO DETERMINED;
  3006                              <1> ;	SET MEDIA TO DETERMINED AT RATE 250.
  3007                              <1> 
  3008 00003BE8 808F[3D200100]94    <1> 	OR	byte [DSK_STATE+eDI], DRV_DET+MED_DET+RATE_250
  3009 00003BEF C3                  <1> 	RETn				; ALL INFORMATION SET
  3010                              <1> IS_80:
  3011 00003BF0 808F[3D200100]01    <1> 	OR	byte [DSK_STATE+eDI], TRK_CAPA ; SETUP 80 TRACK CAPABILITY
  3012                              <1> DD_BAC:
  3013 00003BF7 C3                  <1> 	RETn
  3014                              <1> POP_BAC:
  3015 00003BF8 6659                <1> 	POP	CX			; THROW AWAY
  3016 00003BFA C3                  <1> 	RETn
  3017                              <1> 
  3018                              <1> fdc_int:  
  3019                              <1> 	  ; 30/07/2015	
  3020                              <1> 	  ; 16/02/2015
  3021                              <1> ;int_0Eh: ; 11/12/2014
  3022                              <1> 
  3023                              <1> ;--- HARDWARE INT 0EH -- ( IRQ LEVEL  6 ) --------------------------------------
  3024                              <1> ; DISK_INT
  3025                              <1> ;	THIS ROUTINE HANDLES THE DISKETTE INTERRUPT.
  3026                              <1> ;
  3027                              <1> ; ON EXIT:	THE INTERRUPT FLAG IS SET IN @SEEK_STATUS.
  3028                              <1> ;-------------------------------------------------------------------------------
  3029                              <1> DISK_INT_1:
  3030                              <1> 
  3031 00003BFB 6650                <1> 	PUSH	AX			; SAVE WORK REGISTER
  3032 00003BFD 1E                  <1> 	push	ds
  3033 00003BFE 66B81000            <1> 	mov	ax, KDATA
  3034 00003C02 8ED8                <1> 	mov 	ds, ax
  3035 00003C04 800D[2D200100]80    <1>         OR      byte [SEEK_STATUS], INT_FLAG ; TURN ON INTERRUPT OCCURRED
  3036 00003C0B B020                <1> 	MOV     AL,EOI                  ; END OF INTERRUPT MARKER
  3037 00003C0D E620                <1> 	OUT	INTA00,AL		; INTERRUPT CONTROL PORT
  3038 00003C0F 1F                  <1> 	pop	ds
  3039 00003C10 6658                <1> 	POP	AX			; RECOVER REGISTER
  3040 00003C12 CF                  <1> 	IRET				; RETURN FROM INTERRUPT
  3041                              <1> 
  3042                              <1> ;-------------------------------------------------------------------------------
  3043                              <1> ; DSKETTE_SETUP
  3044                              <1> ;	THIS ROUTINE DOES A PRELIMINARY CHECK TO SEE WHAT TYPE OF
  3045                              <1> ;	DISKETTE DRIVES ARE ATTACH TO THE SYSTEM.
  3046                              <1> ;-------------------------------------------------------------------------------
  3047                              <1> 
  3048                              <1> ; 29/05/2016 - TRDOS 386 (TRDOS v2.0)
  3049                              <1> 
  3050                              <1> DSKETTE_SETUP:
  3051                              <1> 	;PUSH	AX			; SAVE REGISTERS
  3052                              <1> 	;PUSH	BX
  3053                              <1> 	;PUSH	CX
  3054 00003C13 52                  <1> 	PUSH	eDX
  3055                              <1> 	;PUSH	DI
  3056                              <1> 	;;PUSH	DS
  3057                              <1> 	; 14/12/2014
  3058                              <1> 	;mov	word [DISK_POINTER], MD_TBL6
  3059                              <1> 	;mov	[DISK_POINTER+2], cs
  3060                              <1> 	;
  3061                              <1> 	;OR	byte [RTC_WAIT_FLAG], 1	; NO RTC WAIT, FORCE USE OF LOOP
  3062 00003C14 31FF                <1> 	XOR	eDI,eDI			; INITIALIZE DRIVE POINTER
  3063 00003C16 66C705[3D200100]00- <1> 	MOV	WORD [DSK_STATE],0	; INITIALIZE STATES
  3063 00003C1E 00                  <1>
  3064 00003C1F 8025[38200100]33    <1> 	AND	byte [LASTRATE],~(STRT_MSK+SEND_MSK) ; CLEAR START & SEND
  3065 00003C26 800D[38200100]C0    <1> 	OR	byte [LASTRATE],SEND_MSK ; INITIALIZE SENT TO IMPOSSIBLE
  3066 00003C2D C605[2D200100]00    <1> 	MOV	byte [SEEK_STATUS],0	; INDICATE RECALIBRATE NEEDED
  3067 00003C34 C605[2F200100]00    <1> 	MOV	byte [MOTOR_COUNT],0	; INITIALIZE MOTOR COUNT
  3068 00003C3B C605[2E200100]00    <1> 	MOV	byte [MOTOR_STATUS],0	; INITIALIZE DRIVES TO OFF STATE
  3069 00003C42 C605[30200100]00    <1> 	MOV	byte [DSKETTE_STATUS],0	; NO ERRORS
  3070                              <1> 	;
  3071                              <1> 	; 28/02/2015
  3072                              <1> 	;mov	word [cfd], 100h 
  3073 00003C49 E848F2FFFF          <1> 	call	DSK_RESET
  3074 00003C4E 5A                  <1> 	pop	edx
  3075 00003C4F F8                  <1> 	clc	; 29/05/2016
  3076 00003C50 C3                  <1> 	retn
  3077                              <1> 
  3078                              <1> ;SUP0:
  3079                              <1> ;	CALL	DRIVE_DET		; DETERMINE DRIVE
  3080                              <1> ;	CALL	XLAT_OLD		; TRANSLATE STATE TO COMPATIBLE MODE
  3081                              <1> ;	; 02/01/2015
  3082                              <1> ;	;INC	DI			; POINT TO NEXT DRIVE
  3083                              <1> ;	;CMP	DI,MAX_DRV		; SEE IF DONE
  3084                              <1> ;	;JNZ	short SUP0		; REPEAT FOR EACH ORIVE
  3085                              <1> ;       cmp     byte [fd1_type], 0	
  3086                              <1> ;	jna	short sup1
  3087                              <1> ;	or	di, di
  3088                              <1> ;	jnz	short sup1
  3089                              <1> ;	inc	di
  3090                              <1> ;       jmp     short SUP0
  3091                              <1> ;sup1:
  3092                              <1> ;	MOV	byte [SEEK_STATUS],0	; FORCE RECALIBRATE
  3093                              <1> ;	;AND	byte [RTC_WAIT_FLAG],0FEH ; ALLOW FOR RTC WAIT
  3094                              <1> ;	CALL	SETUP_END		; VARIOUS CLEANUPS
  3095                              <1> ;	;;POP	DS			; RESTORE CALLERS REGISTERS
  3096                              <1> ;	;POP	DI
  3097                              <1> ;	POP	eDX
  3098                              <1> ;	;POP	CX
  3099                              <1> ;	;POP	BX
  3100                              <1> ;	;POP	AX
  3101                              <1> ;	RETn
  3102                              <1> 
  3103                              <1> ;//////////////////////////////////////////////////////
  3104                              <1> ;; END OF DISKETTE I/O ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3105                              <1> ;
  3106                              <1> 
  3107                              <1> int13h: ; 21/02/2015
  3108 00003C51 9C                  <1> 	pushfd
  3109 00003C52 0E                  <1> 	push 	cs
  3110 00003C53 E841010000          <1> 	call 	DISK_IO
  3111 00003C58 C3                  <1> 	retn
  3112                              <1> 
  3113                              <1> ;;;;;; DISK I/O ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 21/02/2015 ;;;
  3114                              <1> ;/////////////////////////////////////////////////////////////////////
  3115                              <1> 
  3116                              <1> ; DISK I/O - Erdogan Tan (Retro UNIX 386 v1 project)
  3117                              <1> ; 18/02/2016
  3118                              <1> ; 17/02/2016
  3119                              <1> ; 23/02/2015
  3120                              <1> ; 21/02/2015 (unix386.s)
  3121                              <1> ; 22/12/2014 - 14/02/2015 (dsectrm2.s)
  3122                              <1> ;
  3123                              <1> ; Original Source Code:
  3124                              <1> ; DISK ----- 09/25/85 FIXED DISK BIOS
  3125                              <1> ; (IBM PC XT Model 286 System BIOS Source Code, 04-21-86)
  3126                              <1> ;
  3127                              <1> ; Modifications: by reference of AWARD BIOS 1999 (D1A0622) 
  3128                              <1> ;		 Source Code - ATORGS.ASM, AHDSK.ASM
  3129                              <1> ;
  3130                              <1> 
  3131                              <1> 
  3132                              <1> ;The wait for controller to be not busy is 10 seconds.
  3133                              <1> ;10,000,000 / 30 = 333,333.  333,333 decimal = 051615h
  3134                              <1> ;;WAIT_HDU_CTLR_BUSY_LO	equ	1615h		
  3135                              <1> ;;WAIT_HDU_CTLR_BUSY_HI	equ	  05h
  3136                              <1> WAIT_HDU_CTRL_BUSY_LH	equ	51615h	 ;21/02/2015		
  3137                              <1> 
  3138                              <1> ;The wait for controller to issue completion interrupt is 10 seconds.
  3139                              <1> ;10,000,000 / 30 = 333,333.  333,333 decimal = 051615h
  3140                              <1> ;;WAIT_HDU_INT_LO	equ	1615h
  3141                              <1> ;;WAIT_HDU_INT_HI	equ	  05h
  3142                              <1> WAIT_HDU_INT_LH		equ	51615h	; 21/02/2015
  3143                              <1> 
  3144                              <1> ;The wait for Data request on read and write longs is
  3145                              <1> ;2000 us. (?)
  3146                              <1> ;;WAIT_HDU_DRQ_LO	equ	1000	; 03E8h
  3147                              <1> ;;WAIT_HDU_DRQ_HI	equ	0
  3148                              <1> WAIT_HDU_DRQ_LH		equ	1000	; 21/02/2015
  3149                              <1> 
  3150                              <1> ; Port 61h (PORT_B)
  3151                              <1> SYS1		equ	61h	; PORT_B  (diskette.inc)
  3152                              <1> 
  3153                              <1> ; 23/12/2014
  3154                              <1> %define CMD_BLOCK       eBP-8  ; 21/02/2015
  3155                              <1> 
  3156                              <1> 
  3157                              <1> ;--- INT 13H -------------------------------------------------------------------
  3158                              <1> ;									       :
  3159                              <1> ; FIXED DISK I/O INTERFACE						       :
  3160                              <1> ;									       :
  3161                              <1> ;	THIS INTERFACE PROVIDES ACCESS TO 5 1/4" FIXED DISKS THROUGH           :
  3162                              <1> ;	THE IBM FIXED DISK CONTROLLER.					       :
  3163                              <1> ;									       :
  3164                              <1> ;	THE  BIOS  ROUTINES  ARE  MEANT  TO  BE  ACCESSED  THROUGH	       :
  3165                              <1> ;	SOFTWARE  INTERRUPTS  ONLY.    ANY  ADDRESSES  PRESENT	IN	       :
  3166                              <1> ;	THESE  LISTINGS  ARE  INCLUDED	 ONLY	FOR  COMPLETENESS,	       :
  3167                              <1> ;	NOT  FOR  REFERENCE.  APPLICATIONS   WHICH  REFERENCE  ANY	       :
  3168                              <1> ;	ABSOLUTE  ADDRESSES  WITHIN  THE  CODE	SEGMENTS  OF  BIOS	       :
  3169                              <1> ;	VIOLATE  THE  STRUCTURE  AND  DESIGN  OF  BIOS. 		       :
  3170                              <1> ;									       :
  3171                              <1> ;------------------------------------------------------------------------------:
  3172                              <1> ;									       :
  3173                              <1> ; INPUT  (AH)= HEX COMMAND VALUE					       :
  3174                              <1> ;									       :
  3175                              <1> ;	(AH)= 00H  RESET DISK (DL = 80H,81H) / DISKETTE 		       :
  3176                              <1> ;	(AH)= 01H  READ THE STATUS OF THE LAST DISK OPERATION INTO (AL)        :
  3177                              <1> ;		    NOTE: DL < 80H - DISKETTE				       :
  3178                              <1> ;			  DL > 80H - DISK				       :
  3179                              <1> ;	(AH)= 02H  READ THE DESIRED SECTORS INTO MEMORY 		       :
  3180                              <1> ;	(AH)= 03H  WRITE THE DESIRED SECTORS FROM MEMORY		       :
  3181                              <1> ;	(AH)= 04H  VERIFY THE DESIRED SECTORS				       :
  3182                              <1> ;	(AH)= 05H  FORMAT THE DESIRED TRACK				       :
  3183                              <1> ;	(AH)= 06H  UNUSED						       :
  3184                              <1> ;	(AH)= 07H  UNUSED						       :
  3185                              <1> ;	(AH)= 08H  RETURN THE CURRENT DRIVE PARAMETERS			       :
  3186                              <1> ;	(AH)= 09H  INITIALIZE DRIVE PAIR CHARACTERISTICS		       :
  3187                              <1> ;		    INTERRUPT 41 POINTS TO DATA BLOCK FOR DRIVE 0	       :
  3188                              <1> ;		    INTERRUPT 46 POINTS TO DATA BLOCK FOR DRIVE 1	       :
  3189                              <1> ;	(AH)= 0AH  READ LONG						       :
  3190                              <1> ;	(AH)= 0BH  WRITE LONG  (READ & WRITE LONG ENCOMPASS 512 + 4 BYTES ECC) :
  3191                              <1> ;	(AH)= 0CH  SEEK 						       :
  3192                              <1> ;	(AH)= 0DH  ALTERNATE DISK RESET (SEE DL)			       :
  3193                              <1> ;	(AH)= 0EH  UNUSED						       :
  3194                              <1> ;	(AH)= 0FH  UNUSED						       :
  3195                              <1> ;	(AH)= 10H  TEST DRIVE READY					       :
  3196                              <1> ;	(AH)= 11H  RECALIBRATE						       :
  3197                              <1> ;	(AH)= 12H  UNUSED						       :
  3198                              <1> ;	(AH)= 13H  UNUSED						       :
  3199                              <1> ;	(AH)= 14H  CONTROLLER INTERNAL DIAGNOSTIC			       :
  3200                              <1> ;	(AH)= 15H  READ DASD TYPE					       :
  3201                              <1> ;									       :
  3202                              <1> ;-------------------------------------------------------------------------------
  3203                              <1> ;									       :
  3204                              <1> ;	REGISTERS USED FOR FIXED DISK OPERATIONS			       :
  3205                              <1> ;									       :
  3206                              <1> ;		(DL)	-  DRIVE NUMBER     (80H-81H FOR DISK. VALUE CHECKED)  :
  3207                              <1> ;		(DH)	-  HEAD NUMBER	    (0-15 ALLOWED, NOT VALUE CHECKED)  :
  3208                              <1> ;		(CH)	-  CYLINDER NUMBER  (0-1023, NOT VALUE CHECKED)(SEE CL):
  3209                              <1> ;		(CL)	-  SECTOR NUMBER    (1-17, NOT VALUE CHECKED)	       :
  3210                              <1> ;									       :
  3211                              <1> ;			   NOTE: HIGH 2 BITS OF CYLINDER NUMBER ARE PLACED     :
  3212                              <1> ;				 IN THE HIGH 2 BITS OF THE CL REGISTER	       :
  3213                              <1> ;				 (10 BITS TOTAL)			       :
  3214                              <1> ;									       :
  3215                              <1> ;		(AL)	-  NUMBER OF SECTORS (MAXIMUM POSSIBLE RANGE 1-80H,    :
  3216                              <1> ;					      FOR READ/WRITE LONG 1-79H)       :
  3217                              <1> ;									       :
  3218                              <1> ;		(ES:BX) -  ADDRESS OF BUFFER FOR READS AND WRITES,	       :
  3219                              <1> ;			   (NOT REQUIRED FOR VERIFY)			       :
  3220                              <1> ;									       :
  3221                              <1> ;		FORMAT (AH=5) ES:BX POINTS TO A 512 BYTE BUFFER. THE FIRST     :
  3222                              <1> ;			   2*(SECTORS/TRACK) BYTES CONTAIN F,N FOR EACH SECTOR.:
  3223                              <1> ;			   F = 00H FOR A GOOD SECTOR			       :
  3224                              <1> ;			       80H FOR A BAD SECTOR			       :
  3225                              <1> ;			   N = SECTOR NUMBER				       :
  3226                              <1> ;			   FOR AN INTERLEAVE OF 2 AND 17 SECTORS/TRACK	       :
  3227                              <1> ;			   THE TABLE SHOULD BE: 			       :
  3228                              <1> ;									       :
  3229                              <1> ;		   DB	   00H,01H,00H,0AH,00H,02H,00H,0BH,00H,03H,00H,0CH     :
  3230                              <1> ;		   DB	   00H,04H,00H,0DH,00H,05H,00H,0EH,00H,06H,00H,0FH     :
  3231                              <1> ;		   DB	   00H,07H,00H,10H,00H,08H,00H,11H,00H,09H	       :
  3232                              <1> ;									       :
  3233                              <1> ;-------------------------------------------------------------------------------
  3234                              <1> 
  3235                              <1> ;-------------------------------------------------------------------------------
  3236                              <1> ; OUTPUT								       :
  3237                              <1> ;	AH = STATUS OF CURRENT OPERATION				       :
  3238                              <1> ;	     STATUS BITS ARE DEFINED IN THE EQUATES BELOW		       :
  3239                              <1> ;	CY = 0	SUCCESSFUL OPERATION (AH=0 ON RETURN)			       :
  3240                              <1> ;	CY = 1	FAILED OPERATION (AH HAS ERROR REASON)			       :
  3241                              <1> ;									       :
  3242                              <1> ;	NOTE:	ERROR 11H  INDICATES THAT THE DATA READ HAD A RECOVERABLE      :
  3243                              <1> ;		ERROR WHICH WAS CORRECTED BY THE ECC ALGORITHM.  THE DATA      :
  3244                              <1> ;		IS PROBABLY GOOD,   HOWEVER THE BIOS ROUTINE INDICATES AN      :
  3245                              <1> ;		ERROR TO ALLOW THE CONTROLLING PROGRAM A CHANCE TO DECIDE      :
  3246                              <1> ;		FOR ITSELF.  THE  ERROR  MAY  NOT  RECUR  IF  THE DATA IS      :
  3247                              <1> ;		REWRITTEN.						       :
  3248                              <1> ;									       :
  3249                              <1> ;	IF DRIVE PARAMETERS WERE REQUESTED (DL >= 80H), 		       :
  3250                              <1> ;	   INPUT:							       :
  3251                              <1> ;	     (DL) = DRIVE NUMBER					       :	
  3252                              <1> ;	     ; 27/05/2016 - TRDOS 386 (TRDOS v2.0)						       :	 	
  3253                              <1> ;	     EBX = Buffer address for fixed disk parameters table (32 bytes)   :
  3254                              <1> ;	   OUTPUT:							       :
  3255                              <1> ;	     (DL) = NUMBER OF CONSECUTIVE ACKNOWLEDGING DRIVES ATTACHED (1-2)  :
  3256                              <1> ;		    (CONTROLLER CARD ZERO TALLY ONLY)			       :
  3257                              <1> ;	     (DH) = MAXIMUM USEABLE VALUE FOR HEAD NUMBER		       :
  3258                              <1> ;	     (CH) = MAXIMUM USEABLE VALUE FOR CYLINDER NUMBER		       :
  3259                              <1> ;	     (CL) = MAXIMUM USEABLE VALUE FOR SECTOR NUMBER		       :
  3260                              <1> ;		    AND CYLINDER NUMBER HIGH BITS			       :
  3261                              <1> ;									       :
  3262                              <1> ;	IF READ DASD TYPE WAS REQUESTED,				       :
  3263                              <1> ;									       :
  3264                              <1> ;	AH = 0 - NOT PRESENT						       :
  3265                              <1> ;	     1 - DISKETTE - NO CHANGE LINE AVAILABLE			       :
  3266                              <1> ;	     2 - DISKETTE - CHANGE LINE AVAILABLE			       :
  3267                              <1> ;	     3 - FIXED DISK						       :
  3268                              <1> ;									       :
  3269                              <1> ;	CX,DX = NUMBER OF 512 BYTE BLOCKS WHEN AH = 3			       :
  3270                              <1> ;									       :
  3271                              <1> ;	REGISTERS WILL BE PRESERVED EXCEPT WHEN THEY ARE USED TO RETURN        :
  3272                              <1> ;	INFORMATION.							       :
  3273                              <1> ;									       :
  3274                              <1> ;	NOTE: IF AN ERROR IS REPORTED BY THE DISK CODE, THE APPROPRIATE        :
  3275                              <1> ;		ACTION IS TO RESET THE DISK, THEN RETRY THE OPERATION.	       :
  3276                              <1> ;									       :
  3277                              <1> ;-------------------------------------------------------------------------------
  3278                              <1> 
  3279                              <1> SENSE_FAIL	EQU	0FFH		; NOT IMPLEMENTED
  3280                              <1> NO_ERR		EQU	0E0H		; STATUS ERROR/ERROR REGISTER=0
  3281                              <1> WRITE_FAULT	EQU	0CCH		; WRITE FAULT ON SELECTED DRIVE
  3282                              <1> UNDEF_ERR	EQU	0BBH		; UNDEFINED ERROR OCCURRED
  3283                              <1> NOT_RDY 	EQU	0AAH		; DRIVE NOT READY
  3284                              <1> TIME_OUT	EQU	80H		; ATTACHMENT FAILED TO RESPOND
  3285                              <1> BAD_SEEK	EQU	40H		; SEEK OPERATION FAILED
  3286                              <1> BAD_CNTLR	EQU	20H		; CONTROLLER HAS FAILED
  3287                              <1> DATA_CORRECTED	EQU	11H		; ECC CORRECTED DATA ERROR
  3288                              <1> BAD_ECC 	EQU	10H		; BAD ECC ON DISK READ
  3289                              <1> BAD_TRACK	EQU	0BH		; NOT IMPLEMENTED
  3290                              <1> BAD_SECTOR	EQU	0AH		; BAD SECTOR FLAG DETECTED
  3291                              <1> ;DMA_BOUNDARY	EQU	09H		; DATA EXTENDS TOO FAR
  3292                              <1> INIT_FAIL	EQU	07H		; DRIVE PARAMETER ACTIVITY FAILED
  3293                              <1> BAD_RESET	EQU	05H		; RESET FAILED
  3294                              <1> ;RECORD_NOT_FND	EQU	04H		; REQUESTED SECTOR NOT FOUND
  3295                              <1> ;BAD_ADDR_MARK	EQU	02H		; ADDRESS MARK NOT FOUND
  3296                              <1> ;BAD_CMD 	EQU	01H		; BAD COMMAND PASSED TO DISK I/O
  3297                              <1> 
  3298                              <1> ;--------------------------------------------------------
  3299                              <1> ;							:
  3300                              <1> ; FIXED DISK PARAMETER TABLE				:
  3301                              <1> ;  -  THE TABLE IS COMPOSED OF A BLOCK DEFINED AS:	:
  3302                              <1> ;							:
  3303                              <1> ;  +0	(1 WORD) - MAXIMUM NUMBER OF CYLINDERS		:
  3304                              <1> ;  +2	(1 BYTE) - MAXIMUM NUMBER OF HEADS		:
  3305                              <1> ;  +3	(1 WORD) - NOT USED/SEE PC-XT			:
  3306                              <1> ;  +5	(1 WORD) - STARTING WRITE PRECOMPENSATION CYL	:
  3307                              <1> ;  +7	(1 BYTE) - MAXIMUM ECC DATA BURST LENGTH	:
  3308                              <1> ;  +8	(1 BYTE) - CONTROL BYTE 			:
  3309                              <1> ;		   BIT	  7 DISABLE RETRIES -OR-	:
  3310                              <1> ;		   BIT	  6 DISABLE RETRIES		:
  3311                              <1> ;		   BIT	  3 MORE THAN 8 HEADS		:
  3312                              <1> ;  +9	(3 BYTES)- NOT USED/SEE PC-XT			:
  3313                              <1> ; +12	(1 WORD) - LANDING ZONE 			:
  3314                              <1> ; +14	(1 BYTE) - NUMBER OF SECTORS/TRACK		:
  3315                              <1> ; +15	(1 BYTE) - RESERVED FOR FUTURE USE		:
  3316                              <1> ;							:
  3317                              <1> ;	 - TO DYNAMICALLY DEFINE A SET OF PARAMETERS	:
  3318                              <1> ;	   BUILD A TABLE FOR UP TO 15 TYPES AND PLACE	:
  3319                              <1> ;	   THE CORRESPONDING VECTOR INTO INTERRUPT 41	:
  3320                              <1> ;	   FOR DRIVE 0 AND INTERRUPT 46 FOR DRIVE 1.	:
  3321                              <1> ;							:
  3322                              <1> ;--------------------------------------------------------
  3323                              <1> 
  3324                              <1> ;--------------------------------------------------------
  3325                              <1> ;							:
  3326                              <1> ; HARDWARE SPECIFIC VALUES				:
  3327                              <1> ;							:
  3328                              <1> ;  -  CONTROLLER I/O PORT				:
  3329                              <1> ;							:
  3330                              <1> ;     > WHEN READ FROM: 				:
  3331                              <1> ;	HF_PORT+0 - READ DATA (FROM CONTROLLER TO CPU)	:
  3332                              <1> ;	HF_PORT+1 - GET ERROR REGISTER			:
  3333                              <1> ;	HF_PORT+2 - GET SECTOR COUNT			:
  3334                              <1> ;	HF_PORT+3 - GET SECTOR NUMBER			:
  3335                              <1> ;	HF_PORT+4 - GET CYLINDER LOW			:
  3336                              <1> ;	HF_PORT+5 - GET CYLINDER HIGH (2 BITS)		:
  3337                              <1> ;	HF_PORT+6 - GET SIZE/DRIVE/HEAD 		:
  3338                              <1> ;	HF_PORT+7 - GET STATUS REGISTER 		:
  3339                              <1> ;							:
  3340                              <1> ;     > WHEN WRITTEN TO:				:
  3341                              <1> ;	HF_PORT+0 - WRITE DATA (FROM CPU TO CONTROLLER) :
  3342                              <1> ;	HF_PORT+1 - SET PRECOMPENSATION CYLINDER	:
  3343                              <1> ;	HF_PORT+2 - SET SECTOR COUNT			:
  3344                              <1> ;	HF_PORT+3 - SET SECTOR NUMBER			:
  3345                              <1> ;	HF_PORT+4 - SET CYLINDER LOW			:
  3346                              <1> ;	HF_PORT+5 - SET CYLINDER HIGH (2 BITS)		:
  3347                              <1> ;	HF_PORT+6 - SET SIZE/DRIVE/HEAD 		:
  3348                              <1> ;	HF_PORT+7 - SET COMMAND REGISTER		:
  3349                              <1> ;							:
  3350                              <1> ;--------------------------------------------------------
  3351                              <1> 
  3352                              <1> ;HF_PORT 	EQU	01F0H	; DISK PORT
  3353                              <1> ;HF1_PORT	equ	0170h	
  3354                              <1> ;HF_REG_PORT	EQU	03F6H
  3355                              <1> ;HF1_REG_PORT	equ	0376h
  3356                              <1> 
  3357                              <1> HDC1_BASEPORT	equ	1F0h
  3358                              <1> HDC2_BASEPORT	equ	170h		
  3359                              <1> 
  3360 00003C59 90                  <1> align 2
  3361                              <1> 
  3362                              <1> ;-----		STATUS REGISTER
  3363                              <1> 
  3364                              <1> ST_ERROR	EQU	00000001B	;
  3365                              <1> ST_INDEX	EQU	00000010B	;
  3366                              <1> ST_CORRCTD	EQU	00000100B	; ECC CORRECTION SUCCESSFUL
  3367                              <1> ST_DRQ		EQU	00001000B	;
  3368                              <1> ST_SEEK_COMPL	EQU	00010000B	; SEEK COMPLETE
  3369                              <1> ST_WRT_FLT	EQU	00100000B	; WRITE FAULT
  3370                              <1> ST_READY	EQU	01000000B	;
  3371                              <1> ST_BUSY 	EQU	10000000B	;
  3372                              <1> 
  3373                              <1> ;-----		ERROR REGISTER
  3374                              <1> 
  3375                              <1> ERR_DAM 	EQU	00000001B	; DATA ADDRESS MARK NOT FOUND
  3376                              <1> ERR_TRK_0	EQU	00000010B	; TRACK 0 NOT FOUND ON RECAL
  3377                              <1> ERR_ABORT	EQU	00000100B	; ABORTED COMMAND
  3378                              <1> ;		EQU	00001000B	; NOT USED
  3379                              <1> ERR_ID		EQU	00010000B	; ID NOT FOUND
  3380                              <1> ;		EQU	00100000B	; NOT USED
  3381                              <1> ERR_DATA_ECC	EQU	01000000B
  3382                              <1> ERR_BAD_BLOCK	EQU	10000000B
  3383                              <1> 
  3384                              <1> 
  3385                              <1> RECAL_CMD	EQU	00010000B	; DRIVE RECAL	(10H)
  3386                              <1> READ_CMD	EQU	00100000B	;	READ	(20H)
  3387                              <1> WRITE_CMD	EQU	00110000B	;	WRITE	(30H)
  3388                              <1> VERIFY_CMD	EQU	01000000B	;	VERIFY	(40H)
  3389                              <1> FMTTRK_CMD	EQU	01010000B	; FORMAT TRACK	(50H)
  3390                              <1> INIT_CMD	EQU	01100000B	;   INITIALIZE	(60H)
  3391                              <1> SEEK_CMD	EQU	01110000B	;	SEEK	(70H)
  3392                              <1> DIAG_CMD	EQU	10010000B	; DIAGNOSTIC	(90H)
  3393                              <1> SET_PARM_CMD	EQU	10010001B	; DRIVE PARMS	(91H)
  3394                              <1> NO_RETRIES	EQU	00000001B	; CHD MODIFIER	(01H)
  3395                              <1> ECC_MODE	EQU	00000010B	; CMD MODIFIER	(02H)
  3396                              <1> BUFFER_MODE	EQU	00001000B	; CMD MODIFIER	(08H)
  3397                              <1> 
  3398                              <1> ;MAX_FILE	EQU	2
  3399                              <1> ;S_MAX_FILE	EQU	2
  3400                              <1> MAX_FILE	equ	4		; 22/12/2014
  3401                              <1> S_MAX_FILE	equ	4		; 22/12/2014
  3402                              <1> 
  3403                              <1> DELAY_1 	EQU	25H		; DELAY FOR OPERATION COMPLETE
  3404                              <1> DELAY_2 	EQU	0600H		; DELAY FOR READY
  3405                              <1> DELAY_3 	EQU	0100H		; DELAY FOR DATA REQUEST
  3406                              <1> 
  3407                              <1> HF_FAIL 	EQU	08H		; CMOS FLAG IN BYTE 0EH
  3408                              <1> 
  3409                              <1> ;-----		COMMAND BLOCK REFERENCE
  3410                              <1> 
  3411                              <1> ;CMD_BLOCK      EQU     BP-8            ; @CMD_BLOCK REFERENCES BLOCK HEAD IN SS
  3412                              <1> 					;  (BP) POINTS TO COMMAND BLOCK TAIL
  3413                              <1> 					;	AS DEFINED BY THE "ENTER" PARMS
  3414                              <1> ; 19/12/2014
  3415                              <1> ORG_VECTOR	equ	4*13h		; INT 13h vector
  3416                              <1> DISK_VECTOR	equ	4*40h		; INT 40h vector (for floppy disks)
  3417                              <1> ;HDISK_INT	equ	4*76h		; Primary HDC - Hardware interrupt (IRQ14)
  3418                              <1> ;HDISK_INT1	equ	4*76h		; Primary HDC - Hardware interrupt (IRQ14)
  3419                              <1> ;HDISK_INT2	equ	4*77h		; Secondary HDC - Hardware interrupt (IRQ15)
  3420                              <1> ;HF_TBL_VEC	equ	4*41h		; Pointer to 1st fixed disk parameter table
  3421                              <1> ;HF1_TBL_VEC	equ	4*46h		; Pointer to 2nd fixed disk parameter table
  3422                              <1> 
  3423                              <1> align 2
  3424                              <1> 
  3425                              <1> ;----------------------------------------------------------------
  3426                              <1> ; FIXED DISK I/O SETUP						:
  3427                              <1> ;								:
  3428                              <1> ;  -  ESTABLISH TRANSFER VECTORS FOR THE FIXED DISK		:
  3429                              <1> ;  -  PERFORM POWER ON DIAGNOSTICS				:
  3430                              <1> ;     SHOULD AN ERROR OCCUR A "1701" MESSAGE IS DISPLAYED       :
  3431                              <1> ;								:
  3432                              <1> ;----------------------------------------------------------------
  3433                              <1> 
  3434                              <1> ; 29/05/2016 - TRDOS 386 (TRDOS v2.0)
  3435                              <1> 
  3436                              <1> DISK_SETUP:
  3437                              <1> 	;CLI
  3438                              <1> 	;;MOV	AX,ABS0 			; GET ABSOLUTE SEGMENT
  3439                              <1> 	;xor	ax,ax
  3440                              <1> 	;MOV	DS,AX				; SET SEGMENT REGISTER
  3441                              <1> 	;MOV	AX, [ORG_VECTOR] 		; GET DISKETTE VECTOR
  3442                              <1> 	;MOV	[DISK_VECTOR],AX		;  INTO INT 40H
  3443                              <1> 	;MOV	AX, [ORG_VECTOR+2]
  3444                              <1> 	;MOV	[DISK_VECTOR+2],AX
  3445                              <1> 	;MOV	word [ORG_VECTOR],DISK_IO	; FIXED DISK HANDLER
  3446                              <1> 	;MOV	[ORG_VECTOR+2],CS
  3447                              <1> 	; 1st controller (primary master, slave)   - IRQ 14
  3448                              <1> 	;;MOV	word [HDISK_INT],HD_INT		; FIXED DISK INTERRUPT
  3449                              <1> 	;mov	word [HDISK_INT1],HD_INT	;
  3450                              <1> 	;;MOV	[HDISK_INT+2],CS
  3451                              <1> 	;mov	[HDISK_INT1+2],CS
  3452                              <1> 	; 2nd controller (secondary master, slave) - IRQ 15
  3453                              <1> 	;mov	word [HDISK_INT2],HD1_INT	;
  3454                              <1> 	;mov	[HDISK_INT2+2],CS
  3455                              <1> 	;
  3456                              <1> 	;;MOV	word [HF_TBL_VEC],HD0_DPT	; PARM TABLE DRIVE 80
  3457                              <1> 	;;MOV	word [HF_TBL_VEC+2],DPT_SEGM
  3458                              <1> 	;;MOV	word [HF1_TBL_VEC],HD1_DPT	; PARM TABLE DRIVE 81
  3459                              <1> 	;;MOV	word [HF1_TBL_VEC+2],DPT_SEGM
  3460                              <1> 	;push	cs
  3461                              <1> 	;pop	ds
  3462                              <1> 	;mov	word [HDPM_TBL_VEC],HD0_DPT	; PARM TABLE DRIVE 80h
  3463                              <1> 	;mov	word [HDPM_TBL_VEC+2],DPT_SEGM
  3464 00003C5A C705[48200100]0000- <1> 	mov 	dword [HDPM_TBL_VEC], (DPT_SEGM*16)+HD0_DPT
  3464 00003C62 0900                <1>
  3465                              <1> 	;mov	word [HDPS_TBL_VEC],HD1_DPT	; PARM TABLE DRIVE 81h
  3466                              <1> 	;mov	word [HDPS_TBL_VEC+2],DPT_SEGM
  3467 00003C64 C705[4C200100]2000- <1> 	mov 	dword [HDPS_TBL_VEC], (DPT_SEGM*16)+HD1_DPT
  3467 00003C6C 0900                <1>
  3468                              <1> 	;mov	word [HDSM_TBL_VEC],HD2_DPT	; PARM TABLE DRIVE 82h
  3469                              <1> 	;mov	word [HDSM_TBL_VEC+2],DPT_SEGM
  3470 00003C6E C705[50200100]4000- <1> 	mov 	dword [HDSM_TBL_VEC], (DPT_SEGM*16)+HD2_DPT
  3470 00003C76 0900                <1>
  3471                              <1> 	;mov	word [HDSS_TBL_VEC],HD3_DPT	; PARM TABLE DRIVE 83h
  3472                              <1> 	;mov	word [HDSS_TBL_VEC+2],DPT_SEGM
  3473 00003C78 C705[54200100]6000- <1> 	mov 	dword [HDSS_TBL_VEC], (DPT_SEGM*16)+HD3_DPT
  3473 00003C80 0900                <1>
  3474                              <1> 	;
  3475                              <1> 	;;IN	AL,INTB01		; TURN ON SECOND INTERRUPT CHIP
  3476                              <1> 	;;;AND	AL,0BFH
  3477                              <1> 	;;and	al, 3Fh			; enable IRQ 14 and IRQ 15
  3478                              <1> 	;;;JMP	$+2
  3479                              <1> 	;;IODELAY
  3480                              <1> 	;;OUT	INTB01,AL
  3481                              <1> 	;;IODELAY
  3482                              <1> 	;;IN	AL,INTA01		; LET INTERRUPTS PASS THRU TO
  3483                              <1> 	;;AND	AL,0FBH 		;  SECOND CHIP
  3484                              <1> 	;;;JMP	$+2
  3485                              <1> 	;;IODELAY
  3486                              <1> 	;;OUT	INTA01,AL
  3487                              <1> 	;
  3488                              <1> 	;STI
  3489                              <1> 	;;PUSH	DS			; MOVE ABS0 POINTER TO
  3490                              <1> 	;;POP	ES			; EXTRA SEGMENT POINTER
  3491                              <1> 	;;;CALL	DDS			; ESTABLISH DATA SEGMENT
  3492                              <1> 	;;MOV	byte [DISK_STATUS1],0 	; RESET THE STATUS INDICATOR
  3493                              <1> 	;;MOV	byte [HF_NUM],0		; ZERO NUMBER OF FIXED DISKS
  3494                              <1> 	;;MOV	byte [CONTROL_BYTE],0
  3495                              <1> 	;;MOV	byte [PORT_OFF],0	; ZERO CARD OFFSET
  3496                              <1> 	; 20/12/2014 - private code by Erdogan Tan
  3497                              <1> 		      ; (out of original PC-AT, PC-XT BIOS code)
  3498                              <1> 	;mov	si, hd0_type
  3499 00003C82 BE[FAEC0000]        <1> 	mov	esi, hd0_type
  3500                              <1> 	;mov	cx, 4
  3501 00003C87 B904000000          <1> 	mov	ecx, 4
  3502                              <1> hde_l:
  3503 00003C8C AC                  <1> 	lodsb
  3504 00003C8D 3C80                <1> 	cmp	al, 80h			; 8?h = existing
  3505 00003C8F 7206                <1> 	jb	short _L4
  3506 00003C91 FE05[44200100]      <1> 	inc	byte [HF_NUM]		; + 1 hard (fixed) disk drives
  3507                              <1> _L4: ; 26/02/2015
  3508 00003C97 E2F3                <1> 	loop	hde_l	
  3509                              <1> ;_L4:					; 0 <= [HF_NUM] =< 4
  3510                              <1> ;L4:
  3511                              <1> 	; 
  3512                              <1> 	;; 31/12/2014 - cancel controller diagnostics here
  3513                              <1> 	;;;mov 	cx, 3  ; 26/12/2014 (Award BIOS 1999)
  3514                              <1> 	;;mov 	cl, 3
  3515                              <1> 	;;
  3516                              <1> 	;;MOV	DL,80H			; CHECK THE CONTROLLER
  3517                              <1> ;;hdc_dl:
  3518                              <1> 	;;MOV	AH,14H			; USE CONTROLLER DIAGNOSTIC COMMAND
  3519                              <1> 	;;INT	13H			; CALL BIOS WITH DIAGNOSTIC COMMAND
  3520                              <1> 	;;;JC	short CTL_ERRX		; DISPLAY ERROR MESSAGE IF BAD RETURN
  3521                              <1> 	;;;jc	short POD_DONE ;22/12/2014
  3522                              <1> 	;;jnc	short hdc_reset0
  3523                              <1> 	;;loop	hdc_dl
  3524                              <1> 	;;; 27/12/2014
  3525                              <1> 	;;stc
  3526                              <1> 	;;retn
  3527                              <1> 	;
  3528                              <1> ;;hdc_reset0:
  3529                              <1> 	; 18/01/2015
  3530 00003C99 8A0D[44200100]      <1> 	mov	cl, [HF_NUM]
  3531 00003C9F 20C9                <1> 	and	cl, cl
  3532 00003CA1 740E                <1> 	jz	short POD_DONE
  3533                              <1> 	;
  3534 00003CA3 B27F                <1> 	mov	dl, 7Fh
  3535                              <1> hdc_reset1:
  3536 00003CA5 FEC2                <1> 	inc	dl
  3537                              <1> 	;; 31/12/2015
  3538                              <1> 	;;push	dx
  3539                              <1> 	;;push	cx
  3540                              <1> 	;;push	ds
  3541                              <1> 	;;sub	ax, ax
  3542                              <1> 	;;mov	ds, ax
  3543                              <1> 	;;MOV	AX, [TIMER_LOW]		; GET START TIMER COUNTS
  3544                              <1> 	;;pop	ds
  3545                              <1> 	;;MOV	BX,AX
  3546                              <1> 	;;ADD	AX,6*182		; 60 SECONDS* 18.2
  3547                              <1> 	;;MOV	CX,AX
  3548                              <1> 	;;mov	word [wait_count], 0	; 22/12/2014 (reset wait counter)
  3549                              <1> 	;;
  3550                              <1> 	;; 31/12/2014 - cancel HD_RESET_1
  3551                              <1> 	;;CALL	HD_RESET_1		; SET UP DRIVE 0, (1,2,3)
  3552                              <1> 	;;pop	cx
  3553                              <1> 	;;pop	dx
  3554                              <1> 	;;
  3555                              <1> 	; 18/01/2015
  3556 00003CA7 B40D                <1> 	mov	ah, 0Dh ; ALTERNATE RESET
  3557                              <1> 	;int	13h
  3558 00003CA9 E8A3FFFFFF          <1> 	call	int13h
  3559 00003CAE E2F5                <1> 	loop	hdc_reset1
  3560 00003CB0 F8                  <1> 	clc 	; 29/05/2016
  3561                              <1> POD_DONE:
  3562 00003CB1 C3                  <1> 	RETn
  3563                              <1> 
  3564                              <1> ;;-----	POD_ERROR
  3565                              <1> 
  3566                              <1> ;;CTL_ERRX:
  3567                              <1> ;	;MOV	SI,OFFSET F1782 	; CONTROLLER ERROR
  3568                              <1> ;	;CALL	SET_FAIL		; DO NOT IPL FROM DISK
  3569                              <1> ;	;CALL	E_MSG			; DISPLAY ERROR AND SET (BP) ERROR FLAG
  3570                              <1> ;	;JMP	short POD_DONE
  3571                              <1> 
  3572                              <1> ;;HD_RESET_1:
  3573                              <1> ;;	;PUSH	BX			; SAVE TIMER LIMITS
  3574                              <1> ;;	;PUSH	CX
  3575                              <1> ;;RES_1: MOV	AH,09H			; SET DRIVE PARAMETERS
  3576                              <1> ;;	INT	13H
  3577                              <1> ;;	JC	short RES_2
  3578                              <1> ;;	MOV	AH,11H			; RECALIBRATE DRIVE
  3579                              <1> ;;	INT	13H
  3580                              <1> ;;	JNC	short RES_CK		; DRIVE OK
  3581                              <1> ;;RES_2: ;CALL	POD_TCHK		; CHECK TIME OUT
  3582                              <1> ;;	cmp	word [wait_count], 6*182 ; waiting time (in timer ticks)
  3583                              <1> ;;					; (30 seconds)		
  3584                              <1> ;;	;cmc
  3585                              <1> ;;	;JNC	short RES_1
  3586                              <1> ;;	jb	short RES_1
  3587                              <1> ;;;RES_FL: ;MOV	SI,OFFSET F1781 	; INDICATE DISK 1 FAILURE;
  3588                              <1> ;;	;TEST	DL,1
  3589                              <1> ;;	;JNZ	RES_E1
  3590                              <1> ;;	;MOV	SI,OFFSET F1780 	; INDICATE DISK 0 FAILURE
  3591                              <1> ;;	;CALL	SET_FAIL		; DO NOT TRY TO IPL DISK 0
  3592                              <1> ;;	;JMP	SHORT RES_E1
  3593                              <1> ;;RES_ER: ; 22/12/2014
  3594                              <1> ;;RES_OK:
  3595                              <1> ;;	;POP	CX			; RESTORE TIMER LIMITS
  3596                              <1> ;;	;POP	BX
  3597                              <1> ;;	RETn
  3598                              <1> ;;
  3599                              <1> ;;RES_RS: MOV	AH,00H			; RESET THE DRIVE
  3600                              <1> ;;	INT	13H
  3601                              <1> ;;RES_CK: MOV	AH,08H			; GET MAX CYLINDER,HEAD,SECTOR
  3602                              <1> ;;	MOV	BL,DL			; SAVE DRIVE CODE
  3603                              <1> ;;	INT	13H
  3604                              <1> ;;	JC	short RES_ER
  3605                              <1> ;;	MOV	[NEC_STATUS],CX 	; SAVE MAX CYLINDER, SECTOR
  3606                              <1> ;;	MOV	DL,BL			; RESTORE DRIVE CODE
  3607                              <1> ;;RES_3: MOV	AX,0401H		; VERIFY THE LAST SECTOR
  3608                              <1> ;;	INT	13H
  3609                              <1> ;;	JNC	short RES_OK		; VERIFY OK
  3610                              <1> ;;	CMP	AH,BAD_SECTOR		; OK ALSO IF JUST ID READ
  3611                              <1> ;;	JE	short RES_OK
  3612                              <1> ;;	CMP	AH,DATA_CORRECTED
  3613                              <1> ;;	JE	short RES_OK
  3614                              <1> ;;	CMP	AH,BAD_ECC
  3615                              <1> ;;	JE	short RES_OK
  3616                              <1> ;;	;CALL	POD_TCHK		; CHECK FOR TIME OUT
  3617                              <1> ;;	cmp	word [wait_count], 6*182 ; waiting time (in timer ticks)
  3618                              <1> ;;					; (60 seconds)		
  3619                              <1> ;;	cmc
  3620                              <1> ;;	JC	short RES_ER		; FAILED
  3621                              <1> ;;	MOV	CX,[NEC_STATUS] 	; GET SECTOR ADDRESS, AND CYLINDER
  3622                              <1> ;;	MOV	AL,CL			; SEPARATE OUT SECTOR NUMBER
  3623                              <1> ;;	AND	AL,3FH
  3624                              <1> ;;	DEC	AL			; TRY PREVIOUS ONE
  3625                              <1> ;;	JZ	short RES_RS		; WE'VE TRIED ALL SECTORS ON TRACK
  3626                              <1> ;;	AND	CL,0C0H 		; KEEP CYLINDER BITS
  3627                              <1> ;;	OR	CL,AL			; MERGE SECTOR WITH CYLINDER BITS
  3628                              <1> ;;	MOV	[NEC_STATUS],CX 	; SAVE CYLINDER, NEW SECTOR NUMBER
  3629                              <1> ;;	JMP	short RES_3		; TRY AGAIN
  3630                              <1> ;;;RES_ER: MOV	SI,OFFSET F1791 	; INDICATE DISK 1 ERROR
  3631                              <1> ;;	;TEST	DL,1
  3632                              <1> ;;	;JNZ	short RES_E1
  3633                              <1> ;;	;MOV	SI,OFFSET F1790 	; INDICATE DISK 0 ERROR
  3634                              <1> ;;;RES_E1:
  3635                              <1> ;;	;CALL	E_MSG			; DISPLAY ERROR AND SET (BP) ERROR FLAG
  3636                              <1> ;;;RES_OK:
  3637                              <1> ;;	;POP	CX			; RESTORE TIMER LIMITS
  3638                              <1> ;;	;POP	BX
  3639                              <1> ;;	;RETn
  3640                              <1> ;
  3641                              <1> ;;SET_FAIL:
  3642                              <1> ;	;MOV	AX,X*(CMOS_DIAG+NMI)	; GET CMOS ERROR BYTE
  3643                              <1> ;	;CALL	CMOS_READ
  3644                              <1> ;	;OR	AL,HF_FAIL		; SET DO NOT IPL FROM DISK FLAG
  3645                              <1> ;	;XCHG	AH,AL			; SAVE IT
  3646                              <1> ;	;CALL	CMOS_WRITE		; PUT IT OUT
  3647                              <1> ;	;RETn
  3648                              <1> ;
  3649                              <1> ;;POD_TCHK:				; CHECK FOR 30 SECOND TIME OUT
  3650                              <1> ;	;POP	AX			; SAVE RETURN
  3651                              <1> ;	;POP	CX			; GET TIME OUT LIMITS
  3652                              <1> ;	;POP	BX
  3653                              <1> ;	;PUSH	BX			; AND SAVE THEM AGAIN
  3654                              <1> ;	;PUSH	CX
  3655                              <1> ;	;PUSH	AX
  3656                              <1> ;	;push	ds
  3657                              <1> ;	;xor	ax, ax
  3658                              <1> ;	;mov	ds, ax			; RESTORE RETURN
  3659                              <1> ;	;MOV	AX, [TIMER_LOW]		; AX = CURRENT TIME
  3660                              <1> ;	;				; BX = START TIME
  3661                              <1> ;	;				; CX = END TIME
  3662                              <1> ;	;pop	ds
  3663                              <1> ;	;CMP	BX,CX
  3664                              <1> ;	;JB	short TCHK1		; START < END
  3665                              <1> ;	;CMP	BX,AX
  3666                              <1> ;	;JB	short TCHKG		; END < START < CURRENT
  3667                              <1> ;	;JMP	SHORT TCHK2		; END, CURRENT < START
  3668                              <1> ;;TCHK1: CMP	AX,BX
  3669                              <1> ;;	JB	short TCHKNG		; CURRENT < START < END
  3670                              <1> ;;TCHK2: CMP	AX,CX
  3671                              <1> ;;	JB	short TCHKG		; START < CURRENT < END
  3672                              <1> ;;					; OR CURRENT < END < START
  3673                              <1> ;;TCHKNG: STC				; CARRY SET INDICATES TIME OUT
  3674                              <1> ;;	RETn
  3675                              <1> ;;TCHKG: CLC				; INDICATE STILL TIME
  3676                              <1> ;;	RETn
  3677                              <1> ;;
  3678                              <1> ;;int_13h:
  3679                              <1> 
  3680                              <1> ;----------------------------------------
  3681                              <1> ;	FIXED DISK BIOS ENTRY POINT	:
  3682                              <1> ;----------------------------------------
  3683                              <1> 
  3684                              <1> ; 01/06/2016
  3685                              <1> ; 29/05/2016 
  3686                              <1> ; 28/05/2016
  3687                              <1> ; 27/05/2016
  3688                              <1> ; 16/05/2016
  3689                              <1> ; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
  3690                              <1> int33h:  ; DISK I/O
  3691                              <1> 	; 29/05/2016
  3692 00003CB2 80642408FE          <1> 	and	byte [esp+8], 11111110b  ; clear carry bit of eflags register
  3693                              <1> 	; 16/05/2016
  3694 00003CB7 1E                  <1> 	push	ds
  3695 00003CB8 53                  <1> 	push	ebx ; user's buffer address (virtual)
  3696 00003CB9 66BB1000            <1> 	mov	bx, KDATA ; System (Kernel's) data segment
  3697 00003CBD 8EDB                <1> 	mov	ds, bx
  3698 00003CBF 8F05[282D0100]      <1> 	pop	dword [user_buffer] ; 01/06/2016
  3699 00003CC5 C605[6E260100]00    <1> 	mov	byte [scount], 0 ; sector count for transfer
  3700 00003CCC 80FC03              <1> 	cmp	ah, 03h ; chs write
  3701 00003CCF 7743                <1> 	ja	short int33h_2
  3702 00003CD1 7407                <1> 	je	short int33h_0
  3703 00003CD3 80FC02              <1> 	cmp	ah, 02h ; chs read
  3704 00003CD6 7269                <1> 	jb	short int33h_5
  3705 00003CD8 EB62                <1> 	jmp	short int33h_4
  3706                              <1> int33h_0:
  3707                              <1> 	; transfer user's buffer content to sector buffer
  3708 00003CDA 51                  <1> 	push	ecx
  3709 00003CDB 0FB6C8              <1> 	movzx	ecx, al
  3710                              <1> int33h_1:
  3711 00003CDE 56                  <1> 	push	esi
  3712 00003CDF 8B35[282D0100]      <1> 	mov	esi, [user_buffer]
  3713                              <1> 	; esi = user's buffer address (virtual, ebx)
  3714 00003CE5 57                  <1> 	push	edi
  3715 00003CE6 06                  <1> 	push	es
  3716 00003CE7 50                  <1> 	push	eax
  3717 00003CE8 66B81000            <1> 	mov	ax, KDATA
  3718 00003CEC 8EC0                <1> 	mov	es, ax
  3719 00003CEE BF00000700          <1> 	mov	edi, Cluster_Buffer
  3720 00003CF3 C1E109              <1> 	shl	ecx, 9 ; * 512
  3721 00003CF6 E89F9C0000          <1> 	call	transfer_from_user_buffer
  3722 00003CFB 58                  <1> 	pop	eax
  3723 00003CFC 07                  <1> 	pop	es
  3724 00003CFD 5F                  <1> 	pop	edi
  3725 00003CFE 5E                  <1> 	pop	esi
  3726 00003CFF 59                  <1> 	pop	ecx
  3727 00003D00 733F                <1> 	jnc	short int33h_5
  3728 00003D02 8B1D[282D0100]      <1> 	mov	ebx, [user_buffer] ; 01/06/2016
  3729 00003D08 1F                  <1> 	pop	ds
  3730                              <1> 
  3731                              <1> 	; (*) 29/05/2016
  3732                              <1> 	; (*) retf 4 ; skip eflags on stack
  3733                              <1> 
  3734                              <1> 	; 29/05/2016 -set carry flag on stack-
  3735                              <1> 	; [esp] = EIP
  3736                              <1> 	; [esp+4] = CS
  3737                              <1> 	; [esp+8] = E-FLAGS
  3738 00003D09 804C240801          <1> 	or	byte [esp+8], 1  ; set carry bit of eflags register
  3739                              <1> 	; [esp+12] = ESP (user)
  3740                              <1> 	; [esp+16] = SS (User)
  3741 00003D0E B8FF000000          <1> 	mov	eax, 0FFh ; Unknown error !?
  3742 00003D13 CF                  <1> 	iretd
  3743                              <1> 	
  3744                              <1> 	; (*) 29/05/2016 - 'ref 4' intruction causes to stack fault
  3745                              <1> 	; (OUTER-PRIVILEGE-LEVEL)
  3746                              <1> 	; INTEL 80386 PROGRAMMER'S REFERENCE MANUAL 1986
  3747                              <1> 	; // RETF instruction:
  3748                              <1> 	;
  3749                              <1> 	; IF OperandMode=32 THEN
  3750                              <1>  	;    Load CS:EIP from stack;
  3751                              <1>  	;    Set CS RPL to CPL;
  3752                              <1>  	;    Increment eSP by 8 plus the immediate offset if it exists;
  3753                              <1>  	;    Load SS:eSP from stack;
  3754                              <1>  	; ELSE (* OperandMode=16 *)
  3755                              <1>  	;    Load CS:IP from stack;
  3756                              <1>  	;    Set CS RPL to CPL;
  3757                              <1>  	;    Increment eSP by 4 plus the immediate offset if it exists;
  3758                              <1> 	;    Load SS:eSP from stack;
  3759                              <1>  	; FI;
  3760                              <1> 	;
  3761                              <1> 	; //
  3762                              <1> 
  3763                              <1> int33h_2:
  3764 00003D14 80FC05              <1> 	cmp	ah, 05h ; format track
  3765 00003D17 770A                <1> 	ja	short int33h_3
  3766 00003D19 7226                <1> 	jb	short int33h_5
  3767 00003D1B 51                  <1> 	push	ecx
  3768 00003D1C B901000000          <1> 	mov	ecx, 1
  3769 00003D21 EBBB                <1> 	jmp	short int33h_1
  3770                              <1> int33h_3:
  3771 00003D23 80FC1C              <1> 	cmp	ah, 1Ch ; LBA write
  3772 00003D26 7719                <1> 	ja	short int33h_5
  3773 00003D28 74B0                <1> 	je	short int33h_0
  3774 00003D2A 80FC1B              <1> 	cmp	ah, 1Bh ; LBA read
  3775 00003D2D 740D                <1> 	je	short int33h_4
  3776 00003D2F 80FC08              <1> 	cmp	ah, 08h ; get disk parameters
  3777 00003D32 750D                <1> 	jne	short int33h_5
  3778                              <1> 	; 01/06/2016
  3779 00003D34 8B1D[282D0100]      <1> 	mov	ebx, [user_buffer] ; user's buffer address
  3780 00003D3A EB0A                <1> 	jmp	short int33h_6
  3781                              <1> int33h_4:
  3782 00003D3C A2[6E260100]        <1> 	mov	byte [scount], al ; <= 128 sectors
  3783                              <1> int33h_5:
  3784 00003D41 BB00000700          <1> 	mov	ebx, Cluster_Buffer ; max. 65536 bytes
  3785                              <1> 				    ; buf. addr: 70000h	
  3786                              <1> 	;mov	byte [ClusterBuffer_Valid], 0
  3787                              <1> int33h_6:
  3788 00003D46 1F                  <1> 	pop	ds
  3789 00003D47 9C                  <1> 	pushfd
  3790 00003D48 0E                  <1> 	push 	cs
  3791 00003D49 E84B000000          <1> 	call 	DISK_IO
  3792 00003D4E 2E8B1D[282D0100]    <1> 	mov	ebx, [CS:user_buffer] ; 01/06/2016
  3793 00003D55 723C                <1> 	jc	short int33h_9
  3794                              <1> 	;
  3795 00003D57 2E803D[6E260100]00  <1> 	cmp	byte [CS:scount], 0
  3796 00003D5F 762C                <1> 	jna	short int33h_7
  3797                              <1> 	; transfer sector buffer content to user's buffer
  3798 00003D61 06                  <1> 	push	es
  3799 00003D62 1E                  <1> 	push	ds
  3800 00003D63 50                  <1> 	push	eax
  3801 00003D64 66B81000            <1> 	mov	ax, KDATA
  3802 00003D68 8ED8                <1> 	mov	ds, ax
  3803 00003D6A 8EC0                <1> 	mov	es, ax
  3804 00003D6C 51                  <1> 	push	ecx
  3805 00003D6D 56                  <1> 	push	esi
  3806 00003D6E 57                  <1> 	push	edi
  3807 00003D6F 0FB60D[6E260100]    <1> 	movzx	ecx, byte [scount]
  3808 00003D76 C1E109              <1> 	shl	ecx, 9 ; * 512 bytes
  3809 00003D79 89DF                <1> 	mov	edi, ebx ; user's buffer address
  3810 00003D7B BE00000700          <1> 	mov	esi, Cluster_Buffer
  3811 00003D80 E8CB9B0000          <1> 	call	transfer_to_user_buffer
  3812 00003D85 5F                  <1> 	pop	edi
  3813 00003D86 5E                  <1> 	pop	esi
  3814 00003D87 59                  <1> 	pop	ecx
  3815 00003D88 58                  <1> 	pop	eax
  3816 00003D89 1F                  <1> 	pop	ds
  3817 00003D8A 07                  <1> 	pop	es
  3818 00003D8B 7201                <1> 	jc	short int33h_8
  3819                              <1> int33h_7:
  3820                              <1> 	; cf = 0  ; use eflags which is in stack
  3821 00003D8D CF                  <1> 	iretd	
  3822                              <1> int33h_8:
  3823 00003D8E B8FF000000          <1> 	mov	eax, 0FFh ; Unknown error !?
  3824                              <1> int33h_9:
  3825                              <1> 	; cf = 1
  3826                              <1> 
  3827                              <1> 	; (*) 29/05/2016	
  3828                              <1> 	; (*) retf 4 ; skip eflags on stack
  3829                              <1> 	; Note: This 'retf 4' was wrong, -it was causing
  3830                              <1> 	;       to stack errors in ring 3-
  3831                              <1> 	;	POP sequence of 'retf 4' is as
  3832                              <1> 	;       "eip, cs, eflags, esp, ss, +4 bytes" 
  3833                              <1>         ;       it is not as "eip, cs, +4 bytes, esp, ss" ! 
  3834                              <1> 
  3835                              <1> 	; 29/05/2016 -set carry flag on stack-
  3836 00003D93 804C240801          <1> 	or	byte [esp+8], 1  ; set carry bit of eflags register
  3837 00003D98 CF                  <1> 	iretd
  3838                              <1> 
  3839                              <1> ; 29/05/2016
  3840                              <1> ; 27/05/2016 - TRDOS 386 (TRDOS v2.0)
  3841                              <1> 
  3842                              <1> DISK_IO:
  3843 00003D99 80FA80              <1> 	CMP	DL,80H			; TEST FOR FIXED DISK DRIVE
  3844                              <1> 	;JAE	short A1		; YES, HANDLE HERE
  3845                              <1> 	;;;INT	40H			; DISKETTE HANDLER
  3846                              <1> 	;;call	int40h
  3847 00003D9C 0F8224F0FFFF        <1> 	jb	DISKETTE_IO_1
  3848                              <1> ;RET_2:
  3849                              <1> 	;RETf	2			; BACK TO CALLER
  3850                              <1> ;	retf	4
  3851                              <1> A1:
  3852 00003DA2 FB                  <1> 	STI				; ENABLE INTERRUPTS
  3853                              <1> 	;; 04/01/2015
  3854                              <1> 	;;OR	AH,AH
  3855                              <1> 	;;JNZ	short A2
  3856                              <1> 	;;INT	40H			; RESET NEC WHEN AH=0
  3857                              <1> 	;;SUB	AH,AH
  3858 00003DA3 80FA83              <1> 	CMP	DL,(80H + S_MAX_FILE - 1)
  3859                              <1> 	;JA	short RET_2
  3860 00003DA6 7616                <1> 	jna	short _A0
  3861                              <1> 	; 29/05/2016
  3862 00003DA8 1E                  <1> 	push	ds
  3863 00003DA9 6650                <1> 	push	ax
  3864 00003DAB 66B81000            <1> 	mov	ax, KDATA
  3865 00003DAF 8ED8                <1> 	mov	ds, ax
  3866 00003DB1 6658                <1> 	pop	ax
  3867 00003DB3 B4AA                <1>         mov     ah, 0AAh        ; Hard disk drive not ready !
  3868                              <1> 				; (Programmer's guide to AMIBIOS, 1992)
  3869 00003DB5 8825[43200100]      <1> 	mov     byte [DISK_STATUS1], ah
  3870 00003DBB 1F                  <1> 	pop	ds
  3871 00003DBC EB38                <1> 	jmp	short RET_2
  3872                              <1> _A0:
  3873                              <1> 	; 18/01/2015
  3874 00003DBE 08E4                <1> 	or	ah,ah
  3875 00003DC0 743A                <1> 	jz	short A4
  3876 00003DC2 80FC0D              <1> 	cmp	ah, 0Dh	; Alternate reset
  3877 00003DC5 7504                <1> 	jne	short A2
  3878 00003DC7 28E4                <1> 	sub	ah,ah	; Reset
  3879 00003DC9 EB31                <1> 	jmp	short A4
  3880                              <1> A2:
  3881 00003DCB 80FC08              <1> 	CMP	AH,08H			; GET PARAMETERS IS A SPECIAL CASE
  3882                              <1> 	;JNZ	short A3
  3883                              <1>         ;JMP    GET_PARM_N
  3884 00003DCE 0F8431030000        <1> 	je	GET_PARM_N
  3885 00003DD4 80FC15              <1> A3:	CMP	AH,15H			; READ DASD TYPE IS ALSO
  3886                              <1> 	;JNZ	short A4
  3887                              <1>         ;JMP    READ_DASD_TYPE
  3888 00003DD7 0F84DA020000        <1>         je      READ_DASD_TYPE
  3889                              <1> 	; 02/02/2015
  3890 00003DDD 80FC1D              <1> 	cmp	ah, 1Dh			;(Temporary for Retro UNIX 386 v1)
  3891                              <1> 	; 12/01/2015
  3892 00003DE0 F5                  <1> 	cmc
  3893 00003DE1 7319                <1> 	jnc	short A4
  3894                              <1> int33h_bad_cmd:
  3895                              <1> 	; 16/05/2016
  3896                              <1> 	; 30/01/2015
  3897                              <1> 	; 29/05/2016
  3898 00003DE3 1E                  <1> 	push	ds
  3899 00003DE4 6650                <1> 	push	ax
  3900 00003DE6 66B81000            <1> 	mov	ax, KDATA
  3901 00003DEA 8ED8                <1> 	mov	ds, ax
  3902 00003DEC 6658                <1> 	pop	ax
  3903 00003DEE B401                <1> 	mov	ah, BAD_CMD
  3904 00003DF0 8825[43200100]      <1> 	mov     [DISK_STATUS1], ah ; BAD_CMD  ; COMMAND ERROR
  3905                              <1>         ;jmp	short RET_2
  3906                              <1> RET_2:
  3907                              <1> 	; (*) 29/05/2016
  3908                              <1> 	; (*) retf 4
  3909 00003DF6 804C240801          <1> 	or	byte [esp+8], 1 ; set carry bit of eflags register
  3910 00003DFB CF                  <1> 	iretd
  3911                              <1> A4:					; SAVE REGISTERS DURING OPERATION
  3912 00003DFC C8080000            <1> 	ENTER	8,0			; SAVE (BP) AND MAKE ROOM FOR @CMD_BLOCK
  3913 00003E00 53                  <1> 	PUSH	eBX			;  IN THE STACK, THE COMMAND BLOCK IS:
  3914 00003E01 51                  <1> 	PUSH	eCX			;   @CMD_BLOCK == BYTE PTR [BP]-8
  3915 00003E02 52                  <1> 	PUSH	eDX
  3916 00003E03 1E                  <1> 	PUSH	DS
  3917 00003E04 06                  <1> 	PUSH	ES
  3918 00003E05 56                  <1> 	PUSH	eSI
  3919 00003E06 57                  <1> 	PUSH	eDI
  3920                              <1> 	;;04/01/2015
  3921                              <1> 	;;OR	AH,AH			; CHECK FOR RESET
  3922                              <1> 	;;JNZ	short A5
  3923                              <1> 	;;MOV	DL,80H			; FORCE DRIVE 80 FOR RESET
  3924                              <1> ;;A5:	
  3925                              <1> 	;push	cs
  3926                              <1> 	;pop	ds
  3927                              <1> 	; 21/02/2015
  3928 00003E07 6650                <1> 	push	ax
  3929 00003E09 66B81000            <1> 	mov	ax, KDATA
  3930 00003E0D 8ED8                <1> 	mov	ds, ax
  3931 00003E0F 8EC0                <1> 	mov	es, ax	
  3932 00003E11 6658                <1> 	pop	ax
  3933 00003E13 E88D000000          <1> 	CALL	DISK_IO_CONT		; PERFORM THE OPERATION
  3934                              <1> 	;;CALL	DDS			; ESTABLISH SEGMENT
  3935 00003E18 8A25[43200100]      <1> 	MOV	AH,[DISK_STATUS1]	; GET STATUS FROM OPERATION
  3936                              <1> 	;(*) CMP AH,1			; SET THE CARRY FLAG TO INDICATE
  3937                              <1> 	;(*) CMC			; SUCCESS OR FAILURE
  3938 00003E1E 5F                  <1> 	POP	eDI			; RESTORE REGISTERS
  3939 00003E1F 5E                  <1> 	POP	eSI
  3940 00003E20 07                  <1>         POP     ES
  3941 00003E21 1F                  <1>         POP     DS
  3942 00003E22 5A                  <1> 	POP	eDX
  3943 00003E23 59                  <1> 	POP	eCX
  3944 00003E24 5B                  <1> 	POP	eBX
  3945 00003E25 C9                  <1> 	LEAVE				; ADJUST (SP) AND RESTORE (BP)
  3946                              <1> 	;RETf	2			; THROW AWAY SAVED FLAGS
  3947                              <1> 	; (*) 29/05/2016
  3948                              <1> 	; (*) retf 4
  3949 00003E26 80FC01              <1> 	cmp	ah, 1
  3950 00003E29 7205                <1> 	jc	short _A5 
  3951 00003E2B 804C240801          <1> 	or	byte [esp+8], 1 ; set carry bit of eflags register
  3952                              <1> _A5:
  3953 00003E30 CF                  <1> 	iretd
  3954                              <1> 
  3955                              <1> ; 21/02/2015
  3956                              <1> ;       dw --> dd
  3957                              <1> D1:					; FUNCTION TRANSFER TABLE
  3958 00003E31 [F33F0000]          <1> 	dd	DISK_RESET		; 000H
  3959 00003E35 [6A400000]          <1> 	dd	RETURN_STATUS		; 001H
  3960 00003E39 [77400000]          <1> 	dd	DISK_READ		; 002H
  3961 00003E3D [80400000]          <1> 	dd	DISK_WRITE		; 003H
  3962 00003E41 [89400000]          <1> 	dd	DISK_VERF		; 004H
  3963 00003E45 [A1400000]          <1> 	dd	FMT_TRK 		; 005H
  3964 00003E49 [E93F0000]          <1> 	dd	BAD_COMMAND		; 006H	FORMAT BAD SECTORS
  3965 00003E4D [E93F0000]          <1> 	dd	BAD_COMMAND		; 007H	FORMAT DRIVE
  3966 00003E51 [E93F0000]          <1> 	dd	BAD_COMMAND		; 008H	RETURN PARAMETERS
  3967 00003E55 [8C410000]          <1> 	dd	INIT_DRV		; 009H
  3968 00003E59 [EB410000]          <1> 	dd	RD_LONG 		; 00AH
  3969 00003E5D [F4410000]          <1> 	dd	WR_LONG 		; 00BH
  3970 00003E61 [FD410000]          <1> 	dd	DISK_SEEK		; 00CH
  3971 00003E65 [F33F0000]          <1> 	dd	DISK_RESET		; 00DH
  3972 00003E69 [E93F0000]          <1> 	dd	BAD_COMMAND		; 00EH	READ BUFFER
  3973 00003E6D [E93F0000]          <1> 	dd	BAD_COMMAND		; 00FH	WRITE BUFFER
  3974 00003E71 [25420000]          <1> 	dd	TST_RDY 		; 010H
  3975 00003E75 [49420000]          <1> 	dd	HDISK_RECAL		; 011H
  3976 00003E79 [E93F0000]          <1> 	dd	BAD_COMMAND		; 012H	MEMORY DIAGNOSTIC
  3977 00003E7D [E93F0000]          <1> 	dd	BAD_COMMAND		; 013H	DRIVE DIAGNOSTIC
  3978 00003E81 [7F420000]          <1> 	dd	CTLR_DIAGNOSTIC 	; 014H	CONTROLLER DIAGNOSTIC
  3979                              <1> 	; 02/02/2015 (Temporary - Retro UNIX 386 v1 - DISK I/O test)
  3980 00003E85 [E93F0000]          <1> 	dd	BAD_COMMAND		; 015h
  3981 00003E89 [E93F0000]          <1> 	dd	BAD_COMMAND		; 016h
  3982 00003E8D [E93F0000]          <1> 	dd	BAD_COMMAND		; 017h
  3983 00003E91 [E93F0000]          <1> 	dd	BAD_COMMAND		; 018h
  3984 00003E95 [E93F0000]          <1> 	dd	BAD_COMMAND		; 019h
  3985 00003E99 [E93F0000]          <1> 	dd	BAD_COMMAND		; 01Ah
  3986 00003E9D [77400000]          <1> 	dd	DISK_READ		; 01Bh ; LBA read
  3987 00003EA1 [80400000]          <1> 	dd	DISK_WRITE		; 01Ch ; LBA write
  3988                              <1> D1L     EQU    $ - D1
  3989                              <1> 
  3990                              <1> DISK_IO_CONT:
  3991                              <1> 	;;CALL	DDS			; ESTABLISH SEGMENT
  3992 00003EA5 80FC01              <1> 	CMP	AH,01H			; RETURN STATUS
  3993                              <1> 	;;JNZ	short SU0
  3994                              <1>         ;;JMP    RETURN_STATUS
  3995 00003EA8 0F84BC010000        <1> 	je	RETURN_STATUS
  3996                              <1> SU0:
  3997 00003EAE C605[43200100]00    <1> 	MOV	byte [DISK_STATUS1],0 	; RESET THE STATUS INDICATOR
  3998                              <1> 	;;PUSH	BX			; SAVE DATA ADDRESS
  3999                              <1> 	;mov	si, bx ;; 14/02/2015
  4000 00003EB5 89DE                <1> 	mov	esi, ebx ; 21/02/2015
  4001 00003EB7 8A1D[44200100]      <1> 	MOV	BL,[HF_NUM]		; GET NUMBER OF DRIVES
  4002                              <1> 	;; 04/01/2015
  4003                              <1> 	;;PUSH	AX
  4004 00003EBD 80E27F              <1> 	AND	DL,7FH			; GET DRIVE AS 0 OR 1
  4005                              <1> 					; (get drive number as 0 to 3)
  4006 00003EC0 38D3                <1> 	CMP	BL,DL
  4007                              <1>         ;;JBE   BAD_COMMAND_POP         ; INVALID DRIVE
  4008 00003EC2 0F8621010000        <1>         jbe     BAD_COMMAND ;; 14/02/2015
  4009                              <1>         ;
  4010                              <1> 	;;03/01/2015
  4011 00003EC8 29DB                <1> 	sub	ebx, ebx
  4012 00003ECA 88D3                <1> 	mov	bl, dl
  4013                              <1> 	;sub	bh, bh
  4014 00003ECC 883D[58200100]      <1> 	mov	[LBAMode], bh 	; 0
  4015                              <1> 	;;test	byte [bx+hd0_type], 1	; LBA ready ?
  4016                              <1> 	;test	byte [ebx+hd0_type], 1
  4017                              <1> 	;jz	short su1		; no
  4018                              <1> 	;inc	byte [LBAMode]
  4019                              <1> ;su1:
  4020                              <1> 	; 21/02/2015 (32 bit modification)
  4021                              <1> 	;04/01/2015
  4022 00003ED2 6650                <1> 	push	ax ; ***
  4023                              <1> 	;PUSH	ES ; **
  4024 00003ED4 6652                <1> 	PUSH	DX ; *
  4025 00003ED6 6650                <1> 	push	ax
  4026 00003ED8 E888060000          <1> 	CALL	GET_VEC 		; GET DISK PARAMETERS
  4027                              <1> 	; 02/02/2015
  4028                              <1> 	;mov	ax, [ES:BX+16] ; I/O port base address (1F0h, 170h)
  4029 00003EDD 668B4310            <1> 	mov	ax, [ebx+16]
  4030 00003EE1 66A3[EEEC0000]      <1> 	mov	[HF_PORT], ax
  4031                              <1> 	;mov	dx, [ES:BX+18] ; control port address (3F6h, 376h)
  4032 00003EE7 668B5312            <1> 	mov	dx, [ebx+18]
  4033 00003EEB 668915[F0EC0000]    <1> 	mov	[HF_REG_PORT], dx
  4034                              <1> 	;mov	al, [ES:BX+20] ; head register upper nibble (A0h,B0h,E0h,F0h)
  4035 00003EF2 8A4314              <1> 	mov	al, [ebx+20]
  4036                              <1> 	; 23/02/2015
  4037 00003EF5 A840                <1> 	test	al, 40h	 ; LBA bit (bit 6)
  4038 00003EF7 7406                <1> 	jz 	short su1
  4039 00003EF9 FE05[58200100]      <1> 	inc	byte [LBAMode] ; 1 
  4040                              <1> su1: 	 
  4041 00003EFF C0E804              <1> 	shr 	al, 4
  4042 00003F02 2401                <1> 	and	al, 1			
  4043 00003F04 A2[F2EC0000]        <1> 	mov	[hf_m_s], al 
  4044                              <1> 	;
  4045                              <1> 	; 03/01/2015
  4046                              <1> 	;MOV	AL,byte [ES:BX+8]	; GET CONTROL BYTE MODIFIER
  4047 00003F09 8A4308              <1> 	mov	al, [ebx+8]
  4048                              <1> 	;MOV	DX,[HF_REG_PORT]	; Device Control register	
  4049 00003F0C EE                  <1> 	OUT	DX,AL			; SET EXTRA HEAD OPTION
  4050                              <1> 					; Control Byte:  (= 08h, here)
  4051                              <1> 					; bit 0 - 0
  4052                              <1> 					; bit 1 - nIEN (1 = disable irq)
  4053                              <1> 					; bit 2 - SRST (software RESET)
  4054                              <1> 					; bit 3 - use extra heads (8 to 15)
  4055                              <1> 					;         -always set to 1-	
  4056                              <1> 					; (bits 3 to 7 are reserved
  4057                              <1> 					;          for ATA devices)
  4058 00003F0D 8A25[45200100]      <1> 	MOV	AH,[CONTROL_BYTE]	; SET EXTRA HEAD OPTION IN
  4059 00003F13 80E4C0              <1> 	AND	AH,0C0H 		; CONTROL BYTE
  4060 00003F16 08C4                <1> 	OR	AH,AL
  4061 00003F18 8825[45200100]      <1> 	MOV	[CONTROL_BYTE],AH	
  4062                              <1> 	; 04/01/2015
  4063 00003F1E 6658                <1> 	pop	ax
  4064 00003F20 665A                <1> 	pop	dx ; * ;; 14/02/2015
  4065 00003F22 20E4                <1> 	and	ah, ah	; Reset function ?
  4066 00003F24 7507                <1> 	jnz	short su2
  4067                              <1> 	;;pop	dx ; * ;; 14/02/2015
  4068                              <1> 	;pop	es ; **
  4069 00003F26 6658                <1> 	pop	ax ; ***
  4070                              <1> 	;;pop	bx
  4071 00003F28 E9C6000000          <1>         jmp     DISK_RESET
  4072                              <1> su2:
  4073 00003F2D 803D[58200100]00    <1> 	cmp	byte [LBAMode], 0
  4074 00003F34 7661                <1> 	jna	short su3
  4075                              <1> 	;
  4076                              <1> 	; 02/02/2015 (LBA read/write function calls)
  4077 00003F36 80FC1B              <1> 	cmp	ah, 1Bh
  4078 00003F39 720B                <1> 	jb	short lbarw1
  4079 00003F3B 80FC1C              <1> 	cmp	ah, 1Ch
  4080 00003F3E 775C                <1> 	ja 	short invldfnc
  4081                              <1> 	;;pop	dx ; * ; 14/02/2015
  4082                              <1> 	;mov	ax, cx ; Lower word of LBA address (bits 0-15)
  4083 00003F40 89C8                <1> 	mov	eax, ecx ; LBA address (21/02/2015)
  4084                              <1> 	;; 14/02/2015
  4085 00003F42 88D1                <1> 	mov	cl, dl ; 14/02/2015
  4086                              <1> 	;;mov	dx, bx
  4087                              <1> 	;mov	dx, si ; higher word of LBA address (bits 16-23)
  4088                              <1> 	;;mov	bx, di
  4089                              <1> 	;mov	si, di ; Buffer offset
  4090 00003F44 EB31                <1> 	jmp	short lbarw2
  4091                              <1> lbarw1:
  4092                              <1> 	; convert CHS to LBA
  4093                              <1> 	;
  4094                              <1> 	; LBA calculation - AWARD BIOS - 1999 - AHDSK.ASM
  4095                              <1> 	; LBA = "# of Heads" * Sectors/Track * Cylinder + Head * Sectors/Track
  4096                              <1> 	;	+ Sector - 1
  4097 00003F46 6652                <1> 	push	dx ; * ;; 14/02/2015
  4098                              <1> 	;xor	dh, dh
  4099 00003F48 31D2                <1> 	xor	edx, edx
  4100                              <1> 	;mov	dl, [ES:BX+14]	; sectors per track (logical)
  4101 00003F4A 8A530E              <1> 	mov	dl, [ebx+14]
  4102                              <1> 	;xor	ah, ah
  4103 00003F4D 31C0                <1> 	xor	eax, eax
  4104                              <1> 	;mov	al, [ES:BX+2]	; heads (logical) 	
  4105 00003F4F 8A4302              <1> 	mov	al, [ebx+2]
  4106 00003F52 FEC8                <1> 	dec	al
  4107 00003F54 6640                <1> 	inc	ax		; 0 =  256
  4108 00003F56 66F7E2              <1> 	mul 	dx
  4109                              <1> 		; AX = # of Heads" * Sectors/Track
  4110 00003F59 6689CA              <1> 	mov	dx, cx
  4111                              <1> 	;and	cx, 3Fh	 ; sector  (1 to 63)
  4112 00003F5C 83E13F              <1> 	and	ecx, 3fh
  4113 00003F5F 86D6                <1> 	xchg	dl, dh
  4114 00003F61 C0EE06              <1> 	shr	dh, 6
  4115                              <1> 		; DX = cylinder (0 to 1023)
  4116                              <1> 	;mul 	dx
  4117                              <1> 		; DX:AX = # of Heads" * Sectors/Track * Cylinder
  4118 00003F64 F7E2                <1> 	mul	edx
  4119 00003F66 FEC9                <1> 	dec	cl  ; sector - 1
  4120                              <1> 	;add	ax, cx
  4121                              <1> 	;adc	dx, 0
  4122                              <1> 		; DX:AX = # of Heads" * Sectors/Track * Cylinder + Sector -1
  4123 00003F68 01C8                <1> 	add	eax, ecx
  4124 00003F6A 6659                <1> 	pop	cx ; * ; ch = head, cl = drive number (zero based)
  4125                              <1> 	;push	dx
  4126                              <1> 	;push	ax
  4127 00003F6C 50                  <1> 	push	eax
  4128                              <1> 	;mov	al, [ES:BX+14]	; sectors per track (logical)	
  4129 00003F6D 8A430E              <1> 	mov	al, [ebx+14]
  4130 00003F70 F6E5                <1> 	mul	ch
  4131                              <1> 		;  AX = Head * Sectors/Track
  4132 00003F72 6699                <1>         cwd
  4133                              <1> 	;pop	dx
  4134 00003F74 5A                  <1> 	pop	edx
  4135                              <1> 	;add	ax, dx
  4136                              <1> 	;pop	dx
  4137                              <1> 	;adc	dx, 0 ; add carry bit
  4138 00003F75 01D0                <1> 	add	eax, edx
  4139                              <1> lbarw2:
  4140 00003F77 29D2                <1> 	sub	edx, edx ; 21/02/2015
  4141 00003F79 88CA                <1> 	mov	dl, cl ; 21/02/2015
  4142 00003F7B C645F800            <1>         mov     byte [CMD_BLOCK], 0 ; Features Register
  4143                              <1> 				; NOTE: Features register (1F1h, 171h)
  4144                              <1> 				; is not used for ATA device R/W functions. 
  4145                              <1> 				; It is old/obsolete 'write precompensation'
  4146                              <1> 				; register and error register
  4147                              <1> 				; for old ATA/IDE devices.
  4148                              <1> 	; 18/01/2014
  4149                              <1> 	;mov	ch, [hf_m_s]	; Drive 0 (master) or 1 (slave)
  4150 00003F7F 8A0D[F2EC0000]      <1> 	mov	cl, [hf_m_s]
  4151                              <1> 	;shl	ch, 4		; bit 4 (drive bit)
  4152                              <1> 	;or	ch, 0E0h	; bit 5 = 1
  4153                              <1> 				; bit 6 = 1 = LBA mode
  4154                              <1> 				; bit 7 = 1
  4155 00003F85 80C90E              <1> 	or	cl, 0Eh ; 1110b
  4156                              <1> 	;and	dh, 0Fh		; LBA byte 4 (bits 24 to 27)
  4157 00003F88 25FFFFFF0F          <1> 	and	eax, 0FFFFFFFh
  4158 00003F8D C1E11C              <1> 	shl	ecx, 28 ; 21/02/2015
  4159                              <1> 	;or	dh, ch
  4160 00003F90 09C8                <1> 	or	eax, ecx	
  4161                              <1> 	;;mov	[CMD_BLOCK+2], al ; LBA byte 1 (bits 0 to 7)
  4162                              <1> 				  ; (Sector Number Register)
  4163                              <1> 	;;mov	[CMD_BLOCK+3], ah ; LBA byte 2 (bits 8 to 15)
  4164                              <1> 				  ; (Cylinder Low Register)
  4165                              <1> 	;mov	[CMD_BLOCK+2], ax ; LBA byte 1, 2
  4166                              <1> 	;mov	[CMD_BLOCK+4], dl ; LBA byte 3 (bits 16 to 23)
  4167                              <1> 				  ; (Cylinder High Register)
  4168                              <1> 	;;mov	[CMD_BLOCK+5], dh ; LBA byte 4 (bits 24 to 27)
  4169                              <1> 				  ; (Drive/Head Register)
  4170                              <1> 	
  4171                              <1> 	;mov	[CMD_BLOCK+4], dx ; LBA byte 4, LBA & DEV select bits
  4172 00003F92 8945FA              <1> 	mov	[CMD_BLOCK+2], eax ; 21/02/2015
  4173                              <1> 	;14/02/2015
  4174                              <1> 	;mov	dl, cl ; Drive number (INIT_DRV)		
  4175 00003F95 EB38                <1> 	jmp	short su4
  4176                              <1> su3:
  4177                              <1> 	; 02/02/2015 
  4178                              <1> 	; (Temporary functions 1Bh & 1Ch are not valid for CHS mode) 
  4179 00003F97 80FC14              <1> 	cmp 	ah, 14h
  4180 00003F9A 7604                <1> 	jna 	short chsfnc
  4181                              <1> invldfnc:
  4182                              <1>         ; 14/02/2015  
  4183                              <1> 	;pop	es ; **
  4184 00003F9C 6658                <1>         pop     ax ; ***
  4185                              <1>         ;jmp     short BAD_COMMAND_POP
  4186 00003F9E EB49                <1>         jmp     short BAD_COMMAND
  4187                              <1> chsfnc:	
  4188                              <1> 	;MOV	AX,[ES:BX+5]		; GET WRITE PRE-COMPENSATION CYLINDER
  4189 00003FA0 668B4305            <1> 	mov	ax, [ebx+5]
  4190 00003FA4 66C1E802            <1> 	SHR	AX,2
  4191 00003FA8 8845F8              <1> 	MOV	[CMD_BLOCK],AL
  4192                              <1> 	;;MOV	AL,[ES:BX+8]		; GET CONTROL BYTE MODIFIER
  4193                              <1> 	;;PUSH	DX
  4194                              <1> 	;;MOV	DX,[HF_REG_PORT]
  4195                              <1> 	;;OUT	DX,AL			; SET EXTRA HEAD OPTION
  4196                              <1> 	;;POP	DX ; * 
  4197                              <1> 	;;POP	ES ; **
  4198                              <1> 	;;MOV	AH,[CONTROL_BYTE]	; SET EXTRA HEAD OPTION IN
  4199                              <1> 	;;AND	AH,0C0H 		; CONTROL BYTE	
  4200                              <1> 	;;OR	AH,AL
  4201                              <1> 	;;MOV	[CONTROL_BYTE],AH
  4202                              <1> 	;
  4203 00003FAB 88C8                <1> 	MOV	AL,CL			; GET SECTOR NUMBER
  4204 00003FAD 243F                <1> 	AND	AL,3FH
  4205 00003FAF 8845FA              <1> 	MOV	[CMD_BLOCK+2],AL
  4206 00003FB2 886DFB              <1> 	MOV	[CMD_BLOCK+3],CH 	; GET CYLINDER NUMBER
  4207 00003FB5 88C8                <1> 	MOV	AL,CL
  4208 00003FB7 C0E806              <1> 	SHR	AL,6
  4209 00003FBA 8845FC              <1> 	MOV	[CMD_BLOCK+4],AL 	; CYLINDER HIGH ORDER 2 BITS
  4210                              <1> 	;;05/01/2015
  4211                              <1> 	;;MOV	AL,DL			; DRIVE NUMBER
  4212 00003FBD A0[F2EC0000]        <1> 	mov	al, [hf_m_s]
  4213 00003FC2 C0E004              <1> 	SHL	AL,4
  4214 00003FC5 80E60F              <1> 	AND	DH,0FH			; HEAD NUMBER
  4215 00003FC8 08F0                <1> 	OR	AL,DH
  4216                              <1> 	;OR	AL,80H or 20H
  4217 00003FCA 0CA0                <1> 	OR	AL,80h+20h		; ECC AND 512 BYTE SECTORS
  4218 00003FCC 8845FD              <1> 	MOV	[CMD_BLOCK+5],AL 	; ECC/SIZE/DRIVE/HEAD
  4219                              <1> su4:
  4220                              <1> 	;POP	ES ; **
  4221                              <1>         ;; 14/02/2015
  4222                              <1>         ;;POP   AX
  4223                              <1>         ;;MOV   [CMD_BLOCK+1],AL        ; SECTOR COUNT
  4224                              <1>         ;;PUSH  AX
  4225                              <1>         ;;MOV   AL,AH                   ; GET INTO LOW BYTE
  4226                              <1>         ;;XOR   AH,AH                   ; ZERO HIGH BYTE
  4227                              <1>         ;;SAL   AX,1                    ; *2 FOR TABLE LOOKUP
  4228 00003FCF 6658                <1>         pop     ax ; ***
  4229 00003FD1 8845F9              <1>         mov     [CMD_BLOCK+1], al
  4230 00003FD4 29DB                <1>         sub	ebx, ebx
  4231 00003FD6 88E3                <1> 	mov     bl, ah
  4232                              <1>         ;xor     bh, bh
  4233                              <1>         ;sal     bx, 1
  4234 00003FD8 66C1E302            <1>         sal	bx, 2	; 32 bit offset (21/02/2015)
  4235                              <1> 	;;MOV   SI,AX                   ; PUT INTO SI FOR BRANCH
  4236                              <1>         ;;CMP   AX,D1L                  ; TEST WITHIN RANGE
  4237                              <1>         ;;JNB   short BAD_COMMAND_POP
  4238                              <1>         ;cmp     bx, D1L
  4239 00003FDC 83FB74              <1> 	cmp	ebx, D1L
  4240 00003FDF 7308                <1> 	jnb	short BAD_COMMAND
  4241                              <1>         ;xchg    bx, si
  4242 00003FE1 87DE                <1>         xchg	ebx, esi
  4243                              <1> 	;;;POP	AX			; RESTORE AX
  4244                              <1> 	;;;POP	BX			; AND DATA ADDRESS
  4245                              <1> 	
  4246                              <1> 	;;PUSH	CX
  4247                              <1> 	;;PUSH	AX			; ADJUST ES:BX
  4248                              <1> 	;MOV	CX,BX			; GET 3 HIGH ORDER NIBBLES OF BX
  4249                              <1> 	;SHR	CX,4
  4250                              <1> 	;MOV	AX,ES
  4251                              <1> 	;ADD	AX,CX
  4252                              <1> 	;MOV	ES,AX
  4253                              <1> 	;AND	BX,000FH		; ES:BX CHANGED TO ES:000X
  4254                              <1> 	;;POP	AX
  4255                              <1> 	;;POP	CX
  4256                              <1> 	;;JMP	word [CS:SI+D1]
  4257                              <1> 	;jmp	word [SI+D1]
  4258 00003FE3 FFA6[313E0000]      <1> 	jmp	dword [esi+D1]
  4259                              <1> ;;BAD_COMMAND_POP:
  4260                              <1> ;;	POP	AX
  4261                              <1> ;;	POP	BX
  4262                              <1> BAD_COMMAND:
  4263 00003FE9 C605[43200100]01    <1>         MOV     byte [DISK_STATUS1],BAD_CMD  ; COMMAND ERROR
  4264 00003FF0 B000                <1> 	MOV	AL,0
  4265 00003FF2 C3                  <1> 	RETn
  4266                              <1> 
  4267                              <1> ;----------------------------------------
  4268                              <1> ;	RESET THE DISK SYSTEM  (AH=00H) :
  4269                              <1> ;----------------------------------------
  4270                              <1> 
  4271                              <1> ; 18-1-2015 : one controller reset (not other one)
  4272                              <1> 
  4273                              <1> DISK_RESET:
  4274 00003FF3 FA                  <1> 	CLI
  4275 00003FF4 E4A1                <1> 	IN	AL,INTB01		; GET THE MASK REGISTER
  4276                              <1> 	;JMP	$+2
  4277                              <1> 	IODELAY
  4277 00003FF6 EB00                <2>  jmp short $+2
  4277 00003FF8 EB00                <2>  jmp short $+2
  4278                              <1> 	;AND	AL,0BFH 		; ENABLE FIXED DISK INTERRUPT
  4279 00003FFA 243F                <1> 	and	al,3Fh			; 22/12/2014 (IRQ 14 & IRQ 15)
  4280 00003FFC E6A1                <1> 	OUT	INTB01,AL
  4281 00003FFE FB                  <1> 	STI				; START INTERRUPTS
  4282                              <1> 	; 14/02/2015
  4283 00003FFF 6689D7              <1> 	mov	di, dx	
  4284                              <1> 	; 04/01/2015
  4285                              <1> 	;xor	di,di
  4286                              <1> drst0:
  4287 00004002 B004                <1> 	MOV	AL,04H  ; bit 2 - SRST 
  4288                              <1> 	;MOV	DX,HF_REG_PORT
  4289 00004004 668B15[F0EC0000]    <1> 	MOV	DX,[HF_REG_PORT]
  4290 0000400B EE                  <1> 	OUT	DX,AL			; RESET
  4291                              <1> ;	MOV	CX,10			; DELAY COUNT
  4292                              <1> ;DRD:	DEC	CX
  4293                              <1> ;	JNZ	short DRD		; WAIT 4.8 MICRO-SEC
  4294                              <1> 	;mov	cx,2			; wait for 30 micro seconds	
  4295 0000400C B902000000          <1>         mov	ecx, 2 ; 21/02/2015
  4296 00004011 E841DCFFFF          <1> 	call    WAITF                   ; (Award Bios 1999 - WAIT_REFRESH,
  4297                              <1>                                         ; 40 micro seconds)
  4298 00004016 A0[45200100]        <1> 	mov	al,[CONTROL_BYTE]
  4299 0000401B 240F                <1> 	AND	AL,0FH			; SET HEAD OPTION
  4300 0000401D EE                  <1> 	OUT	DX,AL			; TURN RESET OFF
  4301 0000401E E838040000          <1> 	CALL	NOT_BUSY
  4302 00004023 7515                <1> 	JNZ	short DRERR		; TIME OUT ON RESET
  4303 00004025 668B15[EEEC0000]    <1> 	MOV	DX,[HF_PORT]
  4304 0000402C FEC2                <1> 	inc	dl  ; HF_PORT+1
  4305                              <1> 	; 02/01/2015 - Award BIOS 1999 - AHDSK.ASM
  4306                              <1>         ;mov     cl, 10
  4307 0000402E B90A000000          <1>         mov     ecx, 10 ; 21/02/2015 
  4308                              <1> drst1:
  4309 00004033 EC                  <1> 	IN	AL,DX			; GET RESET STATUS
  4310 00004034 3C01                <1> 	CMP	AL,1
  4311                              <1> 	; 04/01/2015
  4312 00004036 740A                <1> 	jz	short drst2
  4313                              <1> 	;JNZ	short DRERR		; BAD RESET STATUS
  4314                              <1>         	; Drive/Head Register - bit 4
  4315 00004038 E2F9                <1> 	loop	drst1
  4316                              <1> DRERR:	
  4317 0000403A C605[43200100]05    <1> 	MOV	byte [DISK_STATUS1],BAD_RESET ; CARD FAILED
  4318 00004041 C3                  <1> 	RETn
  4319                              <1> drst2:
  4320                              <1> 	; 14/02/2015
  4321 00004042 6689FA              <1> 	mov	dx,di
  4322                              <1> ;drst3:
  4323                              <1> ;	; 05/01/2015
  4324                              <1> ;	shl 	di,1
  4325                              <1> ;	; 04/01/2015
  4326                              <1> ;	mov	ax,[di+hd_cports]
  4327                              <1> ;	cmp	ax,[HF_REG_PORT]
  4328                              <1> ;	je	short drst4
  4329                              <1> ;	mov	[HF_REG_PORT], ax
  4330                              <1> ;	; 03/01/2015
  4331                              <1> ;	mov	ax,[di+hd_ports]
  4332                              <1> ;       mov     [HF_PORT], ax
  4333                              <1> ;	; 05/01/2014
  4334                              <1> ;	shr	di,1
  4335                              <1> ;	; 04/01/2015
  4336                              <1> ;	jmp	short drst0	; reset other controller
  4337                              <1> ;drst4:
  4338                              <1> ;	; 05/01/2015
  4339                              <1> ;	shr	di,1
  4340                              <1> ;	mov	al,[di+hd_dregs]
  4341                              <1> ;	and	al,10h ; bit 4 only
  4342                              <1> ;	shr	al,4 ; bit 4  -> bit 0
  4343                              <1> ;	mov	[hf_m_s], al ; (0 = master, 1 = slave)
  4344                              <1> 	;
  4345 00004045 A0[F2EC0000]        <1> 	mov	al, [hf_m_s] ; 18/01/2015
  4346 0000404A A801                <1> 	test	al,1
  4347                              <1> ;	jnz	short drst6
  4348 0000404C 7516                <1>         jnz     short drst4
  4349 0000404E 8065FDEF            <1> 	AND     byte [CMD_BLOCK+5],0EFH ; SET TO DRIVE 0
  4350                              <1> ;drst5:
  4351                              <1> drst3:
  4352 00004052 E835010000          <1> 	CALL	INIT_DRV		; SET MAX HEADS
  4353                              <1> 	;mov	dx,di
  4354 00004057 E8ED010000          <1> 	CALL	HDISK_RECAL		; RECAL TO RESET SEEK SPEED
  4355                              <1> 	; 04/01/2014
  4356                              <1> ;	inc	di
  4357                              <1> ;	mov	dx,di
  4358                              <1> ;	cmp	dl,[HF_NUM]
  4359                              <1> ;	jb	short drst3
  4360                              <1> ;DRE:
  4361 0000405C C605[43200100]00    <1> 	MOV	byte [DISK_STATUS1],0 	; IGNORE ANY SET UP ERRORS
  4362 00004063 C3                  <1> 	RETn
  4363                              <1> ;drst6:
  4364                              <1> drst4:		; Drive/Head Register - bit 4
  4365 00004064 804DFD10            <1> 	OR      byte [CMD_BLOCK+5],010H ; SET TO DRIVE 1     
  4366                              <1>         ;jmp    short drst5
  4367 00004068 EBE8                <1>         jmp     short drst3
  4368                              <1> 
  4369                              <1> ;----------------------------------------
  4370                              <1> ;	DISK STATUS ROUTINE  (AH = 01H) :
  4371                              <1> ;----------------------------------------
  4372                              <1> 
  4373                              <1> RETURN_STATUS:
  4374 0000406A A0[43200100]        <1> 	MOV	AL,[DISK_STATUS1]	; OBTAIN PREVIOUS STATUS
  4375 0000406F C605[43200100]00    <1>         MOV     byte [DISK_STATUS1],0   ; RESET STATUS
  4376 00004076 C3                  <1> 	RETn
  4377                              <1> 
  4378                              <1> ;----------------------------------------
  4379                              <1> ;	DISK READ ROUTINE    (AH = 02H) :
  4380                              <1> ;----------------------------------------
  4381                              <1> 
  4382                              <1> DISK_READ:
  4383 00004077 C645FE20            <1> 	MOV	byte [CMD_BLOCK+6],READ_CMD
  4384 0000407B E954020000          <1>         JMP     COMMANDI
  4385                              <1> 
  4386                              <1> ;----------------------------------------
  4387                              <1> ;	DISK WRITE ROUTINE   (AH = 03H) :
  4388                              <1> ;----------------------------------------
  4389                              <1> 
  4390                              <1> DISK_WRITE:
  4391 00004080 C645FE30            <1> 	MOV	byte [CMD_BLOCK+6],WRITE_CMD
  4392 00004084 E9A6020000          <1>         JMP     COMMANDO
  4393                              <1> 
  4394                              <1> ;----------------------------------------
  4395                              <1> ;	DISK VERIFY	     (AH = 04H) :
  4396                              <1> ;----------------------------------------
  4397                              <1> 
  4398                              <1> DISK_VERF:
  4399 00004089 C645FE40            <1> 	MOV	byte [CMD_BLOCK+6],VERIFY_CMD
  4400 0000408D E814030000          <1> 	CALL	COMMAND
  4401 00004092 750C                <1> 	JNZ	short VERF_EXIT		; CONTROLLER STILL BUSY
  4402 00004094 E886030000          <1> 	CALL	_WAIT			; (Original: CALL WAIT)	
  4403 00004099 7505                <1> 	JNZ	short VERF_EXIT		; TIME OUT
  4404 0000409B E813040000          <1> 	CALL	CHECK_STATUS
  4405                              <1> VERF_EXIT:
  4406 000040A0 C3                  <1> 	RETn
  4407                              <1> 
  4408                              <1> ;----------------------------------------
  4409                              <1> ;	FORMATTING	     (AH = 05H) :
  4410                              <1> ;----------------------------------------
  4411                              <1> 
  4412                              <1> FMT_TRK:				; FORMAT TRACK	(AH = 005H)
  4413 000040A1 C645FE50            <1> 	MOV	byte [CMD_BLOCK+6],FMTTRK_CMD
  4414                              <1> 	;PUSH	ES
  4415                              <1> 	;PUSH	BX
  4416 000040A5 53                  <1> 	push	ebx
  4417 000040A6 E8BA040000          <1> 	CALL	GET_VEC 		; GET DISK PARAMETERS ADDRESS
  4418                              <1> 	;MOV	AL,[ES:BX+14]		; GET SECTORS/TRACK
  4419 000040AB 8A430E              <1> 	mov	al, [ebx+14]
  4420 000040AE 8845F9              <1> 	MOV	[CMD_BLOCK+1],AL 	; SET SECTOR COUNT IN COMMAND
  4421 000040B1 5B                  <1> 	pop	ebx
  4422                              <1> 	;POP	BX
  4423                              <1> 	;POP	ES
  4424 000040B2 E97F020000          <1>         JMP     CMD_OF                  ; GO EXECUTE THE COMMAND
  4425                              <1> 
  4426                              <1> ;----------------------------------------
  4427                              <1> ;	READ DASD TYPE	     (AH = 15H) :
  4428                              <1> ;----------------------------------------
  4429                              <1> 
  4430                              <1> READ_DASD_TYPE:
  4431                              <1> READ_D_T:				; GET DRIVE PARAMETERS
  4432 000040B7 1E                  <1> 	PUSH	DS			; SAVE REGISTERS
  4433                              <1> 	;PUSH	ES
  4434 000040B8 53                  <1> 	PUSH	eBX
  4435                              <1> 	;CALL	DDS			; ESTABLISH ADDRESSING
  4436                              <1> 	;push	cs
  4437                              <1> 	;pop	ds
  4438 000040B9 66BB1000            <1>         mov	bx, KDATA
  4439 000040BD 8EDB                <1> 	mov	ds, bx
  4440                              <1> 	;mov	es, bx
  4441 000040BF C605[43200100]00    <1> 	MOV     byte [DISK_STATUS1],0
  4442 000040C6 8A1D[44200100]      <1> 	MOV	BL,[HF_NUM]		; GET NUMBER OF DRIVES
  4443 000040CC 80E27F              <1> 	AND	DL,7FH			; GET DRIVE NUMBER
  4444 000040CF 38D3                <1> 	CMP	BL,DL
  4445 000040D1 7627                <1> 	JBE	short RDT_NOT_PRESENT 	; RETURN DRIVE NOT PRESENT
  4446 000040D3 E88D040000          <1> 	CALL	GET_VEC 		; GET DISK PARAMETER ADDRESS
  4447                              <1> 	;MOV	AL,[ES:BX+2]		; HEADS
  4448 000040D8 8A4302              <1> 	mov	al, [ebx+2]
  4449                              <1> 	;MOV	CL,[ES:BX+14]
  4450 000040DB 8A4B0E              <1> 	mov	cl, [ebx+14]
  4451 000040DE F6E9                <1> 	IMUL	CL			; * NUMBER OF SECTORS
  4452                              <1> 	;MOV	CX,[ES:BX]		; MAX NUMBER OF CYLINDERS
  4453 000040E0 668B0B              <1> 	mov	cx ,[ebx]
  4454                              <1> 	;
  4455                              <1> 	; 02/01/2015 
  4456                              <1> 	; ** leave the last cylinder as reserved for diagnostics **
  4457                              <1> 	; (Also in Award BIOS - 1999, AHDSK.ASM, FUN15 -> sub ax, 1)
  4458 000040E3 6649                <1> 	DEC	CX			; LEAVE ONE FOR DIAGNOSTICS
  4459                              <1> 	;
  4460 000040E5 66F7E9              <1> 	IMUL	CX			; NUMBER OF SECTORS
  4461 000040E8 6689D1              <1> 	MOV	CX,DX			; HIGH ORDER HALF
  4462 000040EB 6689C2              <1> 	MOV	DX,AX			; LOW ORDER HALF
  4463                              <1> 	;SUB	AX,AX
  4464 000040EE 28C0                <1> 	sub	al, al
  4465 000040F0 B403                <1> 	MOV	AH,03H			; INDICATE FIXED DISK
  4466 000040F2 5B                  <1> RDT2:	POP	eBX			; RESTORE REGISTERS
  4467                              <1> 	;POP	ES
  4468 000040F3 1F                  <1> 	POP	DS
  4469                              <1> 	; (*) CLC			; CLEAR CARRY
  4470                              <1> 	;RETf	2
  4471                              <1> 	; (*) 29/05/2016
  4472                              <1> 	; (*) retf 4
  4473 000040F4 80642408FE          <1> 	and	byte [esp+8], 0FEh ; clear carry bit of eflags register
  4474 000040F9 CF                  <1> 	iretd
  4475                              <1> 
  4476                              <1> RDT_NOT_PRESENT:
  4477 000040FA 6629C0              <1> 	SUB	AX,AX			; DRIVE NOT PRESENT RETURN
  4478 000040FD 6689C1              <1> 	MOV	CX,AX			; ZERO BLOCK COUNT
  4479 00004100 6689C2              <1> 	MOV	DX,AX
  4480 00004103 EBED                <1> 	JMP	short RDT2
  4481                              <1> 
  4482                              <1> ; 28/05/2016
  4483                              <1> ; 27/05/2016 - TRDOS 386 (TRDOS v2.0)
  4484                              <1> 
  4485                              <1> ;----------------------------------------
  4486                              <1> ;	GET PARAMETERS	     (AH = 08H) :
  4487                              <1> ;----------------------------------------
  4488                              <1> 
  4489                              <1> GET_PARM_N:
  4490                              <1> 	; ebx = user's buffer address for parameters table
  4491                              <1> ;GET_PARM:				; GET DRIVE PARAMETERS
  4492 00004105 1E                  <1> 	PUSH	DS			; SAVE REGISTERS
  4493 00004106 06                  <1> 	PUSH	ES
  4494 00004107 53                  <1> 	PUSH	eBX
  4495                              <1> 	;MOV	AX,ABS0 		; ESTABLISH ADDRESSING
  4496                              <1> 	;MOV	DS,AX
  4497                              <1> 	;TEST	DL,1			; CHECK FOR DRIVE 1
  4498                              <1> 	;JZ	short G0
  4499                              <1> 	;LES	BX,@HF1_TBL_VEC
  4500                              <1> 	;JMP	SHORT G1
  4501                              <1> ;G0:	LES	BX,@HF_TBL_VEC
  4502                              <1> ;G1:
  4503                              <1> 	;CALL	DDS			; ESTABLISH SEGMENT
  4504                              <1> 	; 22/12/2014
  4505                              <1> 	;push	cs
  4506                              <1> 	;pop	ds
  4507 00004108 66BB1000            <1> 	mov	bx, KDATA
  4508 0000410C 8EDB                <1> 	mov	ds, bx
  4509 0000410E 8EC3                <1> 	mov	es, bx	; 27/05/2016
  4510                              <1> 	;
  4511 00004110 80EA80              <1> 	SUB	DL,80H
  4512 00004113 80FA04              <1> 	CMP	DL,MAX_FILE		; TEST WITHIN RANGE
  4513 00004116 7361                <1> 	JAE	short G4
  4514                              <1> 	;
  4515 00004118 31DB                <1> 	xor	ebx, ebx ; 21/02/2015
  4516                              <1> 	; 22/12/2014
  4517 0000411A 88D3                <1> 	mov	bl, dl
  4518                              <1> 	;xor	bh, bh  
  4519 0000411C C0E302              <1> 	shl	bl, 2			; convert index to offset
  4520                              <1> 	;add	bx, HF_TBL_VEC
  4521 0000411F 81C3[48200100]      <1> 	add	ebx, HF_TBL_VEC
  4522                              <1> 	;mov	ax, [bx+2]
  4523                              <1> 	;mov	es, ax			; dpt segment
  4524                              <1> 	;mov	bx, [bx]		; dpt offset
  4525 00004125 8B1B                <1> 	mov	ebx, [ebx] ; 32 bit offset	
  4526                              <1> 
  4527 00004127 C605[43200100]00    <1> 	MOV	byte [DISK_STATUS1],0
  4528                              <1>         ;MOV     AX,[ES:BX]             ; MAX NUMBER OF CYLINDERS
  4529 0000412E 668B03              <1> 	mov	ax, [ebx]
  4530                              <1> 	;;SUB	AX,2			; ADJUST FOR 0-N
  4531 00004131 6648                <1> 	dec	ax			; max. cylinder number
  4532 00004133 88C5                <1> 	MOV	CH,AL
  4533 00004135 66250003            <1> 	AND	AX,0300H		; HIGH TWO BITS OF CYLINDER
  4534 00004139 66D1E8              <1> 	SHR	AX,1
  4535 0000413C 66D1E8              <1> 	SHR	AX,1
  4536                              <1> 	;OR	AL,[ES:BX+14]		; SECTORS
  4537 0000413F 0A430E              <1> 	or	al, [ebx+14]
  4538 00004142 88C1                <1> 	MOV	CL,AL
  4539                              <1> 	;MOV	DH,[ES:BX+2]		; HEADS
  4540 00004144 8A7302              <1> 	mov	dh, [ebx+2]
  4541 00004147 FECE                <1> 	DEC	DH			; 0-N RANGE
  4542 00004149 8A15[44200100]      <1> 	MOV	DL,[HF_NUM]		; DRIVE COUNT
  4543 0000414F 6629C0              <1> 	SUB	AX,AX
  4544                              <1>         ;27/12/2014 
  4545                              <1> 	;mov	di, bx			; HDPT offset
  4546                              <1> 	
  4547                              <1> 	; 27/05/2016
  4548                              <1> 	; return fixed disk parameters table to user
  4549                              <1> 	; in user's buffer, which is pointed by EBX
  4550                              <1> 	;
  4551 00004152 873C24              <1> 	xchg	edi, [esp]		; ebx (input)-> edi, edi -> [esp]
  4552 00004155 56                  <1> 	push	esi
  4553 00004156 89DE                <1> 	mov	esi, ebx		; hard disk parameter table (32 bytes)	
  4554 00004158 89FB                <1> 	mov	ebx, edi		; ebx = user's buffer address
  4555 0000415A 51                  <1> 	push	ecx
  4556 0000415B 50                  <1> 	push	eax
  4557 0000415C B920000000          <1> 	mov	ecx, 32 ; 32 bytes
  4558 00004161 E8EA970000          <1> 	call	transfer_to_user_buffer ; trdosk6.s (16/05/2016)
  4559 00004166 58                  <1> 	pop	eax
  4560 00004167 59                  <1> 	pop	ecx
  4561 00004168 5E                  <1> 	pop	esi
  4562 00004169 5F                  <1> 	pop	edi
  4563 0000416A 730A                <1> 	jnc	short G5
  4564                              <1> 	; 29/05/2016 (*)
  4565 0000416C B8FF000000          <1> 	mov	eax, 0FFh ; unknown error !
  4566                              <1> _G6:
  4567 00004171 804C241001          <1> 	or	byte [esp+16], 1 ; set carry bit of eflags register
  4568                              <1> G5:
  4569                              <1> 	; 27/05/2016
  4570                              <1> 	;POP	eBX			; RESTORE REGISTERS
  4571 00004176 07                  <1> 	POP	ES
  4572 00004177 1F                  <1> 	POP	DS
  4573                              <1> 	;RETf	2
  4574                              <1> 	; (*) 29/05/2016
  4575                              <1> 	; (*) retf 4
  4576                              <1> 	; (*) or byte [esp+8], 1 ; set carry bit of eflags register
  4577 00004178 CF                  <1> 	iretd
  4578                              <1> G4:
  4579 00004179 C605[43200100]07    <1> 	MOV     byte [DISK_STATUS1],INIT_FAIL ; OPERATION FAILED
  4580 00004180 B407                <1> 	MOV	AH,INIT_FAIL
  4581 00004182 28C0                <1> 	SUB	AL,AL
  4582 00004184 6629D2              <1> 	SUB	DX,DX
  4583 00004187 6629C9              <1> 	SUB	CX,CX
  4584                              <1> 	; 29/05/2016 (*)
  4585                              <1> 	;STC				; SET ERROR FLAG
  4586                              <1> 	;JMP	short G5
  4587 0000418A EBE5                <1> 	jmp	short _G6
  4588                              <1> 
  4589                              <1> ;----------------------------------------
  4590                              <1> ;	INITIALIZE DRIVE     (AH = 09H) :
  4591                              <1> ;----------------------------------------
  4592                              <1> 	; 03/01/2015
  4593                              <1> 	; According to ATA-ATAPI specification v2.0 to v5.0
  4594                              <1> 	; logical sector per logical track
  4595                              <1> 	; and logical heads - 1 would be set but
  4596                              <1> 	; it is seen as it will be good
  4597                              <1> 	; if physical parameters will be set here
  4598                              <1> 	; because, number of heads <= 16.
  4599                              <1> 	; (logical heads usually more than 16)
  4600                              <1> 	; NOTE: ATA logical parameters (software C, H, S)
  4601                              <1> 	;	== INT 13h physical parameters
  4602                              <1> 
  4603                              <1> ;INIT_DRV:
  4604                              <1> ;	MOV	byte [CMD_BLOCK+6],SET_PARM_CMD
  4605                              <1> ;	CALL	GET_VEC 		; ES:BX -> PARAMETER BLOCK
  4606                              <1> ;	MOV	AL,[ES:BX+2]		; GET NUMBER OF HEADS
  4607                              <1> ;	DEC	AL			; CONVERT TO 0-INDEX
  4608                              <1> ;	MOV	AH,[CMD_BLOCK+5] 	; GET SDH REGISTER
  4609                              <1> ;	AND	AH,0F0H 		; CHANGE HEAD NUMBER
  4610                              <1> ;	OR	AH,AL			; TO MAX HEAD
  4611                              <1> ;	MOV	[CMD_BLOCK+5],AH
  4612                              <1> ;	MOV	AL,[ES:BX+14]		; MAX SECTOR NUMBER
  4613                              <1> ;	MOV	[CMD_BLOCK+1],AL
  4614                              <1> ;	SUB	AX,AX
  4615                              <1> ;	MOV	[CMD_BLOCK+3],AL 	; ZERO FLAGS
  4616                              <1> ;	CALL	COMMAND 		; TELL CONTROLLER
  4617                              <1> ;	JNZ	short INIT_EXIT		; CONTROLLER BUSY ERROR
  4618                              <1> ;	CALL	NOT_BUSY		; WAIT FOR IT TO BE DONE
  4619                              <1> ;	JNZ	short INIT_EXIT		; TIME OUT
  4620                              <1> ;	CALL	CHECK_STATUS
  4621                              <1> ;INIT_EXIT:
  4622                              <1> ;	RETn
  4623                              <1> 
  4624                              <1> ; 04/01/2015
  4625                              <1> ; 02/01/2015 - Derived from from AWARD BIOS 1999
  4626                              <1> ;				 AHDSK.ASM - INIT_DRIVE
  4627                              <1> INIT_DRV:
  4628                              <1> 	;xor	ah,ah
  4629 0000418C 31C0                <1> 	xor	eax, eax ; 21/02/2015
  4630 0000418E B00B                <1> 	mov	al,11 ; Physical heads from translated HDPT
  4631 00004190 3825[58200100]      <1>         cmp     [LBAMode], ah   ; 0
  4632 00004196 7702                <1> 	ja	short idrv0
  4633 00004198 B002                <1> 	mov	al,2  ; Physical heads from standard HDPT
  4634                              <1> idrv0:
  4635                              <1> 	; DL = drive number (0 based)
  4636 0000419A E8C6030000          <1> 	call	GET_VEC
  4637                              <1> 	;push	bx
  4638 0000419F 53                  <1> 	push	ebx ; 21/02/2015
  4639                              <1> 	;add	bx,ax
  4640 000041A0 01C3                <1> 	add	ebx, eax
  4641                              <1> 	;; 05/01/2015
  4642 000041A2 8A25[F2EC0000]      <1> 	mov	ah, [hf_m_s] ; drive number (0= master, 1= slave)
  4643                              <1> 	;;and 	ah,1 
  4644 000041A8 C0E404              <1> 	shl	ah,4
  4645 000041AB 80CCA0              <1> 	or	ah,0A0h  ; Drive/Head register - 10100000b (A0h)	
  4646                              <1> 	;mov	al,[es:bx]
  4647 000041AE 8A03                <1> 	mov	al, [ebx] ; 21/02/2015
  4648 000041B0 FEC8                <1> 	dec	al	 ; last head number 
  4649                              <1> 	;and	al,0Fh
  4650 000041B2 08E0                <1> 	or	al,ah	 ; lower 4 bits for head number
  4651                              <1> 	;
  4652 000041B4 C645FE91            <1> 	mov	byte [CMD_BLOCK+6],SET_PARM_CMD
  4653 000041B8 8845FD              <1> 	mov	[CMD_BLOCK+5],al
  4654                              <1> 	;pop	bx
  4655 000041BB 5B                  <1> 	pop	ebx
  4656 000041BC 29C0                <1> 	sub	eax, eax ; 21/02/2015
  4657 000041BE B004                <1> 	mov	al,4 ; Physical sec per track from translated HDPT
  4658 000041C0 803D[58200100]00    <1> 	cmp	byte [LBAMode], 0
  4659 000041C7 7702                <1> 	ja	short idrv1
  4660 000041C9 B00E                <1> 	mov	al,14 ; Physical sec per track from standard HDPT
  4661                              <1> idrv1:
  4662                              <1> 	;xor	ah,ah
  4663                              <1> 	;add	bx,ax
  4664 000041CB 01C3                <1> 	add	ebx, eax ; 21/02/2015
  4665                              <1> 	;mov	al,[es:bx]
  4666                              <1> 			; sector number
  4667 000041CD 8A03                <1> 	mov	al, [ebx]
  4668 000041CF 8845F9              <1> 	mov	[CMD_BLOCK+1],al
  4669 000041D2 28C0                <1> 	sub	al,al
  4670 000041D4 8845FB              <1> 	mov	[CMD_BLOCK+3],al  ; ZERO FLAGS
  4671 000041D7 E8CA010000          <1> 	call	COMMAND 	  ; TELL CONTROLLER
  4672 000041DC 750C                <1> 	jnz	short INIT_EXIT	  ; CONTROLLER BUSY ERROR
  4673 000041DE E878020000          <1> 	call	NOT_BUSY	  ; WAIT FOR IT TO BE DONE
  4674 000041E3 7505                <1> 	jnz	short INIT_EXIT	  ; TIME OUT
  4675 000041E5 E8C9020000          <1> 	call	CHECK_STATUS
  4676                              <1> INIT_EXIT:
  4677 000041EA C3                  <1> 	RETn
  4678                              <1> 
  4679                              <1> ;----------------------------------------
  4680                              <1> ;	READ LONG	     (AH = 0AH) :
  4681                              <1> ;----------------------------------------
  4682                              <1> 
  4683                              <1> RD_LONG:
  4684                              <1> 	;MOV	@CMD_BLOCK+6,READ_CMD OR ECC_MODE
  4685 000041EB C645FE22            <1>         mov     byte [CMD_BLOCK+6],READ_CMD + ECC_MODE 
  4686 000041EF E9E0000000          <1>         JMP     COMMANDI
  4687                              <1> 
  4688                              <1> ;----------------------------------------
  4689                              <1> ;	WRITE LONG	     (AH = 0BH) :
  4690                              <1> ;----------------------------------------
  4691                              <1> 
  4692                              <1> WR_LONG:
  4693                              <1> 	;MOV	@CMD_BLOCK+6,WRITE_CMD OR ECC_MODE
  4694 000041F4 C645FE32            <1>         MOV     byte [CMD_BLOCK+6],WRITE_CMD + ECC_MODE
  4695 000041F8 E932010000          <1>         JMP     COMMANDO
  4696                              <1> 
  4697                              <1> ;----------------------------------------
  4698                              <1> ;	SEEK		     (AH = 0CH) :
  4699                              <1> ;----------------------------------------
  4700                              <1> 
  4701                              <1> DISK_SEEK:
  4702 000041FD C645FE70            <1>         MOV     byte [CMD_BLOCK+6],SEEK_CMD
  4703 00004201 E8A0010000          <1> 	CALL	COMMAND
  4704 00004206 751C                <1> 	JNZ	short DS_EXIT 		; CONTROLLER BUSY ERROR
  4705 00004208 E812020000          <1> 	CALL	_WAIT
  4706 0000420D 7515                <1>         JNZ     DS_EXIT                 ; TIME OUT ON SEEK
  4707 0000420F E89F020000          <1> 	CALL	CHECK_STATUS
  4708 00004214 803D[43200100]40    <1>         CMP     byte [DISK_STATUS1],BAD_SEEK
  4709 0000421B 7507                <1> 	JNE	short DS_EXIT
  4710 0000421D C605[43200100]00    <1>         MOV     byte [DISK_STATUS1],0
  4711                              <1> DS_EXIT:
  4712 00004224 C3                  <1> 	RETn
  4713                              <1> 
  4714                              <1> ;----------------------------------------
  4715                              <1> ;	TEST DISK READY      (AH = 10H) :
  4716                              <1> ;----------------------------------------
  4717                              <1> 
  4718                              <1> TST_RDY:				; WAIT FOR CONTROLLER
  4719 00004225 E831020000          <1> 	CALL	NOT_BUSY
  4720 0000422A 751C                <1> 	JNZ	short TR_EX
  4721 0000422C 8A45FD              <1> 	MOV	AL,[CMD_BLOCK+5] 	; SELECT DRIVE
  4722 0000422F 668B15[EEEC0000]    <1> 	MOV	DX,[HF_PORT]
  4723 00004236 80C206              <1> 	add	dl,6
  4724 00004239 EE                  <1> 	OUT	DX,AL
  4725 0000423A E88C020000          <1> 	CALL	CHECK_ST		; CHECK STATUS ONLY
  4726 0000423F 7507                <1> 	JNZ	short TR_EX
  4727 00004241 C605[43200100]00    <1> 	MOV	byte [DISK_STATUS1],0 	; WIPE OUT DATA CORRECTED ERROR
  4728                              <1> TR_EX:	
  4729 00004248 C3                  <1> 	RETn
  4730                              <1> 
  4731                              <1> ;----------------------------------------
  4732                              <1> ;	RECALIBRATE	     (AH = 11H) :
  4733                              <1> ;----------------------------------------
  4734                              <1> 
  4735                              <1> HDISK_RECAL:
  4736 00004249 C645FE10            <1>         MOV     byte [CMD_BLOCK+6],RECAL_CMD ; 10h, 16
  4737 0000424D E854010000          <1> 	CALL	COMMAND 		; START THE OPERATION
  4738 00004252 7523                <1> 	JNZ	short RECAL_EXIT	; ERROR
  4739 00004254 E8C6010000          <1> 	CALL	_WAIT			; WAIT FOR COMPLETION
  4740 00004259 7407                <1> 	JZ	short RECAL_X 		; TIME OUT ONE OK ?
  4741 0000425B E8BF010000          <1> 	CALL	_WAIT			; WAIT FOR COMPLETION LONGER
  4742 00004260 7515                <1> 	JNZ	short RECAL_EXIT	; TIME OUT TWO TIMES IS ERROR
  4743                              <1> RECAL_X:
  4744 00004262 E84C020000          <1> 	CALL	CHECK_STATUS
  4745 00004267 803D[43200100]40    <1> 	CMP	byte [DISK_STATUS1],BAD_SEEK ; SEEK NOT COMPLETE
  4746 0000426E 7507                <1> 	JNE	short RECAL_EXIT	; IS OK
  4747 00004270 C605[43200100]00    <1> 	MOV	byte [DISK_STATUS1],0
  4748                              <1> RECAL_EXIT:
  4749 00004277 803D[43200100]00    <1>         CMP     byte [DISK_STATUS1],0
  4750 0000427E C3                  <1> 	RETn
  4751                              <1> 
  4752                              <1> ;----------------------------------------
  4753                              <1> ;      CONTROLLER DIAGNOSTIC (AH = 14H) :
  4754                              <1> ;----------------------------------------
  4755                              <1> 
  4756                              <1> CTLR_DIAGNOSTIC:
  4757 0000427F FA                  <1>         CLI                             ; DISABLE INTERRUPTS WHILE CHANGING MASK
  4758 00004280 E4A1                <1> 	IN	AL,INTB01		; TURN ON SECOND INTERRUPT CHIP
  4759                              <1> 	;AND	AL,0BFH
  4760 00004282 243F                <1> 	and	al, 3Fh			; enable IRQ 14 & IRQ 15
  4761                              <1> 	;JMP	$+2
  4762                              <1> 	IODELAY
  4762 00004284 EB00                <2>  jmp short $+2
  4762 00004286 EB00                <2>  jmp short $+2
  4763 00004288 E6A1                <1> 	OUT	INTB01,AL
  4764                              <1> 	IODELAY
  4764 0000428A EB00                <2>  jmp short $+2
  4764 0000428C EB00                <2>  jmp short $+2
  4765 0000428E E421                <1> 	IN	AL,INTA01		; LET INTERRUPTS PASS THRU TO
  4766 00004290 24FB                <1> 	AND	AL,0FBH 		;  SECOND CHIP
  4767                              <1> 	;JMP	$+2
  4768                              <1> 	IODELAY
  4768 00004292 EB00                <2>  jmp short $+2
  4768 00004294 EB00                <2>  jmp short $+2
  4769 00004296 E621                <1> 	OUT	INTA01,AL
  4770 00004298 FB                  <1> 	STI
  4771 00004299 E8BD010000          <1> 	CALL	NOT_BUSY		; WAIT FOR CARD
  4772 0000429E 752B                <1> 	JNZ	short CD_ERR		; BAD CARD
  4773                              <1> 	;MOV	DX, HF_PORT+7
  4774 000042A0 668B15[EEEC0000]    <1> 	mov	dx, [HF_PORT]
  4775 000042A7 80C207              <1> 	add	dl, 7
  4776 000042AA B090                <1> 	MOV	AL,DIAG_CMD		; START DIAGNOSE
  4777 000042AC EE                  <1> 	OUT	DX,AL
  4778 000042AD E8A9010000          <1> 	CALL	NOT_BUSY		; WAIT FOR IT TO COMPLETE
  4779 000042B2 B480                <1> 	MOV	AH,TIME_OUT
  4780 000042B4 7517                <1> 	JNZ	short CD_EXIT 		; TIME OUT ON DIAGNOSTIC
  4781                              <1> 	;MOV	DX,HF_PORT+1		; GET ERROR REGISTER
  4782 000042B6 668B15[EEEC0000]    <1> 	mov	dx, [HF_PORT]
  4783 000042BD FEC2                <1> 	inc	dl
  4784 000042BF EC                  <1> 	IN	AL,DX
  4785 000042C0 A2[3A200100]        <1> 	MOV	[HF_ERROR],AL		; SAVE IT
  4786 000042C5 B400                <1> 	MOV	AH,0
  4787 000042C7 3C01                <1> 	CMP	AL,1			; CHECK FOR ALL OK
  4788 000042C9 7402                <1> 	JE	SHORT CD_EXIT
  4789 000042CB B420                <1> CD_ERR: MOV	AH,BAD_CNTLR
  4790                              <1> CD_EXIT:
  4791 000042CD 8825[43200100]      <1> 	MOV	[DISK_STATUS1],AH
  4792 000042D3 C3                  <1> 	RETn
  4793                              <1> 
  4794                              <1> ;----------------------------------------
  4795                              <1> ; COMMANDI				:
  4796                              <1> ;	REPEATEDLY INPUTS DATA TILL	:
  4797                              <1> ;	NSECTOR RETURNS ZERO		:
  4798                              <1> ;----------------------------------------
  4799                              <1> COMMANDI:
  4800 000042D4 E862020000          <1> 	CALL	CHECK_DMA		; CHECK 64K BOUNDARY ERROR
  4801 000042D9 7253                <1> 	JC	short CMD_ABORT
  4802                              <1> 	;MOV	DI,BX
  4803 000042DB 89DF                <1> 	mov	edi, ebx ; 21/02/2015
  4804 000042DD E8C4000000          <1> 	CALL	COMMAND 		; OUTPUT COMMAND
  4805 000042E2 754A                <1> 	JNZ	short CMD_ABORT
  4806                              <1> CMD_I1:
  4807 000042E4 E836010000          <1> 	CALL	_WAIT			; WAIT FOR DATA REQUEST INTERRUPT
  4808 000042E9 7543                <1> 	JNZ	short TM_OUT		; TIME OUT
  4809                              <1> cmd_i1x: ; 18/02/2016
  4810                              <1> 	;MOV	CX,256			; SECTOR SIZE IN WORDS
  4811 000042EB B900010000          <1> 	mov	ecx, 256 ; 21/02/2015	
  4812                              <1> 	;MOV	DX,HF_PORT
  4813 000042F0 668B15[EEEC0000]    <1> 	mov	dx,[HF_PORT]
  4814 000042F7 FA                  <1> 	CLI
  4815 000042F8 FC                  <1> 	CLD
  4816 000042F9 F3666D              <1> 	REP	INSW			; GET THE SECTOR
  4817 000042FC FB                  <1> 	STI
  4818 000042FD F645FE02            <1> 	TEST	byte [CMD_BLOCK+6],ECC_MODE ; CHECK FOR NORMAL INPUT
  4819 00004301 7419                <1> 	JZ	short CMD_I3
  4820 00004303 E880010000          <1> 	CALL	WAIT_DRQ		; WAIT FOR DATA REQUEST
  4821 00004308 7224                <1> 	JC	short TM_OUT
  4822                              <1> 	;MOV	DX,HF_PORT
  4823 0000430A 668B15[EEEC0000]    <1> 	mov	dx,[HF_PORT]
  4824                              <1> 	;MOV	CX,4			; GET ECC BYTES
  4825 00004311 B904000000          <1> 	mov 	ecx, 4 ; mov cx, 4 
  4826 00004316 EC                  <1> CMD_I2: IN	AL,DX
  4827                              <1> 	;MOV	[ES:DI],AL		; GO SLOW FOR BOARD
  4828 00004317 8807                <1> 	mov 	[edi], al ; 21/02/2015
  4829 00004319 47                  <1> 	INC	eDI
  4830 0000431A E2FA                <1> 	LOOP	CMD_I2
  4831                              <1> CMD_I3: 
  4832                              <1> 	; wait for 400 ns
  4833 0000431C 80C207              <1> 	add 	dl, 7
  4834 0000431F EC                  <1> 	in	al, dx
  4835 00004320 EC                  <1> 	in	al, dx
  4836 00004321 EC                  <1> 	in	al, dx
  4837                              <1> 	;
  4838 00004322 E88C010000          <1> 	CALL	CHECK_STATUS
  4839 00004327 7505                <1> 	JNZ	short CMD_ABORT		; ERROR RETURNED
  4840 00004329 FE4DF9              <1> 	DEC	byte [CMD_BLOCK+1]	; CHECK FOR MORE
  4841                              <1> 	;JNZ	SHORT CMD_I1
  4842 0000432C 75BD                <1> 	jnz	short cmd_i1x ; 18/02/2016
  4843                              <1> CMD_ABORT:
  4844 0000432E C3                  <1> TM_OUT: RETn
  4845                              <1> 
  4846                              <1> ;----------------------------------------
  4847                              <1> ; COMMANDO				:
  4848                              <1> ;	REPEATEDLY OUTPUTS DATA TILL	:
  4849                              <1> ;	NSECTOR RETURNS ZERO		:
  4850                              <1> ;----------------------------------------
  4851                              <1> COMMANDO:
  4852 0000432F E807020000          <1> 	CALL	CHECK_DMA		; CHECK 64K BOUNDARY ERROR
  4853 00004334 72F8                <1> 	JC	short CMD_ABORT
  4854 00004336 89DE                <1> CMD_OF: MOV	eSI,eBX ; 21/02/2015
  4855 00004338 E869000000          <1> 	CALL	COMMAND 		; OUTPUT COMMAND
  4856 0000433D 75EF                <1> 	JNZ	short CMD_ABORT
  4857 0000433F E844010000          <1> 	CALL	WAIT_DRQ		; WAIT FOR DATA REQUEST
  4858 00004344 72E8                <1> 	JC	short TM_OUT			; TOO LONG
  4859                              <1> CMD_O1: ;PUSH	DS
  4860                              <1> 	;PUSH	ES			; MOVE ES TO DS
  4861                              <1> 	;POP	DS
  4862                              <1> 	;MOV	CX,256			; PUT THE DATA OUT TO THE CARD
  4863                              <1> 	;MOV	DX,HF_PORT
  4864                              <1> 	; 01/02/2015
  4865 00004346 668B15[EEEC0000]    <1> 	mov	dx, [HF_PORT]
  4866                              <1> 	;push	es
  4867                              <1> 	;pop	ds
  4868                              <1> 	;mov	cx, 256
  4869 0000434D B900010000          <1> 	mov	ecx, 256 ; 21/02/2015
  4870 00004352 FA                  <1> 	CLI
  4871 00004353 FC                  <1> 	CLD
  4872 00004354 F3666F              <1> 	REP	OUTSW
  4873 00004357 FB                  <1> 	STI
  4874                              <1> 	;POP	DS			; RESTORE DS
  4875 00004358 F645FE02            <1> 	TEST	byte [CMD_BLOCK+6],ECC_MODE ; CHECK FOR NORMAL OUTPUT
  4876 0000435C 7419                <1> 	JZ	short CMD_O3
  4877 0000435E E825010000          <1> 	CALL	WAIT_DRQ		; WAIT FOR DATA REQUEST
  4878 00004363 72C9                <1> 	JC	short TM_OUT
  4879                              <1> 	;MOV	DX,HF_PORT
  4880 00004365 668B15[EEEC0000]    <1> 	mov	dx, [HF_PORT]
  4881                              <1> 	;MOV	CX,4			; OUTPUT THE ECC BYTES
  4882 0000436C B904000000          <1> 	mov	ecx, 4  ; mov cx, 4
  4883                              <1> CMD_O2: ;MOV	AL,[ES:SI]
  4884 00004371 8A06                <1> 	mov	al, [esi]
  4885 00004373 EE                  <1> 	OUT	DX,AL
  4886 00004374 46                  <1> 	INC	eSI
  4887 00004375 E2FA                <1> 	LOOP	CMD_O2
  4888                              <1> CMD_O3:
  4889 00004377 E8A3000000          <1> 	CALL	_WAIT			; WAIT FOR SECTOR COMPLETE INTERRUPT
  4890 0000437C 75B0                <1> 	JNZ	short TM_OUT		; ERROR RETURNED
  4891 0000437E E830010000          <1> 	CALL	CHECK_STATUS
  4892 00004383 75A9                <1> 	JNZ	short CMD_ABORT
  4893 00004385 F605[39200100]08    <1> 	TEST	byte [HF_STATUS],ST_DRQ	; CHECK FOR MORE
  4894 0000438C 75B8                <1> 	JNZ	SHORT CMD_O1
  4895                              <1> 	;MOV	DX,HF_PORT+2		; CHECK RESIDUAL SECTOR COUNT
  4896 0000438E 668B15[EEEC0000]    <1> 	mov	dx, [HF_PORT]
  4897                              <1> 	;add	dl, 2
  4898 00004395 FEC2                <1> 	inc	dl
  4899 00004397 FEC2                <1> 	inc	dl
  4900 00004399 EC                  <1> 	IN	AL,DX			;
  4901 0000439A A8FF                <1> 	TEST	AL,0FFH 		;
  4902 0000439C 7407                <1> 	JZ	short CMD_O4			; COUNT = 0  OK
  4903 0000439E C605[43200100]BB    <1> 	MOV	byte [DISK_STATUS1],UNDEF_ERR 
  4904                              <1> 					; OPERATION ABORTED - PARTIAL TRANSFER
  4905                              <1> CMD_O4:
  4906 000043A5 C3                  <1> 	RETn
  4907                              <1> 
  4908                              <1> ;--------------------------------------------------------
  4909                              <1> ; COMMAND						:
  4910                              <1> ;	THIS ROUTINE OUTPUTS THE COMMAND BLOCK		:
  4911                              <1> ; OUTPUT						:
  4912                              <1> ;	BL = STATUS					:
  4913                              <1> ;	BH = ERROR REGISTER				:
  4914                              <1> ;--------------------------------------------------------
  4915                              <1> 
  4916                              <1> COMMAND:
  4917 000043A6 53                  <1> 	PUSH	eBX			; WAIT FOR SEEK COMPLETE AND READY
  4918                              <1> 	;;MOV	CX,DELAY_2		; SET INITIAL DELAY BEFORE TEST
  4919                              <1> COMMAND1:
  4920                              <1> 	;;PUSH	CX			; SAVE LOOP COUNT
  4921 000043A7 E879FEFFFF          <1> 	CALL	TST_RDY 		; CHECK DRIVE READY
  4922                              <1> 	;;POP	CX
  4923 000043AC 7419                <1> 	JZ	short COMMAND2		; DRIVE IS READY
  4924 000043AE 803D[43200100]80    <1>         CMP     byte [DISK_STATUS1],TIME_OUT ; TST_RDY TIMED OUT--GIVE UP
  4925                              <1> 	;JZ	short CMD_TIMEOUT
  4926                              <1> 	;;LOOP	COMMAND1		; KEEP TRYING FOR A WHILE
  4927                              <1> 	;JMP	SHORT COMMAND4		; ITS NOT GOING TO GET READY
  4928 000043B5 7507                <1> 	jne	short COMMAND4
  4929                              <1> CMD_TIMEOUT:
  4930 000043B7 C605[43200100]20    <1> 	MOV	byte [DISK_STATUS1],BAD_CNTLR
  4931                              <1> COMMAND4:
  4932 000043BE 5B                  <1> 	POP	eBX
  4933 000043BF 803D[43200100]00    <1>         CMP     byte [DISK_STATUS1],0   ; SET CONDITION CODE FOR CALLER
  4934 000043C6 C3                  <1> 	RETn
  4935                              <1> COMMAND2:
  4936 000043C7 5B                  <1> 	POP	eBX
  4937 000043C8 57                  <1> 	PUSH	eDI
  4938 000043C9 C605[3B200100]00    <1> 	MOV	byte [HF_INT_FLAG],0	; RESET INTERRUPT FLAG
  4939 000043D0 FA                  <1> 	CLI				; INHIBIT INTERRUPTS WHILE CHANGING MASK
  4940 000043D1 E4A1                <1> 	IN	AL,INTB01		; TURN ON SECOND INTERRUPT CHIP
  4941                              <1> 	;AND	AL,0BFH
  4942 000043D3 243F                <1> 	and	al, 3Fh			; Enable IRQ 14 & 15
  4943                              <1> 	;JMP	$+2
  4944                              <1> 	IODELAY
  4944 000043D5 EB00                <2>  jmp short $+2
  4944 000043D7 EB00                <2>  jmp short $+2
  4945 000043D9 E6A1                <1> 	OUT	INTB01,AL
  4946 000043DB E421                <1> 	IN	AL,INTA01		; LET INTERRUPTS PASS THRU TO
  4947 000043DD 24FB                <1> 	AND	AL,0FBH 		;  SECOND CHIP
  4948                              <1> 	;JMP	$+2
  4949                              <1> 	IODELAY
  4949 000043DF EB00                <2>  jmp short $+2
  4949 000043E1 EB00                <2>  jmp short $+2
  4950 000043E3 E621                <1> 	OUT	INTA01,AL
  4951 000043E5 FB                  <1> 	STI
  4952 000043E6 31FF                <1> 	XOR	eDI,eDI			; INDEX THE COMMAND TABLE
  4953                              <1> 	;MOV	DX,HF_PORT+1		; DISK ADDRESS
  4954 000043E8 668B15[EEEC0000]    <1> 	mov	dx, [HF_PORT]
  4955 000043EF FEC2                <1> 	inc	dl
  4956 000043F1 F605[45200100]C0    <1> 	TEST	byte [CONTROL_BYTE],0C0H ; CHECK FOR RETRY SUPPRESSION
  4957 000043F8 7411                <1> 	JZ	short COMMAND3
  4958 000043FA 8A45FE              <1> 	MOV	AL, [CMD_BLOCK+6] 	; YES-GET OPERATION CODE
  4959 000043FD 24F0                <1> 	AND	AL,0F0H 		; GET RID OF MODIFIERS
  4960 000043FF 3C20                <1> 	CMP	AL,20H			; 20H-40H IS READ, WRITE, VERIFY
  4961 00004401 7208                <1> 	JB	short COMMAND3
  4962 00004403 3C40                <1> 	CMP	AL,40H
  4963 00004405 7704                <1> 	JA	short COMMAND3
  4964 00004407 804DFE01            <1> 	OR	byte [CMD_BLOCK+6],NO_RETRIES 
  4965                              <1> 					; VALID OPERATION FOR RETRY SUPPRESS
  4966                              <1> COMMAND3:
  4967 0000440B 8A443DF8            <1> 	MOV	AL,[CMD_BLOCK+eDI]	; GET THE COMMAND STRING BYTE
  4968 0000440F EE                  <1> 	OUT	DX,AL			; GIVE IT TO CONTROLLER
  4969                              <1> 	IODELAY
  4969 00004410 EB00                <2>  jmp short $+2
  4969 00004412 EB00                <2>  jmp short $+2
  4970 00004414 47                  <1> 	INC	eDI			; NEXT BYTE IN COMMAND BLOCK
  4971 00004415 6642                <1> 	INC	DX			; NEXT DISK ADAPTER REGISTER
  4972 00004417 6683FF07            <1> 	cmp	di, 7	; 1/1/2015	; ALL DONE?
  4973 0000441B 75EE                <1> 	JNZ	short COMMAND3		; NO--GO DO NEXT ONE
  4974 0000441D 5F                  <1> 	POP	eDI
  4975 0000441E C3                  <1> 	RETn				; ZERO FLAG IS SET
  4976                              <1> 
  4977                              <1> ;CMD_TIMEOUT:
  4978                              <1> ;	MOV	byte [DISK_STATUS1],BAD_CNTLR
  4979                              <1> ;COMMAND4:
  4980                              <1> ;	POP	BX
  4981                              <1> ;	CMP	[DISK_STATUS1],0 	; SET CONDITION CODE FOR CALLER
  4982                              <1> ;	RETn
  4983                              <1> 
  4984                              <1> ;----------------------------------------
  4985                              <1> ;	WAIT FOR INTERRUPT		:
  4986                              <1> ;----------------------------------------
  4987                              <1> ;WAIT:
  4988                              <1> _WAIT:
  4989 0000441F FB                  <1> 	STI				; MAKE SURE INTERRUPTS ARE ON
  4990                              <1> 	;SUB	CX,CX			; SET INITIAL DELAY BEFORE TEST
  4991                              <1> 	;CLC
  4992                              <1> 	;MOV	AX,9000H		; DEVICE WAIT INTERRUPT
  4993                              <1> 	;INT	15H
  4994                              <1> 	;JC	WT2			; DEVICE TIMED OUT
  4995                              <1> 	;MOV	BL,DELAY_1		; SET DELAY COUNT
  4996                              <1> 
  4997                              <1> 	;mov	bl, WAIT_HDU_INT_HI
  4998                              <1> 	;; 21/02/2015
  4999                              <1> 	;;mov	bl, WAIT_HDU_INT_HI + 1
  5000                              <1> 	;;mov	cx, WAIT_HDU_INT_LO
  5001 00004420 B915160500          <1> 	mov	ecx, WAIT_HDU_INT_LH
  5002                              <1> 					; (AWARD BIOS -> WAIT_FOR_MEM)
  5003                              <1> ;-----	WAIT LOOP
  5004                              <1> 
  5005                              <1> WT1:	
  5006                              <1> 	;TEST	byte [HF_INT_FLAG],80H	; TEST FOR INTERRUPT
  5007 00004425 F605[3B200100]C0    <1> 	test 	byte [HF_INT_FLAG],0C0h
  5008                              <1> 	;LOOPZ	WT1
  5009 0000442C 7517                <1> 	JNZ	short WT3		; INTERRUPT--LETS GO
  5010                              <1> 	;DEC	BL
  5011                              <1> 	;JNZ	short WT1		; KEEP TRYING FOR A WHILE
  5012                              <1> 
  5013                              <1> WT1_hi:
  5014 0000442E E461                <1> 	in	al, SYS1 ; 61h (PORT_B)	; wait for lo to hi
  5015 00004430 A810                <1> 	test	al, 10h			; transition on memory
  5016 00004432 75FA                <1> 	jnz	short WT1_hi		; refresh.
  5017                              <1> WT1_lo:
  5018 00004434 E461                <1> 	in	al, SYS1 		; 061h (PORT_B)	
  5019 00004436 A810                <1> 	test	al, 10h			
  5020 00004438 74FA                <1> 	jz	short WT1_lo
  5021 0000443A E2E9                <1> 	loop	WT1
  5022                              <1> 	;;or	bl, bl
  5023                              <1> 	;;jz	short WT2	
  5024                              <1> 	;;dec	bl
  5025                              <1> 	;;jmp	short WT1
  5026                              <1> 	;dec	bl
  5027                              <1> 	;jnz	short WT1	
  5028                              <1> 
  5029 0000443C C605[43200100]80    <1> WT2:	MOV	byte [DISK_STATUS1],TIME_OUT ; REPORT TIME OUT ERROR
  5030 00004443 EB0E                <1> 	JMP	SHORT WT4
  5031 00004445 C605[43200100]00    <1> WT3:	MOV	byte [DISK_STATUS1],0
  5032 0000444C C605[3B200100]00    <1> 	MOV	byte [HF_INT_FLAG],0
  5033 00004453 803D[43200100]00    <1> WT4:	CMP	byte [DISK_STATUS1],0 	; SET CONDITION CODE FOR CALLER
  5034 0000445A C3                  <1> 	RETn
  5035                              <1> 
  5036                              <1> ;----------------------------------------
  5037                              <1> ;	WAIT FOR CONTROLLER NOT BUSY	:
  5038                              <1> ;----------------------------------------
  5039                              <1> NOT_BUSY:
  5040 0000445B FB                  <1> 	STI				; MAKE SURE INTERRUPTS ARE ON
  5041                              <1> 	;PUSH	eBX
  5042                              <1> 	;SUB	CX,CX			; SET INITIAL DELAY BEFORE TEST
  5043 0000445C 668B15[EEEC0000]    <1> 	mov	DX, [HF_PORT]
  5044 00004463 80C207              <1> 	add	dl, 7			; Status port (HF_PORT+7)
  5045                              <1> 	;MOV	BL,DELAY_1
  5046                              <1> 					; wait for 10 seconds
  5047                              <1> 	;mov 	cx, WAIT_HDU_INT_LO	; 1615h
  5048                              <1> 	;;mov 	bl, WAIT_HDU_INT_HI	;   05h
  5049                              <1> 	;mov	bl, WAIT_HDU_INT_HI + 1
  5050 00004466 B915160500          <1> 	mov	ecx, WAIT_HDU_INT_LH  ; 21/02/2015
  5051                              <1> 	;
  5052                              <1> ;;      mov     byte [wait_count], 0    ; Reset wait counter
  5053                              <1> NB1:	
  5054 0000446B EC                  <1> 	IN	AL,DX			; CHECK STATUS
  5055                              <1> 	;TEST	AL,ST_BUSY
  5056 0000446C 2480                <1> 	and	al, ST_BUSY
  5057                              <1> 	;LOOPNZ	NB1
  5058 0000446E 7410                <1> 	JZ	short NB2		; NOT BUSY--LETS GO
  5059                              <1> 	;DEC	BL			
  5060                              <1> 	;JNZ	short NB1		; KEEP TRYING FOR A WHILE
  5061                              <1> 
  5062 00004470 E461                <1> NB1_hi: IN	AL,SYS1			; wait for hi to lo
  5063 00004472 A810                <1> 	TEST	AL,010H			; transition on memory
  5064 00004474 75FA                <1> 	JNZ	SHORT NB1_hi		; refresh.
  5065 00004476 E461                <1> NB1_lo: IN	AL,SYS1
  5066 00004478 A810                <1> 	TEST	AL,010H
  5067 0000447A 74FA                <1> 	JZ	short NB1_lo
  5068 0000447C E2ED                <1> 	LOOP	NB1
  5069                              <1> 	;dec	bl
  5070                              <1> 	;jnz	short NB1
  5071                              <1> 	;
  5072                              <1> ;;      cmp     byte [wait_count], 182  ; 10 seconds (182 timer ticks)
  5073                              <1> ;;	jb	short NB1
  5074                              <1> 	;
  5075                              <1> 	;MOV	[DISK_STATUS1],TIME_OUT	; REPORT TIME OUT ERROR
  5076                              <1> 	;JMP	SHORT NB3
  5077 0000447E B080                <1> 	mov	al, TIME_OUT
  5078                              <1> NB2:	
  5079                              <1> 	;MOV	byte [DISK_STATUS1],0
  5080                              <1> ;NB3:	
  5081                              <1> 	;POP	eBX
  5082 00004480 A2[43200100]        <1> 	mov	[DISK_STATUS1], al	;;; will be set after return
  5083                              <1> 	;CMP	byte [DISK_STATUS1],0 	; SET CONDITION CODE FOR CALLER
  5084 00004485 08C0                <1> 	or	al, al			; (zf = 0 --> timeout)
  5085 00004487 C3                  <1> 	RETn
  5086                              <1> 
  5087                              <1> ;----------------------------------------
  5088                              <1> ;	WAIT FOR DATA REQUEST		:
  5089                              <1> ;----------------------------------------
  5090                              <1> WAIT_DRQ:
  5091                              <1> 	;MOV	CX,DELAY_3
  5092                              <1> 	;MOV	DX,HF_PORT+7
  5093 00004488 668B15[EEEC0000]    <1> 	mov	dx, [HF_PORT]
  5094 0000448F 80C207              <1> 	add	dl, 7
  5095                              <1> 	;;MOV	bl, WAIT_HDU_DRQ_HI	; 0
  5096                              <1> 	;MOV	cx, WAIT_HDU_DRQ_LO	; 1000 (30 milli seconds)
  5097                              <1> 					; (but it is written as 2000
  5098                              <1> 					; micro seconds in ATORGS.ASM file
  5099                              <1> 					; of Award Bios - 1999, D1A0622)
  5100 00004492 B9E8030000          <1> 	mov 	ecx, WAIT_HDU_DRQ_LH ; 21/02/2015 
  5101 00004497 EC                  <1> WQ_1:	IN	AL,DX			; GET STATUS
  5102 00004498 A808                <1> 	TEST	AL,ST_DRQ		; WAIT FOR DRQ
  5103 0000449A 7516                <1> 	JNZ	short WQ_OK
  5104                              <1> 	;LOOP	WQ_1			; KEEP TRYING FOR A SHORT WHILE
  5105                              <1> WQ_hi:	
  5106 0000449C E461                <1> 	IN	AL,SYS1			; wait for hi to lo
  5107 0000449E A810                <1> 	TEST	AL,010H			; transition on memory
  5108 000044A0 75FA                <1> 	JNZ	SHORT WQ_hi		; refresh.
  5109 000044A2 E461                <1> WQ_lo:  IN      AL,SYS1
  5110 000044A4 A810                <1> 	TEST	AL,010H
  5111 000044A6 74FA                <1> 	JZ	SHORT WQ_lo
  5112 000044A8 E2ED                <1> 	LOOP	WQ_1
  5113                              <1> 
  5114 000044AA C605[43200100]80    <1>         MOV     byte [DISK_STATUS1],TIME_OUT ; ERROR
  5115 000044B1 F9                  <1> 	STC
  5116                              <1> WQ_OK:
  5117 000044B2 C3                  <1> 	RETn
  5118                              <1> ;WQ_OK:	;CLC
  5119                              <1> ;	RETn
  5120                              <1> 
  5121                              <1> ;----------------------------------------
  5122                              <1> ;	CHECK FIXED DISK STATUS 	:
  5123                              <1> ;----------------------------------------
  5124                              <1> CHECK_STATUS:
  5125 000044B3 E813000000          <1> 	CALL	CHECK_ST		; CHECK THE STATUS BYTE
  5126 000044B8 7509                <1> 	JNZ	short CHECK_S1		; AN ERROR WAS FOUND
  5127 000044BA A801                <1> 	TEST	AL,ST_ERROR		; WERE THERE ANY OTHER ERRORS
  5128 000044BC 7405                <1> 	JZ	short CHECK_S1		; NO ERROR REPORTED
  5129 000044BE E849000000          <1> 	CALL	CHECK_ER		; ERROR REPORTED
  5130                              <1> CHECK_S1:
  5131 000044C3 803D[43200100]00    <1> 	CMP	byte [DISK_STATUS1],0 	; SET STATUS FOR CALLER
  5132 000044CA C3                  <1> 	RETn
  5133                              <1> 
  5134                              <1> ;----------------------------------------
  5135                              <1> ;	CHECK FIXED DISK STATUS BYTE	:
  5136                              <1> ;----------------------------------------
  5137                              <1> CHECK_ST:
  5138                              <1> 	;MOV	DX,HF_PORT+7		; GET THE STATUS
  5139 000044CB 668B15[EEEC0000]    <1> 	mov	dx, [HF_PORT]
  5140 000044D2 80C207              <1> 	add	dl, 7
  5141                              <1> 	
  5142                              <1> 	; 17/02/2016
  5143                              <1> 	;(http://wiki.osdev.org/ATA_PIO_Mode)
  5144                              <1> 	;"delay 400ns to allow drive to set new values of BSY and DRQ"
  5145 000044D5 EC                  <1> 	IN	AL,DX
  5146                              <1> 	;in	al, dx ; 100ns
  5147                              <1> 	;in	al, dx ; 100ns
  5148                              <1>  	;in	al, dx ; 100ns
  5149                              <1> 	NEWIODELAY ; 18/02/2016 (AWARD BIOS - 1999, 'CKST' in AHSDK.ASM)
  5149 000044D6 E6EB                <2>  out 0ebh,al
  5150                              <1> 	;
  5151 000044D8 A2[39200100]        <1> 	MOV	[HF_STATUS],AL
  5152 000044DD B400                <1> 	MOV	AH,0
  5153 000044DF A880                <1> 	TEST	AL,ST_BUSY		; IF STILL BUSY
  5154 000044E1 751A                <1> 	JNZ	short CKST_EXIT		;  REPORT OK
  5155 000044E3 B4CC                <1> 	MOV	AH,WRITE_FAULT
  5156 000044E5 A820                <1> 	TEST	AL,ST_WRT_FLT		; CHECK FOR WRITE FAULT
  5157 000044E7 7514                <1> 	JNZ	short CKST_EXIT
  5158 000044E9 B4AA                <1> 	MOV	AH,NOT_RDY
  5159 000044EB A840                <1> 	TEST	AL,ST_READY		; CHECK FOR NOT READY
  5160 000044ED 740E                <1> 	JZ	short CKST_EXIT
  5161 000044EF B440                <1> 	MOV	AH,BAD_SEEK
  5162 000044F1 A810                <1> 	TEST	AL,ST_SEEK_COMPL	; CHECK FOR SEEK NOT COMPLETE
  5163 000044F3 7408                <1> 	JZ	short CKST_EXIT
  5164 000044F5 B411                <1> 	MOV	AH,DATA_CORRECTED
  5165 000044F7 A804                <1> 	TEST	AL,ST_CORRCTD		; CHECK FOR CORRECTED ECC
  5166 000044F9 7502                <1> 	JNZ	short CKST_EXIT
  5167 000044FB B400                <1> 	MOV	AH,0
  5168                              <1> CKST_EXIT:
  5169 000044FD 8825[43200100]      <1> 	MOV	[DISK_STATUS1],AH	; SET ERROR FLAG
  5170 00004503 80FC11              <1> 	CMP	AH,DATA_CORRECTED	; KEEP GOING WITH DATA CORRECTED
  5171 00004506 7403                <1> 	JZ	short CKST_EX1
  5172 00004508 80FC00              <1> 	CMP	AH,0
  5173                              <1> CKST_EX1:
  5174 0000450B C3                  <1> 	RETn
  5175                              <1> 
  5176                              <1> ;----------------------------------------
  5177                              <1> ;	CHECK FIXED DISK ERROR REGISTER :
  5178                              <1> ;----------------------------------------
  5179                              <1> CHECK_ER:
  5180                              <1> 	;MOV	DX, HF_PORT+1		; GET THE ERROR REGISTER
  5181 0000450C 668B15[EEEC0000]    <1> 	mov	dx, [HF_PORT]		;
  5182 00004513 FEC2                <1> 	inc	dl
  5183 00004515 EC                  <1> 	IN	AL,DX
  5184 00004516 A2[3A200100]        <1> 	MOV	[HF_ERROR],AL
  5185 0000451B 53                  <1> 	PUSH	eBX ; 21/02/2015
  5186 0000451C B908000000          <1> 	MOV	eCX,8			; TEST ALL 8 BITS
  5187 00004521 D0E0                <1> CK1:	SHL	AL,1			; MOVE NEXT ERROR BIT TO CARRY
  5188 00004523 7202                <1> 	JC	short CK2		; FOUND THE ERROR
  5189 00004525 E2FA                <1> 	LOOP	CK1			; KEEP TRYING
  5190 00004527 BB[E2EC0000]        <1> CK2:	MOV	eBX, ERR_TBL		; COMPUTE ADDRESS OF
  5191 0000452C 01CB                <1> 	ADD	eBX,eCX			; ERROR CODE
  5192                              <1> 	;;MOV	AH,BYTE [CS:BX]		; GET ERROR CODE
  5193                              <1> 	;mov	ah, [bx]
  5194 0000452E 8A23                <1> 	mov	ah, [ebx] ; 21/02/2015	
  5195 00004530 8825[43200100]      <1> CKEX:	MOV	[DISK_STATUS1],AH	; SAVE ERROR CODE
  5196 00004536 5B                  <1> 	POP	eBX
  5197 00004537 80FC00              <1> 	CMP	AH,0
  5198 0000453A C3                  <1> 	RETn
  5199                              <1> 
  5200                              <1> ;--------------------------------------------------------
  5201                              <1> ; CHECK_DMA						:
  5202                              <1> ;  -CHECK ES:BX AND # SECTORS TO MAKE SURE THAT IT WILL :
  5203                              <1> ;   FIT WITHOUT SEGMENT OVERFLOW.			:
  5204                              <1> ;  -ES:BX HAS BEEN REVISED TO THE FORMAT SSSS:000X	:
  5205                              <1> ;  -OK IF # SECTORS < 80H (7FH IF LONG READ OR WRITE)	:
  5206                              <1> ;  -OK IF # SECTORS = 80H (7FH) AND BX <= 00H (04H)	:
  5207                              <1> ;  -ERROR OTHERWISE					:
  5208                              <1> ;--------------------------------------------------------
  5209                              <1> CHECK_DMA:
  5210 0000453B 6650                <1> 	PUSH	AX			; SAVE REGISTERS
  5211 0000453D 66B80080            <1> 	MOV	AX,8000H		; AH = MAX # SECTORS AL = MAX OFFSET
  5212 00004541 F645FE02            <1>         TEST    byte [CMD_BLOCK+6],ECC_MODE
  5213 00004545 7404                <1> 	JZ	short CKD1
  5214 00004547 66B8047F            <1> 	MOV	AX,7F04H		; ECC IS 4 MORE BYTES
  5215 0000454B 3A65F9              <1> CKD1:	CMP	AH, [CMD_BLOCK+1] 	; NUMBER OF SECTORS
  5216 0000454E 7706                <1> 	JA	short CKDOK		; IT WILL FIT
  5217 00004550 7208                <1> 	JB	short CKDERR		; TOO MANY
  5218 00004552 38D8                <1> 	CMP	AL,BL			; CHECK OFFSET ON MAX SECTORS
  5219 00004554 7204                <1> 	JB	short CKDERR		; ERROR
  5220 00004556 F8                  <1> CKDOK:	CLC				; CLEAR CARRY
  5221 00004557 6658                <1> 	POP	AX
  5222 00004559 C3                  <1> 	RETn				; NORMAL RETURN
  5223 0000455A F9                  <1> CKDERR: STC				; INDICATE ERROR
  5224 0000455B C605[43200100]09    <1>         MOV     byte [DISK_STATUS1],DMA_BOUNDARY
  5225 00004562 6658                <1> 	POP	AX
  5226 00004564 C3                  <1> 	RETn
  5227                              <1> 
  5228                              <1> ;----------------------------------------
  5229                              <1> ;	SET UP ES:BX-> DISK PARMS	:
  5230                              <1> ;----------------------------------------
  5231                              <1> 					
  5232                              <1> ; INPUT -> DL = 0 based drive number
  5233                              <1> ; OUTPUT -> ES:BX = disk parameter table address
  5234                              <1> 
  5235                              <1> GET_VEC:
  5236                              <1> 	;SUB	AX,AX			; GET DISK PARAMETER ADDRESS
  5237                              <1> 	;MOV	ES,AX
  5238                              <1> 	;TEST	DL,1
  5239                              <1> 	;JZ	short GV_0
  5240                              <1> ;	LES	BX,[HF1_TBL_VEC] 	; ES:BX -> DRIVE PARAMETERS
  5241                              <1> ;	JMP	SHORT GV_EXIT
  5242                              <1> ;GV_0:
  5243                              <1> ;	LES	BX,[HF_TBL_VEC]		; ES:BX -> DRIVE PARAMETERS
  5244                              <1> ;
  5245                              <1> 	;xor	bh, bh
  5246 00004565 31DB                <1> 	xor	ebx, ebx
  5247 00004567 88D3                <1> 	mov	bl, dl
  5248                              <1> 	;;02/01/2015
  5249                              <1> 	;;shl	bl, 1			; port address offset
  5250                              <1> 	;;mov	ax, [bx+hd_ports]	; Base port address (1F0h, 170h)
  5251                              <1> 	;;shl	bl, 1			; dpt pointer offset
  5252 00004569 C0E302              <1> 	shl	bl, 2	;;
  5253                              <1> 	;add	bx, HF_TBL_VEC		; Disk parameter table pointer
  5254 0000456C 81C3[48200100]      <1> 	add	ebx, HF_TBL_VEC ; 21/02/2015
  5255                              <1> 	;push	word [bx+2]		; dpt segment
  5256                              <1> 	;pop	es
  5257                              <1> 	;mov	bx, [bx]		; dpt offset
  5258 00004572 8B1B                <1> 	mov	ebx, [ebx]		
  5259                              <1> ;GV_EXIT:
  5260 00004574 C3                  <1> 	RETn
  5261                              <1> 
  5262                              <1> hdc1_int: ; 21/02/2015
  5263                              <1> ;--- HARDWARE INT 76H -- ( IRQ LEVEL  14 ) ----------------------
  5264                              <1> ;								:
  5265                              <1> ;	FIXED DISK INTERRUPT ROUTINE				:
  5266                              <1> ;								:
  5267                              <1> ;----------------------------------------------------------------
  5268                              <1> 
  5269                              <1> ; 22/12/2014
  5270                              <1> ; IBM PC-XT Model 286 System BIOS Source Code - DISK.ASM (HD_INT)
  5271                              <1> ;	 '11/15/85'
  5272                              <1> ; AWARD BIOS 1999 (D1A0622) 
  5273                              <1> ;	Source Code - ATORGS.ASM (INT_HDISK, INT_HDISK1)
  5274                              <1> 
  5275                              <1> ;int_76h:
  5276                              <1> HD_INT:
  5277 00004575 6650                <1> 	PUSH	AX
  5278 00004577 1E                  <1> 	PUSH	DS
  5279                              <1> 	;CALL	DDS
  5280                              <1> 	; 21/02/2015 (32 bit, 386 pm modification)
  5281 00004578 66B81000            <1> 	mov	ax, KDATA
  5282 0000457C 8ED8                <1> 	mov 	ds, ax
  5283                              <1> 	;
  5284                              <1> 	;;MOV	@HF_INT_FLAG,0FFH	; ALL DONE
  5285                              <1>         ;mov     byte [CS:HF_INT_FLAG], 0FFh
  5286 0000457E C605[3B200100]FF    <1> 	mov	byte [HF_INT_FLAG], 0FFh
  5287                              <1> 	;
  5288 00004585 6652                <1> 	push	dx
  5289 00004587 66BAF701            <1> 	mov	dx, HDC1_BASEPORT+7	; Status Register (1F7h)
  5290                              <1> 					; Clear Controller
  5291                              <1> Clear_IRQ1415:				; (Award BIOS - 1999)
  5292 0000458B EC                  <1> 	in	al, dx			;
  5293 0000458C 665A                <1> 	pop	dx
  5294                              <1> 	NEWIODELAY
  5294 0000458E E6EB                <2>  out 0ebh,al
  5295                              <1> 	;
  5296 00004590 B020                <1> 	MOV	AL,EOI			; NON-SPECIFIC END OF INTERRUPT
  5297 00004592 E6A0                <1> 	OUT	INTB00,AL		; FOR CONTROLLER #2
  5298                              <1> 	;JMP	$+2			; WAIT
  5299                              <1> 	NEWIODELAY
  5299 00004594 E6EB                <2>  out 0ebh,al
  5300 00004596 E620                <1> 	OUT	INTA00,AL		; FOR CONTROLLER #1
  5301 00004598 1F                  <1> 	POP	DS
  5302                              <1> 	;STI				; RE-ENABLE INTERRUPTS
  5303                              <1> 	;MOV	AX,9100H		; DEVICE POST
  5304                              <1> 	;INT	15H			;  INTERRUPT
  5305                              <1> irq15_iret: ; 25/02/2015
  5306 00004599 6658                <1> 	POP	AX
  5307 0000459B CF                  <1> 	IRETd				; RETURN FROM INTERRUPT
  5308                              <1> 
  5309                              <1> hdc2_int: ; 21/02/2015
  5310                              <1> ;++++ HARDWARE INT 77H ++ ( IRQ LEVEL  15 ) +++++++++++++++++++++
  5311                              <1> ;								:
  5312                              <1> ;	FIXED DISK INTERRUPT ROUTINE				:
  5313                              <1> ;								:
  5314                              <1> ;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  5315                              <1> 
  5316                              <1> ;int_77h:
  5317                              <1> HD1_INT:
  5318 0000459C 6650                <1> 	PUSH	AX
  5319                              <1> 	; Check if that is a spurious IRQ (from slave PIC)
  5320                              <1> 	; 25/02/2015 (source: http://wiki.osdev.org/8259_PIC)
  5321 0000459E B00B                <1> 	mov	al, 0Bh  ; In-Service Register
  5322 000045A0 E6A0                <1> 	out	0A0h, al
  5323 000045A2 EB00                <1>         jmp short $+2
  5324 000045A4 EB00                <1> 	jmp short $+2
  5325 000045A6 E4A0                <1> 	in	al, 0A0h
  5326 000045A8 2480                <1> 	and 	al, 80h ; bit 7 (is it real IRQ 15 or fake?)
  5327 000045AA 74ED                <1> 	jz	short irq15_iret ; Fake (spurious)IRQ, do not send EOI)
  5328                              <1> 	;
  5329 000045AC 1E                  <1> 	PUSH	DS
  5330                              <1> 	;CALL	DDS
  5331                              <1> 	; 21/02/2015 (32 bit, 386 pm modification)
  5332 000045AD 66B81000            <1> 	mov	ax, KDATA
  5333 000045B1 8ED8                <1> 	mov 	ds, ax
  5334                              <1> 	;
  5335                              <1> 	;;MOV	@HF_INT_FLAG,0FFH	; ALL DONE
  5336                              <1>         ;or      byte [CS:HF_INT_FLAG],0C0h 
  5337 000045B3 800D[3B200100]C0    <1> 	or	byte [HF_INT_FLAG], 0C0h
  5338                              <1> 	;
  5339 000045BA 6652                <1> 	push	dx
  5340 000045BC 66BA7701            <1> 	mov	dx, HDC2_BASEPORT+7	; Status Register (177h)
  5341                              <1> 					; Clear Controller (Award BIOS 1999)
  5342 000045C0 EBC9                <1> 	jmp	short Clear_IRQ1415
  5343                              <1> 
  5344                              <1> 
  5345                              <1> ;%include 'diskdata.inc' ; 11/03/2015
  5346                              <1> ;%include 'diskbss.inc' ; 11/03/2015
  5347                              <1> 
  5348                              <1> 
  5349                              <1> ;////////////////////////////////////////////////////////////////////
  5350                              <1> ;; END OF DISK I/O SYTEM ///
  1914                                  %include 'memory.s'  ; 09/03/2015
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.0 - memory.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 16/07/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> ; 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 1			; insufficient (out of) memory
    46                              <1> ERR_MINOR_DSK	equ 2			; disk read/write error
    47                              <1> ERR_MINOR_PV	equ 3			; protection violation
    48                              <1> SWP_DISK_READ_ERR equ 4
    49                              <1> SWP_DISK_NOT_PRESENT_ERR equ 5
    50                              <1> SWP_SECTOR_NOT_PRESENT_ERR equ 6
    51                              <1> SWP_NO_FREE_SPACE_ERR equ 7
    52                              <1> SWP_DISK_WRITE_ERR equ 8
    53                              <1> SWP_NO_PAGE_TO_SWAP_ERR equ 9
    54                              <1> PTE_A_ACCESS_BIT equ 5  ; Bit 5 (accessed flag)        
    55                              <1> SECTOR_SHIFT    equ 3   ; sector shift (to convert page block number)
    56                              <1> ; 12/07/2016
    57                              <1> PTE_SHARED	equ 400h		; AVL bit 1, direct memory access bit	
    58                              <1> 					; (Indicates that the page is not allocated
    59                              <1> 					; for the process, it is a shared or system
    60                              <1>                                         ; page, it must not be deallocated!)
    61                              <1> ;
    62                              <1> ;; Retro Unix 386 v1 - paging method/principles
    63                              <1> ;;
    64                              <1> ;; 10/10/2014
    65                              <1> ;; RETRO UNIX 386 v1 - PAGING METHOD/PRINCIPLES
    66                              <1> ;;
    67                              <1> ;; KERNEL PAGE MAP: 1 to 1 physical memory page map
    68                              <1> ;;	(virtual address = physical address)
    69                              <1> ;; KERNEL PAGE TABLES:
    70                              <1> ;;	Kernel page directory and all page tables are
    71                              <1> ;;	on memory as initialized, as equal to physical memory
    72                              <1> ;;	layout. Kernel pages can/must not be swapped out/in.
    73                              <1> ;;
    74                              <1> ;;	what for: User pages may be swapped out, when accessing
    75                              <1> ;;	a page in kernel/system mode, if it would be swapped out,
    76                              <1> ;;	kernel would have to swap it in! But it is also may be
    77                              <1> ;;	in use by a user process. (In system/kernel mode
    78                              <1> ;;	kernel can access all memory pages even if they are
    79                              <1> ;;	reserved/allocated for user processes. Swap out/in would
    80                              <1> ;;	cause conflicts.) 
    81                              <1> ;;	
    82                              <1> ;;	As result of these conditions,
    83                              <1> ;;	all kernel pages must be initialized as equal to 
    84                              <1> ;;	physical layout for preventing page faults. 
    85                              <1> ;;	Also, calling "allocate page" procedure after
    86                              <1> ;;	a page fault can cause another page fault (double fault)
    87                              <1> ;;	if all kernel page tables would not be initialized.
    88                              <1> ;;
    89                              <1> ;;	[first_page] = Beginning of users space, as offset to 
    90                              <1> ;;	memory allocation table. (double word aligned)
    91                              <1> ;;
    92                              <1> ;;	[next_page] = first/next free space to be searched
    93                              <1> ;;	as offset to memory allocation table. (dw aligned)
    94                              <1> ;;
    95                              <1> ;;	[last_page] = End of memory (users space), as offset
    96                              <1> ;;	to memory allocation table. (double word aligned)
    97                              <1> ;;
    98                              <1> ;; USER PAGE TABLES:
    99                              <1> ;;	Demand paging (& 'copy on write' allocation method) ...
   100                              <1> ;;		'ready only' marked copies of the 
   101                              <1> ;;		parent process's page table entries (for
   102                              <1> ;;		same physical memory).
   103                              <1> ;;		(A page will be copied to a new page after
   104                              <1> ;;		 if it causes R/W page fault.)
   105                              <1> ;;
   106                              <1> ;;	Every user process has own (different)
   107                              <1> ;;	page directory and page tables.	
   108                              <1> ;;
   109                              <1> ;;	Code starts at virtual address 0, always.
   110                              <1> ;;	(Initial value of EIP is 0 in user mode.)
   111                              <1> ;;	(Programs can be written/developed as simple
   112                              <1> ;;	 flat memory programs.)
   113                              <1> ;;
   114                              <1> ;; MEMORY ALLOCATION STRATEGY:
   115                              <1> ;;	Memory page will be allocated by kernel only 
   116                              <1> ;;		(in kernel/system mode only).
   117                              <1> ;;	* After a
   118                              <1> ;;	  - 'not present' page fault
   119                              <1> ;;	  - 'writing attempt on read only page' page fault 	 	
   120                              <1> ;;	* For loading (opening, reading) a file or disk/drive
   121                              <1> ;;	* As responce to 'allocate additional memory blocks' 
   122                              <1> ;;	  request by running process.
   123                              <1> ;;	* While creating a process, allocating a new buffer,
   124                              <1> ;;	  new page tables etc.
   125                              <1> ;;
   126                              <1> ;;	At first,
   127                              <1> ;;	- 'allocate page' procedure will be called;
   128                              <1> ;,	   if it will return with a valid (>0) physical address
   129                              <1> ;;	   (that means the relevant M.A.T. bit has been RESET)	
   130                              <1> ;;	   relevant memory page/block will be cleared (zeroed).
   131                              <1> ;;	- 'allocate page' will be called for allocating page
   132                              <1> ;;	   directory, page table and running space (data/code).
   133                              <1> ;;	- every successful 'allocate page' call will decrease
   134                              <1> ;;	  'free_pages' count (pointer).
   135                              <1> ;;	- 'out of (insufficient) memory error' will be returned
   136                              <1> ;;	  if 'free_pages' points to a ZERO.
   137                              <1> ;;	- swapping out and swapping in (if it is not a new page)
   138                              <1> ;;	  procedures will be called as responce to 'out of memory'
   139                              <1> ;;	  error except errors caused by attribute conflicts.
   140                              <1> ;;	 (swapper functions)	 
   141                              <1> ;;					
   142                              <1> ;;	At second,
   143                              <1> ;;	- page directory entry will be updated then page table
   144                              <1> ;;	  entry will be updated.		
   145                              <1> ;;
   146                              <1> ;; MEMORY ALLOCATION TABLE FORMAT:
   147                              <1> ;;	- M.A.T. has a size according to available memory as
   148                              <1> ;;	  follows:
   149                              <1> ;;		  - 1 (allocation) bit per 1 page (4096 bytes)
   150                              <1> ;;		  - a bit with value of 0 means allocated page
   151                              <1> ;;		  - a bit with value of 1 means a free page
   152                              <1> ;,	- 'free_pages' pointer holds count of free pages
   153                              <1> ;;	  depending on M.A.T.
   154                              <1> ;;		(NOTE: Free page count will not be checked
   155                              <1> ;;		again -on M.A.T.- after initialization. 
   156                              <1> ;;		Kernel will trust on initial count.)
   157                              <1> ;,	- 'free_pages' count will be decreased by allocation
   158                              <1> ;;	  and it will be increased by deallocation procedures.
   159                              <1> ;;	
   160                              <1> ;;	- Available memory will be calculated during
   161                              <1> ;;	  the kernel's initialization stage (in real mode).
   162                              <1> ;;	  Memory allocation table and kernel page tables 
   163                              <1> ;;	  will be formatted/sized as result of available
   164                              <1> ;;	  memory calculation before paging is enabled.
   165                              <1> ;;
   166                              <1> ;; For 4GB Available/Present Memory: (max. possible memory size)
   167                              <1> ;;	- Memory Allocation Table size will be 128 KB.
   168                              <1> ;;	- Memory allocation for kernel page directory size 
   169                              <1> ;;	  is always 4 KB. (in addition to total allocation size
   170                              <1> ;;	  for page tables)
   171                              <1> ;;	- Memory allocation for kernel page tables (1024 tables)
   172                              <1> ;;	  is 4 MB (1024*4*1024 bytes).
   173                              <1> ;;	- User (available) space will be started 
   174                              <1> ;;	  at 6th MB of the memory (after 1MB+4MB).
   175                              <1> ;;	- The first 640 KB is for kernel's itself plus
   176                              <1> ;;	  memory allocation table and kernel's page directory
   177                              <1> ;;	  (D0000h-EFFFFh may be used as kernel space...)	
   178                              <1> ;;	- B0000h to B7FFFh address space (32 KB) will be used
   179                              <1> ;; 	  for buffers.
   180                              <1> ;;	- ROMBIOS, VIDEO BUFFER and VIDEO ROM space are reserved.
   181                              <1> ;,	  (A0000h-AFFFFh, C0000h-CFFFFh, F0000h-FFFFFh)
   182                              <1> ;;	- Kernel page tables start at 100000h (2nd MB)
   183                              <1> ;;
   184                              <1> ;; For 1GB Available Memory:
   185                              <1> ;;	- Memory Allocation Table size will be 32 KB.
   186                              <1> ;;	- Memory allocation for kernel page directory size 
   187                              <1> ;;	  is always 4 KB. (in addition to total allocation size
   188                              <1> ;;	  for page tables)
   189                              <1> ;;	- Memory allocation for kernel page tables (256 tables)
   190                              <1> ;;	  is 1 MB (256*4*1024 bytes).
   191                              <1> ;;	- User (available) space will be started 
   192                              <1> ;;	  at 3th MB of the memory (after 1MB+1MB).
   193                              <1> ;;	- The first 640 KB is for kernel's itself plus
   194                              <1> ;;	  memory allocation table and kernel's page directory
   195                              <1> ;;	  (D0000h-EFFFFh may be used as kernel space...)	
   196                              <1> ;;	- B0000h to B7FFFh address space (32 KB) will be used
   197                              <1> ;; 	  for buffers.
   198                              <1> ;;	- ROMBIOS, VIDEO BUFFER and VIDEO ROM space are reserved.
   199                              <1> ;,	  (A0000h-AFFFFh, C0000h-CFFFFh, F0000h-FFFFFh)
   200                              <1> ;;	- Kernel page tables start at 100000h (2nd MB).	
   201                              <1> ;;
   202                              <1> ;;
   203                              <1> 
   204                              <1> 
   205                              <1> ;;************************************************************************************
   206                              <1> ;; 
   207                              <1> ;; RETRO UNIX 386 v1 - Paging (Method for Copy On Write paging principle)
   208                              <1> ;; DEMAND PAGING - PARENT&CHILD PAGE TABLE DUPLICATION PRINCIPLES (23/04/2015)
   209                              <1> 
   210                              <1> ;; Main factor: "sys fork" system call 
   211                              <1> ;;	
   212                              <1> ;; 		FORK
   213                              <1> ;;                      |----> parent - duplicated PTEs, read only pages
   214                              <1> ;;  writable pages ---->|
   215                              <1> ;;                      |----> child - duplicated PTEs, read only pages
   216                              <1> ;; 
   217                              <1> ;; AVL bit (0) of Page Table Entry is used as duplication sign 
   218                              <1> ;; 
   219                              <1> ;; AVL Bit 0 [PTE Bit 9] = 'Duplicated PTE belongs to child' sign/flag (if it is set)
   220                              <1> ;; Note: Dirty bit (PTE bit 6) may be used instead of AVL bit 0 (PTE bit 9)
   221                              <1> ;;       -while R/W bit is 0-. 
   222                              <1> ;; 
   223                              <1> ;; Duplicate page tables with writable pages (the 1st sys fork in the process):
   224                              <1> ;; # Parent's Page Table Entries are updated to point same pages as read only, 
   225                              <1> ;;   as duplicated PTE bit  -AVL bit 0, PTE bit 9- are reset/clear.
   226                              <1> ;; # Then Parent's Page Table is copied to Child's Page Table.
   227                              <1> ;; # Child's Page Table Entries are updated as duplicated child bit
   228                              <1> ;;   -AVL bit 0, PTE bit 9- is set.	  
   229                              <1> ;; 
   230                              <1> ;; Duplicate page tables with read only pages (several sys fork system calls):
   231                              <1> ;; # Parent's read only pages are copied to new child pages. 
   232                              <1> ;;   Parent's PTE attributes are not changed.
   233                              <1> ;;   (Because, there is another parent-child fork before this fork! We must not
   234                              <1> ;;    destroy/mix previous fork result).
   235                              <1> ;; # Child's Page Table Entries (which are corresponding to Parent's 
   236                              <1> ;;   read only pages) are set as writable (while duplicated PTE bit is clear). 
   237                              <1> ;; # Parent's PTEs with writable page attribute are updated to point same pages 
   238                              <1> ;;   as read only, (while) duplicated PTE bit is reset (clear).
   239                              <1> ;; # Parent's Page Table Entries (with writable page attribute) are duplicated 
   240                              <1> ;;   as Child's Page Table Entries without copying actual page.
   241                              <1> ;; # Child 's Page Table Entries (which are corresponding to Parent's writable 
   242                              <1> ;;   pages) are updated as duplicated PTE bit (AVL bit 0, PTE bit 9- is set.
   243                              <1> ;; 
   244                              <1> ;; !? WHAT FOR (duplication after duplication):
   245                              <1> ;; In UNIX method for sys fork (a typical 'fork' application in /etc/init)
   246                              <1> ;; program/executable code continues from specified location as child process, 
   247                              <1> ;; returns back previous code location as parent process, every child after 
   248                              <1> ;; every sys fork uses last image of code and data just prior the fork.
   249                              <1> ;; Even if the parent code changes data, the child will not see the changed data 
   250                              <1> ;; after the fork. In Retro UNIX 8086 v1, parent's process segment (32KB)
   251                              <1> ;; was copied to child's process segment (all of code and data) according to
   252                              <1> ;; original UNIX v1 which copies all of parent process code and data -core- 
   253                              <1> ;; to child space -core- but swaps that core image -of child- on to disk.
   254                              <1> ;; If I (Erdogan Tan) would use a method of to copy parent's core
   255                              <1> ;; (complete running image of parent process) to the child process; 
   256                              <1> ;; for big sizes, i would force Retro UNIX 386 v1 to spend many memory pages 
   257                              <1> ;; and times only for a sys fork. (It would excessive reservation for sys fork,
   258                              <1> ;; because sys fork usually is prior to sys exec; sys exec always establishes
   259                              <1> ;; a new/fresh core -running space-, by clearing all code/data content). 
   260                              <1> ;; 'Read Only' page flag ensures page fault handler is needed only for a few write
   261                              <1> ;; attempts between sys fork and sys exec, not more... (I say so by thinking 
   262                              <1> ;; of "/etc/init" content, specially.) sys exec will clear page tables and
   263                              <1> ;; new/fresh pages will be used to load and run new executable/program.
   264                              <1> ;; That is what for i have preferred "copy on write", "duplication" method
   265                              <1> ;; for sharing same read only pages between parent and child processes.
   266                              <1> ;; That is a pitty i have to use new private flag (AVL bit 0, "duplicated PTE 
   267                              <1> ;; belongs to child" sign) for cooperation on duplicated pages between a parent 
   268                              <1> ;; and it's child processes; otherwise parent process would destroy data belongs
   269                              <1> ;; to its child or vice versa; or some pages would remain unclaimed 
   270                              <1> ;; -deallocation problem-.
   271                              <1> ;; Note: to prevent conflicts, read only pages must not be swapped out... 
   272                              <1> ;; 
   273                              <1> ;; WHEN PARENT TRIES TO WRITE IT'S READ ONLY (DUPLICATED) PAGE:
   274                              <1> ;; # Page fault handler will do those:
   275                              <1> ;;   - 'Duplicated PTE' flag (PTE bit 9) is checked (on the failed PTE).
   276                              <1> ;;   - If it is reset/clear, there is a child uses same page.
   277                              <1> ;;   - Parent's read only page -previous page- is copied to a new writable page. 
   278                              <1> ;;   - Parent's PTE is updated as writable page, as unique page (AVL=0)
   279                              <1> ;;   - (Page fault handler whill check this PTE later, if child process causes to
   280                              <1> ;;     page fault due to write attempt on read only page. Of course, the previous 
   281                              <1> ;;     read only page will be converted to writable and unique page which belongs
   282                              <1> ;;     to child process.)	
   283                              <1> ;; WHEN CHILD TRIES TO WRITE IT'S READ ONLY (DUPLICATED) PAGE:
   284                              <1> ;; # Page fault handler will do those:
   285                              <1> ;;   - 'Duplicated PTE' flag (PTE bit 9) is checked (on the failed PTE).
   286                              <1> ;;   - If it is set, there is a parent uses -or was using- same page.
   287                              <1> ;;   - Same PTE address within parent's page table is checked if it has same page
   288                              <1> ;;     address or not. 
   289                              <1> ;;   - If parent's PTE has same address, child will continue with a new writable page.
   290                              <1> ;;     Parent's PTE will point to same (previous) page as writable, unique (AVL=0).	
   291                              <1> ;;   - If parent's PTE has different address, child will continue with it's 
   292                              <1> ;;     own/same page but read only flag (0) will be changed to writable flag (1) and
   293                              <1> ;;     'duplicated PTE (belongs to child)' flag/sign will be cleared/reset. 	  	
   294                              <1> ;; 
   295                              <1> ;; NOTE: When a child process is terminated, read only flags of parent's page tables
   296                              <1> ;;       will be set as writable (and unique) in case of child process was using 
   297                              <1> ;;       same pages with duplicated child PTE sign... Depending on sys fork and 
   298                              <1> ;;       duplication method details, it is not possible multiple child processes
   299                              <1> ;;       were using same page with duplicated PTEs.
   300                              <1> ;; 
   301                              <1> ;;************************************************************************************   
   302                              <1> 
   303                              <1> ;; 08/10/2014
   304                              <1> ;; 11/09/2014 - Retro UNIX 386 v1 PAGING (further) draft
   305                              <1> ;;		by Erdogan Tan (Based on KolibriOS 'memory.inc')
   306                              <1> 
   307                              <1> ;; 'allocate_page' code is derived and modified from KolibriOS
   308                              <1> ;; 'alloc_page' procedure in 'memory.inc' 
   309                              <1> ;; (25/08/2014, Revision: 5057) file 
   310                              <1> ;; by KolibriOS Team (2004-2012)
   311                              <1> 
   312                              <1> allocate_page:
   313                              <1> 	; 01/07/2015
   314                              <1> 	; 05/05/2015
   315                              <1> 	; 30/04/2015
   316                              <1> 	; 16/10/2014
   317                              <1> 	; 08/10/2014
   318                              <1> 	; 09/09/2014 (Retro UNIX 386 v1 - beginning)
   319                              <1> 	;
   320                              <1> 	; INPUT -> none
   321                              <1> 	;
   322                              <1> 	; OUTPUT ->
   323                              <1> 	;	EAX = PHYSICAL (real/flat) ADDRESS OF THE ALLOCATED PAGE
   324                              <1> 	;	(corresponding MEMORY ALLOCATION TABLE bit is RESET)
   325                              <1> 	;
   326                              <1> 	;	CF = 1 and EAX = 0 
   327                              <1> 	; 		   if there is not a free page to be allocated	
   328                              <1> 	;
   329                              <1> 	; Modified Registers -> none (except EAX)
   330                              <1> 	;
   331 000045C2 A1[B01F0100]        <1> 	mov	eax, [free_pages]
   332 000045C7 21C0                <1> 	and	eax, eax
   333 000045C9 7438                <1> 	jz	short out_of_memory
   334                              <1> 	;
   335 000045CB 53                  <1> 	push	ebx
   336 000045CC 51                  <1> 	push	ecx
   337                              <1> 	;
   338 000045CD BB00001000          <1> 	mov	ebx, MEM_ALLOC_TBL   ; Memory Allocation Table offset
   339 000045D2 89D9                <1> 	mov	ecx, ebx
   340                              <1>  				     ; NOTE: 32 (first_page) is initial
   341                              <1> 				     ; value of [next_page].
   342                              <1> 				     ; It points to the first available
   343                              <1> 				     ; page block for users (ring 3) ...	
   344                              <1> 				     ; (MAT offset 32 = 1024/32)	
   345                              <1> 				     ; (at the of the first 4 MB)		
   346 000045D4 031D[B41F0100]      <1> 	add	ebx, [next_page] ; Free page searching starts from here
   347                              <1> 				 ; next_free_page >> 5
   348 000045DA 030D[B81F0100]      <1> 	add	ecx, [last_page] ; Free page searching ends here
   349                              <1> 				 ; (total_pages - 1) >> 5
   350                              <1> al_p_scan:
   351 000045E0 39CB                <1> 	cmp	ebx, ecx
   352 000045E2 770A                <1> 	ja	short al_p_notfound
   353                              <1> 	;
   354                              <1> 	; 01/07/2015
   355                              <1> 	; AMD64 Architecture Programmers Manual
   356                              <1> 	; Volume 3:
   357                              <1> 	; General-Purpose and System Instructions
   358                              <1> 	;
   359                              <1> 	; BSF - Bit Scan Forward
   360                              <1> 	;
   361                              <1> 	;   Searches the value in a register or a memory location
   362                              <1> 	;   (second operand) for the least-significant set bit. 
   363                              <1> 	;   If a set bit is found, the instruction clears the zero flag (ZF)
   364                              <1> 	;   and stores the index of the least-significant set bit in a destination
   365                              <1> 	;   register (first operand). If the second operand contains 0, 
   366                              <1> 	;   the instruction sets ZF to 1 and does not change the contents of the 
   367                              <1> 	;   destination register. The bit index is an unsigned offset from bit 0 
   368                              <1> 	;   of the searched value
   369                              <1> 	;
   370 000045E4 0FBC03              <1> 	bsf	eax, [ebx] ; Scans source operand for first bit set (1).
   371                              <1> 			   ; Clear ZF if a bit is found set (1) and 
   372                              <1> 			   ; loads the destination with an index to
   373                              <1> 			   ; first set bit. (0 -> 31) 
   374                              <1> 			   ; Sets ZF to 1 if no bits are found set.
   375 000045E7 7525                <1> 	jnz	short al_p_found ; ZF = 0 -> a free page has been found
   376                              <1> 			 ;
   377                              <1> 			 ; NOTE:  a Memory Allocation Table bit 
   378                              <1> 			 ;	  with value of 1 means 
   379                              <1> 			 ;	  the corresponding page is free 
   380                              <1> 			 ;	  (Retro UNIX 386 v1 feaure only!)
   381 000045E9 83C304              <1> 	add	ebx, 4
   382                              <1> 			 ; We return back for searching next page block
   383                              <1> 			 ; NOTE: [free_pages] is not ZERO; so, 
   384                              <1> 			 ;	 we always will find at least 1 free page here.
   385 000045EC EBF2                <1>         jmp     short al_p_scan
   386                              <1> 	;
   387                              <1> al_p_notfound:
   388 000045EE 81E900001000        <1> 	sub	ecx, MEM_ALLOC_TBL
   389 000045F4 890D[B41F0100]      <1> 	mov	[next_page], ecx ; next/first free page = last page 
   390                              <1> 				 ; (deallocate_page procedure will change it)
   391 000045FA 31C0                <1> 	xor	eax, eax
   392 000045FC A3[B01F0100]        <1> 	mov	[free_pages], eax ; 0
   393 00004601 59                  <1> 	pop	ecx
   394 00004602 5B                  <1> 	pop	ebx
   395                              <1> 	;
   396                              <1> out_of_memory:
   397 00004603 E85B040000          <1> 	call	swap_out
   398 00004608 7325                <1> 	jnc	short al_p_ok  ; [free_pages] = 0, re-allocation by swap_out
   399                              <1> 	;
   400 0000460A 29C0                <1> 	sub 	eax, eax ; 0
   401 0000460C F9                  <1> 	stc
   402 0000460D C3                  <1> 	retn
   403                              <1> 
   404                              <1> al_p_found:
   405 0000460E 89D9                <1> 	mov	ecx, ebx
   406 00004610 81E900001000        <1> 	sub	ecx, MEM_ALLOC_TBL
   407 00004616 890D[B41F0100]      <1> 	mov	[next_page], ecx ; Set first free page searching start
   408                              <1> 				 ; address/offset (to the next)
   409 0000461C FF0D[B01F0100]      <1>         dec     dword [free_pages] ; 1 page has been allocated (X = X-1) 
   410                              <1> 	;
   411 00004622 0FB303              <1> 	btr	[ebx], eax	 ; The destination bit indexed by the source value
   412                              <1> 				 ; is copied into the Carry Flag and then cleared
   413                              <1> 				 ; in the destination.
   414                              <1> 				 ;
   415                              <1> 				 ; Reset the bit which is corresponding to the 
   416                              <1> 				 ; (just) allocated page.
   417                              <1> 	; 01/07/2015 (4*8 = 32, 1 allocation byte = 8 pages)	
   418 00004625 C1E103              <1> 	shl	ecx, 3		 ; (page block offset * 32) + page index
   419 00004628 01C8                <1> 	add	eax, ecx	 ; = page number
   420 0000462A C1E00C              <1> 	shl	eax, 12		 ; physical address of the page (flat/real value)
   421                              <1> 	; EAX = physical address of memory page
   422                              <1> 	;
   423                              <1> 	; NOTE: The relevant page directory and page table entry will be updated
   424                              <1> 	;       according to this EAX value...
   425 0000462D 59                  <1> 	pop	ecx
   426 0000462E 5B                  <1> 	pop	ebx
   427                              <1> al_p_ok:
   428 0000462F C3                  <1> 	retn
   429                              <1> 
   430                              <1> 
   431                              <1> make_page_dir:
   432                              <1> 	; 18/04/2015
   433                              <1> 	; 12/04/2015
   434                              <1> 	; 23/10/2014
   435                              <1> 	; 16/10/2014
   436                              <1> 	; 09/10/2014 ; (Retro UNIX 386 v1 - beginning)
   437                              <1> 	;
   438                              <1> 	; INPUT ->
   439                              <1> 	;	none
   440                              <1> 	; OUTPUT ->
   441                              <1> 	;	(EAX = 0)
   442                              <1> 	;	cf = 1 -> insufficient (out of) memory error
   443                              <1> 	;	cf = 0 ->
   444                              <1> 	;	u.pgdir = page directory (physical) address of the current
   445                              <1> 	;		  process/user.
   446                              <1> 	;
   447                              <1> 	; Modified Registers -> EAX
   448                              <1> 	;
   449 00004630 E88DFFFFFF          <1> 	call	allocate_page
   450 00004635 7216                <1> 	jc	short mkpd_error
   451                              <1> 	;
   452 00004637 A3[E1300100]        <1> 	mov	[u.pgdir], eax    ; Page dir address for current user/process
   453                              <1> 				  ; (Physical address)
   454                              <1> clear_page:
   455                              <1> 	; 18/04/2015
   456                              <1> 	; 09/10/2014 ; (Retro UNIX 386 v1 - beginning)
   457                              <1> 	;
   458                              <1> 	; INPUT ->
   459                              <1> 	;	EAX = physical address of the page
   460                              <1> 	; OUTPUT ->
   461                              <1> 	;	all bytes of the page will be cleared
   462                              <1> 	;
   463                              <1> 	; Modified Registers -> none
   464                              <1> 	;
   465 0000463C 57                  <1> 	push	edi
   466 0000463D 51                  <1> 	push	ecx
   467 0000463E 50                  <1> 	push	eax
   468 0000463F B900040000          <1> 	mov	ecx, PAGE_SIZE / 4
   469 00004644 89C7                <1> 	mov	edi, eax
   470 00004646 31C0                <1> 	xor	eax, eax
   471 00004648 F3AB                <1> 	rep	stosd
   472 0000464A 58                  <1> 	pop	eax
   473 0000464B 59                  <1> 	pop	ecx
   474 0000464C 5F                  <1> 	pop	edi
   475                              <1> mkpd_error:
   476                              <1> mkpt_error:
   477 0000464D C3                  <1> 	retn
   478                              <1> 
   479                              <1> make_page_table:
   480                              <1> 	; 23/06/2015
   481                              <1> 	; 18/04/2015
   482                              <1> 	; 12/04/2015
   483                              <1> 	; 16/10/2014
   484                              <1> 	; 09/10/2014 ; (Retro UNIX 386 v1 - beginning)
   485                              <1> 	;
   486                              <1> 	; INPUT ->
   487                              <1> 	;	EBX = virtual (linear) address
   488                              <1> 	;	ECX = page table attributes (lower 12 bits)
   489                              <1> 	;	      (higher 20 bits must be ZERO)
   490                              <1> 	;	      (bit 0 must be 1)	 
   491                              <1> 	;	u.pgdir = page directory (physical) address
   492                              <1> 	; OUTPUT ->
   493                              <1> 	;	EDX = Page directory entry address
   494                              <1> 	;	EAX = Page table address
   495                              <1> 	;	cf = 1 -> insufficient (out of) memory error
   496                              <1> 	;	cf = 0 -> page table address in the PDE (EDX)
   497                              <1> 	;
   498                              <1> 	; Modified Registers -> EAX, EDX
   499                              <1> 	;
   500 0000464E E86FFFFFFF          <1> 	call	allocate_page
   501 00004653 72F8                <1> 	jc	short mkpt_error
   502 00004655 E811000000          <1> 	call	set_pde	
   503 0000465A EBE0                <1> 	jmp	short clear_page
   504                              <1> 
   505                              <1> make_page:
   506                              <1> 	; 24/07/2015
   507                              <1> 	; 23/06/2015 ; (Retro UNIX 386 v1 - beginning)
   508                              <1> 	;
   509                              <1> 	; INPUT ->
   510                              <1> 	;	EBX = virtual (linear) address
   511                              <1> 	;	ECX = page attributes (lower 12 bits)
   512                              <1> 	;	      (higher 20 bits must be ZERO)
   513                              <1> 	;	      (bit 0 must be 1)	 
   514                              <1> 	;	u.pgdir = page directory (physical) address
   515                              <1> 	; OUTPUT ->
   516                              <1> 	;	EBX = Virtual address
   517                              <1> 	;	(EDX = PTE value)
   518                              <1> 	;	EAX = Physical address
   519                              <1> 	;	cf = 1 -> insufficient (out of) memory error
   520                              <1> 	;
   521                              <1> 	; Modified Registers -> EAX, EDX
   522                              <1> 	;
   523 0000465C E861FFFFFF          <1> 	call	allocate_page
   524 00004661 7207                <1> 	jc	short mkp_err
   525 00004663 E821000000          <1> 	call	set_pte	
   526 00004668 73D2                <1> 	jnc	short clear_page ; 18/04/2015
   527                              <1> mkp_err:
   528 0000466A C3                  <1> 	retn
   529                              <1> 
   530                              <1> 
   531                              <1> set_pde:	; Set page directory entry (PDE)
   532                              <1> 	; 20/07/2015
   533                              <1> 	; 18/04/2015
   534                              <1> 	; 12/04/2015
   535                              <1> 	; 23/10/2014
   536                              <1> 	; 10/10/2014 ; (Retro UNIX 386 v1 - beginning)
   537                              <1> 	;
   538                              <1> 	; INPUT ->
   539                              <1> 	;	EAX = physical address
   540                              <1> 	;	      (use present value if EAX = 0)
   541                              <1> 	;	EBX = virtual (linear) address
   542                              <1> 	;	ECX = page table attributes (lower 12 bits)
   543                              <1> 	;	      (higher 20 bits must be ZERO)
   544                              <1> 	;	      (bit 0 must be 1)	 
   545                              <1> 	;	u.pgdir = page directory (physical) address
   546                              <1> 	; OUTPUT ->
   547                              <1> 	;	EDX = PDE address
   548                              <1> 	;	EAX = page table address (physical)
   549                              <1> 	;	;(CF=1 -> Invalid page address)
   550                              <1> 	;
   551                              <1> 	; Modified Registers -> EDX
   552                              <1> 	;
   553 0000466B 89DA                <1> 	mov	edx, ebx
   554 0000466D C1EA16              <1> 	shr	edx, PAGE_D_SHIFT ; 22
   555 00004670 C1E202              <1> 	shl	edx, 2 ; offset to page directory (1024*4)
   556 00004673 0315[E1300100]      <1> 	add	edx, [u.pgdir]
   557                              <1> 	;
   558 00004679 21C0                <1> 	and	eax, eax
   559 0000467B 7506                <1> 	jnz	short spde_1
   560                              <1> 	;
   561 0000467D 8B02                <1> 	mov	eax, [edx]  ; old PDE value
   562                              <1> 	;test	al, 1
   563                              <1> 	;jz	short spde_2
   564 0000467F 662500F0            <1> 	and	ax, PDE_A_CLEAR ; 0F000h  ; clear lower 12 bits
   565                              <1> spde_1:
   566                              <1> 	;and	cx, 0FFFh
   567 00004683 8902                <1> 	mov	[edx], eax
   568 00004685 66090A              <1> 	or	[edx], cx
   569 00004688 C3                  <1> 	retn
   570                              <1> ;spde_2: ; error
   571                              <1> ;	stc
   572                              <1> ;	retn
   573                              <1> 
   574                              <1> set_pte:	; Set page table entry (PTE)
   575                              <1> 	; 24/07/2015
   576                              <1> 	; 20/07/2015
   577                              <1> 	; 23/06/2015
   578                              <1> 	; 18/04/2015
   579                              <1> 	; 12/04/2015
   580                              <1> 	; 10/10/2014 ; (Retro UNIX 386 v1 - beginning)
   581                              <1> 	;
   582                              <1> 	; INPUT ->
   583                              <1> 	;	EAX = physical page address
   584                              <1> 	;	      (use present value if EAX = 0)
   585                              <1> 	;	EBX = virtual (linear) address
   586                              <1> 	;	ECX = page attributes (lower 12 bits)
   587                              <1> 	;	      (higher 20 bits must be ZERO)
   588                              <1> 	;	      (bit 0 must be 1)	 
   589                              <1> 	;	u.pgdir = page directory (physical) address
   590                              <1> 	; OUTPUT ->
   591                              <1> 	;	EAX = physical page address
   592                              <1> 	;	(EDX = PTE value)
   593                              <1> 	;	EBX = virtual address
   594                              <1> 	;
   595                              <1> 	;	CF = 1 -> error
   596                              <1> 	;
   597                              <1> 	; Modified Registers -> EAX, EDX
   598                              <1> 	;
   599 00004689 50                  <1> 	push	eax
   600 0000468A A1[E1300100]        <1> 	mov	eax, [u.pgdir] ; 20/07/2015
   601 0000468F E837000000          <1> 	call 	get_pde
   602                              <1> 		; EDX = PDE address
   603                              <1> 		; EAX = PDE value
   604 00004694 5A                  <1> 	pop	edx ; physical page address
   605 00004695 722A                <1> 	jc	short spte_err ; PDE not present
   606                              <1> 	;
   607 00004697 53                  <1> 	push	ebx ; 24/07/2015
   608 00004698 662500F0            <1> 	and	ax, PDE_A_CLEAR ; 0F000h ; clear lower 12 bits
   609                              <1> 			    ; EDX = PT address (physical)	
   610 0000469C C1EB0C              <1> 	shr	ebx, PAGE_SHIFT ; 12
   611 0000469F 81E3FF030000        <1> 	and	ebx, PTE_MASK	; 03FFh
   612                              <1> 			 ; clear higher 10 bits (PD bits)
   613 000046A5 C1E302              <1> 	shl	ebx, 2   ; offset to page table (1024*4)
   614 000046A8 01C3                <1> 	add	ebx, eax
   615                              <1> 	;
   616 000046AA 8B03                <1> 	mov	eax, [ebx] ; Old PTE value
   617 000046AC A801                <1> 	test	al, 1
   618 000046AE 740C                <1> 	jz	short spte_0
   619 000046B0 09D2                <1> 	or	edx, edx
   620 000046B2 750F                <1> 	jnz	short spte_1
   621 000046B4 662500F0            <1> 	and	ax, PTE_A_CLEAR ; 0F000h ; clear lower 12 bits
   622 000046B8 89C2                <1> 	mov	edx, eax
   623 000046BA EB09                <1> 	jmp	short spte_2	
   624                              <1> spte_0:
   625                              <1> 	; If this PTE contains a swap (disk) address,
   626                              <1> 	; it can be updated by using 'swap_in' procedure
   627                              <1> 	; only!
   628 000046BC 21C0                <1> 	and	eax, eax
   629 000046BE 7403                <1> 	jz	short spte_1
   630                              <1> 	; 24/07/2015
   631                              <1> 	; swapped page ! (on disk)
   632 000046C0 5B                  <1> 	pop	ebx
   633                              <1> spte_err:
   634 000046C1 F9                  <1> 	stc
   635 000046C2 C3                  <1> 	retn
   636                              <1> spte_1: 
   637 000046C3 89D0                <1> 	mov	eax, edx
   638                              <1> spte_2:
   639 000046C5 09CA                <1> 	or	edx, ecx
   640                              <1> 	; 23/06/2015
   641 000046C7 8913                <1> 	mov	[ebx], edx ; PTE value in EDX
   642                              <1> 	; 24/07/2015
   643 000046C9 5B                  <1> 	pop	ebx
   644 000046CA C3                  <1> 	retn
   645                              <1> 
   646                              <1> get_pde:	; Get present value of the relevant PDE
   647                              <1> 	; 20/07/2015
   648                              <1> 	; 18/04/2015
   649                              <1> 	; 12/04/2015
   650                              <1> 	; 10/10/2014 ; (Retro UNIX 386 v1 - beginning)
   651                              <1> 	;
   652                              <1> 	; INPUT ->
   653                              <1> 	;	EBX = virtual (linear) address
   654                              <1> 	;	EAX = page directory (physical) address
   655                              <1> 	; OUTPUT ->
   656                              <1> 	;	EDX = Page directory entry address
   657                              <1> 	;	EAX = Page directory entry value
   658                              <1> 	;	CF = 1 -> PDE not present or invalid ? 
   659                              <1> 	; Modified Registers -> EDX, EAX
   660                              <1> 	;
   661 000046CB 89DA                <1> 	mov	edx, ebx
   662 000046CD C1EA16              <1> 	shr	edx, PAGE_D_SHIFT ; 22  (12+10)
   663 000046D0 C1E202              <1> 	shl 	edx, 2 ; offset to page directory (1024*4)
   664 000046D3 01C2                <1> 	add	edx, eax ; page directory address (physical)
   665 000046D5 8B02                <1> 	mov	eax, [edx]
   666 000046D7 A801                <1> 	test	al, PDE_A_PRESENT ; page table is present or not !
   667 000046D9 751F                <1> 	jnz	short gpte_retn
   668 000046DB F9                  <1> 	stc
   669                              <1> gpde_retn:	
   670 000046DC C3                  <1> 	retn
   671                              <1> 
   672                              <1> get_pte:
   673                              <1> 		; Get present value of the relevant PTE
   674                              <1> 	; 29/07/2015
   675                              <1> 	; 20/07/2015
   676                              <1> 	; 18/04/2015
   677                              <1> 	; 12/04/2015
   678                              <1> 	; 10/10/2014 ; (Retro UNIX 386 v1 - beginning)
   679                              <1> 	;
   680                              <1> 	; INPUT ->
   681                              <1> 	;	EBX = virtual (linear) address
   682                              <1> 	;	EAX = page directory (physical) address
   683                              <1> 	; OUTPUT ->
   684                              <1> 	;	EDX = Page table entry address (if CF=0)
   685                              <1> 	;	      Page directory entry address (if CF=1)
   686                              <1> 	;            (Bit 0 value is 0 if PT is not present)
   687                              <1> 	;	EAX = Page table entry value (page address)
   688                              <1> 	;	CF = 1 -> PDE not present or invalid ? 
   689                              <1> 	; Modified Registers -> EAX, EDX
   690                              <1> 	;
   691 000046DD E8E9FFFFFF          <1> 	call 	get_pde
   692 000046E2 72F8                <1> 	jc	short gpde_retn	; page table is not present
   693                              <1> 	;jnc	short gpte_1
   694                              <1> 	;retn
   695                              <1> ;gpte_1:
   696 000046E4 662500F0            <1> 	and	ax, PDE_A_CLEAR ; 0F000h ; clear lower 12 bits
   697 000046E8 89DA                <1> 	mov	edx, ebx
   698 000046EA C1EA0C              <1> 	shr	edx, PAGE_SHIFT ; 12
   699 000046ED 81E2FF030000        <1> 	and	edx, PTE_MASK	; 03FFh
   700                              <1> 			 ; clear higher 10 bits (PD bits)
   701 000046F3 C1E202              <1> 	shl	edx, 2 ; offset from start of page table (1024*4)
   702 000046F6 01C2                <1> 	add	edx, eax
   703 000046F8 8B02                <1> 	mov	eax, [edx]
   704                              <1> gpte_retn:
   705 000046FA C3                  <1> 	retn
   706                              <1> 
   707                              <1> deallocate_page_dir:
   708                              <1> 	; 15/09/2015
   709                              <1> 	; 05/08/2015
   710                              <1> 	; 30/04/2015
   711                              <1> 	; 28/04/2015
   712                              <1> 	; 17/10/2014
   713                              <1> 	; 12/10/2014 (Retro UNIX 386 v1 - beginning)
   714                              <1> 	;
   715                              <1> 	; INPUT ->
   716                              <1> 	;	EAX = PHYSICAL ADDRESS OF THE PAGE DIRECTORY (CHILD)
   717                              <1> 	;	EBX = PHYSICAL ADDRESS OF THE PARENT'S PAGE DIRECTORY
   718                              <1> 	; OUTPUT ->
   719                              <1> 	;	All of page tables in the page directory
   720                              <1> 	;	and page dir's itself will be deallocated
   721                              <1> 	;	except 'read only' duplicated pages (will be converted
   722                              <1> 	;	to writable pages).
   723                              <1> 	;
   724                              <1> 	; Modified Registers -> EAX
   725                              <1> 	;
   726                              <1> 	;
   727 000046FB 56                  <1> 	push	esi
   728 000046FC 51                  <1> 	push	ecx
   729 000046FD 50                  <1> 	push	eax
   730 000046FE 89C6                <1> 	mov	esi, eax 
   731 00004700 31C9                <1> 	xor	ecx, ecx
   732                              <1> 	; The 1st PDE points to Kernel Page Table 0 (the 1st 4MB),
   733                              <1> 	; it must not be deallocated
   734 00004702 890E                <1> 	mov	[esi], ecx ; 0 ; clear PDE 0
   735                              <1> dapd_0:
   736 00004704 AD                  <1> 	lodsd
   737 00004705 A801                <1> 	test	al, PDE_A_PRESENT ; bit 0, present flag (must be 1)
   738 00004707 7409                <1> 	jz	short dapd_1	
   739 00004709 662500F0            <1> 	and	ax, PDE_A_CLEAR ; 0F000h ; clear lower 12 (attribute) bits
   740 0000470D E812000000          <1> 	call	deallocate_page_table			
   741                              <1> dapd_1:
   742 00004712 41                  <1> 	inc	ecx ; page directory entry index
   743 00004713 81F900040000        <1> 	cmp	ecx, PAGE_SIZE / 4 ; 1024
   744 00004719 72E9                <1> 	jb	short dapd_0
   745                              <1> dapd_2:
   746 0000471B 58                  <1> 	pop	eax
   747 0000471C E87F000000          <1> 	call	deallocate_page	; deallocate the page dir's itself
   748 00004721 59                  <1> 	pop	ecx
   749 00004722 5E                  <1> 	pop	esi
   750 00004723 C3                  <1> 	retn
   751                              <1> 
   752                              <1> deallocate_page_table:
   753                              <1> 	; 12/07/2016
   754                              <1> 	; 19/09/2015
   755                              <1> 	; 15/09/2015
   756                              <1> 	; 05/08/2015
   757                              <1> 	; 30/04/2015
   758                              <1> 	; 28/04/2015
   759                              <1> 	; 24/10/2014
   760                              <1> 	; 23/10/2014
   761                              <1> 	; 12/10/2014 (Retro UNIX 386 v1 - beginning)
   762                              <1> 	;
   763                              <1> 	; INPUT ->
   764                              <1> 	;	EAX = PHYSICAL (real/flat) ADDRESS OF THE PAGE TABLE
   765                              <1> 	;	EBX = PHYSICAL ADDRESS OF THE PARENT'S PAGE DIRECTORY
   766                              <1> 	;	(ECX = page directory entry index)
   767                              <1> 	; OUTPUT ->
   768                              <1> 	;	All of pages in the page table and page table's itself
   769                              <1> 	;	will be deallocated except 'read only' duplicated pages
   770                              <1> 	;	(will be converted to writable pages).
   771                              <1> 	;
   772                              <1> 	; Modified Registers -> EAX
   773                              <1> 	;
   774 00004724 56                  <1> 	push	esi
   775 00004725 57                  <1> 	push	edi
   776 00004726 52                  <1> 	push	edx
   777 00004727 50                  <1> 	push	eax ; *
   778 00004728 89C6                <1> 	mov	esi, eax 
   779 0000472A 31FF                <1> 	xor	edi, edi ; 0
   780                              <1> dapt_0:
   781 0000472C AD                  <1> 	lodsd
   782 0000472D A801                <1> 	test	al, PTE_A_PRESENT ; bit 0, present flag (must be 1)
   783 0000472F 7441                <1> 	jz	short dapt_1
   784                              <1> 	;
   785 00004731 A802                <1> 	test	al, PTE_A_WRITE   ; bit 1, writable (r/w) flag
   786                              <1> 				  ; (must be 1)
   787 00004733 754C                <1> 	jnz	short dapt_3
   788                              <1> 	; Read only -duplicated- page (belongs to a parent or a child)
   789 00004735 66A90002            <1>         test    ax, PTE_DUPLICATED ; Was this page duplicated 
   790                              <1> 				   ; as child's page ?
   791 00004739 7451                <1> 	jz	short dapt_4 ; Clear PTE but don't deallocate the page!
   792                              <1> 	; check the parent's PTE value is read only & same page or not.. 
   793                              <1> 	; ECX = page directory entry index (0-1023)
   794 0000473B 53                  <1> 	push	ebx
   795 0000473C 51                  <1> 	push	ecx
   796 0000473D 66C1E102            <1> 	shl	cx, 2 ; *4 
   797 00004741 01CB                <1> 	add	ebx, ecx ; PDE offset (for the parent)
   798 00004743 8B0B                <1> 	mov	ecx, [ebx]
   799 00004745 F6C101              <1> 	test	cl, PDE_A_PRESENT ; present (valid) or not ?
   800 00004748 7435                <1> 	jz	short dapt_2	; parent process does not use this page
   801 0000474A 6681E100F0          <1> 	and	cx, PDE_A_CLEAR ; 0F000h ; Clear attribute bits
   802                              <1> 	; EDI = page table entry index (0-1023)
   803 0000474F 89FA                <1> 	mov	edx, edi 
   804 00004751 66C1E202            <1> 	shl	dx, 2 ; *4 
   805 00004755 01CA                <1> 	add	edx, ecx ; PTE offset (for the parent)
   806 00004757 8B1A                <1> 	mov	ebx, [edx]
   807 00004759 F6C301              <1> 	test	bl, PTE_A_PRESENT ; present or not ?
   808 0000475C 7421                <1> 	jz	short dapt_2	; parent process does not use this page
   809 0000475E 662500F0            <1> 	and	ax, PTE_A_CLEAR ; 0F000h ; Clear attribute bits 
   810 00004762 6681E300F0          <1> 	and	bx, PTE_A_CLEAR ; 0F000h ; Clear attribute bits
   811 00004767 39D8                <1> 	cmp	eax, ebx	; parent's and child's pages are same ?
   812 00004769 7514                <1> 	jne	short dapt_2	; not same page
   813                              <1> 				; deallocate the child's page
   814 0000476B 800A02              <1>         or      byte [edx], PTE_A_WRITE ; convert to writable page (parent)
   815 0000476E 59                  <1> 	pop	ecx
   816 0000476F 5B                  <1> 	pop	ebx
   817 00004770 EB1A                <1> 	jmp	short dapt_4
   818                              <1> dapt_1:
   819 00004772 09C0                <1> 	or	eax, eax	; swapped page ?
   820 00004774 741D                <1> 	jz	short dapt_5	; no
   821                              <1> 				; yes
   822 00004776 D1E8                <1> 	shr	eax, 1
   823 00004778 E8CD040000          <1> 	call	unlink_swap_block ; Deallocate swapped page block
   824                              <1> 				  ; on the swap disk (or in file)
   825 0000477D EB14                <1> 	jmp	short dapt_5
   826                              <1> dapt_2:
   827 0000477F 59                  <1> 	pop	ecx
   828 00004780 5B                  <1> 	pop	ebx
   829                              <1> dapt_3:	
   830                              <1> 	; 12/07/2016
   831 00004781 66A90004            <1> 	test	ax, PTE_SHARED ; shared or direct memory access indicator
   832 00004785 7505                <1> 	jnz	short dapt_4   ; AVL bit 1 = 1, do not deallocate this page!
   833                              <1> 	;
   834                              <1> 	;and	ax, PTE_A_CLEAR ; 0F000h ; clear lower 12 (attribute) bits
   835 00004787 E814000000          <1> 	call	deallocate_page ; set the mem allocation bit of this page
   836                              <1> dapt_4:
   837 0000478C C746FC00000000      <1> 	mov	dword [esi-4], 0 ; clear/reset PTE (child, dupl. as parent)
   838                              <1> dapt_5:
   839 00004793 47                  <1> 	inc	edi ; page table entry index
   840 00004794 81FF00040000        <1> 	cmp	edi, PAGE_SIZE / 4 ; 1024
   841 0000479A 7290                <1> 	jb	short dapt_0
   842                              <1> 	;
   843 0000479C 58                  <1> 	pop	eax ; *
   844 0000479D 5A                  <1> 	pop	edx
   845 0000479E 5F                  <1> 	pop	edi	
   846 0000479F 5E                  <1> 	pop	esi
   847                              <1> 	;
   848                              <1> 	;call	deallocate_page	; deallocate the page table's itself
   849                              <1> 	;retn
   850                              <1> 
   851                              <1> deallocate_page:
   852                              <1> 	; 15/09/2015
   853                              <1> 	; 28/04/2015
   854                              <1> 	; 10/03/2015
   855                              <1> 	; 17/10/2014
   856                              <1> 	; 12/10/2014 (Retro UNIX 386 v1 - beginning)
   857                              <1> 	;
   858                              <1> 	; INPUT -> 
   859                              <1> 	;	EAX = PHYSICAL (real/flat) ADDRESS OF THE ALLOCATED PAGE
   860                              <1> 	; OUTPUT ->
   861                              <1> 	;	[free_pages] is increased
   862                              <1> 	;	(corresponding MEMORY ALLOCATION TABLE bit is SET)
   863                              <1> 	;	CF = 1 if the page is already deallocated
   864                              <1> 	; 	       (or not allocated) before.  
   865                              <1> 	;
   866                              <1> 	; Modified Registers -> EAX
   867                              <1> 	;
   868 000047A0 53                  <1> 	push	ebx
   869 000047A1 52                  <1> 	push	edx
   870                              <1> 	;
   871 000047A2 C1E80C              <1> 	shr	eax, PAGE_SHIFT      ; shift physical address to 
   872                              <1> 				     ; 12 bits right
   873                              <1> 				     ; to get page number
   874 000047A5 89C2                <1> 	mov	edx, eax
   875                              <1> 	; 15/09/2015
   876 000047A7 C1EA03              <1> 	shr	edx, 3		     ; to get offset to M.A.T.
   877                              <1> 				     ; (1 allocation bit = 1 page)
   878                              <1> 				     ; (1 allocation bytes = 8 pages)
   879 000047AA 80E2FC              <1> 	and	dl, 0FCh 	     ; clear lower 2 bits
   880                              <1> 				     ; (to get 32 bit position)			
   881                              <1> 	;
   882 000047AD BB00001000          <1> 	mov	ebx, MEM_ALLOC_TBL   ; Memory Allocation Table address
   883 000047B2 01D3                <1> 	add	ebx, edx
   884 000047B4 83E01F              <1> 	and	eax, 1Fh	     ; lower 5 bits only
   885                              <1> 				     ; (allocation bit position)	 
   886 000047B7 3B15[B41F0100]      <1> 	cmp 	edx, [next_page]     ; is the new free page address lower
   887                              <1> 				     ; than the address in 'next_page' ?
   888                              <1> 				     ; (next/first free page value)		
   889 000047BD 7306                <1> 	jnb	short dap_1	     ; no	
   890 000047BF 8915[B41F0100]      <1> 	mov	[next_page], edx     ; yes
   891                              <1> dap_1:
   892 000047C5 0FAB03              <1> 	bts	[ebx], eax	     ; unlink/release/deallocate page
   893                              <1> 				     ; set relevant bit to 1.
   894                              <1> 				     ; set CF to the previous bit value	
   895                              <1> 	;cmc			     ; complement carry flag	
   896                              <1> 	;jc	short dap_2	     ; do not increase free_pages count
   897                              <1> 				     ; if the page is already deallocated
   898                              <1> 				     ; before.	
   899 000047C8 FF05[B01F0100]      <1>         inc     dword [free_pages]
   900                              <1> dap_2:
   901 000047CE 5A                  <1> 	pop	edx
   902 000047CF 5B                  <1> 	pop	ebx
   903 000047D0 C3                  <1> 	retn
   904                              <1> 
   905                              <1> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   906                              <1> ;;                                                              ;;
   907                              <1> ;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;;
   908                              <1> ;; Distributed under terms of the GNU General Public License    ;;
   909                              <1> ;;                                                              ;;
   910                              <1> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   911                              <1> 
   912                              <1> ;;$Revision: 5057 $
   913                              <1> 
   914                              <1> 
   915                              <1> ;;align 4
   916                              <1> ;;proc alloc_page
   917                              <1> 
   918                              <1> ;;        pushfd
   919                              <1> ;;        cli
   920                              <1> ;;        push    ebx
   921                              <1> ;;;//-
   922                              <1> ;;        cmp     [pg_data.pages_free], 1
   923                              <1> ;;        jle     .out_of_memory
   924                              <1> ;;;//-
   925                              <1> ;;
   926                              <1> ;;        mov     ebx, [page_start]
   927                              <1> ;;        mov     ecx, [page_end]
   928                              <1> ;;.l1:
   929                              <1> ;;        bsf     eax, [ebx];
   930                              <1> ;;        jnz     .found
   931                              <1> ;;        add     ebx, 4
   932                              <1> ;;        cmp     ebx, ecx
   933                              <1> ;;        jb      .l1
   934                              <1> ;;        pop     ebx
   935                              <1> ;;        popfd
   936                              <1> ;;        xor     eax, eax
   937                              <1> ;;        ret
   938                              <1> ;;.found:
   939                              <1> ;;;//-
   940                              <1> ;;        dec     [pg_data.pages_free]
   941                              <1> ;;        jz      .out_of_memory
   942                              <1> ;;;//-
   943                              <1> ;;        btr     [ebx], eax
   944                              <1> ;;        mov     [page_start], ebx
   945                              <1> ;;        sub     ebx, sys_pgmap
   946                              <1> ;;        lea     eax, [eax+ebx*8]
   947                              <1> ;;        shl     eax, 12
   948                              <1> ;;;//-       dec [pg_data.pages_free]
   949                              <1> ;;        pop     ebx
   950                              <1> ;;        popfd
   951                              <1> ;;        ret
   952                              <1> ;;;//-
   953                              <1> ;;.out_of_memory:
   954                              <1> ;;        mov     [pg_data.pages_free], 1
   955                              <1> ;;        xor     eax, eax
   956                              <1> ;;        pop     ebx
   957                              <1> ;;        popfd
   958                              <1> ;;        ret
   959                              <1> ;;;//-
   960                              <1> ;;endp
   961                              <1> 
   962                              <1> duplicate_page_dir:
   963                              <1> 	; 21/09/2015
   964                              <1> 	; 31/08/2015
   965                              <1> 	; 20/07/2015
   966                              <1> 	; 28/04/2015
   967                              <1> 	; 27/04/2015
   968                              <1> 	; 18/04/2015
   969                              <1> 	; 12/04/2015
   970                              <1> 	; 18/10/2014
   971                              <1> 	; 16/10/2014 (Retro UNIX 386 v1 - beginning)
   972                              <1> 	;
   973                              <1> 	; INPUT -> 
   974                              <1> 	;	[u.pgdir] = PHYSICAL (real/flat) ADDRESS of the parent's
   975                              <1> 	;		    page directory.
   976                              <1> 	; OUTPUT ->
   977                              <1> 	;	EAX =  PHYSICAL (real/flat) ADDRESS of the child's
   978                              <1> 	;	       page directory.
   979                              <1> 	;	(New page directory with new page table entries.)
   980                              <1> 	;	(New page tables with read only copies of the parent's
   981                              <1> 	;	pages.)
   982                              <1> 	;	EAX = 0 -> Error (CF = 1)
   983                              <1> 	;
   984                              <1> 	; Modified Registers -> none (except EAX)
   985                              <1> 	;
   986 000047D1 E8ECFDFFFF          <1> 	call	allocate_page
   987 000047D6 723E                <1> 	jc	short dpd_err
   988                              <1> 	;
   989 000047D8 55                  <1> 	push	ebp ; 20/07/2015
   990 000047D9 56                  <1> 	push	esi
   991 000047DA 57                  <1> 	push	edi
   992 000047DB 53                  <1> 	push	ebx
   993 000047DC 51                  <1> 	push	ecx
   994 000047DD 8B35[E1300100]      <1> 	mov	esi, [u.pgdir]
   995 000047E3 89C7                <1> 	mov	edi, eax
   996 000047E5 50                  <1> 	push	eax ; save child's page directory address
   997                              <1> 	; 31/08/2015
   998                              <1> 	; copy PDE 0 from the parent's page dir to the child's page dir
   999                              <1> 	; (use same system space for all user page tables) 
  1000 000047E6 A5                  <1> 	movsd
  1001 000047E7 BD00004000          <1> 	mov	ebp, 1024*4096 ; pass the 1st 4MB (system space)
  1002 000047EC B9FF030000          <1> 	mov	ecx, (PAGE_SIZE / 4) - 1 ; 1023
  1003                              <1> dpd_0:	
  1004 000047F1 AD                  <1> 	lodsd
  1005                              <1> 	;or	eax, eax
  1006                              <1>         ;jnz     short dpd_1
  1007 000047F2 A801                <1> 	test	al, PDE_A_PRESENT ;  bit 0 =  1
  1008 000047F4 7508                <1> 	jnz	short dpd_1
  1009                              <1>  	; 20/07/2015 (virtual address at the end of the page table)	
  1010 000047F6 81C500004000        <1> 	add	ebp, 1024*4096 ; page size * PTE count
  1011 000047FC EB0F                <1> 	jmp	short dpd_2
  1012                              <1> dpd_1:	
  1013 000047FE 662500F0            <1> 	and	ax, PDE_A_CLEAR ; 0F000h ; clear attribute bits
  1014 00004802 89C3                <1> 	mov	ebx, eax
  1015                              <1> 	; EBX = Parent's page table address
  1016 00004804 E81F000000          <1> 	call	duplicate_page_table
  1017 00004809 720C                <1> 	jc	short dpd_p_err
  1018                              <1> 	; EAX = Child's page table address
  1019 0000480B 0C07                <1> 	or	al, PDE_A_PRESENT + PDE_A_WRITE + PDE_A_USER
  1020                              <1> 			 ; set bit 0, bit 1 and bit 2 to 1
  1021                              <1> 			 ; (present, writable, user)
  1022                              <1> dpd_2:
  1023 0000480D AB                  <1> 	stosd
  1024 0000480E E2E1                <1> 	loop	dpd_0
  1025                              <1> 	;
  1026 00004810 58                  <1> 	pop	eax  ; restore child's page directory address
  1027                              <1> dpd_3:
  1028 00004811 59                  <1> 	pop	ecx
  1029 00004812 5B                  <1> 	pop	ebx
  1030 00004813 5F                  <1> 	pop	edi
  1031 00004814 5E                  <1> 	pop	esi
  1032 00004815 5D                  <1> 	pop	ebp ; 20/07/2015
  1033                              <1> dpd_err:
  1034 00004816 C3                  <1> 	retn
  1035                              <1> dpd_p_err:
  1036                              <1> 	; release the allocated pages missing (recover free space)
  1037 00004817 58                  <1> 	pop	eax  ; the new page directory address (physical)
  1038 00004818 8B1D[E1300100]      <1> 	mov	ebx, [u.pgdir] ; parent's page directory address 
  1039 0000481E E8D8FEFFFF          <1> 	call 	deallocate_page_dir
  1040 00004823 29C0                <1> 	sub	eax, eax ; 0
  1041 00004825 F9                  <1> 	stc
  1042 00004826 EBE9                <1> 	jmp	short dpd_3	
  1043                              <1> 
  1044                              <1> duplicate_page_table:
  1045                              <1> 	; 21/09/2015
  1046                              <1> 	; 20/07/2015
  1047                              <1> 	; 05/05/2015
  1048                              <1> 	; 28/04/2015
  1049                              <1> 	; 27/04/2015
  1050                              <1> 	; 18/04/2015
  1051                              <1> 	; 18/10/2014
  1052                              <1> 	; 16/10/2014 (Retro UNIX 386 v1 - beginning)
  1053                              <1> 	;
  1054                              <1> 	; INPUT -> 
  1055                              <1> 	;	EBX = PHYSICAL (real/flat) ADDRESS of the parent's page table.
  1056                              <1> 	;	EBP = page table entry index (from 'duplicate_page_dir')
  1057                              <1> 	; OUTPUT ->
  1058                              <1> 	;	EAX = PHYSICAL (real/flat) ADDRESS of the child's page table.
  1059                              <1> 	;	      (with 'read only' attribute of page table entries)
  1060                              <1> 	;	EBP = (recent) page table index (for 'add_to_swap_queue')	
  1061                              <1> 	;	CF = 1 -> error 
  1062                              <1> 	;
  1063                              <1> 	; Modified Registers -> EBP (except EAX)
  1064                              <1> 	;
  1065 00004828 E895FDFFFF          <1> 	call	allocate_page
  1066 0000482D 726A                <1> 	jc	short dpt_err
  1067                              <1> 	;
  1068 0000482F 50                  <1> 	push	eax ; *
  1069 00004830 56                  <1> 	push	esi
  1070 00004831 57                  <1> 	push	edi
  1071 00004832 52                  <1> 	push	edx
  1072 00004833 51                  <1> 	push	ecx
  1073                              <1> 	;
  1074 00004834 89DE                <1> 	mov	esi, ebx
  1075 00004836 89C7                <1> 	mov	edi, eax
  1076 00004838 89C2                <1> 	mov	edx, eax
  1077 0000483A 81C200100000        <1> 	add	edx, PAGE_SIZE 	
  1078                              <1> dpt_0:
  1079 00004840 AD                  <1> 	lodsd
  1080 00004841 21C0                <1> 	and	eax, eax
  1081 00004843 7444                <1> 	jz	short dpt_3
  1082 00004845 A801                <1> 	test	al, PTE_A_PRESENT ;  bit 0 =  1
  1083 00004847 7507                <1> 	jnz	short dpt_1
  1084                              <1> 	; 20/07/2015
  1085                              <1> 	; ebp = virtual (linear) address of the memory page
  1086 00004849 E806050000          <1> 	call	reload_page ; 28/04/2015
  1087 0000484E 7244                <1> 	jc	short dpt_p_err
  1088                              <1> dpt_1:
  1089                              <1> 	; 21/09/2015
  1090 00004850 89C1                <1> 	mov	ecx, eax
  1091 00004852 662500F0            <1> 	and	ax, PTE_A_CLEAR ; 0F000h ; clear attribute bits
  1092 00004856 F6C102              <1> 	test	cl, PTE_A_WRITE ; writable page ?
  1093 00004859 7525                <1> 	jnz	short dpt_2
  1094                              <1> 	; Read only (parent) page
  1095                              <1> 	; 	- there is a third process which uses this page -
  1096                              <1> 	; Allocate a new page for the child process
  1097 0000485B E862FDFFFF          <1> 	call	allocate_page
  1098 00004860 7232                <1> 	jc	short dpt_p_err
  1099 00004862 57                  <1> 	push	edi
  1100 00004863 56                  <1> 	push	esi
  1101 00004864 89CE                <1> 	mov	esi, ecx
  1102 00004866 89C7                <1> 	mov	edi, eax
  1103 00004868 B900040000          <1> 	mov	ecx, PAGE_SIZE/4
  1104 0000486D F3A5                <1> 	rep	movsd	; copy page (4096 bytes)
  1105 0000486F 5E                  <1> 	pop	esi
  1106 00004870 5F                  <1> 	pop	edi
  1107                              <1> 	; 
  1108 00004871 53                  <1> 	push	ebx
  1109 00004872 50                  <1> 	push	eax
  1110                              <1> 	; 20/07/2015
  1111 00004873 89EB                <1> 	mov	ebx, ebp
  1112                              <1> 	; ebx = virtual address of the memory page
  1113 00004875 E88A030000          <1> 	call	add_to_swap_queue
  1114 0000487A 58                  <1> 	pop	eax
  1115 0000487B 5B                  <1> 	pop	ebx
  1116                              <1> 	; 21/09/2015
  1117 0000487C 0C07                <1> 	or	al, PTE_A_USER+PTE_A_WRITE+PTE_A_PRESENT 
  1118                              <1> 		; user + writable + present page
  1119 0000487E EB09                <1> 	jmp	short dpt_3
  1120                              <1> dpt_2:
  1121                              <1> 	;or	ax, PTE_A_USER+PTE_A_PRESENT 
  1122 00004880 0C05                <1> 	or	al, PTE_A_USER+PTE_A_PRESENT 
  1123                              <1> 		    ; (read only page!)
  1124 00004882 8946FC              <1> 	mov	[esi-4], eax ; update parent's PTE
  1125 00004885 660D0002            <1> 	or      ax, PTE_DUPLICATED  ; (read only page & duplicated PTE!)
  1126                              <1> dpt_3:
  1127 00004889 AB                  <1> 	stosd  ; EDI points to child's PTE  	 
  1128                              <1> 	;
  1129 0000488A 81C500100000        <1> 	add	ebp, 4096 ; 20/07/2015 (next page)
  1130                              <1> 	;
  1131 00004890 39D7                <1> 	cmp	edi, edx
  1132 00004892 72AC                <1> 	jb	short dpt_0
  1133                              <1> dpt_p_err:
  1134 00004894 59                  <1> 	pop	ecx
  1135 00004895 5A                  <1> 	pop	edx
  1136 00004896 5F                  <1> 	pop	edi
  1137 00004897 5E                  <1> 	pop	esi
  1138 00004898 58                  <1> 	pop	eax ; *
  1139                              <1> dpt_err:
  1140 00004899 C3                  <1> 	retn
  1141                              <1> 
  1142                              <1> page_fault_handler:	; CPU EXCEPTION 0Eh (14) : Page Fault !
  1143                              <1> 	; 21/09/2015
  1144                              <1> 	; 19/09/2015
  1145                              <1> 	; 17/09/2015
  1146                              <1> 	; 28/08/2015
  1147                              <1> 	; 20/07/2015
  1148                              <1> 	; 28/06/2015
  1149                              <1> 	; 03/05/2015
  1150                              <1> 	; 30/04/2015
  1151                              <1> 	; 18/04/2015
  1152                              <1> 	; 12/04/2015
  1153                              <1> 	; 30/10/2014
  1154                              <1> 	; 11/09/2014
  1155                              <1> 	; 10/09/2014 (Retro UNIX 386 v1 - beginning)
  1156                              <1> 	;
  1157                              <1> 	; Note: This is not an interrupt/exception handler.
  1158                              <1> 	;	This is a 'page fault remedy' subroutine 
  1159                              <1> 	;	which will be called by standard/uniform
  1160                              <1> 	;	exception handler.
  1161                              <1> 	;
  1162                              <1> 	; INPUT -> 
  1163                              <1> 	;	[error_code] = 32 bit ERROR CODE (lower 5 bits are valid)
  1164                              <1> 	;
  1165                              <1> 	;	cr2 = the virtual (linear) address 
  1166                              <1> 	;	      which has caused to page fault (19/09/2015)
  1167                              <1> 	;
  1168                              <1> 	; OUTPUT ->
  1169                              <1> 	;	(corresponding PAGE TABLE ENTRY is mapped/set)
  1170                              <1> 	;	EAX = 0 -> no error
  1171                              <1> 	;	EAX > 0 -> error code in EAX (also CF = 1)
  1172                              <1> 	;
  1173                              <1> 	; Modified Registers -> none (except EAX)
  1174                              <1> 	;	
  1175                              <1>         ;
  1176                              <1>         ; ERROR CODE:
  1177                              <1> 	;	 31  .....	4   3	2   1	0
  1178                              <1> 	;	+---+-- --+---+---+---+---+---+---+
  1179                              <1> 	;	|   Reserved  | I | R | U | W | P |
  1180                              <1> 	;	+---+-- --+---+---+---+---+---+---+
  1181                              <1> 	;
  1182                              <1> 	; P : PRESENT -	When set, the page fault was caused by 
  1183                              <1>     	;		a page-protection violation. When not set,
  1184                              <1> 	;		it was caused by a non-present page.
  1185                              <1> 	; W : WRITE   -	When set, the page fault was caused by
  1186                              <1> 	;		a page write. When not set, it was caused
  1187                              <1> 	;		by a page read.
  1188                              <1> 	; U : USER    -	When set, the page fault was caused 
  1189                              <1> 	;		while CPL = 3. 
  1190                              <1> 	;		This does not necessarily mean that
  1191                              <1> 	;		the page fault was a privilege violation.
  1192                              <1> 	; R : RESERVD -	When set, the page fault was caused by
  1193                              <1> 	;     WRITE	reading a 1 in a reserved field.
  1194                              <1> 	; I : INSTRUC -	When set, the page fault was caused by
  1195                              <1> 	;     FETCH	an instruction fetch
  1196                              <1> 	;
  1197                              <1> 	;; x86 (32 bit) VIRTUAL ADDRESS TRANSLATION
  1198                              <1> 	;  31               22                  12 11                    0
  1199                              <1> 	; +-------------------+-------------------+-----------------------+
  1200                              <1>        	; | PAGE DIR. ENTRY # | PAGE TAB. ENTRY # |        OFFSET         |
  1201                              <1>        	; +-------------------+-------------------+-----------------------+
  1202                              <1> 	;
  1203                              <1> 
  1204                              <1> 	;; CR3 REGISTER (Control Register 3)
  1205                              <1> 	;  31                                   12             5 4 3 2   0
  1206                              <1> 	; +---------------------------------------+-------------+---+-----+
  1207                              <1>       	; |                                       |  		|P|P|     |
  1208                              <1>       	; |   PAGE DIRECTORY TABLE BASE ADDRESS   |  reserved	|C|W|rsvrd|
  1209                              <1>       	; |                                       | 		|D|T|     |
  1210                              <1>    	; +---------------------------------------+-------------+---+-----+
  1211                              <1> 	;
  1212                              <1> 	;	PWT    - WRITE THROUGH
  1213                              <1> 	;	PCD    - CACHE DISABLE		
  1214                              <1> 	;
  1215                              <1> 	;
  1216                              <1> 	;; x86 PAGE DIRECTORY ENTRY (4 KByte Page)
  1217                              <1> 	;  31                                   12 11  9 8 7 6 5 4 3 2 1 0
  1218                              <1> 	; +---------------------------------------+-----+---+-+-+---+-+-+-+
  1219                              <1>       	; |                                       |     | | | | |P|P|U|R| |
  1220                              <1>       	; |     PAGE TABLE BASE ADDRESS 31..12    | AVL |G|0|D|A|C|W|/|/|P|
  1221                              <1>       	; |                                       |     | | | | |D|T|S|W| |
  1222                              <1>    	; +---------------------------------------+-----+---+-+-+---+-+-+-+
  1223                              <1> 	;
  1224                              <1>         ;       P      - PRESENT
  1225                              <1>         ;       R/W    - READ/WRITE
  1226                              <1>         ;       U/S    - USER/SUPERVISOR
  1227                              <1> 	;	PWT    - WRITE THROUGH
  1228                              <1> 	;	PCD    - CACHE DISABLE	
  1229                              <1> 	;	A      - ACCESSED	
  1230                              <1>         ;       D      - DIRTY (IGNORED)
  1231                              <1> 	;	PAT    - PAGE ATTRIBUTE TABLE INDEX (CACHE BEHAVIOR)
  1232                              <1> 	;	G      - GLOBAL	(IGNORED) 
  1233                              <1>         ;       AVL    - AVAILABLE FOR SYSTEMS PROGRAMMER USE
  1234                              <1> 	;
  1235                              <1> 	;
  1236                              <1> 	;; x86 PAGE TABLE ENTRY (4 KByte Page)
  1237                              <1> 	;  31                                   12 11  9 8 7 6 5 4 3 2 1 0
  1238                              <1> 	; +---------------------------------------+-----+---+-+-+---+-+-+-+
  1239                              <1>       	; |                                       |     | |P| | |P|P|U|R| |
  1240                              <1>       	; |     PAGE FRAME BASE ADDRESS 31..12    | AVL |G|A|D|A|C|W|/|/|P|
  1241                              <1>       	; |                                       |     | |T| | |D|T|S|W| |
  1242                              <1>    	; +---------------------------------------+-----+---+-+-+---+-+-+-+
  1243                              <1> 	;
  1244                              <1>         ;       P      - PRESENT
  1245                              <1>         ;       R/W    - READ/WRITE
  1246                              <1>         ;       U/S    - USER/SUPERVISOR
  1247                              <1> 	;	PWT    - WRITE THROUGH
  1248                              <1> 	;	PCD    - CACHE DISABLE	
  1249                              <1> 	;	A      - ACCESSED	
  1250                              <1>         ;       D      - DIRTY
  1251                              <1> 	;	PAT    - PAGE ATTRIBUTE TABLE INDEX (CACHE BEHAVIOR)
  1252                              <1> 	;	G      - GLOBAL	 
  1253                              <1>         ;       AVL    - AVAILABLE FOR SYSTEMS PROGRAMMER USE
  1254                              <1> 	;
  1255                              <1> 	;
  1256                              <1> 	;; 80386 PAGE TABLE ENTRY (4 KByte Page)
  1257                              <1> 	;  31                                   12 11  9 8 7 6 5 4 3 2 1 0
  1258                              <1> 	; +---------------------------------------+-----+-+-+-+-+---+-+-+-+
  1259                              <1>       	; |                                       |     | | | | | | |U|R| |
  1260                              <1>       	; |     PAGE FRAME BASE ADDRESS 31..12    | AVL |0|0|D|A|0|0|/|/|P|
  1261                              <1>       	; |                                       |     | | | | | | |S|W| |
  1262                              <1>       	; +---------------------------------------+-----+-+-+-+-+---+-+-+-+
  1263                              <1> 	;
  1264                              <1>         ;       P      - PRESENT
  1265                              <1>         ;       R/W    - READ/WRITE
  1266                              <1>         ;       U/S    - USER/SUPERVISOR
  1267                              <1>         ;       D      - DIRTY
  1268                              <1>         ;       AVL    - AVAILABLE FOR SYSTEMS PROGRAMMER USE
  1269                              <1> 	;
  1270                              <1>         ;       NOTE: 0 INDICATES INTEL RESERVED. DO NOT DEFINE.
  1271                              <1> 	;
  1272                              <1> 	;
  1273                              <1> 	;; Invalid Page Table Entry
  1274                              <1> 	; 31                                                           1 0
  1275                              <1>       	; +-------------------------------------------------------------+-+
  1276                              <1>       	; |                                                             | |
  1277                              <1>       	; |                          AVAILABLE                          |0|
  1278                              <1>       	; |                                                             | |
  1279                              <1>       	; +-------------------------------------------------------------+-+
  1280                              <1> 	;
  1281                              <1> 
  1282 0000489A 53                  <1> 	push	ebx
  1283 0000489B 52                  <1> 	push	edx
  1284 0000489C 51                  <1> 	push	ecx
  1285                              <1> 	;
  1286                              <1> 	; 21/09/2015 (debugging)
  1287 0000489D FF05[F1300100]      <1> 	inc	dword [u.pfcount] ; page fault count for running process
  1288 000048A3 FF05[6C3E0100]      <1> 	inc	dword [PF_Count] ; total page fault count	
  1289                              <1> 	; 28/06/2015
  1290                              <1> 	;mov	edx, [error_code] ; Lower 5 bits are valid
  1291 000048A9 8A15[643E0100]      <1> 	mov	dl, [error_code]
  1292                              <1> 	;
  1293 000048AF F6C201              <1> 	test	dl, 1	; page fault was caused by a non-present page
  1294                              <1> 			; sign
  1295 000048B2 7422                <1> 	jz	short pfh_alloc_np
  1296                              <1> 	; 
  1297                              <1> 	; If it is not a 'write on read only page' type page fault
  1298                              <1> 	; major page fault error with minor reason must be returned without 
  1299                              <1> 	; fixing the problem. 'sys_exit with error' will be needed
  1300                              <1> 	; after return here!
  1301                              <1> 	; Page fault will be remedied, by copying page contents
  1302                              <1> 	; to newly allocated page with write permission;
  1303                              <1> 	; sys_fork -> sys_exec -> copy on write, demand paging method is 
  1304                              <1> 	; used for working with minimum possible memory usage. 
  1305                              <1> 	; sys_fork will duplicate page directory and tables of parent  
  1306                              <1> 	; process with 'read only' flag. If the child process attempts to
  1307                              <1> 	; write on these read only pages, page fault will be directed here
  1308                              <1> 	; for allocating a new page with same data/content. 
  1309                              <1> 	;
  1310                              <1> 	; IMPORTANT : Retro UNIX 386 v1 (and SINGLIX and TR-DOS)
  1311                              <1> 	; will not force to separate CODE and DATA space 
  1312                              <1> 	; in a process/program... 
  1313                              <1> 	; CODE segment/section may contain DATA!
  1314                              <1> 	; It is flat, smoth and simplest programming method already as in 
  1315                              <1> 	; Retro UNIX 8086 v1 and MS-DOS programs.
  1316                              <1> 	;	
  1317 000048B4 F6C202              <1> 	test	dl, 2	; page fault was caused by a page write
  1318                              <1> 			; sign
  1319 000048B7 0F84AB000000        <1>         jz      pfh_p_err
  1320                              <1> 	; 31/08/2015
  1321 000048BD F6C204              <1> 	test	dl, 4	; page fault was caused while CPL = 3 (user mode)
  1322                              <1> 			; sign.  (U+W+P = 4+2+1 = 7)
  1323 000048C0 0F84A2000000        <1>         jz	pfh_pv_err
  1324                              <1> 	;
  1325                              <1> 	; make a new page and copy the parent's page content
  1326                              <1> 	; as the child's new page content
  1327                              <1> 	;
  1328 000048C6 0F20D3              <1> 	mov	ebx, cr2 ; CR2 contains the linear address 
  1329                              <1> 			 ; which has caused to page fault
  1330 000048C9 E8A2000000          <1> 	call 	copy_page
  1331 000048CE 0F828D000000        <1>         jc      pfh_im_err ; insufficient memory
  1332                              <1> 	;
  1333 000048D4 EB7D                <1>         jmp     pfh_cpp_ok
  1334                              <1> 	;
  1335                              <1> pfh_alloc_np:
  1336 000048D6 E8E7FCFFFF          <1> 	call	allocate_page	; (allocate a new page)
  1337 000048DB 0F8280000000        <1>         jc      pfh_im_err	; 'insufficient memory' error
  1338                              <1> pfh_chk_cpl:
  1339                              <1> 	; EAX = Physical (base) address of the allocated (new) page
  1340                              <1> 		; (Lower 12 bits are ZERO, because 
  1341                              <1> 		;	the address is on a page boundary)
  1342 000048E1 80E204              <1> 	and	dl, 4	; CPL = 3 ?
  1343 000048E4 7505                <1> 	jnz	short pfh_um
  1344                              <1> 			; Page fault handler for kernel/system mode (CPL=0)		
  1345 000048E6 0F20DB              <1> 	mov	ebx, cr3 ; CR3 (Control Register 3) contains physical address
  1346                              <1> 			 ; of the current/active page directory
  1347                              <1> 			 ; (Always kernel/system mode page directory, here!)
  1348                              <1> 			 ; Note: Lower 12 bits are 0. (page boundary)
  1349 000048E9 EB06                <1> 	jmp	short pfh_get_pde
  1350                              <1> 	;
  1351                              <1> pfh_um:			; Page fault handler for user/appl. mode (CPL=3)
  1352 000048EB 8B1D[E1300100]      <1>  	mov	ebx, [u.pgdir] ; Page directory of current/active process
  1353                              <1> 			; Physical address of the USER's page directory
  1354                              <1> 			; Note: Lower 12 bits are 0. (page boundary)
  1355                              <1> pfh_get_pde:
  1356 000048F1 80CA03              <1> 	or	dl, 3	; USER + WRITE + PRESENT or SYSTEM + WRITE + PRESENT
  1357 000048F4 0F20D1              <1> 	mov	ecx, cr2 ; CR2 contains the virtual address 
  1358                              <1> 			 ; which has been caused to page fault
  1359                              <1> 			 ;
  1360 000048F7 C1E914              <1> 	shr	ecx, 20	 ; shift 20 bits right
  1361 000048FA 80E1FC              <1> 	and	cl, 0FCh ; mask lower 2 bits to get PDE offset		
  1362                              <1> 	;
  1363 000048FD 01CB                <1> 	add	ebx, ecx ; now, EBX points to the relevant page dir entry 
  1364 000048FF 8B0B                <1> 	mov	ecx, [ebx] ; physical (base) address of the page table 	
  1365 00004901 F6C101              <1> 	test	cl, 1	 ; check bit 0 is set (1) or not (0).
  1366 00004904 740B                <1> 	jz	short pfh_set_pde ; Page directory entry is not valid,
  1367                              <1> 			  	  ; set/validate page directory entry
  1368 00004906 6681E100F0          <1> 	and	cx, PDE_A_CLEAR ; 0F000h ; Clear attribute bits
  1369 0000490B 89CB                <1> 	mov	ebx, ecx ; Physical address of the page table
  1370 0000490D 89C1                <1> 	mov	ecx, eax ; new page address (physical) 	
  1371 0000490F EB16                <1> 	jmp	short pfh_get_pte
  1372                              <1> pfh_set_pde:
  1373                              <1> 	;; NOTE: Page directories and page tables never be swapped out!
  1374                              <1> 	;;	 (So, we know this PDE is empty or invalid)
  1375                              <1> 	;
  1376 00004911 08D0                <1> 	or	al, dl	 ; lower 3 bits are used as U/S, R/W, P flags
  1377 00004913 8903                <1> 	mov	[ebx], eax ; Let's put the new page directory entry here !
  1378 00004915 30C0                <1> 	xor	al, al	 ; clear lower (3..8) bits
  1379 00004917 89C3                <1> 	mov	ebx, eax
  1380 00004919 E8A4FCFFFF          <1> 	call	allocate_page	 ; (allocate a new page)
  1381 0000491E 7241                <1> 	jc	short pfh_im_err   ; 'insufficient memory' error
  1382                              <1> pfh_spde_1:
  1383                              <1> 	; EAX = Physical (base) address of the allocated (new) page
  1384 00004920 89C1                <1> 	mov	ecx, eax
  1385 00004922 E815FDFFFF          <1> 	call	clear_page ; Clear page content
  1386                              <1> pfh_get_pte:
  1387 00004927 0F20D0              <1> 	mov	eax, cr2 ; virtual address
  1388                              <1> 			 ; which has been caused to page fault
  1389 0000492A 89C7                <1> 	mov	edi, eax ; 20/07/2015
  1390 0000492C C1E80C              <1> 	shr	eax, 12	 ; shift 12 bit right to get 
  1391                              <1> 			 ; higher 20 bits of the page fault address 
  1392 0000492F 25FF030000          <1> 	and	eax, 3FFh ; mask PDE# bits, the result is PTE# (0 to 1023)
  1393 00004934 C1E002              <1> 	shl	eax, 2	; shift 2 bits left to get PTE offset
  1394 00004937 01C3                <1> 	add	ebx, eax ; now, EBX points to the relevant page table entry 
  1395 00004939 8B03                <1> 	mov	eax, [ebx] ; get previous value of pte
  1396                              <1> 		; bit 0 of EAX is always 0 (otherwise we would not be here)
  1397 0000493B 21C0                <1> 	and	eax, eax
  1398 0000493D 7410                <1> 	jz	short pfh_gpte_1
  1399                              <1> 	; 20/07/2015
  1400 0000493F 87D9                <1> 	xchg	ebx, ecx ; new page address (physical)
  1401 00004941 55                  <1> 	push	ebp ; 20/07/2015
  1402 00004942 0F20D5              <1> 	mov	ebp, cr2
  1403                              <1> 		; ECX = physical address of the page table entry
  1404                              <1> 		; EBX = Memory page address (physical!)
  1405                              <1> 		; EAX = Swap disk (offset) address
  1406                              <1> 		; EBP = virtual address (page fault address)
  1407 00004945 E8B7000000          <1> 	call	swap_in
  1408 0000494A 5D                  <1> 	pop	ebp
  1409 0000494B 7210                <1> 	jc      short pfh_err_retn
  1410 0000494D 87CB                <1> 	xchg	ecx, ebx
  1411                              <1> 		; EBX = physical address of the page table entry
  1412                              <1> 		; ECX = new page
  1413                              <1> pfh_gpte_1:
  1414 0000494F 08D1                <1> 	or	cl, dl	; lower 3 bits are used as U/S, R/W, P flags
  1415 00004951 890B                <1> 	mov	[ebx], ecx ; Let's put the new page table entry here !
  1416                              <1> pfh_cpp_ok:
  1417                              <1> 	; 20/07/2015
  1418 00004953 0F20D3              <1> 	mov	ebx, cr2
  1419 00004956 E8A9020000          <1> 	call 	add_to_swap_queue
  1420                              <1> 	;
  1421                              <1> 	; The new PTE (which contains the new page) will be added to 
  1422                              <1> 	; the swap queue, here. 
  1423                              <1> 	; (Later, if memory will become insufficient, 
  1424                              <1> 	; one page will be swapped out which is at the head of 
  1425                              <1> 	; the swap queue by using FIFO and access check methods.)
  1426                              <1> 	;
  1427 0000495B 31C0                <1> 	xor	eax, eax  ; 0
  1428                              <1> 	;
  1429                              <1> pfh_err_retn:
  1430 0000495D 59                  <1> 	pop	ecx
  1431 0000495E 5A                  <1> 	pop	edx
  1432 0000495F 5B                  <1> 	pop	ebx
  1433 00004960 C3                  <1> 	retn 
  1434                              <1> 	
  1435                              <1> pfh_im_err:
  1436 00004961 B8E1000000          <1> 	mov	eax, ERR_MAJOR_PF + ERR_MINOR_IM ; Error code in AX
  1437                              <1> 			; Major (Primary) Error: Page Fault
  1438                              <1> 			; Minor (Secondary) Error: Insufficient Memory !
  1439 00004966 EBF5                <1> 	jmp	short pfh_err_retn
  1440                              <1> 
  1441                              <1> 
  1442                              <1> pfh_p_err: ; 09/03/2015
  1443                              <1> pfh_pv_err:
  1444                              <1> 	; Page fault was caused by a protection-violation
  1445 00004968 B8E3000000          <1> 	mov	eax, ERR_MAJOR_PF + ERR_MINOR_PV ; Error code in AX
  1446                              <1> 			; Major (Primary) Error: Page Fault
  1447                              <1> 			; Minor (Secondary) Error: Protection violation !
  1448 0000496D F9                  <1> 	stc
  1449 0000496E EBED                <1> 	jmp	short pfh_err_retn
  1450                              <1> 
  1451                              <1> copy_page:
  1452                              <1> 	; 22/09/2015
  1453                              <1> 	; 21/09/2015
  1454                              <1> 	; 19/09/2015
  1455                              <1> 	; 07/09/2015
  1456                              <1> 	; 31/08/2015
  1457                              <1> 	; 20/07/2015
  1458                              <1> 	; 05/05/2015
  1459                              <1> 	; 03/05/2015
  1460                              <1> 	; 18/04/2015
  1461                              <1> 	; 12/04/2015
  1462                              <1> 	; 30/10/2014
  1463                              <1> 	; 18/10/2014 (Retro UNIX 386 v1 - beginning)
  1464                              <1> 	;
  1465                              <1> 	; INPUT -> 
  1466                              <1> 	;	EBX = Virtual (linear) address of source page
  1467                              <1> 	;	     (Page fault address)
  1468                              <1> 	; OUTPUT ->
  1469                              <1> 	;	EAX = PHYSICAL (real/flat) ADDRESS OF THE ALLOCATED PAGE
  1470                              <1> 	;	(corresponding PAGE TABLE ENTRY is mapped/set)
  1471                              <1> 	;	EAX = 0 (CF = 1) 
  1472                              <1> 	;		if there is not a free page to be allocated
  1473                              <1> 	;	(page content of the source page will be copied
  1474                              <1> 	;	onto the target/new page) 	
  1475                              <1> 	;
  1476                              <1> 	; Modified Registers -> ecx, ebx (except EAX)
  1477                              <1> 	;	
  1478 00004970 56                  <1> 	push	esi
  1479 00004971 57                  <1> 	push	edi
  1480                              <1> 	;push	ebx
  1481                              <1> 	;push	ecx
  1482 00004972 31F6                <1> 	xor 	esi, esi
  1483 00004974 C1EB0C              <1> 	shr	ebx, 12 ; shift 12 bits right to get PDE & PTE numbers
  1484 00004977 89D9                <1> 	mov	ecx, ebx ; save page fault address (as 12 bit shifted)
  1485 00004979 C1EB08              <1> 	shr	ebx, 8	 ; shift 8 bits right and then
  1486 0000497C 80E3FC              <1> 	and	bl, 0FCh ; mask lower 2 bits to get PDE offset	
  1487 0000497F 89DF                <1> 	mov 	edi, ebx ; save it for the parent of current process
  1488 00004981 031D[E1300100]      <1> 	add	ebx, [u.pgdir] ; EBX points to the relevant page dir entry 
  1489 00004987 8B03                <1> 	mov	eax, [ebx] ; physical (base) address of the page table
  1490 00004989 662500F0            <1> 	and	ax, PTE_A_CLEAR ; 0F000h ; clear attribute bits 	
  1491 0000498D 89CB                <1> 	mov	ebx, ecx   ; (restore higher 20 bits of page fault address)
  1492 0000498F 81E3FF030000        <1> 	and	ebx, 3FFh  ; mask PDE# bits, the result is PTE# (0 to 1023)
  1493 00004995 66C1E302            <1> 	shl	bx, 2	   ; shift 2 bits left to get PTE offset
  1494 00004999 01C3                <1> 	add	ebx, eax   ; EBX points to the relevant page table entry 
  1495                              <1> 	; 07/09/2015
  1496 0000499B 66F7030002          <1>         test    word [ebx], PTE_DUPLICATED ; (Does current process share this
  1497                              <1> 				     ; read only page as a child process?)	
  1498 000049A0 7509                <1> 	jnz	short cpp_0 ; yes
  1499 000049A2 8B0B                <1> 	mov	ecx, [ebx] ; PTE value
  1500 000049A4 6681E100F0          <1> 	and	cx, PTE_A_CLEAR ; 0F000h  ; clear page attributes
  1501 000049A9 EB32                <1> 	jmp	short cpp_1
  1502                              <1> cpp_0:
  1503 000049AB 89FE                <1> 	mov	esi, edi
  1504 000049AD 0335[E5300100]      <1> 	add	esi, [u.ppgdir] ; the parent's page directory entry
  1505 000049B3 8B06                <1> 	mov	eax, [esi] ; physical (base) address of the page table
  1506 000049B5 662500F0            <1> 	and	ax, PTE_A_CLEAR ; 0F000h ; clear attribute bits
  1507 000049B9 89CE                <1> 	mov	esi, ecx   ; (restore higher 20 bits of page fault address)	
  1508 000049BB 81E6FF030000        <1> 	and	esi, 3FFh  ; mask PDE# bits, the result is PTE# (0 to 1023)
  1509 000049C1 66C1E602            <1> 	shl	si, 2	   ; shift 2 bits left to get PTE offset
  1510 000049C5 01C6                <1> 	add	esi, eax   ; EDX points to the relevant page table entry  	
  1511 000049C7 8B0E                <1> 	mov	ecx, [esi] ; PTE value of the parent process
  1512                              <1> 	; 21/09/2015
  1513 000049C9 8B03                <1> 	mov	eax, [ebx] ; PTE value of the child process
  1514 000049CB 662500F0            <1> 	and	ax, PTE_A_CLEAR ; 0F000h ; clear page attributes	
  1515                              <1> 	;
  1516 000049CF F6C101              <1> 	test	cl, PTE_A_PRESENT ; is it a present/valid page ?
  1517 000049D2 7424                <1> 	jz	short cpp_3 ; the parent's page is not same page  	
  1518                              <1> 	;
  1519 000049D4 6681E100F0          <1> 	and	cx, PTE_A_CLEAR ; 0F000h ; clear page attributes
  1520 000049D9 39C8                <1> 	cmp	eax, ecx   ; Same page?	
  1521 000049DB 751B                <1> 	jne	short cpp_3 ; Parent page and child page are not same 
  1522                              <1> 			    ; Convert child's page to writable page
  1523                              <1> cpp_1:
  1524 000049DD E8E0FBFFFF          <1> 	call	allocate_page
  1525 000049E2 721A                <1> 	jc	short cpp_4 ; 'insufficient memory' error
  1526 000049E4 21F6                <1> 	and	esi, esi    ; check ESI is valid or not
  1527 000049E6 7405                <1> 	jz	short cpp_2
  1528                              <1> 		; Convert read only page to writable page 
  1529                              <1> 		;(for the parent of the current process)
  1530                              <1> 	;and	word [esi], PTE_A_CLEAR ; 0F000h
  1531                              <1> 	; 22/09/2015
  1532 000049E8 890E                <1> 	mov	[esi], ecx
  1533 000049EA 800E07              <1> 	or	byte [esi], PTE_A_PRESENT + PTE_A_WRITE + PTE_A_USER
  1534                              <1> 				 ; 1+2+4 = 7
  1535                              <1> cpp_2:
  1536 000049ED 89C7                <1> 	mov	edi, eax ; new page address of the child process
  1537                              <1> 	; 07/09/2015
  1538 000049EF 89CE                <1> 	mov	esi, ecx ; the page address of the parent process
  1539 000049F1 B900040000          <1> 	mov	ecx, PAGE_SIZE / 4
  1540 000049F6 F3A5                <1> 	rep	movsd ; 31/08/2015
  1541                              <1> cpp_3:		
  1542 000049F8 0C07                <1> 	or	al, PTE_A_PRESENT + PTE_A_WRITE + PTE_A_USER ; 1+2+4 = 7
  1543 000049FA 8903                <1> 	mov	[ebx], eax ; Update PTE
  1544 000049FC 28C0                <1> 	sub	al, al ; clear attributes
  1545                              <1> cpp_4:
  1546                              <1> 	;pop	ecx
  1547                              <1> 	;pop	ebx
  1548 000049FE 5F                  <1> 	pop	edi
  1549 000049FF 5E                  <1> 	pop	esi
  1550 00004A00 C3                  <1> 	retn
  1551                              <1> 
  1552                              <1> ;; 28/04/2015
  1553                              <1> ;; 24/10/2014
  1554                              <1> ;; 21/10/2014 (Retro UNIX 386 v1 - beginning)
  1555                              <1> ;; SWAP_PAGE_QUEUE (4096 bytes)
  1556                              <1> ;;
  1557                              <1> ;;   0000   0001   0002   0003   ....   1020   1021   1022   1023	
  1558                              <1> ;; +------+------+------+------+-    -+------+------+------+------+
  1559                              <1> ;; |  pg1 |  pg2 |  pg3 |  pg4 | .... |pg1021|pg1022|pg1023|pg1024|
  1560                              <1> ;; +------+------+------+------+-    -+------+------+------+------+    
  1561                              <1> ;;
  1562                              <1> ;; [swpq_last] = 0 to 4096 (step 4) -> the last position on the queue
  1563                              <1> ;;
  1564                              <1> ;; Method:
  1565                              <1> ;;	Swap page queue is a list of allocated pages with physical
  1566                              <1> ;;	addresses (system mode virtual adresses = physical addresses).
  1567                              <1> ;;	It is used for 'swap_in' and 'swap_out' procedures.
  1568                              <1> ;;	When a new page is being allocated, swap queue is updated
  1569                              <1> ;;	by 'swap_queue_shift' procedure, header of the queue (offset 0)
  1570                              <1> ;;	is checked for 'accessed' flag. If the 1st page on the queue
  1571                              <1> ;;	is 'accessed' or 'read only', it is dropped from the list;
  1572                              <1> ;;	other pages from the 2nd to the last (in [swpq_last]) shifted
  1573                              <1> ;; 	to head then the 2nd page becomes the 1st and '[swpq_last]' 
  1574                              <1> ;;	offset value becomes it's previous offset value - 4.
  1575                              <1> ;;	If the 1st page of the swap page queue is not 'accessed'	
  1576                              <1> ;;	the queue/list is not shifted.
  1577                              <1> ;;	After the queue/list shift, newly allocated page is added
  1578                              <1> ;;	to the tail of the queue at the [swpq_count*4] position.
  1579                              <1> ;;	But, if [swpq_count] > 1023, the newly allocated page
  1580                              <1> ;;	will not be added to the tail of swap page queue.  		 
  1581                              <1> ;;	
  1582                              <1> ;;	During 'swap_out' procedure, swap page queue is checked for
  1583                              <1> ;;	the first non-accessed, writable page in the list, 
  1584                              <1> ;;	from the head to the tail. The list is shifted to left 
  1585                              <1> ;;	(to the head) till a non-accessed page will be found in the list.
  1586                              <1> ;;	Then, this page	is swapped out (to disk) and then it is dropped
  1587                              <1> ;;	from the list by a final swap queue shift. [swpq_count] value
  1588                              <1> ;;	is changed. If all pages on the queue' are 'accessed', 
  1589                              <1> ;;	'insufficient memory' error will be returned ('swap_out' 
  1590                              <1> ;;	procedure will be failed)...
  1591                              <1> ;;
  1592                              <1> ;;	Note: If the 1st page of the queue is an 'accessed' page,
  1593                              <1> ;;	'accessed' flag of the page will be reset (0) and that page
  1594                              <1> ;;	(PTE) will be added to the tail of the queue after
  1595                              <1> ;;	the check, if [swpq_count] < 1023. If [swpq_count] = 1024
  1596                              <1> ;;	the queue will be rotated and the PTE in the head will be
  1597                              <1> ;;	added to the tail after resetting 'accessed' bit. 
  1598                              <1> ;;
  1599                              <1> ;;
  1600                              <1> ;;	
  1601                              <1> ;; SWAP DISK/FILE (with 4096 bytes swapped page blocks)
  1602                              <1> ;;
  1603                              <1> ;;  00000000  00000004  00000008  0000000C   ...   size-8    size-4
  1604                              <1> ;; +---------+---------+---------+---------+-- --+---------+---------+
  1605                              <1> ;; |descriptr| page(1) | page(2) | page(3) | ... |page(n-1)| page(n) |
  1606                              <1> ;; +---------+---------+---------+---------+-- --+---------+---------+    
  1607                              <1> ;;
  1608                              <1> ;; [swpd_next] = the first free block address in swapped page records
  1609                              <1> ;;    		 for next free block search by 'swap_out' procedure.
  1610                              <1> ;; [swpd_size] = swap disk/file size in sectors (512 bytes)
  1611                              <1> ;;		 NOTE: max. possible swap disk size is 1024 GB
  1612                              <1> ;; 		 (entire swap space must be accessed by using
  1613                              <1> ;;		 31 bit offset address) 
  1614                              <1> ;; [swpd_free] = free block (4096 bytes) count in swap disk/file space
  1615                              <1> ;; [swpd_start] = absolute/start address of the swap disk/file
  1616                              <1> ;;		  0 for file, or beginning sector of the swap partition
  1617                              <1> ;; [swp_drv] = logical drive description table addr. of swap disk/file
  1618                              <1> ;;
  1619                              <1> ;; 					
  1620                              <1> ;; Method:
  1621                              <1> ;;	When the memory (ram) becomes insufficient, page allocation
  1622                              <1> ;;	procedure swaps out a page from memory to the swap disk 
  1623                              <1> ;;	(partition) or swap file to get a new free page at the memory.
  1624                              <1> ;;	Swapping out is performed by using swap page queue.
  1625                              <1> ;;
  1626                              <1> ;; 	Allocation block size of swap disk/file is equal to page size
  1627                              <1> ;;	(4096 bytes). Swapping address (in sectors) is recorded
  1628                              <1> ;;	into relevant page file entry as 31 bit physical (logical)
  1629                              <1> ;;	offset address as 1 bit shifted to left for present flag (0).
  1630                              <1> ;;	Swapped page address is between 1 and swap disk/file size - 4.	  
  1631                              <1> ;;	Absolute physical (logical) address of the swapped page is 
  1632                              <1> ;;	calculated by adding offset value to the swap partition's 
  1633                              <1> ;;	start address. If the swap device (disk) is a virtual disk 
  1634                              <1> ;;	or it is a file, start address of the swap disk/volume is 0, 
  1635                              <1> ;;	and offset value is equal to absolute (physical or logical)
  1636                              <1> ;;	address/position. (It has not to be ZERO if the swap partition 
  1637                              <1> ;;	is in a partitioned virtual hard disk.) 
  1638                              <1> ;;
  1639                              <1> ;;	Note: Swap addresses are always specified/declared in sectors, 
  1640                              <1> ;;	not in bytes or	in blocks/zones/clusters (4096 bytes) as unit.
  1641                              <1> ;;
  1642                              <1> ;;	Swap disk/file allocation is mapped via 'Swap Allocation Table'
  1643                              <1> ;;	at memory as similar to 'Memory Allocation Table'.
  1644                              <1> ;;
  1645                              <1> ;;	Every bit of Swap Allocation Table repsesents one swap block
  1646                              <1> ;;	(equal to page size) respectively. Bit 0 of the S.A.T. byte 0
  1647                              <1> ;;	is reserved for swap disk/file block 0 as descriptor block
  1648                              <1> ;;	(also for compatibility with PTE). If bit value is ZERO,
  1649                              <1> ;;	it means relevant (respective) block is in use, and, 
  1650                              <1> ;;	of course, if bit value is 1, it means relevant (respective)
  1651                              <1> ;;      swap disk/file block is free.
  1652                              <1> ;;	For example: bit 1 of the byte 128 repsesents block 1025 
  1653                              <1> ;;	(128*8+1) or sector (offset) 8200 on the swap disk or
  1654                              <1> ;;	byte (offset/position) 4198400 in the swap file. 
  1655                              <1> ;;	4GB swap space is represented via 128KB Swap Allocation Table.
  1656                              <1> ;;	Initial layout of Swap Allocation Table is as follows:
  1657                              <1> ;;	------------------------------------------------------------
  1658                              <1> ;;	0111111111111111111111111 .... 11111111111111111111111111111
  1659                              <1> ;;	------------------------------------------------------------
  1660                              <1> ;;	(0 is reserved block, 1s represent free blocks respectively.)
  1661                              <1> ;;	(Note: Allocation cell/unit of the table is bit, not byte)
  1662                              <1> ;;
  1663                              <1> ;;	..............................................................
  1664                              <1> ;;
  1665                              <1> ;;	'swap_out' procedure checks 'free_swap_blocks' count at first,
  1666                              <1> ;;	then it searches Swap Allocation Table if free count is not
  1667                              <1> ;;	zero. From begining the [swpd_next] dword value, the first bit 
  1668                              <1> ;;	position with value of 1 on the table is converted to swap
  1669                              <1> ;;	disk/file offset address, in sectors (not 4096 bytes block).
  1670                              <1> ;;	'ldrv_write' procedure is called with ldrv (logical drive
  1671                              <1> ;;	number of physical swap disk or virtual swap disk)
  1672                              <1> ;;	number, sector offset (not absolute sector -LBA- number),
  1673                              <1> ;;	and sector count (8, 512*8 = 4096) and buffer adress
  1674                              <1> ;;	(memory page). That will be a direct disk write procedure.
  1675                              <1> ;;	(for preventing late memory allocation, significant waiting). 
  1676                              <1> ;;	If disk write procedure returns with error or free count of 
  1677                              <1> ;;	swap blocks is ZERO, 'swap_out' procedure will return with
  1678                              <1> ;;	'insufficient memory error' (cf=1). 
  1679                              <1> ;;
  1680                              <1> ;;	(Note: Even if free swap disk/file blocks was not zero,
  1681                              <1> ;;	any disk write error will not be fixed by 'swap_out' procedure,
  1682                              <1> ;;	in other words, 'swap_out' will not check the table for other
  1683                              <1> ;;	free blocks after a disk write error. It will return to 
  1684                              <1> ;;	the caller with error (CF=1) which means swapping is failed. 
  1685                              <1> ;;
  1686                              <1> ;;	After writing the page on to swap disk/file address/sector,
  1687                              <1> ;;	'swap_out' procesure returns with that swap (offset) sector
  1688                              <1> ;;	address (cf=0). 
  1689                              <1> ;;
  1690                              <1> ;;	..............................................................
  1691                              <1> ;;
  1692                              <1> ;;	'swap_in' procedure loads addressed (relevant) swap disk or
  1693                              <1> ;;	file sectors at specified memory page. Then page allocation
  1694                              <1> ;;	procedure updates relevant page table entry with 'present' 
  1695                              <1> ;;	attribute. If swap disk or file reading fails there is nothing
  1696                              <1> ;;	to do, except to terminate the process which is the owner of
  1697                              <1> ;;	the swapped page.
  1698                              <1> ;;
  1699                              <1> ;;	'swap_in' procedure sets the relevant/respective bit value
  1700                              <1> ;;	in the Swap Allocation Table (as free block). 'swap_in' also
  1701                              <1> ;;	updates [swpd_first] pointer if it is required.
  1702                              <1> ;;
  1703                              <1> ;;	..............................................................	 
  1704                              <1> ;;
  1705                              <1> ;;	Note: If [swap_enabled] value is ZERO, that means there is not
  1706                              <1> ;;	a swap disk or swap file in use... 'swap_in' and 'swap_out'
  1707                              <1> ;;	procedures ans 'swap page que' procedures will not be active...
  1708                              <1> ;;	'Insufficient memory' error will be returned by 'swap_out'
  1709                              <1> ;;	and 'general protection fault' will be returned by 'swap_in'
  1710                              <1> ;;	procedure, if it is called mistakenly (a wrong value in a PTE).		
  1711                              <1> ;;
  1712                              <1> 
  1713                              <1> swap_in:
  1714                              <1> 	; 31/08/2015
  1715                              <1> 	; 20/07/2015
  1716                              <1> 	; 28/04/2015
  1717                              <1> 	; 18/04/2015
  1718                              <1> 	; 24/10/2014 (Retro UNIX 386 v1 - beginning)
  1719                              <1> 	;
  1720                              <1> 	; INPUT -> 
  1721                              <1> 	;	EBX = PHYSICAL (real/flat) ADDRESS OF THE MEMORY PAGE
  1722                              <1> 	;	EBP = VIRTUAL (LINEAR) ADDRESS (page fault address)
  1723                              <1> 	;	EAX = Offset Address for the swapped page on the
  1724                              <1> 	;	      swap disk or in the swap file.
  1725                              <1> 	;
  1726                              <1> 	; OUTPUT ->
  1727                              <1> 	;	EAX = 0 if loading at memory has been successful
  1728                              <1> 	;
  1729                              <1> 	;	CF = 1 -> swap disk reading error (disk/file not present
  1730                              <1> 	;		  or sector not present or drive not ready
  1731                              <1> 	;	     EAX = Error code
  1732                              <1> 	;	     [u.error] = EAX 
  1733                              <1> 	;		       = The last error code for the process
  1734                              <1> 	;		         (will be reset after returning to user)	  
  1735                              <1> 	;
  1736                              <1> 	; Modified Registers -> EAX
  1737                              <1> 	;
  1738                              <1> 
  1739 00004A01 833D[4E3E0100]00    <1>         cmp     dword [swp_drv], 0
  1740 00004A08 7646                <1> 	jna	short swpin_dnp_err
  1741                              <1> 
  1742 00004A0A 3B05[523E0100]      <1> 	cmp	eax, [swpd_size]
  1743 00004A10 734A                <1> 	jnb	short swpin_snp_err
  1744                              <1> 
  1745 00004A12 56                  <1> 	push	esi
  1746 00004A13 53                  <1> 	push	ebx
  1747 00004A14 51                  <1> 	push	ecx
  1748 00004A15 8B35[4E3E0100]      <1> 	mov	esi, [swp_drv]	
  1749 00004A1B B908000000          <1> 	mov	ecx, PAGE_SIZE / LOGIC_SECT_SIZE  ; 8 !
  1750                              <1> 		; Note: Even if corresponding physical disk's sector 
  1751                              <1> 		; size different than 512 bytes, logical disk sector
  1752                              <1> 		; size is 512 bytes and disk reading procedure
  1753                              <1> 		; will be performed for reading 4096 bytes
  1754                              <1> 		; (2*2048, 8*512). 
  1755                              <1> 	; ESI = Logical disk description table address
  1756                              <1> 	; EBX = Memory page (buffer) address (physical!)
  1757                              <1> 	; EAX = Sector adress (offset address, logical sector number)
  1758                              <1> 	; ECX = Sector count ; 8 sectors
  1759 00004A20 50                  <1> 	push	eax
  1760 00004A21 E8B2020000          <1> 	call	logical_disk_read
  1761 00004A26 58                  <1> 	pop	eax
  1762 00004A27 730C                <1> 	jnc	short swpin_read_ok
  1763                              <1> 	;
  1764 00004A29 B804000000          <1> 	mov	eax, SWP_DISK_READ_ERR ; drive not ready or read error
  1765 00004A2E A3[DD300100]        <1> 	mov	[u.error], eax
  1766 00004A33 EB17                <1> 	jmp	short swpin_retn
  1767                              <1> 	;
  1768                              <1> swpin_read_ok:
  1769                              <1> 	; EAX = Offset address (logical sector number)
  1770 00004A35 E810020000          <1> 	call	unlink_swap_block  ; Deallocate swap block	
  1771                              <1> 	;
  1772                              <1> 	; EBX = Memory page (buffer) address (physical!)
  1773                              <1> 	; 20/07/2015
  1774 00004A3A 89EB                <1> 	mov	ebx, ebp ; virtual address (page fault address)
  1775 00004A3C 6681E300F0          <1>         and     bx, ~PAGE_OFF ; ~0FFFh ; reset bits, 0 to 11
  1776 00004A41 8A1D[D7300100]      <1> 	mov	bl, [u.uno] ; current process number
  1777                              <1> 	; EBX = Virtual address & process number combination
  1778 00004A47 E8DB000000          <1> 	call	swap_queue_shift
  1779                              <1> 	; eax = 0 ; 10/06/2016 (if ebx input > 0, eax output = 0)
  1780                              <1> 	;sub	eax, eax  ; 0 ; Error Code = 0  (no error)
  1781                              <1> 	; zf = 1
  1782                              <1> swpin_retn:
  1783 00004A4C 59                  <1> 	pop	ecx
  1784 00004A4D 5B                  <1> 	pop	ebx
  1785 00004A4E 5E                  <1> 	pop	esi
  1786 00004A4F C3                  <1> 	retn
  1787                              <1> 
  1788                              <1> swpin_dnp_err:
  1789 00004A50 B805000000          <1> 	mov	eax, SWP_DISK_NOT_PRESENT_ERR
  1790                              <1> swpin_err_retn:
  1791 00004A55 A3[DD300100]        <1> 	mov	[u.error], eax
  1792 00004A5A F9                  <1> 	stc
  1793 00004A5B C3                  <1> 	retn
  1794                              <1> 
  1795                              <1> swpin_snp_err:
  1796 00004A5C B806000000          <1> 	mov	eax, SWP_SECTOR_NOT_PRESENT_ERR
  1797 00004A61 EBF2                <1> 	jmp	short swpin_err_retn
  1798                              <1> 
  1799                              <1> swap_out:
  1800                              <1> 	; 10/06/2016
  1801                              <1> 	; 07/06/2016
  1802                              <1>         ; 23/05/2016
  1803                              <1> 	; 19/05/2016 - TRDOS 386 (TRDOS v2.0)
  1804                              <1> 	; 24/10/2014 - 31/08/2015 (Retro UNIX 386 v1)
  1805                              <1> 	;
  1806                              <1> 	; INPUT -> 
  1807                              <1> 	;	none
  1808                              <1> 	;
  1809                              <1> 	; OUTPUT ->
  1810                              <1> 	;	EAX = Physical page address (which is swapped out
  1811                              <1> 	;	      for allocating a new page)
  1812                              <1> 	;	CF = 1 -> swap disk writing error (disk/file not present
  1813                              <1> 	;		  or sector not present or drive not ready
  1814                              <1> 	;	     EAX = Error code
  1815                              <1> 	;	     [u.error] = EAX 
  1816                              <1> 	;		       = The last error code for the process
  1817                              <1> 	;		         (will be reset after returning to user)	  
  1818                              <1> 	;
  1819                              <1> 	; Modified Registers -> none (except EAX)
  1820                              <1> 	;
  1821 00004A63 66833D[4C3E0100]01  <1> 	cmp 	word [swpq_count], 1
  1822 00004A6B 0F82AF000000        <1>         jc      swpout_im_err ; 'insufficient memory'
  1823                              <1> 
  1824                              <1>         ;cmp    dword [swp_drv], 1
  1825                              <1> 	;jc	short swpout_dnp_err ; 'swap disk/file not present'
  1826                              <1> 
  1827 00004A71 833D[563E0100]01    <1>         cmp     dword [swpd_free], 1
  1828 00004A78 0F828F000000        <1>         jc      swpout_nfspc_err ; 'no free space on swap disk'
  1829                              <1> 
  1830 00004A7E 53                  <1> 	push	ebx ; *
  1831                              <1> swpout_1:
  1832                              <1> 	; 10/06/2016
  1833 00004A7F 31DB                <1> 	xor	ebx, ebx ; shift the queue and return a PTE value
  1834 00004A81 E8A1000000          <1> 	call	swap_queue_shift
  1835 00004A86 21C0                <1> 	and	eax, eax	; 0 = empty queue (improper entries)
  1836 00004A88 0F848A000000        <1>         jz      swpout_npts_err        ; There is not any proper PTE
  1837                              <1> 				       ; pointer in the swap queue
  1838                              <1> 	; EAX = PTE value of the page
  1839                              <1> 	; EBX = PTE address of the page
  1840 00004A8E 662500F0            <1> 	and	ax, PTE_A_CLEAR ; 0F000h ; clear attribute bits
  1841                              <1> 	;
  1842                              <1> 	; 07/06/2016
  1843                              <1> 	; 19/05/2016
  1844                              <1> 	; check this page is in timer events or not
  1845                              <1> 	
  1846                              <1> swpout_timer_page_0:
  1847 00004A92 52                  <1> 	push	edx ; **
  1848                              <1> 
  1849                              <1> 	; 07/06/2016
  1850 00004A93 803D[2F2D0100]00    <1> 	cmp	byte [timer_events], 0 
  1851 00004A9A 762F                <1> 	jna	short swpout_2
  1852                              <1> 	;
  1853 00004A9C 8A15[2F2D0100]      <1> 	mov	dl, [timer_events]
  1854                              <1> 
  1855 00004AA2 51                  <1> 	push	ecx ; ***
  1856 00004AA3 53                  <1> 	push	ebx ; ****
  1857 00004AA4 BB[4C3D0100]        <1> 	mov	ebx, timer_set ; beginning address of timer event
  1858                              <1> 			       ; structures 
  1859                              <1> swpout_timer_page_1:
  1860 00004AA9 8A0B                <1> 	mov	cl, [ebx]
  1861 00004AAB 08C9                <1> 	or	cl, cl ; 0 = free, >0 = process number
  1862 00004AAD 7415                <1> 	jz	short swpout_timer_page_3
  1863 00004AAF 8B4B0C              <1> 	mov	ecx, [ebx+12] ; response (signal return) address
  1864 00004AB2 6681E100F0          <1> 	and	cx, PTE_A_CLEAR ; clear offset part (right 12 bits)
  1865                              <1> 				; of the response byte address, to
  1866                              <1> 				; get beginning of the page address)
  1867 00004AB7 39C8                <1> 	cmp	eax, ecx
  1868 00004AB9 7505                <1> 	jne	short swpout_timer_page_2 ; not same page
  1869                              <1> 	
  1870                              <1> 	; !same page!
  1871                              <1> 	;
  1872                              <1> 	; NOTE: // 19/05/2016 // - TRDOS 386 feature only ! -
  1873                              <1> 	; This page will be used by the kernel to put timer event
  1874                              <1> 	; response (signal return) byte at the requested address;
  1875                              <1> 	; in order to prevent a possible wrong write (while
  1876                              <1> 	; this page is swapped out) on physical memory,
  1877                              <1> 	; we must protect this page against to be swapped out!
  1878                              <1> 	;
  1879 00004ABB 5B                  <1> 	pop	ebx ; ****
  1880 00004ABC 59                  <1> 	pop	ecx ; ***
  1881 00004ABD 5A                  <1> 	pop	edx ; **
  1882 00004ABE EBBF                <1> 	jmp	short swpout_1	; do not swap out this page !
  1883                              <1>  
  1884                              <1> swpout_timer_page_2:
  1885                              <1> 	; 07/06/2016
  1886 00004AC0 FECA                <1> 	dec	dl
  1887 00004AC2 7405                <1> 	jz	short swpout_timer_page_4
  1888                              <1> swpout_timer_page_3:
  1889                              <1> 	;cmp	ebx, timer_set + 240 ; last timer event (15*16) 
  1890                              <1> 	;jnb	short swpout_timer_page_4
  1891 00004AC4 83C310              <1> 	add	ebx, 16
  1892 00004AC7 EBE0                <1> 	jmp	short swpout_timer_page_1	
  1893                              <1> 
  1894                              <1> swpout_timer_page_4:
  1895 00004AC9 5B                  <1> 	pop	ebx ; ****
  1896 00004ACA 59                  <1> 	pop	ecx ; ***
  1897                              <1> swpout_2:
  1898 00004ACB 89DA                <1> 	mov	edx, ebx	       ; Page table entry address	
  1899 00004ACD 89C3                <1> 	mov	ebx, eax	       ; Buffer (Page) Address				
  1900                              <1> 	;
  1901 00004ACF E8A9010000          <1> 	call	link_swap_block
  1902 00004AD4 7304                <1> 	jnc	short swpout_3	       ; It may not be needed here	
  1903                              <1> 				       ; because [swpd_free] value
  1904                              <1> 				       ; was checked at the beginging. 	
  1905 00004AD6 5A                  <1> 	pop	edx ; **
  1906 00004AD7 5B                  <1> 	pop	ebx ; *
  1907 00004AD8 EB33                <1> 	jmp	short swpout_nfspc_err 
  1908                              <1> swpout_3:
  1909 00004ADA A900000080          <1> 	test	eax, 80000000h ; test bit 31 (this may not be needed!)
  1910 00004ADF 752C                <1> 	jnz	short swpout_nfspc_err  ; 10/06/2016 (bit 31 = 1 !)
  1911                              <1> 	;	
  1912 00004AE1 56                  <1> 	push	esi ; **
  1913 00004AE2 51                  <1> 	push	ecx ; ***
  1914 00004AE3 50                  <1> 	push	eax ; sector address ; (31 bit !, bit 31 = 0)
  1915 00004AE4 8B35[4E3E0100]      <1> 	mov	esi, [swp_drv]	
  1916 00004AEA B908000000          <1> 	mov	ecx, PAGE_SIZE / LOGIC_SECT_SIZE  ; 8 !
  1917                              <1> 		; Note: Even if corresponding physical disk's sector 
  1918                              <1> 		; size different than 512 bytes, logical disk sector
  1919                              <1> 		; size is 512 bytes and disk writing procedure
  1920                              <1> 		; will be performed for writing 4096 bytes
  1921                              <1> 		; (2*2048, 8*512). 
  1922                              <1> 	; ESI = Logical disk description table address
  1923                              <1> 	; EBX = Buffer (Page) address
  1924                              <1> 	; EAX = Sector adress (offset address, logical sector number)
  1925                              <1> 	; ECX = Sector count ; 8 sectors
  1926                              <1> 	; edx = PTE address
  1927 00004AEF E8E5010000          <1> 	call	logical_disk_write
  1928                              <1> 	; edx = PTE address
  1929 00004AF4 59                  <1> 	pop	ecx ; sector address	
  1930 00004AF5 730C                <1> 	jnc	short swpout_write_ok
  1931                              <1> 	;
  1932                              <1> 	;; call	unlink_swap_block ; this block must be left as 'in use'
  1933                              <1> swpout_dw_err:
  1934 00004AF7 B808000000          <1> 	mov	eax, SWP_DISK_WRITE_ERR ; drive not ready or write error
  1935 00004AFC A3[DD300100]        <1> 	mov	[u.error], eax
  1936 00004B01 EB06                <1> 	jmp	short swpout_retn
  1937                              <1> 	;
  1938                              <1> swpout_write_ok:
  1939                              <1> 	; EBX = Buffer (page) address
  1940                              <1> 	; EDX = Page Table Entry address
  1941                              <1> 	; ECX = Swap disk sector (file block) address (31 bit)
  1942 00004B03 D1E1                <1> 	shl 	ecx, 1  ; 31 bit sector address from bit 1 to bit 31 
  1943 00004B05 890A                <1> 	mov 	[edx], ecx 
  1944                              <1> 		; bit 0 = 0 (swapped page)
  1945 00004B07 89D8                <1> 	mov	eax, ebx
  1946                              <1> swpout_retn:
  1947 00004B09 59                  <1> 	pop	ecx ; ***
  1948 00004B0A 5E                  <1> 	pop	esi ; **
  1949 00004B0B 5B                  <1> 	pop	ebx ; *
  1950 00004B0C C3                  <1> 	retn
  1951                              <1> 
  1952                              <1> ;swpout_dnp_err:
  1953                              <1> ;	mov	eax, SWP_DISK_NOT_PRESENT_ERR ; disk not present
  1954                              <1> ;	jmp	short swpout_err_retn
  1955                              <1> swpout_nfspc_err:
  1956 00004B0D B807000000          <1> 	mov	eax, SWP_NO_FREE_SPACE_ERR ; no free space
  1957                              <1> swpout_err_retn:
  1958 00004B12 A3[DD300100]        <1> 	mov	[u.error], eax
  1959                              <1> 	;stc
  1960 00004B17 C3                  <1> 	retn
  1961                              <1> swpout_npts_err:
  1962 00004B18 B809000000          <1> 	mov	eax, SWP_NO_PAGE_TO_SWAP_ERR
  1963 00004B1D 5B                  <1> 	pop	ebx
  1964 00004B1E EBF2                <1> 	jmp	short swpout_err_retn
  1965                              <1> swpout_im_err:
  1966 00004B20 B801000000          <1> 	mov	eax, ERR_MINOR_IM ; insufficient (out of) memory
  1967 00004B25 EBEB                <1> 	jmp	short swpout_err_retn
  1968                              <1> 
  1969                              <1> swap_queue_shift:
  1970                              <1> 	; 10/06/2016
  1971                              <1> 	; 09/06/2016 - TRDOS 386 (TRDOS v2.0)
  1972                              <1> 	; 23/10/2014 - 20/07/2015 (Retro UNIX 386 v1)
  1973                              <1> 	;
  1974                              <1> 	; INPUT ->
  1975                              <1> 	;	EBX = Virtual (linear) address (bit 12 to 31) 
  1976                              <1> 	;	      and process number combination (bit 0 to 11)
  1977                              <1> 	;	EBX = 0 -> shift/drop from the head (offset 0)
  1978                              <1> 	;	
  1979                              <1> 	; OUTPUT ->
  1980                              <1> 	;	If EBX input > 0 
  1981                              <1> 	;	   the queue will be shifted 4 bytes (dword),
  1982                              <1> 	; 	   from the tail to the head, up to entry offset
  1983                              <1> 	; 	   which points to EBX input value or nothing
  1984                              <1> 	;	   to do if EBX value is not found in the queue.
  1985                              <1> 	;	   (The entry -with EBX value- will be removed
  1986                              <1> 	;	   from the queue if it is found.)
  1987                              <1> 	;
  1988                              <1> 	;	   EAX = 0		
  1989                              <1> 	;
  1990                              <1> 	;	If EBX input = 0
  1991                              <1> 	;	   the queue will be shifted 4 bytes (dword),
  1992                              <1> 	; 	   from the tail to the head, if the PTE address
  1993                              <1> 	;	   which is pointed in head of the queue is marked
  1994                              <1> 	;	   as "accessed" or it is marked as "non present".
  1995                              <1> 	;	   (If "accessed" flag of the PTE -which is pointed
  1996                              <1> 	;	   in the head- is set -to 1-, it will be reset
  1997                              <1> 	;	   -to 0- and then, the queue will be rotated 
  1998                              <1> 	;	   -without dropping pointer of the PTE from 
  1999                              <1> 	;	   the queue- for 4 bytes on head to tail direction.
  2000                              <1> 	;	   Pointer in the head will be moved into the tail,
  2001                              <1> 	;	   other PTEs will be shifted on head direction.)
  2002                              <1> 	;
  2003                              <1> 	;	   Swap queue will be shifted up to the first
  2004                              <1> 	;	   'present' or 'non accessed' page will be found
  2005                              <1> 	;	   (as pointed) in the queue head (then it will be
  2006                              <1>         ;          removed/dropped from the queue).
  2007                              <1> 	;
  2008                              <1> 	;	   EAX (> 0) = PTE value of the page which is
  2009                              <1> 	;		 (it's pointer -virtual address-) dropped
  2010                              <1> 	;		 (removed) from swap queue.
  2011                              <1> 	;	   EBX = PTE address of the page (if EAX > 0)
  2012                              <1> 	;	         which is (it's pointer -virtual address-)
  2013                              <1> 	;		 dropped (removed) from swap queue.
  2014                              <1> 	;
  2015                              <1> 	;	   EAX = 0 -> empty swap queue ! 
  2016                              <1> 	;
  2017                              <1> 	; Modified Registers -> EAX, EBX (if EAX > 0)
  2018                              <1> 	;
  2019 00004B27 0FB705[4C3E0100]    <1> 	movzx   eax, word [swpq_count]  ; Max. 1024
  2020 00004B2E 6621C0              <1> 	and	ax, ax
  2021 00004B31 7433                <1> 	jz	short swpqs_retn
  2022 00004B33 57                  <1> 	push	edi
  2023 00004B34 56                  <1> 	push	esi
  2024 00004B35 51                  <1> 	push	ecx
  2025 00004B36 53                  <1> 	push	ebx
  2026 00004B37 BE00E00800          <1> 	mov	esi, swap_queue
  2027 00004B3C 89C1                <1> 	mov	ecx, eax
  2028 00004B3E 09DB                <1> 	or	ebx, ebx
  2029 00004B40 7425                <1> 	jz	short swpqs_7
  2030                              <1> swpqs_1:
  2031 00004B42 AD                  <1> 	lodsd
  2032 00004B43 39D8                <1> 	cmp	eax, ebx
  2033 00004B45 7406                <1> 	je	short swpqs_2
  2034 00004B47 E2F9                <1> 	loop	swpqs_1
  2035                              <1> 	; 10/06/2016
  2036 00004B49 29C0                <1> 	sub	eax, eax 
  2037 00004B4B EB15                <1> 	jmp	short swpqs_6
  2038                              <1> swpqs_2:
  2039 00004B4D 89F7                <1> 	mov	edi, esi
  2040 00004B4F 83EF04              <1> 	sub 	edi, 4
  2041                              <1> swpqs_3:
  2042 00004B52 66FF0D[4C3E0100]    <1> 	dec	word [swpq_count]
  2043 00004B59 7403                <1> 	jz	short swpqs_5
  2044                              <1> swpqs_4:
  2045 00004B5B 49                  <1> 	dec 	ecx
  2046 00004B5C F3A5                <1> 	rep	movsd	; shift up (to the head)
  2047                              <1> swpqs_5:
  2048 00004B5E 31C0                <1> 	xor	eax, eax
  2049 00004B60 8907                <1> 	mov	[edi], eax
  2050                              <1> swpqs_6:
  2051 00004B62 5B                  <1> 	pop	ebx
  2052                              <1> swpqs_14:
  2053 00004B63 59                  <1> 	pop	ecx
  2054 00004B64 5E                  <1> 	pop	esi
  2055 00004B65 5F                  <1> 	pop	edi
  2056                              <1> swpqs_retn:
  2057 00004B66 C3                  <1> 	retn		
  2058                              <1> swpqs_7:
  2059 00004B67 89F7                <1> 	mov	edi, esi ; head
  2060 00004B69 AD                  <1> 	lodsd
  2061                              <1> 	; 20/07/2015
  2062 00004B6A 89C3                <1> 	mov	ebx, eax
  2063 00004B6C 81E300F0FFFF        <1> 	and	ebx, ~PAGE_OFF ; ~0FFFh 
  2064                              <1> 		      ; ebx = virtual address (at page boundary)	
  2065 00004B72 25FF0F0000          <1> 	and	eax, PAGE_OFF ; 0FFFh
  2066                              <1> 		      ; ax = process number (1 to 4095)
  2067 00004B77 3A05[D7300100]      <1> 	cmp	al, [u.uno]
  2068                              <1> 		; Max. 16 (nproc) processes for Retro UNIX 386 v1
  2069 00004B7D 7507                <1> 	jne	short swpqs_8
  2070 00004B7F A1[E1300100]        <1> 	mov	eax, [u.pgdir]
  2071 00004B84 EB28                <1> 	jmp	short swpqs_9
  2072                              <1> swpqs_8:
  2073                              <1> 	; 09/06/2016
  2074 00004B86 80B8[FB2D0100]00    <1> 	cmp	byte [eax+p.stat-1], 0
  2075 00004B8D 76C3                <1> 	jna	short swpqs_3     ; free (or terminated) process
  2076 00004B8F 80B8[FB2D0100]02    <1> 	cmp	byte [eax+p.stat-1], 2 ; waiting
  2077 00004B96 77BA                <1> 	ja	short swpqs_3 	  ; zombie (3) or undefined ?	
  2078                              <1> 
  2079                              <1> 	;shl	ax, 2
  2080 00004B98 C0E002              <1> 	shl	al, 2
  2081 00004B9B 8B80[082E0100]      <1> 	mov 	eax, [eax+p.upage-4]
  2082 00004BA1 09C0                <1> 	or	eax, eax
  2083 00004BA3 74AD                <1> 	jz	short swpqs_3 ; invalid upage
  2084 00004BA5 83C061              <1> 	add	eax, u.pgdir - user
  2085                              <1> 			 ; u.pgdir value for the process
  2086                              <1> 			 ; is in [eax]
  2087 00004BA8 8B00                <1> 	mov	eax, [eax]
  2088 00004BAA 21C0                <1> 	and	eax, eax
  2089 00004BAC 74A4                <1> 	jz	short swpqs_3 ; invalid page directory
  2090                              <1> swpqs_9:
  2091 00004BAE 52                  <1> 	push	edx
  2092                              <1> 	; eax = page directory
  2093                              <1> 	; ebx = virtual address
  2094 00004BAF E829FBFFFF          <1> 	call	get_pte
  2095 00004BB4 89D3                <1> 	mov	ebx, edx	; PTE address
  2096 00004BB6 5A                  <1> 	pop	edx
  2097                              <1> 	; 10/06/2016
  2098 00004BB7 723B                <1> 	jc	short swpqs_13 ; empty PDE
  2099                              <1> 	; EAX = PTE value
  2100 00004BB9 A801                <1> 	test	al, PTE_A_PRESENT ; bit 0 = 1
  2101 00004BBB 7437                <1> 	jz	short swpqs_13  ; Drop non-present page
  2102                              <1> 			        ; from the queue (head)
  2103 00004BBD A802                <1> 	test	al, PTE_A_WRITE	; bit 1 = 0 (read only)
  2104 00004BBF 7433                <1> 	jz	short swpqs_13  ; Drop read only page
  2105                              <1> 			        ; from the queue (head) 	
  2106                              <1> 	;test	al, PTE_A_ACCESS ; bit 5 = 1 (Accessed)
  2107                              <1> 	;jnz	short swpqs_11  ; present
  2108                              <1> 			        ; accessed page
  2109 00004BC1 0FBAF005            <1>         btr     eax, PTE_A_ACCESS_BIT ; reset 'accessed' bit
  2110 00004BC5 7211                <1> 	jc	short swpqs_11  ; accessed page
  2111                              <1> 
  2112 00004BC7 49                  <1> 	dec	ecx
  2113 00004BC8 66890D[4C3E0100]    <1> 	mov	[swpq_count], cx
  2114 00004BCF 7402                <1>         jz      short swpqs_10
  2115                              <1> 		; esi = head + 4
  2116                              <1> 		; edi = head
  2117 00004BD1 F3A5                <1> 	rep	movsd	 ; n = 1 to k-1, [n - 1] = [n]
  2118                              <1> swpqs_10:
  2119 00004BD3 890F                <1> 	mov	[edi], ecx ; 0
  2120 00004BD5 59                  <1> 	pop	ecx       	;  EBX (input) in stack
  2121                              <1> 				;  EBX = PTE address	
  2122 00004BD6 EB8B                <1> 	jmp	short swpqs_14 
  2123                              <1> 
  2124                              <1> swpqs_11:
  2125 00004BD8 8903                <1> 	mov	[ebx], eax     ; save changed attribute
  2126                              <1> 	; Rotation (head -> tail)
  2127 00004BDA 49                  <1> 	dec	ecx     ; entry count -> last entry number		
  2128 00004BDB 74F6                <1> 	jz	short swpqs_10
  2129                              <1> 		; esi = head + 4
  2130                              <1> 		; edi = head
  2131 00004BDD 8B07                <1> 	mov	eax, [edi] ; 20/07/2015
  2132 00004BDF F3A5                <1> 	rep	movsd	 ; n = 1 to k-1, [n - 1] = [n]
  2133 00004BE1 8907                <1> 	mov	[edi], eax ; head -> tail ; [k] = [1]
  2134                              <1> 
  2135 00004BE3 668B0D[4C3E0100]    <1> 	mov	cx, [swpq_count]
  2136                              <1> 
  2137                              <1> swpqs_12:
  2138 00004BEA BE00E00800          <1> 	mov	esi, swap_queue ; head
  2139 00004BEF E973FFFFFF          <1>         jmp     swpqs_7
  2140                              <1> 
  2141                              <1> swpqs_13:
  2142 00004BF4 49                  <1> 	dec	ecx
  2143 00004BF5 66890D[4C3E0100]    <1> 	mov	[swpq_count], cx
  2144 00004BFC 0F845CFFFFFF        <1>         jz      swpqs_5
  2145 00004C02 EBE6                <1> 	jmp	short swpqs_12
  2146                              <1> 
  2147                              <1> add_to_swap_queue:
  2148                              <1> ; temporary - 16/09/2015
  2149 00004C04 C3                  <1> retn
  2150                              <1> 	; 20/07/2015
  2151                              <1> 	; 24/10/2014 (Retro UNIX 386 v1 - beginning)
  2152                              <1> 	;
  2153                              <1> 	; Adds new page to swap queue
  2154                              <1> 	; (page directories and page tables must not be added
  2155                              <1> 	; to swap queue)	
  2156                              <1> 	;
  2157                              <1> 	; INPUT ->
  2158                              <1> 	;	EBX = Virtual address (for current process, [u.uno])
  2159                              <1> 	;
  2160                              <1> 	; OUTPUT ->
  2161                              <1> 	;	EAX = [swpq_count]
  2162                              <1> 	;	      (after the PTE has been added)
  2163                              <1> 	;	EAX = 0 -> Swap queue is full, (1024 entries)
  2164                              <1> 	;	      the PTE could not be added.
  2165                              <1> 	;
  2166                              <1> 	; Modified Registers -> EAX
  2167                              <1> 	;
  2168 00004C05 53                  <1> 	push	ebx
  2169 00004C06 6681E300F0          <1>         and     bx, ~PAGE_OFF ; ~0FFFh ; reset bits, 0 to 11
  2170 00004C0B 8A1D[D7300100]      <1> 	mov	bl, [u.uno] ; current process number
  2171 00004C11 E811FFFFFF          <1> 	call	swap_queue_shift ; drop from the queue if
  2172                              <1> 				 ; it is already in the queue
  2173                              <1> 		; then add it to the tail of the queue
  2174 00004C16 0FB705[4C3E0100]    <1> 	movzx	eax, word [swpq_count]
  2175 00004C1D 663D0004            <1> 	cmp	ax, 1024
  2176 00004C21 7205                <1> 	jb	short atsq_1
  2177 00004C23 6629C0              <1> 	sub	ax, ax
  2178 00004C26 5B                  <1> 	pop	ebx
  2179 00004C27 C3                  <1> 	retn
  2180                              <1> atsq_1:
  2181 00004C28 56                  <1> 	push	esi
  2182 00004C29 BE00E00800          <1> 	mov	esi, swap_queue
  2183 00004C2E 6621C0              <1> 	and	ax, ax
  2184 00004C31 740A                <1> 	jz	short atsq_2
  2185 00004C33 66C1E002            <1> 	shl	ax, 2	; convert to offset
  2186 00004C37 01C6                <1> 	add	esi, eax
  2187 00004C39 66C1E802            <1> 	shr	ax, 2
  2188                              <1> atsq_2:
  2189 00004C3D 6640                <1> 	inc	ax
  2190 00004C3F 891E                <1> 	mov	[esi], ebx ; Virtual address + [u.uno] combination
  2191 00004C41 66A3[4C3E0100]      <1> 	mov	[swpq_count], ax
  2192 00004C47 5E                  <1> 	pop	esi
  2193 00004C48 5B                  <1> 	pop	ebx
  2194 00004C49 C3                  <1> 	retn
  2195                              <1> 
  2196                              <1> unlink_swap_block:
  2197                              <1> 	; 15/09/2015
  2198                              <1> 	; 30/04/2015
  2199                              <1> 	; 18/04/2015
  2200                              <1> 	; 24/10/2014 (Retro UNIX 386 v1 - beginning)
  2201                              <1> 	;
  2202                              <1> 	; INPUT -> 
  2203                              <1> 	;	EAX = swap disk/file offset address
  2204                              <1> 	;	      (bit 1 to bit 31)
  2205                              <1> 	; OUTPUT ->
  2206                              <1> 	;	[swpd_free] is increased
  2207                              <1> 	;	(corresponding SWAP DISK ALLOC. TABLE bit is SET)
  2208                              <1> 	;
  2209                              <1> 	; Modified Registers -> EAX
  2210                              <1> 	;
  2211 00004C4A 53                  <1> 	push	ebx
  2212 00004C4B 52                  <1> 	push	edx
  2213                              <1> 	;
  2214 00004C4C C1E804              <1> 	shr	eax, SECTOR_SHIFT+1  ;3+1 ; shift sector address to 
  2215                              <1> 				     ; 3 bits right
  2216                              <1> 				     ; to get swap block/page number
  2217 00004C4F 89C2                <1> 	mov	edx, eax
  2218                              <1> 	; 15/09/2015
  2219 00004C51 C1EA03              <1> 	shr	edx, 3		     ; to get offset to S.A.T.
  2220                              <1> 				     ; (1 allocation bit = 1 page)
  2221                              <1> 				     ; (1 allocation bytes = 8 pages)
  2222 00004C54 80E2FC              <1> 	and	dl, 0FCh 	     ; clear lower 2 bits
  2223                              <1> 				     ; (to get 32 bit position)			
  2224                              <1> 	;
  2225 00004C57 BB00000D00          <1> 	mov	ebx, swap_alloc_table ; Swap Allocation Table address
  2226 00004C5C 01D3                <1> 	add	ebx, edx
  2227 00004C5E 83E01F              <1> 	and	eax, 1Fh	     ; lower 5 bits only
  2228                              <1> 				     ; (allocation bit position)	 
  2229 00004C61 3B05[5A3E0100]      <1> 	cmp 	eax, [swpd_next]     ; is the new free block addr. lower
  2230                              <1> 				     ; than the address in 'swpd_next' ?
  2231                              <1> 				     ; (next/first free block value)		
  2232 00004C67 7305                <1> 	jnb	short uswpbl_1	     ; no	
  2233 00004C69 A3[5A3E0100]        <1> 	mov	[swpd_next], eax     ; yes	
  2234                              <1> uswpbl_1:
  2235 00004C6E 0FAB03              <1> 	bts	[ebx], eax	     ; unlink/release/deallocate block
  2236                              <1> 				     ; set relevant bit to 1.
  2237                              <1> 				     ; set CF to the previous bit value	
  2238 00004C71 F5                  <1> 	cmc			     ; complement carry flag	
  2239 00004C72 7206                <1> 	jc	short uswpbl_2	     ; do not increase swfd_free count
  2240                              <1> 				     ; if the block is already deallocated
  2241                              <1> 				     ; before.	
  2242 00004C74 FF05[563E0100]      <1>         inc     dword [swpd_free]
  2243                              <1> uswpbl_2:
  2244 00004C7A 5A                  <1> 	pop	edx
  2245 00004C7B 5B                  <1> 	pop	ebx
  2246 00004C7C C3                  <1> 	retn
  2247                              <1> 
  2248                              <1> link_swap_block:
  2249                              <1> 	; 01/07/2015
  2250                              <1> 	; 18/04/2015
  2251                              <1> 	; 24/10/2014 (Retro UNIX 386 v1 - beginning)
  2252                              <1> 	;
  2253                              <1> 	; INPUT -> none
  2254                              <1> 	;
  2255                              <1> 	; OUTPUT ->
  2256                              <1> 	;	EAX = OFFSET ADDRESS OF THE ALLOCATED BLOCK (4096 bytes)
  2257                              <1> 	;	      in sectors (corresponding 
  2258                              <1> 	;	      SWAP DISK ALLOCATION TABLE bit is RESET)
  2259                              <1> 	;
  2260                              <1> 	;	CF = 1 and EAX = 0 
  2261                              <1> 	; 		   if there is not a free block to be allocated	
  2262                              <1> 	;
  2263                              <1> 	; Modified Registers -> none (except EAX)
  2264                              <1> 	;
  2265                              <1> 
  2266                              <1> 	;mov	eax, [swpd_free]
  2267                              <1> 	;and	eax, eax
  2268                              <1> 	;jz	short out_of_swpspc
  2269                              <1> 	;
  2270 00004C7D 53                  <1> 	push	ebx
  2271 00004C7E 51                  <1> 	push	ecx
  2272                              <1> 	;
  2273 00004C7F BB00000D00          <1> 	mov	ebx, swap_alloc_table ; Swap Allocation Table offset
  2274 00004C84 89D9                <1> 	mov	ecx, ebx
  2275 00004C86 031D[5A3E0100]      <1> 	add	ebx, [swpd_next] ; Free block searching starts from here
  2276                              <1> 				 ; next_free_swap_block >> 5
  2277 00004C8C 030D[5E3E0100]      <1> 	add	ecx, [swpd_last] ; Free block searching ends here
  2278                              <1> 				 ; (total_swap_blocks - 1) >> 5
  2279                              <1> lswbl_scan:
  2280 00004C92 39CB                <1> 	cmp	ebx, ecx
  2281 00004C94 770A                <1> 	ja	short lswbl_notfound
  2282                              <1> 	;
  2283 00004C96 0FBC03              <1> 	bsf	eax, [ebx] ; Scans source operand for first bit set (1).
  2284                              <1> 			   ; Clears ZF if a bit is found set (1) and 
  2285                              <1> 			   ; loads the destination with an index to
  2286                              <1> 			   ; first set bit. (0 -> 31) 
  2287                              <1> 			   ; Sets ZF to 1 if no bits are found set.
  2288                              <1> 	; 01/07/2015
  2289 00004C99 751C                <1> 	jnz	short lswbl_found ; ZF = 0 -> a free block has been found
  2290                              <1> 			 ;
  2291                              <1> 			 ; NOTE:  a Swap Disk Allocation Table bit 
  2292                              <1> 			 ;	  with value of 1 means 
  2293                              <1> 			 ;	  the corresponding page is free 
  2294                              <1> 			 ;	  (Retro UNIX 386 v1 feaure only!)
  2295 00004C9B 83C304              <1> 	add	ebx, 4
  2296                              <1> 			 ; We return back for searching next page block
  2297                              <1> 			 ; NOTE: [swpd_free] is not ZERO; so, 
  2298                              <1> 			 ;	 we always will find at least 1 free block here.
  2299 00004C9E EBF2                <1> 	jmp    	short lswbl_scan
  2300                              <1> 	;
  2301                              <1> lswbl_notfound:	
  2302 00004CA0 81E900000D00        <1> 	sub	ecx, swap_alloc_table
  2303 00004CA6 890D[5A3E0100]      <1> 	mov	[swpd_next], ecx ; next/first free page = last page 
  2304                              <1> 				 ; (unlink_swap_block procedure will change it)
  2305 00004CAC 31C0                <1> 	xor	eax, eax
  2306 00004CAE A3[563E0100]        <1> 	mov	[swpd_free], eax
  2307 00004CB3 F9                  <1> 	stc
  2308                              <1> lswbl_ok:
  2309 00004CB4 59                  <1> 	pop	ecx
  2310 00004CB5 5B                  <1> 	pop	ebx
  2311 00004CB6 C3                  <1> 	retn
  2312                              <1> 	;
  2313                              <1> ;out_of_swpspc:
  2314                              <1> ;	stc
  2315                              <1> ;	retn
  2316                              <1> 
  2317                              <1> lswbl_found:
  2318 00004CB7 89D9                <1> 	mov	ecx, ebx
  2319 00004CB9 81E900000D00        <1> 	sub	ecx, swap_alloc_table
  2320 00004CBF 890D[5A3E0100]      <1> 	mov	[swpd_next], ecx ; Set first free block searching start
  2321                              <1> 				 ; address/offset (to the next)
  2322 00004CC5 FF0D[563E0100]      <1>         dec     dword [swpd_free] ; 1 block has been allocated (X = X-1) 
  2323                              <1> 	;
  2324 00004CCB 0FB303              <1> 	btr	[ebx], eax	 ; The destination bit indexed by the source value
  2325                              <1> 				 ; is copied into the Carry Flag and then cleared
  2326                              <1> 				 ; in the destination.
  2327                              <1> 				 ;
  2328                              <1> 				 ; Reset the bit which is corresponding to the 
  2329                              <1> 				 ; (just) allocated block.
  2330 00004CCE C1E105              <1> 	shl	ecx, 5		 ; (block offset * 32) + block index
  2331 00004CD1 01C8                <1> 	add	eax, ecx	 ; = block number
  2332 00004CD3 C1E003              <1> 	shl	eax, SECTOR_SHIFT ; 3, sector (offset) address of the block
  2333                              <1> 				 ; 1 block =  8 sectors
  2334                              <1> 	;
  2335                              <1> 	; EAX = offset address of swap disk/file sector (beginning of the block)
  2336                              <1> 	;
  2337                              <1> 	; NOTE: The relevant page table entry will be updated
  2338                              <1> 	;       according to this EAX value...
  2339                              <1> 	;
  2340 00004CD6 EBDC                <1> 	jmp	short lswbl_ok
  2341                              <1> 
  2342                              <1> logical_disk_read:
  2343                              <1> 	; 20/07/2015
  2344                              <1> 	; 09/03/2015 (temporary code here)
  2345                              <1> 	;
  2346                              <1> 	; INPUT ->
  2347                              <1> 	; 	ESI = Logical disk description table address
  2348                              <1> 	; 	EBX = Memory page (buffer) address (physical!)
  2349                              <1> 	; 	EAX = Sector adress (offset address, logical sector number)
  2350                              <1> 	; 	ECX = Sector count
  2351                              <1> 	;
  2352                              <1> 	;
  2353 00004CD8 C3                  <1> 	retn
  2354                              <1> 
  2355                              <1> logical_disk_write:
  2356                              <1> 	; 20/07/2015
  2357                              <1> 	; 09/03/2015 (temporary code here)
  2358                              <1> 	;
  2359                              <1> 	; INPUT ->
  2360                              <1> 	; 	ESI = Logical disk description table address
  2361                              <1> 	; 	EBX = Memory page (buffer) address (physical!)
  2362                              <1> 	; 	EAX = Sector adress (offset address, logical sector number)
  2363                              <1> 	; 	ECX = Sector count
  2364                              <1> 	;
  2365 00004CD9 C3                  <1> 	retn
  2366                              <1> 
  2367                              <1> get_physical_addr:
  2368                              <1> 	; 27/05/2016 - TRDOS 386 (TRDOS v2.0)
  2369                              <1> 	; 18/10/2015
  2370                              <1> 	; 29/07/2015
  2371                              <1> 	; 20/07/2015
  2372                              <1> 	; 04/06/2015
  2373                              <1> 	; 20/05/2015
  2374                              <1> 	; 28/04/2015
  2375                              <1> 	; 18/04/2015
  2376                              <1> 	; Get physical address
  2377                              <1> 	;     (allocates a new page for user if it is not present)
  2378                              <1> 	;	
  2379                              <1> 	; (This subroutine is needed for mapping user's virtual 
  2380                              <1> 	; (buffer) address to physical address (of the buffer).)
  2381                              <1> 	; ('sys write', 'sys read' system calls...)
  2382                              <1> 	;
  2383                              <1> 	; INPUT ->
  2384                              <1> 	;	EBX = virtual address
  2385                              <1> 	;	u.pgdir = page directory (physical) address
  2386                              <1> 	;
  2387                              <1> 	; OUTPUT ->
  2388                              <1> 	;	EAX = physical address 
  2389                              <1> 	;	EBX = linear address	
  2390                              <1> 	;	EDX = physical address of the page frame
  2391                              <1> 	;	      (with attribute bits)
  2392                              <1> 	;	ECX = byte count within the page frame
  2393                              <1> 	;
  2394                              <1> 	; Modified Registers -> EAX, EBX, ECX, EDX
  2395                              <1> 	;
  2396 00004CDA 81C300004000        <1> 	add	ebx, CORE ; 18/10/2015
  2397                              <1> get_physical_addr_x: ; 27/05/2016
  2398 00004CE0 A1[E1300100]        <1> 	mov	eax, [u.pgdir]
  2399 00004CE5 E8F3F9FFFF          <1> 	call	get_pte
  2400                              <1> 		; EDX = Page table entry address (if CF=0)
  2401                              <1> 	        ;       Page directory entry address (if CF=1)
  2402                              <1> 		;       (Bit 0 value is 0 if PT is not present)
  2403                              <1> 		; EAX = Page table entry value (page address)
  2404                              <1> 		;	CF = 1 -> PDE not present or invalid ? 
  2405 00004CEA 731C                <1> 	jnc	short gpa_1
  2406                              <1> 	;
  2407 00004CEC E8D1F8FFFF          <1> 	call	allocate_page
  2408 00004CF1 725B                <1> 	jc	short gpa_im_err  ; 'insufficient memory' error
  2409                              <1> gpa_0:
  2410 00004CF3 E844F9FFFF          <1> 	call 	clear_page
  2411                              <1> 	; EAX = Physical (base) address of the allocated (new) page
  2412 00004CF8 0C07                <1> 	or	al, PDE_A_PRESENT + PDE_A_WRITE + PDE_A_USER ; 4+2+1 = 7
  2413                              <1> 			   ; lower 3 bits are used as U/S, R/W, P flags
  2414                              <1> 			   ; (user, writable, present page)	
  2415 00004CFA 8902                <1> 	mov	[edx], eax ; Let's put the new page directory entry here !
  2416 00004CFC A1[E1300100]        <1> 	mov	eax, [u.pgdir]	
  2417 00004D01 E8D7F9FFFF          <1> 	call	get_pte
  2418 00004D06 7246                <1> 	jc	short gpa_im_err ; 'insufficient memory' error
  2419                              <1> gpa_1:
  2420                              <1> 	; EAX = PTE value, EDX = PTE address
  2421 00004D08 A801                <1> 	test 	al, PTE_A_PRESENT
  2422 00004D0A 751A                <1> 	jnz	short gpa_3
  2423 00004D0C 09C0                <1> 	or	eax, eax
  2424 00004D0E 7430                <1> 	jz	short gpa_4  ; Allocate a new page
  2425                              <1> 	; 20/07/2015
  2426 00004D10 55                  <1> 	push	ebp
  2427 00004D11 89DD                <1> 	mov	ebp, ebx ; virtual (linear) address
  2428                              <1> 	; reload swapped page
  2429 00004D13 E83C000000          <1> 	call	reload_page ; 28/04/2015
  2430 00004D18 5D                  <1> 	pop	ebp
  2431 00004D19 7224                <1> 	jc	short gpa_retn
  2432                              <1> gpa_2:
  2433                              <1> 	; 20/07/2015
  2434                              <1> 	; 20/05/2015
  2435                              <1> 	; add this page to swap queue
  2436 00004D1B 50                  <1> 	push	eax 
  2437                              <1> 	; EBX = virtual address
  2438 00004D1C E8E3FEFFFF          <1> 	call 	add_to_swap_queue
  2439 00004D21 58                  <1> 	pop	eax
  2440                              <1> 		; PTE address in EDX
  2441                              <1> 		; virtual address in EBX
  2442                              <1> 	; EAX = memory page address
  2443 00004D22 0C07                <1> 	or	al, PTE_A_PRESENT + PTE_A_USER + PTE_A_WRITE
  2444                              <1> 				  ; present flag, bit 0 = 1
  2445                              <1> 				  ; user flag, bit 2 = 1	
  2446                              <1> 				  ; writable flag, bit 1 = 1
  2447 00004D24 8902                <1> 	mov	[edx], eax  ; Update PTE value
  2448                              <1> gpa_3:
  2449                              <1> 	; 18/10/2015
  2450 00004D26 89D9                <1> 	mov	ecx, ebx
  2451 00004D28 81E1FF0F0000        <1> 	and	ecx, PAGE_OFF
  2452 00004D2E 89C2                <1> 	mov 	edx, eax
  2453 00004D30 662500F0            <1> 	and	ax, PTE_A_CLEAR
  2454 00004D34 01C8                <1> 	add	eax, ecx
  2455 00004D36 F7D9                <1> 	neg	ecx ; 1 -> -1 (0FFFFFFFFh), 4095 (0FFFh) -> -4095
  2456 00004D38 81C100100000        <1> 	add	ecx, PAGE_SIZE
  2457 00004D3E F8                  <1> 	clc
  2458                              <1> gpa_retn:
  2459 00004D3F C3                  <1> 	retn	
  2460                              <1> gpa_4:	
  2461 00004D40 E87DF8FFFF          <1> 	call	allocate_page
  2462 00004D45 7207                <1> 	jc	short gpa_im_err ; 'insufficient memory' error
  2463 00004D47 E8F0F8FFFF          <1> 	call	clear_page
  2464 00004D4C EBCD                <1> 	jmp	short gpa_2
  2465                              <1> 
  2466                              <1> gpa_im_err:	
  2467 00004D4E B801000000          <1> 	mov	eax, ERR_MINOR_IM ; Insufficient memory (minor) error!
  2468                              <1> 				  ; Major error = 0 (No protection fault)	
  2469 00004D53 C3                  <1> 	retn
  2470                              <1> 
  2471                              <1> reload_page:
  2472                              <1> 	; 20/07/2015
  2473                              <1> 	; 28/04/2015 (Retro UNIX 386 v1 - beginning)
  2474                              <1> 	;
  2475                              <1> 	; Reload (Restore) swapped page at memory
  2476                              <1> 	;
  2477                              <1> 	; INPUT -> 
  2478                              <1> 	;	EBP = Virtual (linear) memory address
  2479                              <1> 	;	EAX = PTE value (swap disk sector address)
  2480                              <1> 	;	(Swap disk sector address = bit 1 to bit 31 of EAX)	
  2481                              <1> 	; OUTPUT ->
  2482                              <1> 	;	EAX = PHYSICAL (real/flat) ADDRESS OF RELOADED PAGE
  2483                              <1> 	;
  2484                              <1> 	;	CF = 1 and EAX = error code
  2485                              <1> 	;
  2486                              <1> 	; Modified Registers -> none (except EAX)
  2487                              <1> 	;
  2488 00004D54 D1E8                <1> 	shr	eax, 1   ; Convert PTE value to swap disk address 
  2489 00004D56 53                  <1> 	push	ebx      ;
  2490 00004D57 89C3                <1> 	mov	ebx, eax ; Swap disk (offset) address	
  2491 00004D59 E864F8FFFF          <1> 	call	allocate_page
  2492 00004D5E 720C                <1> 	jc	short rlp_im_err
  2493 00004D60 93                  <1> 	xchg 	eax, ebx	
  2494                              <1> 	; EBX = Physical memory (page) address
  2495                              <1> 	; EAX = Swap disk (offset) address
  2496                              <1> 	; EBP = Virtual (linear) memory address
  2497 00004D61 E89BFCFFFF          <1> 	call	swap_in
  2498 00004D66 720B                <1> 	jc	short rlp_swp_err  ; (swap disk/file read error)
  2499 00004D68 89D8                <1> 	mov	eax, ebx	
  2500                              <1> rlp_retn:
  2501 00004D6A 5B                  <1> 	pop	ebx
  2502 00004D6B C3                  <1> 	retn
  2503                              <1> 	
  2504                              <1> rlp_im_err:	
  2505 00004D6C B801000000          <1> 	mov	eax, ERR_MINOR_IM ; Insufficient memory (minor) error!
  2506                              <1> 				  ; Major error = 0 (No protection fault)	
  2507 00004D71 EBF7                <1> 	jmp	short rlp_retn
  2508                              <1> 
  2509                              <1> rlp_swp_err:
  2510 00004D73 B804000000          <1> 	mov 	eax, SWP_DISK_READ_ERR ; Swap disk read error !
  2511 00004D78 EBF0                <1> 	jmp	short rlp_retn
  2512                              <1> 
  2513                              <1> 
  2514                              <1> copy_page_dir:
  2515                              <1> 	; 19/09/2015
  2516                              <1> 	; temporary - 07/09/2015
  2517                              <1> 	; 07/09/2015 (Retro UNIX 386 v1 - beginning)
  2518                              <1> 	;
  2519                              <1> 	; INPUT -> 
  2520                              <1> 	;	[u.pgdir] = PHYSICAL (real/flat) ADDRESS of the parent's
  2521                              <1> 	;		    page directory.
  2522                              <1> 	; OUTPUT ->
  2523                              <1> 	;	EAX =  PHYSICAL (real/flat) ADDRESS of the child's
  2524                              <1> 	;	       page directory.
  2525                              <1> 	;	(New page directory with new page table entries.)
  2526                              <1> 	;	(New page tables with read only copies of the parent's
  2527                              <1> 	;	pages.)
  2528                              <1> 	;	EAX = 0 -> Error (CF = 1)
  2529                              <1> 	;
  2530                              <1> 	; Modified Registers -> none (except EAX)
  2531                              <1> 	;
  2532 00004D7A E843F8FFFF          <1> 	call	allocate_page
  2533 00004D7F 723E                <1> 	jc	short cpd_err
  2534                              <1> 	;
  2535 00004D81 55                  <1> 	push	ebp ; 20/07/2015
  2536 00004D82 56                  <1> 	push	esi
  2537 00004D83 57                  <1> 	push	edi
  2538 00004D84 53                  <1> 	push	ebx
  2539 00004D85 51                  <1> 	push	ecx
  2540 00004D86 8B35[E1300100]      <1> 	mov	esi, [u.pgdir]
  2541 00004D8C 89C7                <1> 	mov	edi, eax
  2542 00004D8E 50                  <1> 	push	eax ; save child's page directory address
  2543                              <1> 	; copy PDE 0 from the parent's page dir to the child's page dir
  2544                              <1> 	; (use same system space for all user page tables) 
  2545 00004D8F A5                  <1> 	movsd
  2546 00004D90 BD00004000          <1> 	mov	ebp, 1024*4096 ; pass the 1st 4MB (system space)
  2547 00004D95 B9FF030000          <1> 	mov	ecx, (PAGE_SIZE / 4) - 1 ; 1023
  2548                              <1> cpd_0:	
  2549 00004D9A AD                  <1> 	lodsd
  2550                              <1> 	;or	eax, eax
  2551                              <1>         ;jnz     short cpd_1
  2552 00004D9B A801                <1> 	test	al, PDE_A_PRESENT ;  bit 0 =  1
  2553 00004D9D 7508                <1> 	jnz	short cpd_1
  2554                              <1>  	; (virtual address at the end of the page table)	
  2555 00004D9F 81C500004000        <1> 	add	ebp, 1024*4096 ; page size * PTE count
  2556 00004DA5 EB0F                <1> 	jmp	short cpd_2
  2557                              <1> cpd_1:	
  2558 00004DA7 662500F0            <1> 	and	ax, PDE_A_CLEAR ; 0F000h ; clear attribute bits
  2559 00004DAB 89C3                <1> 	mov	ebx, eax
  2560                              <1> 	; EBX = Parent's page table address
  2561 00004DAD E81F000000          <1> 	call	copy_page_table
  2562 00004DB2 720C                <1> 	jc	short cpd_p_err
  2563                              <1> 	; EAX = Child's page table address
  2564 00004DB4 0C07                <1> 	or	al, PDE_A_PRESENT + PDE_A_WRITE + PDE_A_USER
  2565                              <1> 			 ; set bit 0, bit 1 and bit 2 to 1
  2566                              <1> 			 ; (present, writable, user)
  2567                              <1> cpd_2:
  2568 00004DB6 AB                  <1> 	stosd
  2569 00004DB7 E2E1                <1> 	loop	cpd_0
  2570                              <1> 	;
  2571 00004DB9 58                  <1> 	pop	eax  ; restore child's page directory address
  2572                              <1> cpd_3:
  2573 00004DBA 59                  <1> 	pop	ecx
  2574 00004DBB 5B                  <1> 	pop	ebx
  2575 00004DBC 5F                  <1> 	pop	edi
  2576 00004DBD 5E                  <1> 	pop	esi
  2577 00004DBE 5D                  <1> 	pop	ebp
  2578                              <1> cpd_err:
  2579 00004DBF C3                  <1> 	retn
  2580                              <1> cpd_p_err:
  2581                              <1> 	; release the allocated pages missing (recover free space)
  2582 00004DC0 58                  <1> 	pop	eax  ; the new page directory address (physical)
  2583 00004DC1 8B1D[E1300100]      <1> 	mov	ebx, [u.pgdir] ; parent's page directory address 
  2584 00004DC7 E82FF9FFFF          <1> 	call 	deallocate_page_dir
  2585 00004DCC 29C0                <1> 	sub	eax, eax ; 0
  2586 00004DCE F9                  <1> 	stc
  2587 00004DCF EBE9                <1> 	jmp	short cpd_3	
  2588                              <1> 
  2589                              <1> copy_page_table:
  2590                              <1> 	; 19/09/2015
  2591                              <1> 	; temporary - 07/09/2015
  2592                              <1> 	; 07/09/2015 (Retro UNIX 386 v1 - beginning)
  2593                              <1> 	;
  2594                              <1> 	; INPUT -> 
  2595                              <1> 	;	EBX = PHYSICAL (real/flat) ADDRESS of the parent's page table.
  2596                              <1> 	;	EBP = page table entry index (from 'copy_page_dir')
  2597                              <1> 	; OUTPUT ->
  2598                              <1> 	;	EAX = PHYSICAL (real/flat) ADDRESS of the child's page table.
  2599                              <1> 	;	EBP = (recent) page table index (for 'add_to_swap_queue')	
  2600                              <1> 	;	CF = 1 -> error 
  2601                              <1> 	;
  2602                              <1> 	; Modified Registers -> EBP (except EAX)
  2603                              <1> 	;
  2604 00004DD1 E8ECF7FFFF          <1> 	call	allocate_page
  2605 00004DD6 725A                <1> 	jc	short cpt_err
  2606                              <1> 	;
  2607 00004DD8 50                  <1> 	push	eax ; *
  2608                              <1> 	;push 	ebx
  2609 00004DD9 56                  <1> 	push	esi
  2610 00004DDA 57                  <1> 	push	edi
  2611 00004DDB 52                  <1> 	push	edx
  2612 00004DDC 51                  <1> 	push	ecx
  2613                              <1> 	;
  2614 00004DDD 89DE                <1> 	mov	esi, ebx
  2615 00004DDF 89C7                <1> 	mov	edi, eax
  2616 00004DE1 89C2                <1> 	mov	edx, eax
  2617 00004DE3 81C200100000        <1> 	add	edx, PAGE_SIZE 	
  2618                              <1> cpt_0:
  2619 00004DE9 AD                  <1> 	lodsd
  2620 00004DEA A801                <1> 	test	al, PTE_A_PRESENT ;  bit 0 =  1
  2621 00004DEC 750B                <1> 	jnz	short cpt_1
  2622 00004DEE 21C0                <1> 	and	eax, eax
  2623 00004DF0 7430                <1> 	jz	short cpt_2
  2624                              <1> 	; ebp = virtual (linear) address of the memory page
  2625 00004DF2 E85DFFFFFF          <1> 	call	reload_page ; 28/04/2015
  2626 00004DF7 7234                <1> 	jc	short cpt_p_err
  2627                              <1> cpt_1:
  2628 00004DF9 662500F0            <1> 	and	ax, PTE_A_CLEAR ; 0F000h ; clear attribute bits
  2629 00004DFD 89C1                <1> 	mov	ecx, eax
  2630                              <1> 	; Allocate a new page for the child process
  2631 00004DFF E8BEF7FFFF          <1> 	call	allocate_page
  2632 00004E04 7227                <1> 	jc	short cpt_p_err
  2633 00004E06 57                  <1> 	push	edi
  2634 00004E07 56                  <1> 	push	esi
  2635 00004E08 89CE                <1> 	mov	esi, ecx
  2636 00004E0A 89C7                <1> 	mov	edi, eax
  2637 00004E0C B900040000          <1> 	mov	ecx, PAGE_SIZE/4
  2638 00004E11 F3A5                <1> 	rep	movsd	; copy page (4096 bytes)
  2639 00004E13 5E                  <1> 	pop	esi
  2640 00004E14 5F                  <1> 	pop	edi
  2641                              <1> 	; 
  2642 00004E15 53                  <1> 	push	ebx
  2643 00004E16 50                  <1> 	push	eax
  2644 00004E17 89EB                <1> 	mov	ebx, ebp
  2645                              <1> 	; ebx = virtual address of the memory page
  2646 00004E19 E8E6FDFFFF          <1> 	call	add_to_swap_queue
  2647 00004E1E 58                  <1> 	pop	eax
  2648 00004E1F 5B                  <1> 	pop	ebx
  2649                              <1> 	;
  2650                              <1> 	;or	ax, PTE_A_USER+PTE_A_PRESENT 
  2651 00004E20 0C07                <1> 	or	al, PTE_A_USER+PTE_A_WRITE+PTE_A_PRESENT 
  2652                              <1> cpt_2:
  2653 00004E22 AB                  <1> 	stosd  ; EDI points to child's PTE  	 
  2654                              <1> 	;
  2655 00004E23 81C500100000        <1> 	add	ebp, 4096 ; 20/07/2015 (next page)
  2656                              <1> 	;
  2657 00004E29 39D7                <1> 	cmp	edi, edx
  2658 00004E2B 72BC                <1> 	jb	short cpt_0
  2659                              <1> cpt_p_err:
  2660 00004E2D 59                  <1> 	pop	ecx
  2661 00004E2E 5A                  <1> 	pop	edx
  2662 00004E2F 5F                  <1> 	pop	edi
  2663 00004E30 5E                  <1> 	pop	esi
  2664                              <1> 	;pop	ebx
  2665 00004E31 58                  <1> 	pop	eax ; *
  2666                              <1> cpt_err:
  2667 00004E32 C3                  <1> 	retn
  2668                              <1> 
  2669                              <1> 
  2670                              <1> allocate_memory_block:
  2671                              <1> 	; 03/04/2016
  2672                              <1> 	; 02/04/2016
  2673                              <1> 	; 01/04/2016
  2674                              <1> 	; 14/03/2016
  2675                              <1> 	; 13/03/2016
  2676                              <1> 	; 12/03/2016 (TRDOS 386 = TRDOS v2.0)
  2677                              <1> 	; Allocating contiguous memory pages (in the kernel's memory space)
  2678                              <1> 	;
  2679                              <1> 	; INPUT -> 
  2680                              <1> 	;	EAX = Beginning address (physical)
  2681                              <1> 	;	EAX = 0 -> Allocate memory block from the first proper aperture	
  2682                              <1> 	;	ECX = Number of bytes to be allocated
  2683                              <1> 	;
  2684                              <1> 	; OUTPUT ->
  2685                              <1> 	; 	1) cf = 0 -> successful
  2686                              <1> 	;	EAX = Beginning (physical) address of the allocated memory block
  2687                              <1> 	;	ECX = Number of allocated bytes (rounded up to page borders) 
  2688                              <1> 	;	2) cf = 1 -> unsuccessful
  2689                              <1> 	;	 2.1) If EAX > 0 -> 
  2690                              <1> 	;	      (Number of requested pages is more than # of free pages
  2691                              <1> 	;	       but contiguous free pages -the aperture- is not enough!)	   	
  2692                              <1> 	;	      EAX = Beginning address of available aperture
  2693                              <1> 	;		    (one of all aperture with max. aperture size/length)		
  2694                              <1> 	;	      ECX = Size of available aperture (memory block) in bytes
  2695                              <1> 	;	 2.2) If EAX = 0 -> Out of memory error 
  2696                              <1> 	;	            (number of free pages is less than requested number)
  2697                              <1> 	;	      ECX = Total number of free bytes (free pages * 4096) 
  2698                              <1> 	;		    (It is not number of contiguous free bytes)	
  2699                              <1> 	;
  2700                              <1> 	; (Modified Registers -> EAX, ECX)
  2701                              <1> 	;
  2702                              <1> 	; PURPOSE: Loading a file at memory for copying or running etc.
  2703                              <1> 	; If this procedure returns with cf is set, ECX contains maximum
  2704                              <1> 	; available space and EAX contains the beginning address of it.
  2705                              <1> 	; If EAX has zero, ECX contains total number of free bytes.
  2706                              <1> 	; If requested block has been successfully allocated (by rounding up to
  2707                              <1> 	; the last page border), it must be deallocated later by using
  2708                              <1> 	; 'dealloacate_memory_block' procedure.    
  2709                              <1> 
  2710 00004E33 52                  <1> 	push	edx ; *
  2711 00004E34 BAFF0F0000          <1> 	mov	edx, PAGE_SIZE - 1   ; 4095
  2712 00004E39 01D1                <1> 	add	ecx, edx
  2713 00004E3B 01D0                <1> 	add	eax, edx
  2714 00004E3D C1E90C              <1> 	shr	ecx, PAGE_SHIFT	     ; 12
  2715                              <1> 
  2716                              <1> 	; ECX = number of contiguous pages to be allocated
  2717 00004E40 8B15[B01F0100]      <1> 	mov	edx, [free_pages]
  2718 00004E46 39D1                <1> 	cmp	ecx, edx
  2719 00004E48 7775                <1> 	ja	short amb_6
  2720                              <1> 
  2721 00004E4A C1E80C              <1> 	shr	eax, PAGE_SHIFT      ; 12
  2722                              <1> 
  2723 00004E4D 89C2                <1> 	mov	edx, eax 	     ; page number
  2724 00004E4F C1EA03              <1> 	shr	edx, 3		     ; to get offset to M.A.T.
  2725                              <1> 				     ; (1 allocation bit = 1 page)
  2726                              <1> 				     ; (1 allocation bytes = 8 pages)
  2727 00004E52 80E2FC              <1> 	and	dl, 0FCh 	     ; clear lower 2 bits
  2728                              <1> 				     ; (to get 32 bit position)	
  2729 00004E55 53                  <1> 	push	ebx ; **
  2730                              <1> amb_0:
  2731 00004E56 890D[642C0100]      <1> 	mov	[mem_ipg_count], ecx ; initial (reset) value of page count
  2732 00004E5C 890D[682C0100]      <1> 	mov	[mem_pg_count], ecx
  2733 00004E62 31C9                <1> 	xor	ecx, ecx ; 0
  2734 00004E64 890D[6C2C0100]      <1> 	mov	[mem_aperture], ecx ; 0
  2735 00004E6A 890D[702C0100]      <1> 	mov	[mem_max_aperture], ecx ; 0
  2736                              <1> 	
  2737 00004E70 BB00001000          <1> 	mov	ebx, MEM_ALLOC_TBL   ; Memory Allocation Table address.
  2738 00004E75 3B15[B41F0100]      <1> 	cmp	edx, [next_page]     ; Is the beginning page address lower
  2739                              <1> 				     ; than the address in 'next_page' ?
  2740                              <1> 				     ; (the first/next free page of user space)		
  2741 00004E7B 7208                <1> 	jb	short amb_1
  2742 00004E7D 3B15[B81F0100]      <1> 	cmp 	edx, [last_page]     ; is the beginning page address higher
  2743                              <1> 				     ; than the address in 'last_page' ?
  2744                              <1> 				     ; (end of the memory)		
  2745 00004E83 7606                <1> 	jna	short amb_2	     ; no	
  2746                              <1> amb_1:
  2747 00004E85 8B15[B41F0100]      <1> 	mov	edx, [next_page]     ; yes (reset to the first page of user space)
  2748                              <1> amb_2:
  2749 00004E8B 01D3                <1> 	add	ebx, edx
  2750                              <1> 
  2751 00004E8D A3[742C0100]        <1> 	mov	[mem_pg_pos], eax    ; beginning page no (for curr. mem. aperture)
  2752 00004E92 A3[782C0100]        <1>  	mov	[mem_max_pg_pos], eax ; beginning page no for max. mem. aperture
  2753                              <1> 
  2754 00004E97 83E01F              <1> 	and	eax, 1Fh	     ; lower 5 bits only (0 to 31)
  2755                              <1> 				     ; (allocation bit position)	 
  2756 00004E9A 744B                <1> 	jz	short amb_10	     ; 0	
  2757                              <1> amb_3:
  2758 00004E9C 8B13                <1> 	mov	edx, [ebx]
  2759 00004E9E 88C1                <1> 	mov	cl, al ; 1 to 31
  2760 00004EA0 D3EA                <1> 	shr	edx, cl
  2761 00004EA2 89D0                <1> 	mov	eax, edx
  2762                              <1> amb_4:
  2763 00004EA4 D1E8                <1> 	shr	eax, 1 ; (***)
  2764 00004EA6 7321                <1> 	jnc	short amb_7
  2765 00004EA8 FF05[6C2C0100]      <1> 	inc	dword [mem_aperture]
  2766 00004EAE FF0D[682C0100]      <1> 	dec	dword [mem_pg_count]
  2767 00004EB4 747B                <1> 	jz	short amb_15
  2768                              <1> amb_5:
  2769 00004EB6 80F91F              <1> 	cmp	cl, 31
  2770 00004EB9 7317                <1> 	jnb	short amb_8
  2771 00004EBB FEC1                <1> 	inc	cl
  2772 00004EBD EBE5                <1> 	jmp	short amb_4
  2773                              <1> 
  2774                              <1> amb_6:	; out_of_memory
  2775 00004EBF 31C0                <1> 	xor	eax, eax ; 0
  2776 00004EC1 89D1                <1> 	mov	ecx, edx ; free pages
  2777 00004EC3 C1E10C              <1> 	shl	ecx, PAGE_SHIFT
  2778 00004EC6 5A                  <1> 	pop	edx ; *
  2779 00004EC7 F9                  <1> 	stc
  2780 00004EC8 C3                  <1> 	retn
  2781                              <1> amb_7:
  2782 00004EC9 50                  <1> 	push	eax ; (***) allocation bits (in shifted status)
  2783 00004ECA E819010000          <1> 	call	amb_26 ; set maximum memory aperture (free memory block size)
  2784 00004ECF 58                  <1> 	pop	eax ; (***)
  2785 00004ED0 EBE4                <1> 	jmp	short amb_5
  2786                              <1> amb_8:
  2787 00004ED2 28C9                <1> 	sub	cl, cl ; 0
  2788                              <1> amb_9:
  2789 00004ED4 89DA                <1> 	mov	edx, ebx
  2790 00004ED6 81EA00001000        <1> 	sub	edx, MEM_ALLOC_TBL
  2791 00004EDC 3B15[B81F0100]      <1> 	cmp	edx, [last_page]
  2792 00004EE2 7336                <1> 	jnb	short amb_14 ; contiguous pages not enough
  2793 00004EE4 83C304              <1> 	add	ebx, 4
  2794                              <1> amb_10:
  2795 00004EE7 8B03                <1> 	mov	eax, [ebx]
  2796 00004EE9 21C0                <1> 	and 	eax, eax
  2797 00004EEB 7406                <1>         jz      short amb_11 ; there is not a free page bit in this alloc dword
  2798 00004EED 40                  <1> 	inc	eax ; 0FFFFFFFFh -> 0
  2799 00004EEE 740A                <1> 	jz	short amb_12 ; all of bits are set (32 free pages)
  2800 00004EF0 48                  <1> 	dec	eax
  2801 00004EF1 EBB1                <1> 	jmp	short amb_4
  2802                              <1> amb_11:
  2803 00004EF3 E8F0000000          <1> 	call	amb_26 ; set maximum memory aperture (free memory block size)
  2804 00004EF8 EBDA                <1> 	jmp	short amb_9	
  2805                              <1> amb_12:
  2806 00004EFA B120                <1> 	mov	cl, 32
  2807 00004EFC 390D[682C0100]      <1> 	cmp	[mem_pg_count], ecx ; 32
  2808 00004F02 7306                <1> 	jnb	short amb_13
  2809 00004F04 8B0D[682C0100]      <1> 	mov	ecx, [mem_pg_count]
  2810                              <1> amb_13:
  2811 00004F0A 010D[6C2C0100]      <1> 	add	[mem_aperture], ecx
  2812 00004F10 290D[682C0100]      <1> 	sub	[mem_pg_count], ecx
  2813 00004F16 7619                <1> 	jna	short amb_15
  2814 00004F18 EBB8                <1> 	jmp	short amb_8
  2815                              <1> amb_14:
  2816 00004F1A A1[782C0100]        <1> 	mov	eax, [mem_max_pg_pos] ; begin address of max. mem aperture	
  2817 00004F1F 8B0D[702C0100]      <1> 	mov	ecx, [mem_max_aperture] ; max. (largest) memory aperture
  2818 00004F25 C1E00C              <1> 	shl	eax, PAGE_SHIFT	     ; convert to phy. address in bytes
  2819 00004F28 C1E10C              <1> 	shl	ecx, PAGE_SHIFT	     ; convert to byte counts
  2820 00004F2B F9                  <1> 	stc
  2821 00004F2C E9AC000000          <1>         jmp     amb_25
  2822                              <1> 
  2823                              <1> amb_15: ; OK !
  2824 00004F31 A1[742C0100]        <1> 	mov	eax, [mem_pg_pos]    ; Beginning address as page number
  2825 00004F36 8B0D[6C2C0100]      <1> 	mov	ecx, [mem_aperture]  ; Free contiguous page count
  2826                              <1> amb_16:
  2827                              <1> 	; allocate contiguous memory pages (via memory allocation table bits)
  2828 00004F3C 89C2                <1> 	mov	edx, eax
  2829 00004F3E C1EA05              <1> 	shr	edx, 5 ; 32 pages in one allocation dword (32 bits)
  2830 00004F41 BB00001000          <1> 	mov	ebx, MEM_ALLOC_TBL
  2831 00004F46 01D3                <1> 	add	ebx, edx
  2832 00004F48 83E01F              <1> 	and	eax, 1Fh ; 31
  2833                              <1> 	; 03/04/2016
  2834 00004F4B BA20000000          <1> 	mov	edx, 32
  2835 00004F50 28C2                <1> 	sub	dl, al
  2836 00004F52 39CA                <1> 	cmp	edx, ecx
  2837 00004F54 7602                <1> 	jna	short amb_17
  2838 00004F56 89CA                <1> 	mov	edx, ecx
  2839                              <1> amb_17:
  2840 00004F58 29D1                <1> 	sub	ecx, edx
  2841 00004F5A 51                  <1> 	push	ecx ; ***
  2842 00004F5B 89D1                <1> 	mov	ecx, edx
  2843                              <1> amb_18:		
  2844 00004F5D 0FB303              <1> 	btr	[ebx], eax	 ; The destination bit indexed by the source value
  2845                              <1> 				 ; is copied into the Carry Flag and then cleared
  2846                              <1> 				 ; in the destination.
  2847 00004F60 FF0D[B01F0100]      <1> 	dec     dword [free_pages] ; 1 page has been allocated (X = X-1) 
  2848 00004F66 49                  <1> 	dec	ecx
  2849 00004F67 7404                <1> 	jz	short amb_19
  2850 00004F69 FEC0                <1> 	inc	al
  2851 00004F6B EBF0                <1> 	jmp	short amb_18
  2852                              <1> amb_19:	
  2853 00004F6D 59                  <1> 	pop	ecx ; ***
  2854 00004F6E 21C9                <1> 	and	ecx, ecx ; 0 ?
  2855 00004F70 741E                <1> 	jz	short amb_22	
  2856                              <1> 	; 01/04/2016
  2857 00004F72 B020                <1> 	mov	al, 32
  2858                              <1> amb_20:
  2859 00004F74 83C304              <1> 	add	ebx, 4
  2860 00004F77 39C1                <1> 	cmp	ecx, eax ; 32
  2861 00004F79 7305                <1> 	jnb	short amb_21
  2862                              <1> 	; ECX < 32
  2863 00004F7B 28C0                <1> 	sub	al, al ; 0
  2864 00004F7D 50                  <1> 	push	eax ; 0 ***
  2865 00004F7E EBDD                <1> 	jmp	short amb_18
  2866                              <1> amb_21:
  2867 00004F80 2905[B01F0100]      <1> 	sub	[free_pages], eax ; [free_pages] = [free_pages] - 32
  2868 00004F86 C70300000000        <1> 	mov	dword [ebx], 0 ; reset 32 bits
  2869 00004F8C 29C1                <1> 	sub	ecx, eax ; 32
  2870 00004F8E 75E4                <1> 	jnz	short amb_20
  2871                              <1> amb_22:
  2872 00004F90 A1[742C0100]        <1> 	mov	eax, [mem_pg_pos]   ; Beginning address as page number
  2873 00004F95 8B0D[6C2C0100]      <1> 	mov	ecx, [mem_aperture] ; Free contiguous page count
  2874                              <1> 	; [next_page] update
  2875 00004F9B 89C2                <1> 	mov	edx, eax
  2876                              <1> 	; 03/04/2016
  2877 00004F9D C1EA03              <1> 	shr	edx, 3		     ; to get offset to M.A.T.
  2878                              <1> 				     ; (1 allocation bit = 1 page)
  2879                              <1> 				     ; (1 allocation bytes = 8 pages)
  2880 00004FA0 80E2FC              <1> 	and	dl, 0FCh 	     ; clear lower 2 bits
  2881                              <1> 				     ; (to get 32 bit position)	
  2882 00004FA3 3B15[B41F0100]      <1> 	cmp	edx, [next_page] ; first free page pointer offset
  2883 00004FA9 7732                <1> 	ja	short amb_25
  2884 00004FAB BB00001000          <1> 	mov	ebx, MEM_ALLOC_TBL
  2885 00004FB0 833C1300            <1> 	cmp	dword [ebx+edx], 0
  2886 00004FB4 7721                <1> 	ja	short amb_24
  2887 00004FB6 89C2                <1> 	mov	edx, eax
  2888 00004FB8 01CA                <1> 	add	edx, ecx
  2889 00004FBA C1EA03              <1> 	shr	edx, 3
  2890 00004FBD 80E2FC              <1> 	and	dl, 0FCh
  2891                              <1> amb_23:
  2892 00004FC0 833C1300            <1> 	cmp	dword [ebx+edx], 0
  2893 00004FC4 7711                <1> 	ja	short amb_24
  2894 00004FC6 83C204              <1> 	add	edx, 4
  2895 00004FC9 3B15[B81F0100]      <1> 	cmp	edx, [last_page]    ; last page pointer offset
  2896 00004FCF 76EF                <1> 	jna	short amb_23
  2897 00004FD1 8B15[BC1F0100]      <1> 	mov	edx, [first_page]   ; (for) beginning of user's space
  2898                              <1> amb_24:
  2899 00004FD7 8915[B41F0100]      <1> 	mov	[next_page], edx
  2900                              <1> amb_25:
  2901 00004FDD 9C                  <1> 	pushf
  2902 00004FDE C1E00C              <1> 	shl	eax, PAGE_SHIFT	     ; convert to phy. address in bytes
  2903 00004FE1 C1E10C              <1> 	shl	ecx, PAGE_SHIFT	     ; convert to byte counts
  2904 00004FE4 9D                  <1> 	popf
  2905 00004FE5 5B                  <1> 	pop	ebx ; **
  2906 00004FE6 5A                  <1> 	pop	edx ; *
  2907 00004FE7 C3                  <1> 	retn
  2908                              <1> 
  2909                              <1> amb_26:	; set maximum free memory aperture (free memory block size) 
  2910 00004FE8 89DA                <1> 	mov	edx, ebx ; current address
  2911 00004FEA 81EA00001000        <1> 	sub	edx, MEM_ALLOC_TBL ; MAT beginning address
  2912                              <1> 	; 02/04/2016 
  2913 00004FF0 C1E203              <1> 	shl	edx, 3 ; MAT byte offset * 8 = page number base
  2914 00004FF3 01CA                <1> 	add	edx, ecx ; current page number (ecx =  0 to 31)
  2915                              <1> 	;
  2916 00004FF5 A1[6C2C0100]        <1> 	mov	eax, [mem_aperture]
  2917 00004FFA 21C0                <1> 	and	eax, eax
  2918 00004FFC 7424                <1>         jz      short amb_27
  2919 00004FFE C705[6C2C0100]0000- <1>         mov     dword [mem_aperture], 0
  2919 00005006 0000                <1>
  2920 00005008 3B05[702C0100]      <1> 	cmp	eax, [mem_max_aperture]
  2921 0000500E 7612                <1> 	jna	short amb_27
  2922 00005010 A3[702C0100]        <1> 	mov	[mem_max_aperture], eax
  2923                              <1> 	;
  2924 00005015 89D0                <1> 	mov	eax, edx
  2925 00005017 2B05[702C0100]      <1> 	sub	eax, [mem_max_aperture] ; the last aperture size in pages
  2926                              <1> 	; EAX = Beginning page number of the max. aperture 
  2927 0000501D A3[782C0100]        <1> 	mov	[mem_max_pg_pos], eax
  2928                              <1> amb_27: 
  2929 00005022 42                  <1> 	inc	edx	
  2930 00005023 8915[742C0100]      <1> 	mov	[mem_pg_pos], edx ; next page
  2931                              <1> 
  2932 00005029 A1[642C0100]        <1> 	mov	eax, [mem_ipg_count] ; initial (reset) value of page count
  2933 0000502E A3[682C0100]        <1> 	mov	[mem_pg_count], eax
  2934                              <1> 
  2935 00005033 C3                  <1> 	retn
  2936                              <1> 
  2937                              <1> deallocate_memory_block:
  2938                              <1> 	; 03/04/2016
  2939                              <1> 	; 14/03/2016 (TRDOS 386 = TRDOS v2.0)
  2940                              <1> 	; Deallocating contiguous memory pages (in the kernel's memory space)
  2941                              <1> 	;
  2942                              <1> 	; INPUT -> 
  2943                              <1> 	;	EAX = Beginning address (physical)
  2944                              <1> 	;	ECX = Number of bytes to be deallocated
  2945                              <1> 	;
  2946                              <1> 	; OUTPUT ->
  2947                              <1> 	;	Mememory Allocation Table bits will be updated
  2948                              <1> 	;	[free_pages] will be changed (increased)
  2949                              <1> 	;
  2950                              <1> 	; (Modified Registers -> EAX, ECX)
  2951                              <1> 	;
  2952                              <1> 	; PURPOSE: Unloading/Freeing a file -or an allocated memory block- 
  2953                              <1> 	; at memory after copying, running, saving, reading, writing etc.
  2954                              <1> 	;
  2955                              <1> 
  2956 00005034 52                  <1> 	push	edx ; *
  2957 00005035 53                  <1> 	push	ebx ; **
  2958                              <1> 
  2959 00005036 C1E80C              <1> 	shr	eax, PAGE_SHIFT	     ; 12
  2960 00005039 C1E90C              <1> 	shr	ecx, PAGE_SHIFT	     ; 12
  2961                              <1> 
  2962                              <1> 	; EAX = Beginning page number
  2963                              <1> 	; ECX = Number of contiguous pages to be deallocated
  2964                              <1> damb_0:
  2965                              <1> 	; deallocate contiguous memory pages (via memory allocation table bits)
  2966 0000503C 89C2                <1> 	mov	edx, eax
  2967 0000503E C1EA03              <1> 	shr	edx, 3		     ; to get offset to M.A.T.
  2968                              <1> 				     ; (1 allocation bit = 1 page)
  2969                              <1> 				     ; (1 allocation bytes = 8 pages)
  2970 00005041 80E2FC              <1> 	and	dl, 0FCh 	     ; clear lower 2 bits
  2971                              <1> 				     ; (to get 32 bit position)	
  2972 00005044 3B15[B41F0100]      <1> 	cmp	edx, [next_page] ; next free page
  2973 0000504A 7306                <1> 	jnb	short damb_1
  2974 0000504C 8915[B41F0100]      <1> 	mov	[next_page], edx
  2975                              <1> damb_1:
  2976 00005052 BB00001000          <1> 	mov	ebx, MEM_ALLOC_TBL
  2977 00005057 01D3                <1> 	add	ebx, edx
  2978 00005059 83E01F              <1> 	and	eax, 1Fh ; 31
  2979                              <1> 
  2980                              <1> 	; 03/04/2016
  2981 0000505C BA20000000          <1> 	mov	edx, 32
  2982 00005061 28C2                <1> 	sub	dl, al
  2983 00005063 39CA                <1> 	cmp	edx, ecx
  2984 00005065 7602                <1> 	jna	short damb_2
  2985 00005067 89CA                <1> 	mov	edx, ecx
  2986                              <1> damb_2:
  2987 00005069 29D1                <1> 	sub	ecx, edx
  2988 0000506B 51                  <1> 	push	ecx ; ***
  2989 0000506C 89D1                <1> 	mov	ecx, edx
  2990                              <1> damb_3:		
  2991 0000506E 0FAB03              <1> 	bts	[ebx], eax	     ; unlink/release/deallocate page
  2992                              <1> 				     ; set relevant bit to 1.
  2993                              <1> 				     ; set CF to the previous bit value	
  2994 00005071 FF05[B01F0100]      <1> 	inc     dword [free_pages]   ; 1 page has been deallocated (X = X+1) 
  2995 00005077 49                  <1> 	dec	ecx
  2996 00005078 7404                <1> 	jz	short damb_4
  2997 0000507A FEC0                <1> 	inc	al
  2998 0000507C EBF0                <1> 	jmp	short damb_3
  2999                              <1> damb_4:	
  3000 0000507E 59                  <1> 	pop	ecx ; ***
  3001 0000507F 21C9                <1> 	and	ecx, ecx ; 0 ?
  3002 00005081 741E                <1> 	jz	short damb_7
  3003                              <1> 	; 03/04/2016
  3004 00005083 B020                <1> 	mov	al, 32
  3005                              <1> damb_5:
  3006 00005085 83C304              <1> 	add	ebx, 4
  3007 00005088 39C1                <1> 	cmp	ecx, eax ; 32
  3008 0000508A 7305                <1> 	jnb	short damb_6
  3009                              <1> 	; ECX < 32
  3010 0000508C 28C0                <1> 	sub	al, al ; 0
  3011 0000508E 50                  <1> 	push	eax ; 0 ***
  3012 0000508F EBDD                <1> 	jmp	short damb_3
  3013                              <1> damb_6:
  3014 00005091 0105[B01F0100]      <1> 	add	[free_pages], eax ; [free_pages] = [free_pages] + 32
  3015 00005097 C703FFFFFFFF        <1> 	mov	dword [ebx], 0FFFFFFFFh ; set 32 bits
  3016 0000509D 29C1                <1> 	sub	ecx, eax ; 32
  3017 0000509F 75E4                <1> 	jnz	short damb_5
  3018                              <1> damb_7:
  3019 000050A1 5B                  <1> 	pop	ebx ; **
  3020 000050A2 5A                  <1> 	pop	edx ; *
  3021 000050A3 C3                  <1> 	retn
  3022                              <1> 
  3023                              <1> direct_memory_access:
  3024                              <1> 	; 16/07/2016
  3025                              <1> 	; 12/07/2016 (TRDOS 386 = TRDOS v2.0)
  3026                              <1> 	; This processure will be called to map
  3027                              <1> 	; user's (ring 3) page tables to access phsical
  3028                              <1> 	; (flat/linear) memory addresses, directy (without
  3029                              <1> 	;  kernel's data transfer functions).
  3030                              <1> 	; 
  3031                              <1> 	; Purpose: Video memory access and shared memory access.
  3032                              <1> 	;
  3033                              <1> 	; INPUT -> 
  3034                              <1> 	;	EAX = Beginning address (physical).
  3035                              <1> 	;	ECX = Number of contiguous pages to be mapped.
  3036                              <1> 	; OUTPUT ->
  3037                              <1> 	;	User's page directory and pages tables
  3038                              <1> 	;	will be updated.
  3039                              <1> 	;	
  3040                              <1> 	;	If an old page table entry has valid page address, 
  3041                              <1> 	;	that page will be deallocated just before PTE will
  3042                              <1> 	;	be changed for direct (1 to 1) memory page access.
  3043                              <1> 	;
  3044                              <1> 	;	If old PTE value points to a swapped page,
  3045                              <1>         ;       that page (block) will be unlinked on swap disk. 
  3046                              <1> 	;
  3047                              <1> 	;	Newly allocated pages (except page tables) will not
  3048                              <1> 	;	be applied to Memory Allocation Table.
  3049                              <1> 	;	AVL bit 1 (PTE bit 10) of page table entry will be
  3050                              <1> 	;	used to indicate shared (direct) memory page; then,
  3051                              <1> 	;	this page will not be deallocated later during
  3052                              <1> 	;	process termination. (Memory Allocation Table and
  3053                              <1> 	;	free memory count will not be affected.
  3054                              <1> 	;	(Except deallocating page table's itself.)
  3055                              <1> 	;	
  3056                              <1> 	;      CF = 1 -> error (EAX = error code)
  3057                              <1> 	;      CF = 0 -> success (EAX = beginning address)
  3058                              <1> 	;
  3059                              <1> 	;; (Modified Registers -> none)
  3060                              <1> 	; Modified registers: ebp, edx, ecx, ebx, esi, edi	
  3061                              <1> 	;
  3062                              <1> 
  3063                              <1> 	;push	ebp
  3064                              <1> 	;push	ebx
  3065                              <1> 	;push	ecx
  3066                              <1> 	;push	edx
  3067 000050A4 662500F0            <1> 	and	ax, PTE_A_CLEAR ; clear page offset
  3068 000050A8 50                  <1> 	push	eax
  3069 000050A9 89C5                <1> 	mov	ebp, eax
  3070                              <1> dmem_acc_0: 
  3071 000050AB 89C3                <1> 	mov	ebx, eax
  3072 000050AD 81C300004000        <1> 	add	ebx, CORE
  3073 000050B3 A1[E1300100]        <1> 	mov	eax, [u.pgdir] ; page dir address (physical)
  3074 000050B8 E820F6FFFF          <1> 	call	get_pte
  3075                              <1> 		; EDX = Page table entry address (if CF=0)
  3076                              <1> 	        ;       Page directory entry address (if CF=1)
  3077                              <1> 		;       (Bit 0 value is 0 if PT is not present)
  3078                              <1> 		; EAX = Page table entry value (page address)
  3079                              <1> 		;	CF = 1 -> PDE not present or invalid ? 	
  3080 000050BD 7324                <1> 	jnc	short dmem_acc_1
  3081                              <1> 	;
  3082 000050BF E8FEF4FFFF          <1> 	call	allocate_page
  3083 000050C4 0F82A1000000        <1>         jc      dmem_acc_7  ; 'insufficient memory' error
  3084                              <1> 	;
  3085 000050CA E86DF5FFFF          <1> 	call 	clear_page
  3086                              <1> 	; EAX = Physical (base) address of the allocated (new) page
  3087 000050CF 0C07                <1> 	or	al, PDE_A_PRESENT + PDE_A_WRITE + PDE_A_USER ; 4+2+1 = 7
  3088                              <1> 			   ; lower 3 bits are used as U/S, R/W, P flags
  3089                              <1> 			   ; (user, writable, present page)	
  3090 000050D1 8902                <1> 	mov	[edx], eax ; Let's put the new page directory entry here !
  3091 000050D3 A1[E1300100]        <1> 	mov	eax, [u.pgdir]	
  3092 000050D8 E800F6FFFF          <1> 	call	get_pte
  3093 000050DD 0F8288000000        <1>         jc      dmem_acc_7 ; 'insufficient memory' error
  3094                              <1> dmem_acc_1:
  3095                              <1> 	; EAX = PTE value, EDX = PTE address
  3096 000050E3 A801                <1> 	test 	al, PTE_A_PRESENT
  3097 000050E5 750D                <1> 	jnz	short dmem_acc_2
  3098 000050E7 09C0                <1> 	or	eax, eax
  3099 000050E9 7468                <1> 	jz	short dmem_acc_6   ; Change PTE
  3100 000050EB D1E8                <1> 	shr	eax, 1		; swap disk block (8 sectors) address
  3101                              <1> 	; unlink swap disk block
  3102 000050ED E858FBFFFF          <1> 	call	unlink_swap_block
  3103 000050F2 EB5F                <1> 	jmp	short dmem_acc_6
  3104                              <1> 
  3105                              <1> dmem_acc_2:
  3106 000050F4 A802                <1> 	test	al, PTE_A_WRITE   ; bit 1, writable (r/w) flag
  3107                              <1> 				  ; (must be 1)
  3108 000050F6 7550                <1> 	jnz	short dmem_acc_4
  3109                              <1> 	; Read only -duplicated- page (belongs to a parent or a child)
  3110 000050F8 66A90002            <1>         test    ax, PTE_DUPLICATED ; Was this page duplicated 
  3111                              <1> 				   ; as child's page ?
  3112 000050FC 7455                <1> 	jz	short dmem_acc_5 ; Change PTE but don't deallocate the page!
  3113                              <1> 
  3114                              <1> 	;push	edi
  3115                              <1> 	;push	esi
  3116                              <1> 
  3117 000050FE 51                  <1> 	push	ecx
  3118                              <1> 	;push	ebx
  3119 000050FF 8B1D[E5300100]      <1> 	mov	ebx, [u.ppgdir] ; parent's page dir address (physical)
  3120                              <1> 	
  3121                              <1> 	; check the parent's PTE value is read only & same page or not.. 
  3122 00005105 89EF                <1> 	mov	edi, ebp
  3123 00005107 C1EF16              <1> 	shr	edi, PAGE_D_SHIFT ; 22
  3124                              <1> 	; EDI = page directory entry index (0-1023)
  3125 0000510A 89EE                <1> 	mov	esi, ebp
  3126 0000510C C1EE0C              <1> 	shr	esi, PAGE_SHIFT ; 12	
  3127 0000510F 81E6FF030000        <1> 	and	esi, PTE_MASK
  3128                              <1> 	; ESI = page table entry index (0-1023)
  3129                              <1> 
  3130 00005115 66C1E702            <1> 	shl	di, 2 ; * 4
  3131 00005119 01FB                <1> 	add	ebx, edi ; PDE offset (for the parent)
  3132 0000511B 8B0F                <1> 	mov	ecx, [edi]
  3133 0000511D F6C101              <1> 	test	cl, PDE_A_PRESENT ; present (valid) or not ?
  3134 00005120 7425                <1> 	jz	short dmem_acc_3	; parent process does not use this page
  3135 00005122 6681E100F0          <1> 	and	cx, PDE_A_CLEAR ; 0F000h ; Clear attribute bits
  3136 00005127 66C1E602            <1> 	shl	si, 2 ; *4 
  3137 0000512B 01CE                <1> 	add	esi, ecx ; PTE offset (for the parent)
  3138 0000512D 8B1E                <1> 	mov	ebx, [esi]
  3139 0000512F F6C301              <1> 	test	bl, PTE_A_PRESENT ; present or not ?
  3140 00005132 7413                <1> 	jz	short dmem_acc_3	; parent process does not use this page
  3141 00005134 662500F0            <1> 	and	ax, PTE_A_CLEAR ; 0F000h ; Clear attribute bits 
  3142 00005138 6681E300F0          <1> 	and	bx, PTE_A_CLEAR ; 0F000h ; Clear attribute bits
  3143 0000513D 39D8                <1> 	cmp	eax, ebx	; parent's and child's pages are same ?
  3144 0000513F 7506                <1> 	jne	short dmem_acc_3	; not same page
  3145                              <1> 				; deallocate the child's page
  3146 00005141 800E02              <1>         or      byte [esi], PTE_A_WRITE ; convert to writable page (parent)
  3147                              <1> 	;pop	ebx
  3148 00005144 59                  <1> 	pop	ecx
  3149 00005145 EB0C                <1> 	jmp	short dmem_acc_5
  3150                              <1> dmem_acc_3:
  3151                              <1> 	;pop	ebx
  3152 00005147 59                  <1> 	pop	ecx
  3153                              <1> dmem_acc_4:	
  3154 00005148 66A90004            <1> 	test	ax, PTE_SHARED ; shared or direct memory access indicator
  3155 0000514C 7505                <1> 	jnz	short dmem_acc_5   ; AVL bit 1 = 1, do not deallocate this page!
  3156                              <1> 	;
  3157                              <1> 	;and	ax, PTE_A_CLEAR ; 0F000h ; clear lower 12 (attribute) bits
  3158 0000514E E84DF6FFFF          <1> 	call	deallocate_page
  3159                              <1> dmem_acc_5:
  3160                              <1> 	;pop	esi
  3161                              <1> 	;pop	edi
  3162                              <1> dmem_acc_6:
  3163 00005153 89E8                <1> 	mov	eax, ebp ; physical page (offset=0) address
  3164                              <1> 	; EAX = memory page address
  3165                              <1> 	; EDX = PTE entry address (physical)
  3166 00005155 660D0704            <1> 	or	ax, PTE_A_PRESENT+PTE_A_USER+PTE_A_WRITE+PTE_SHARED
  3167                              <1> 			; present flag, bit 0 = 1
  3168                              <1> 			; user flag, bit 2 = 1	
  3169                              <1> 			; writable flag, bit 1 = 1
  3170                              <1> 			; direct memory access flag, bit 10 = 1
  3171                              <1> 			; (This page must not be deallocated!)
  3172 00005159 8902                <1> 	mov	[edx], eax  ; Update PTE value
  3173 0000515B 49                  <1> 	dec	ecx ; remain count of contiguous pages
  3174 0000515C 7414                <1> 	jz	short dmem_acc_8
  3175 0000515E 81C500100000        <1> 	add	ebp, PAGE_SIZE ; next virtual (=pysical) page address
  3176 00005164 89E8                <1> 	mov	eax, ebp
  3177 00005166 E940FFFFFF          <1>         jmp     dmem_acc_0
  3178                              <1> dmem_acc_7:  ; ERROR ! 
  3179 0000516B C7042401000000      <1> 	mov	dword [esp], ERR_MINOR_IM 
  3180                              <1> 		; Insufficient memory (minor) error!
  3181                              <1> 		; Major error = 0 (No protection fault)	
  3182                              <1> 	; cf = 1
  3183                              <1> dmem_acc_8:
  3184 00005172 58                  <1> 	pop	eax
  3185                              <1> 	;pop	edx
  3186                              <1> 	;pop	ecx
  3187                              <1> 	;pop	ebx
  3188                              <1> 	;pop	ebp
  3189 00005173 C3                  <1> 	retn
  3190                              <1> 
  3191                              <1> ; /// End Of MEMORY MANAGEMENT FUNCTIONS ///
  3192                              <1> 
  3193                              <1> ;; Data:
  3194                              <1> 
  3195                              <1> ; 09/03/2015
  3196                              <1> ;swpq_count: dw 0 ; count of pages on the swap que
  3197                              <1> ;swp_drv:    dd 0 ; logical drive description table address of the swap drive/disk
  3198                              <1> ;swpd_size:  dd 0 ; size of swap drive/disk (volume) in sectors (512 bytes). 		  				
  3199                              <1> ;swpd_free:  dd 0 ; free page blocks (4096 bytes) on swap disk/drive (logical)
  3200                              <1> ;swpd_next:  dd 0 ; next free page block
  3201                              <1> ;swpd_last:  dd 0 ; last swap page block		 		
  1915                                  %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: 29/05/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> ;
    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 00005174 9C                  <1> 	pushfd
    30 00005175 0E                  <1> 	push 	cs
    31 00005176 E801000000          <1> 	call 	TIME_OF_DAY_1
    32 0000517B 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> ; 29/05/2016
    98                              <1> ; 29/01/2016
    99                              <1> ; 17/01/2016 (TRDOS 386 = TRDOS v2.0)
   100                              <1> 
   101                              <1> ; 29/05/2016
   102                              <1> ; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
   103                              <1> int35h:  ; Date/Time functions
   104                              <1> 
   105                              <1> TIME_OF_DAY_1:
   106 0000517C FB                  <1> 	sti				; INTERRUPTS BACK ON
   107                              <1> 	; 29/05/2016
   108 0000517D 80642408FE          <1> 	and	byte [esp+8], 11111110b	; clear carry bit of eflags register
   109                              <1> 	;
   110 00005182 80FC08              <1> 	cmp	ah, (RTC_TBE-RTC_TB)/4	; CHECK IF COMMAND IN VALID RANGE (0-7)
   111 00005185 F5                  <1> 	cmc				; COMPLEMENT CARRY FOR ERROR EXIT
   112                              <1> 	; (*) jc short TIME_9		; EXIT WITH CARRY = 1 IF NOT VALID
   113 00005186 721C                <1> 	jc	short _TIME_9 ; 29/05/2016
   114                              <1> 
   115 00005188 1E                  <1> 	push	ds
   116 00005189 56                  <1> 	push	esi
   117 0000518A 66BE1000            <1> 	mov	si, KDATA		; kernel data segment
   118 0000518E 8EDE                <1> 	mov	ds, si
   119 00005190 C0E402              <1> 	shl	ah, 2			; convert function to dword offset
   120 00005193 0FB6F4              <1> 	movzx	esi, ah			; PLACE INTO ADDRESSING REGISTER
   121 00005196 FA                  <1> 	cli				; NO INTERRUPTS DURING TIME FUNCTIONS
   122 00005197 FF96[AA510000]      <1> 	call	[esi+RTC_TB]		; VECTOR TO FUNCTION REQUESTED WITH CY=0
   123                              <1> 					; RETURN WITH CARRY FLAG SET FOR RESULT
   124 0000519D FB                  <1> 	sti				; INTERRUPTS BACK ON
   125 0000519E B400                <1> 	mov	ah, 0			; CLEAR (AH) TO ZERO
   126 000051A0 5E                  <1> 	pop	esi			; RECOVER USERS REGISTER
   127 000051A1 1F                  <1> 	pop	ds			; RECOVER USERS SEGMENT SELECTOR
   128                              <1> ;TIME_9:
   129                              <1> 					; RETURN WITH CY= 0 IF NO ERROR
   130                              <1> 	; (*) 29/05/2016
   131                              <1> 	; (*) retf 4 ; skip eflags on stack
   132 000051A2 7305                <1> 	jnc	short _TIME_10
   133                              <1> _TIME_9:
   134                              <1> 	; 29/05/2016 -set carry flag on stack-
   135                              <1> 	; [esp] = EIP
   136                              <1> 	; [esp+4] = CS
   137                              <1> 	; [esp+8] = E-FLAGS
   138 000051A4 804C240801          <1> 	or	byte [esp+8], 1	 ; set carry bit of eflags register
   139                              <1> 	; [esp+12] = ESP (user)
   140                              <1> 	; [esp+16] = SS (User)
   141                              <1> _TIME_10:
   142 000051A9 CF                  <1> 	iretd
   143                              <1> 	
   144                              <1> 	; (*) 29/05/2016 - 'ref 4' intruction causes to stack fault
   145                              <1> 	; (OUTER-PRIVILEGE-LEVEL)
   146                              <1> 	; INTEL 80386 PROGRAMMER'S REFERENCE MANUAL 1986
   147                              <1> 	; // RETF instruction:
   148                              <1> 	;
   149                              <1> 	; IF OperandMode=32 THEN
   150                              <1>  	;    Load CS:EIP from stack;
   151                              <1>  	;    Set CS RPL to CPL;
   152                              <1>  	;    Increment eSP by 8 plus the immediate offset if it exists;
   153                              <1>  	;    Load SS:eSP from stack;
   154                              <1>  	; ELSE (* OperandMode=16 *)
   155                              <1>  	;    Load CS:IP from stack;
   156                              <1>  	;    Set CS RPL to CPL;
   157                              <1>  	;    Increment eSP by 4 plus the immediate offset if it exists;
   158                              <1> 	;    Load SS:eSP from stack;
   159                              <1>  	; FI;
   160                              <1> 	;
   161                              <1> 	; //					
   162                              <1> 					; ROUTINE VECTOR TABLE (AH)=
   163                              <1> RTC_TB:
   164 000051AA [CA510000]          <1> 	dd	RTC_00			; 0 = READ CURRENT CLOCK COUNT
   165 000051AE [DD510000]          <1> 	dd	RTC_10			; 1 = SET CLOCK COUNT
   166 000051B2 [EB510000]          <1> 	dd	RTC_20			; 2 = READ THE REAL TIME CLOCK TIME
   167 000051B6 [1A520000]          <1> 	dd	RTC_30			; 3 = SET REAL TIME CLOCK TIME
   168 000051BA [5C520000]          <1> 	dd	RTC_40			; 4 = READ THE REAL TIME CLOCK DATE
   169 000051BE [89520000]          <1> 	dd	RTC_50			; 5 = SET REAL TIME CLOCK DATE
   170 000051C2 [D6520000]          <1> 	dd	RTC_60			; 6 = SET THE REAL TIME CLOCK ALARM
   171 000051C6 [29530000]          <1> 	dd	RTC_70			; 7 = RESET ALARM
   172                              <1> 
   173                              <1> RTC_TBE	equ	$
   174                              <1> 
   175                              <1> RTC_00:				; READ TIME COUNT
   176 000051CA A0[2C200100]        <1> 	mov	al, [TIMER_OFL]		; GET THE OVERFLOW FLAG
   177 000051CF C605[2C200100]00    <1> 	mov	byte [TIMER_OFL], 0	; AND THEN RESET THE OVERFLOW FLAG
   178 000051D6 8B0D[28200100]      <1>         mov     ecx, [TIMER_LH]         ; GET COUNT OF TIME
   179 000051DC C3                  <1> 	retn
   180                              <1> 
   181                              <1> RTC_10:				; SET TIME COUNT
   182 000051DD 890D[28200100]      <1>         mov     [TIMER_LH], ecx         ; SET TIME COUNT
   183 000051E3 C605[2C200100]00    <1> 	mov	byte [TIMER_OFL], 0	; RESET OVERFLOW FLAG
   184 000051EA C3                  <1> 	retn				; RETURN WITH NO CARRY
   185                              <1> 
   186                              <1> RTC_20:				; GET RTC TIME
   187 000051EB E8EB010000          <1> 	call	UPD_IPR			; CHECK FOR UPDATE IN PROCESS
   188 000051F0 7227                <1> 	jc	short RTC_29		; EXIT IF ERROR (CY= 1)
   189                              <1> 
   190 000051F2 B000                <1> 	mov	al, CMOS_SECONDS	; SET ADDRESS OF SECONDS
   191 000051F4 E8FD010000          <1> 	call	CMOS_READ		; GET SECONDS
   192 000051F9 88C6                <1> 	mov	dh, al			; SAVE
   193 000051FB B00B                <1> 	mov	al, CMOS_REG_B		; ADDRESS ALARM REGISTER
   194 000051FD E8F4010000          <1> 	call	CMOS_READ		; READ CURRENT VALUE OF DSE BIT
   195 00005202 2401                <1> 	and	al, 00000001b		; MASK FOR VALID DSE BIT
   196 00005204 88C2                <1> 	mov	dl, al			; SET [DL] TO ZERO FOR NO DSE BIT
   197 00005206 B002                <1> 	mov	al, CMOS_MINUTES	; SET ADDRESS OF MINUTES
   198 00005208 E8E9010000          <1> 	call	CMOS_READ		; GET MINUTES
   199 0000520D 88C1                <1> 	mov	cl, al			; SAVE
   200 0000520F B004                <1>         mov     al, CMOS_HOURS          ; SET ADDRESS OF HOURS
   201 00005211 E8E0010000          <1> 	call	CMOS_READ		; GET HOURS
   202 00005216 88C5                <1> 	mov	ch, al			; SAVE
   203 00005218 F8                  <1> 	clc				; SET CY= 0
   204                              <1> RTC_29:
   205 00005219 C3                  <1> 	retn				; RETURN WITH RESULT IN CARRY FLAG
   206                              <1> 
   207                              <1> RTC_30:				; SET RTC TIME
   208 0000521A E8BC010000          <1> 	call	UPD_IPR			; CHECK FOR UPDATE IN PROCESS
   209 0000521F 7305                <1> 	jnc	short RTC_35		; GO AROUND IF CLOCK OPERATING
   210 00005221 E817010000          <1> 	call	RTC_STA			; ELSE TRY INITIALIZING CLOCK
   211                              <1> RTC_35:
   212 00005226 88F4                <1> 	mov	ah, dh			; GET TIME BYTE - SECONDS
   213 00005228 B000                <1> 	mov	al, CMOS_SECONDS	; ADDRESS SECONDS
   214 0000522A E8E0010000          <1> 	call	CMOS_WRITE		; UPDATE SECONDS
   215 0000522F 88CC                <1> 	mov	ah, cl			; GET TIME BYTE - MINUTES
   216 00005231 B002                <1> 	mov	al, CMOS_MINUTES	; ADDRESS MINUTES
   217 00005233 E8D7010000          <1> 	call	CMOS_WRITE		; UPDATE MINUTES
   218 00005238 88EC                <1> 	mov	ah, ch			; GET TIME BYTE - HOURS
   219 0000523A B004                <1> 	mov	al, CMOS_HOURS		; ADDRESS HOURS
   220 0000523C E8CE010000          <1> 	call	CMOS_WRITE		; UPDATE ADDRESS
   221                              <1> 	;mov	al, CMOS_REG_B		; ADDRESS ALARM REGISTER
   222                              <1> 	;mov	ah, al
   223 00005241 66B80B0B            <1> 	mov	ax, CMOS_REG_B * 257
   224 00005245 E8AC010000          <1> 	call	CMOS_READ		; READ CURRENT TIME
   225 0000524A 2462                <1> 	and	al, 01100010b		; MASK FOR VALID BIT POSITIONS
   226 0000524C 0C02                <1> 	or	al, 00000010b		; TURN ON 24 HOUR MODE
   227 0000524E 80E201              <1> 	and	dl, 00000001b		; USE ONLY THE DSE BIT
   228 00005251 08D0                <1> 	or	al, dl			; GET DAY LIGHT SAVINGS TIME BIT (OSE)
   229 00005253 86E0                <1> 	xchg	ah, al			; PLACE IN WORK REGISTER AND GET ADDRESS
   230 00005255 E8B5010000          <1> 	call	CMOS_WRITE		; SET NEW ALARM SITS
   231 0000525A F8                  <1> 	clc				; SET CY= 0
   232 0000525B C3                  <1> 	retn				; RETURN WITH CY= 0
   233                              <1> 
   234                              <1> RTC_40:				; GET RTC DATE
   235 0000525C E87A010000          <1> 	call	UPD_IPR			; CHECK FOR UPDATE IN PROCESS
   236 00005261 7225                <1> 	jc	short RTC_49		; EXIT IF ERROR (CY= 1)
   237                              <1> 
   238 00005263 B007                <1> 	mov	al, CMOS_DAY_MONTH	; ADDRESS DAY OF MONTH
   239 00005265 E88C010000          <1> 	call	CMOS_READ		; READ DAY OF MONTH
   240 0000526A 88C2                <1> 	mov	dl, al			; SAVE
   241 0000526C B008                <1> 	mov	al, CMOS_MONTH		; ADDRESS MONTH
   242 0000526E E883010000          <1> 	call	CMOS_READ		; READ MONTH
   243 00005273 88C6                <1> 	mov	dh, al			; SAVE
   244 00005275 B009                <1> 	mov	al, CMOS_YEAR		; ADDRESS YEAR
   245 00005277 E87A010000          <1> 	call	CMOS_READ		; READ YEAR
   246 0000527C 88C1                <1> 	mov	cl, al			; SAVE
   247 0000527E B032                <1> 	mov	al, CMOS_CENTURY	; ADDRESS CENTURY LOCATION
   248 00005280 E871010000          <1> 	call	CMOS_READ		; GET CENTURY BYTE
   249 00005285 88C5                <1> 	mov	ch, al			; SAVE
   250 00005287 F8                  <1> 	clc				; SET CY=0
   251                              <1> RTC_49:
   252 00005288 C3                  <1> 	retn				; RETURN WITH RESULTS IN CARRY FLAG
   253                              <1> 
   254                              <1> RTC_50:				; SET RTC DATE
   255 00005289 E84D010000          <1> 	call	UPD_IPR			; CHECK FOR UPDATE IN PROCESS
   256 0000528E 7305                <1> 	jnc	short RTC_55		; GO AROUND IF NO ERROR
   257 00005290 E8A8000000          <1> 	call	RTC_STA			; ELSE INITIALIZE CLOCK
   258                              <1> RTC_55:
   259 00005295 66B80600            <1> 	mov	ax, CMOS_DAY_WEEK	; ADDRESS OF DAY OF WEEK BYTE
   260 00005299 E871010000          <1> 	call	CMOS_WRITE		; LOAD ZEROS TO DAY OF WEEK
   261 0000529E 88D4                <1> 	mov	ah, dl			; GET DAY OF MONTH BYTE
   262 000052A0 B007                <1> 	mov	al, CMOS_DAY_MONTH	; ADDRESS DAY OF MONTH BYTE
   263 000052A2 E868010000          <1> 	call	CMOS_WRITE		; WRITE OF DAY OF MONTH REGISTER
   264 000052A7 88F4                <1> 	mov	ah, dh			; GET MONTH
   265 000052A9 B008                <1> 	mov	al, CMOS_MONTH		; ADDRESS MONTH BYTE
   266 000052AB E85F010000          <1> 	call	CMOS_WRITE		; WRITE MONTH REGISTER
   267 000052B0 88CC                <1> 	mov	ah, cl			; GET YEAR BYTE
   268 000052B2 B009                <1> 	mov	al, CMOS_YEAR		; ADDRESS YEAR REGISTER
   269 000052B4 E856010000          <1> 	call	CMOS_WRITE		; WRITE YEAR REGISTER
   270 000052B9 88EC                <1> 	mov	ah, ch			; GET CENTURY BYTE
   271 000052BB B032                <1> 	mov	al, CMOS_CENTURY	; ADDRESS CENTURY BYTE
   272 000052BD E84D010000          <1> 	call	CMOS_WRITE		; WRITE CENTURY LOCATION
   273                              <1> 	;mov	al, CMOS_REG_B		; ADDRESS ALARM REGISTER
   274                              <1> 	;mov	ah, al
   275 000052C2 66B80B0B            <1> 	mov	ax, CMOS_REG_B * 257
   276 000052C6 E82B010000          <1> 	call	CMOS_READ		; READ WIRRENT SETTINGS
   277 000052CB 247F                <1> 	and	al, 07Fh		; CLEAR 'SET BIT'
   278 000052CD 86E0                <1> 	xchg	ah, al			; MOVE TO WORK REGISTER
   279 000052CF E83B010000          <1> 	call	CMOS_WRITE		; AND START CLOCK UPDATING
   280 000052D4 F8                  <1> 	clc				; SET CY= 0
   281 000052D5 C3                  <1> 	retn				; RETURN CY=0
   282                              <1> 
   283                              <1> RTC_60:				; SET RTC ALARM
   284 000052D6 B00B                <1> 	mov	al, CMOS_REG_B		; ADDRESS ALARM
   285 000052D8 E819010000          <1> 	call	CMOS_READ		; READ ALARM REGISTER
   286 000052DD A820                <1> 	test	al, 20h			; CHECK FOR ALARM ALREADY ENABLED
   287 000052DF F9                  <1> 	stc				; SET CARRY IN CASE OF ERROR
   288 000052E0 7542                <1> 	jnz	short RTC_69		; ERROR EXIT IF ALARM SET
   289 000052E2 E8F4000000          <1> 	call	UPD_IPR			; CHECK FOR UPDATE IN PROCESS
   290 000052E7 7305                <1> 	jnc	short RTC_65		; SKIP INITIALIZATION IF NO ERROR
   291 000052E9 E84F000000          <1> 	call	RTC_STA			; ELSE INITIALIZE CLOCK
   292                              <1> RTC_65:	
   293 000052EE 88F4                <1> 	mov	ah, dh			; GET SECONDS BYTE
   294 000052F0 B001                <1> 	mov	al, CMOS_SEC_ALARM	; ADDRESS THE SECONDS ALARM REGISTER
   295 000052F2 E818010000          <1> 	call	CMOS_WRITE		; INSERT SECONDS
   296 000052F7 88CC                <1> 	mov	ah, cl			; GET MINUTES PARAMETER
   297 000052F9 B003                <1> 	mov	al, CMOS_MIN_ALARM	; ADDRESS MINUTES ALARM REGISTER
   298 000052FB E80F010000          <1> 	call	CMOS_WRITE		; INSERT MINUTES
   299 00005300 88EC                <1> 	mov	ah, ch			; GET HOURS PARAMETER
   300 00005302 B005                <1> 	mov	al, CMOS_HR_ALARM	; ADDRESS HOUR ALARM REGISTER
   301 00005304 E806010000          <1> 	call	CMOS_WRITE		; INSERT HOURS
   302 00005309 E4A1                <1> 	in	al, INTB01		; READ SECOND INTERRUPT MASK REGISTER
   303 0000530B 24FE                <1> 	and	al, 0FEh		; ENABLE ALARM TIMER BIT (CY= 0)
   304 0000530D E6A1                <1> 	out	INTB01, al		; WRITE UPDATED MASK
   305                              <1> 	;mov	al, CMOS_REG_B		; ADDRESS ALARM REGISTER
   306                              <1> 	;mov	ah, al
   307 0000530F 66B80B0B            <1> 	mov	ax, CMOS_REG_B * 257
   308 00005313 E8DE000000          <1> 	call	CMOS_READ		; READ CURRENT ALARM REGISTER
   309 00005318 247F                <1> 	and	al, 07Fh		; ENSURE SET BIT TURNED OFF
   310 0000531A 0C20                <1> 	or	al, 20h			; TURN ON ALARM ENABLE
   311 0000531C 86E0                <1> 	xchg	ah, al			; MOVE MASK TO OUTPUT REGISTER
   312 0000531E E8EC000000          <1> 	call	CMOS_WRITE		; WRITE NEW ALARM MASK
   313 00005323 F8                  <1> 	clc				; SET CY= 0
   314                              <1> RTC_69:
   315 00005324 66B80000            <1> 	mov	ax, 0			; CLEAR AX REGISTER
   316 00005328 C3                  <1> 	retn				; RETURN WITH RESULTS IN CARRY FLAC
   317                              <1> 
   318                              <1> RTC_70:				; RESET ALARM
   319                              <1> 	;mov	al, CMOS_REG_B		; ADDRESS ALARM REGISTER
   320                              <1> 	;mov	ah, al
   321 00005329 66B80B0B            <1> 	mov	ax, CMOS_REG_B * 257	; ADDRESS ALARM REGISTER (TO BOTH AH,AL)
   322 0000532D E8C4000000          <1> 	call	CMOS_READ		; READ ALARM REGISTER
   323 00005332 2457                <1> 	and	al, 57h			; TURN OFF ALARM ENABLE
   324 00005334 86E0                <1> 	xchg	ah, al			; SAVE DATA AND RECOVER ADDRESS
   325 00005336 E8D4000000          <1> 	call	CMOS_WRITE		; RESTORE NEW VALUE
   326 0000533B F8                  <1> 	clc				; SET CY= 0
   327 0000533C C3                  <1> 	retn				; RETURN WITH NO CARRY
   328                              <1> 
   329                              <1> RTC_STA:			; INITIALIZE REAL TIME CLOCK
   330                              <1> 	;mov	al, CMOS_REG_A		; ADDRESS REGISTER A AND LOAD DATA MASK		
   331                              <1> 	;mov	ah, 26h
   332 0000533D 66B80A26            <1> 	mov	ax, (26h*100h)+CMOS_REG_A
   333 00005341 E8C9000000          <1> 	call	CMOS_WRITE		; INITIALIZE STATUS REGISTER A
   334                              <1> 	;mov	al, CMOS_REG_B		; SET "SET BIT" FOR CLOCK INITIALIZATION	
   335                              <1> 	;mov	ah, 82h
   336 00005346 66B80B82            <1> 	mov	ax, (82h*100h)+CMOS_REG_B
   337 0000534A E8C0000000          <1> 	call	CMOS_WRITE		; AND 24 HOUR MODE TO REGISTER B
   338 0000534F B00C                <1> 	mov	al, CMOS_REG_C		; ADDRESS REGISTER C
   339 00005351 E8A0000000          <1> 	call	CMOS_READ		; READ REGISTER C TO INITIALIZE
   340 00005356 B00D                <1> 	mov	al, CMOS_REG_D		; ADDRESS REGISTER D
   341 00005358 E899000000          <1> 	call	CMOS_READ		; READ REGISTER D TO INITIALIZE
   342 0000535D C3                  <1> 	retn
   343                              <1> 
   344                              <1> ; 17/01/2016 (TRDOS 386 = TRDOS v2.0)
   345                              <1> 
   346                              <1> ;--- HARDWARE INT  70 H -- ( IRQ LEVEL  8) --------------------------------------
   347                              <1> ; ALARM INTERRUPT HANDLER (RTC)							:
   348                              <1> ;       THIS ROUTINE HANDLES THE PERIODIC AND ALARM INTERRUPTS FROM THE CMOS	:
   349                              <1> ;       TIMER. INPUT FREQUENCY IS 1.024 KHZ OR APPROXIMATELY 1024 INTERRUPTS	:
   350                              <1> ;       EVERY SECOND FOR THE PERIODIC INTERRUPT. FOR THE ALARM FUNCTION,	:
   351                              <1> ;       THE INTERRUPT WILL OCCUR AT THE DESIGNATED TIME.			:
   352                              <1> ;										:
   353                              <1> ;       INTERRUPTS ARE ENABLED WHEN THE EVENT OR ALARM FUNCTION IS ACTIVATED.	:
   354                              <1> ;       FOR THE EVENT INTERRUPT, THE HANDLER WILL DECREMENT THE WAIT COUNTER	:
   355                              <1> ;       AND WHEN IT EXPIRES WILL SET THE DESIGNATED LOCATION TO 80H. FOR	:
   356                              <1> ;       THE ALARM INTERRUPT. THE USER MUST PROVIDE A ROUTINE TO INTERCEPT	:
   357                              <1> ;       THE CORRECT ADDRESS FROM THE VECTOR TABLE INVOKED BY INTERRUPT 4AH	:
   358                              <1> ;       PRIOR TO SETTING THE REAL TIME CLOCK ALARM (INT 1AH, AH= 06H).		:
   359                              <1> ;--------------------------------------------------------------------------------
   360                              <1> 
   361                              <1> RTC_INT:			; ALARM INTERRUPT
   362 0000535E 1E                  <1> 	push	ds			; LEAVE INTERRUPTS DISABLED
   363 0000535F 50                  <1> 	push	eax			; SAVE REGISTERS
   364 00005360 57                  <1> 	push	edi
   365                              <1> RTC_I_1:				; CHECK FOR SECOND INTERRUPT
   366 00005361 66B88C8B            <1> 	mov	ax, 256*(CMOS_REG_B+NMI)+CMOS_REG_C+NMI ; ALARM AND STATUS
   367 00005365 E670                <1> 	out	CMOS_PORT, al		; WRITE ALARM FLAG MASK ADDRESS
   368 00005367 90                  <1> 	nop				; I/O DELAY
   369 00005368 EB00                <1> 	jmp	short $+2
   370 0000536A E471                <1> 	in	al, CMOS_DATA		; READ AND RESET INTERRUPT REQUEST FLAGS
   371 0000536C A860                <1> 	test	al, 01100000b		; CHECK FOR EITHER INTERRUPT PENDING
   372 0000536E 745D                <1> 	jz	short	RTC_I_9		; EXIT IF NOT A VALID RTC INTERRUPT
   373                              <1> 
   374 00005370 86E0                <1> 	xchg	ah, al			; SAVE FLAGS AND GET ENABLE ADDRESS
   375 00005372 E670                <1> 	out	CMOS_PORT, al		; WRITE ALARM ENABLE MASK ADDRESS
   376 00005374 90                  <1> 	nop				; I/O DELAY
   377 00005375 EB00                <1> 	jmp	short $+2	
   378 00005377 E471                <1> 	in	al, CMOS_DATA		; READ CURRENT ALARM ENABLE MASK
   379 00005379 20E0                <1> 	and	al, ah			; ALLOW ONLY SOURCES THAT ARE ENABLED
   380 0000537B A840                <1> 	test	al, 01000000b		; CHECK FOR PERIODIC INTERRUPT
   381 0000537D 743B                <1> 	jz	short RTC_I_5		; SKIP IF NOT A PERIODIC INTERRUPT
   382                              <1> 
   383                              <1> ;-----	DECREMENT WAIT COUNT BY INTERRUPT INTERVAL
   384                              <1> 
   385 0000537F 66BF1000            <1> 	mov	di, KDATA		; kernel data segment
   386 00005383 8EDF                <1> 	mov	ds, di
   387                              <1> 	
   388 00005385 812D[20200100]D003- <1> 	sub	dword [RTC_LH], 976	; DECREMENT COUNT BY 1/1024
   388 0000538D 0000                <1>
   389 0000538F 7329                <1> 	jnc	short RTC_I_5		; SKIP TILL 32 BIT WORD LESS THAN ZERO
   390                              <1> 
   391                              <1> ;-----	TURN OFF PERIODIC INTERRUPT ENABLE
   392                              <1> 
   393 00005391 6650                <1> 	push	ax			; SAVE INTERRUPT FLAG MASK
   394 00005393 66B88B8B            <1> 	mov	ax, 257*(CMOS_REG_B+NMI) ; INTERRUPT ENABLE REGISTER
   395 00005397 E670                <1> 	out	CMOS_PORT, al		; WRITE ADDRESS TO CMOS CLOCK
   396 00005399 90                  <1> 	nop				; I/O DELAY
   397 0000539A EB00                <1> 	jmp	short $+2
   398 0000539C E471                <1> 	in	al, CMOS_DATA		; READ CURRENT ENABLES
   399 0000539E 24BF                <1> 	and	al, 0BFh		; TURN OFF PIE
   400 000053A0 86C4                <1> 	xchg	al, ah			; GET CMOS ADDRESS AND SAVE VALUE
   401 000053A2 E670                <1> 	out	CMOS_PORT, al		; ADDRESS REGISTER B
   402 000053A4 86C4                <1> 	xchg	al, ah			; GET NEW INTERRUPT ENABLE MASK
   403 000053A6 E671                <1> 	out	CMOS_DATA, al		; SET MASK IN INTERRUPT ENABLE REGISTER
   404 000053A8 C605[24200100]00    <1> 	mov	byte [RTC_WAIT_FLAG], 0	; SET FUNCTION ACTIVE FLAG OFF
   405 000053AF 8B3D[25200100]      <1> 	mov	edi, [USER_FLAG]	; SET UP (DS:DI) TO POINT TO USER FLAG
   406 000053B5 C60780              <1> 	mov	byte [edi], 80h		; TURN ON USERS FLAG
   407 000053B8 6658                <1> 	pop	ax			; GET INTERRUPT SOURCE BACK
   408                              <1> RTC_I_5:
   409 000053BA A820                <1> 	test	al, 00100000b		; TEST FOR ALARM INTERRUPT
   410 000053BC 740D                <1> 	jz	short RTC_I_7		; SKIP USER INTERRUPT CALL IF NOT ALARM
   411                              <1> 
   412 000053BE B00D                <1> 	mov	al, CMOS_REG_D		; POINT TO DEFAULT READ ONLY REGISTER
   413 000053C0 E670                <1> 	out	CMOS_PORT, al		; ENABLE NMI AND CMOS ADDRESS TO DEFAULT
   414 000053C2 FB                  <1> 	sti				; INTERRUPTS BACK ON NOW
   415 000053C3 52                  <1> 	push	edx
   416 000053C4 E8F4870000          <1> 	call	INT4Ah			; TRANSFER TO USER ROUTINE
   417 000053C9 5A                  <1> 	pop	edx
   418 000053CA FA                  <1> 	cli				; BLOCK INTERRUPT FOR RETRY
   419                              <1> RTC_I_7:				; RESTART ROUTINE TO HANDLE DELAYED
   420 000053CB EB94                <1> 	jmp	short RTC_I_1		;  ENTRY AND SECOND EVENT BEFORE DONE
   421                              <1> 
   422                              <1> RTC_I_9:				; EXIT - NO PENDING INTERRUPTS
   423 000053CD B00D                <1> 	mov	al, CMOS_REG_D		; POINT TO DEFAULT READ ONLY REGISTER
   424 000053CF E670                <1> 	out	CMOS_PORT, al		; ENABLE NMI AND CMOS ADDRESS TO DEFAULT
   425 000053D1 B020                <1> 	mov	al, EOI			; END OF INTERRUPT MASK TO 8259 - 2
   426 000053D3 E6A0                <1> 	out	INTB00, al		; TO 8259 - 2
   427 000053D5 E620                <1> 	out	INTA00,	al		; TO 8259 - 1
   428 000053D7 5F                  <1> 	pop	edi			; RESTORE REGISTERS
   429 000053D8 58                  <1> 	pop	eax
   430 000053D9 1F                  <1> 	pop	ds
   431 000053DA CF                  <1> 	iret				; END OF INTERRUPT
   432                              <1> 
   433                              <1> 	
   434                              <1> 	; 29/05/2016 - TRDOS 386 (TRDOS v2.0)
   435                              <1> 	; 22/08/2014 (Retro UNIX 386 v1)
   436                              <1> 	; IBM PC/AT BIOS source code ----- 10/06/85 (bios2.asm)
   437                              <1> UPD_IPR:				; WAIT TILL UPDATE NOT IN PROGRESS
   438 000053DB 51                  <1> 	push	ecx
   439                              <1> 
   440                              <1> 	; 29/05/2016
   441 000053DC B968110000          <1> 	mov	ecx, ((1984+244)*4)/2	; AWARD BIOS 1999, ATIME.ASM		
   442                              <1> 					; 'WAITCPU_CK_UD_STAT'
   443                              <1> 					; (244Us + 1984Us)
   444                              <1> 					; (assume each read takes
   445                              <1> 					;  2 microseconds).
   446                              <1> 	;mov	ecx, 65535		
   447                              <1> 		;mov cx, 800		; SET TIMEOUT LOOP COUNT (= 800)	
   448                              <1> UPD_10:
   449 000053E1 B00A                <1> 	mov	al, CMOS_REG_A		; ADDRESS STATUS REGISTER A
   450 000053E3 FA                  <1> 	cli				; NO TIMER INTERRUPTS DURING UPDATES
   451 000053E4 E80D000000          <1> 	call	CMOS_READ		; READ UPDATE IN PROCESS FLAG
   452 000053E9 A880                <1> 	test	al, 80h			; IF UIP BIT IS ON ( CANNOT READ TIME )
   453 000053EB 7406                <1> 	jz	short UPD_90		; EXIT WITH CY= 0 IF CAN READ CLOCK NOW
   454 000053ED FB                  <1> 	sti				; ALLOW INTERRUPTS WHILE WAITING
   455 000053EE E2F1                <1> 	loop	UPD_10			; LOOP TILL READY OR TIMEOUT
   456 000053F0 31C0                <1> 	xor	eax, eax		; CLEAR RESULTS IF ERROR
   457                              <1> 		; xor ax, ax
   458 000053F2 F9                  <1> 	stc				; SET CARRY FOR ERROR
   459                              <1> UPD_90:
   460 000053F3 59                  <1> 	pop	ecx			; RESTORE CALLERS REGISTER
   461 000053F4 FA                  <1> 	cli				; INTERRUPTS OFF DURING SET
   462 000053F5 C3                  <1> 	retn				; RETURN WITH CY FLAG SET
   463                              <1> 
   464                              <1> 
   465                              <1> 	; 29/05/2016 - TRDOS 386 (TRDOS v2.0) 
   466                              <1> 	; 22/08/2014 (Retro UNIX 386 v1)
   467                              <1> 	; IBM PC/AT BIOS source code ----- 10/06/85 (test4.asm)
   468                              <1> 
   469                              <1> ;--- CMOS_READ -----------------------------------------------------------------
   470                              <1> ;		READ BYTE FROM CMOS_SYSTEM CLOCK CONFIGURATION TABLE	       :
   471                              <1> ;									       :
   472                              <1> ; INPUT: (AL)=	CMOS_TABLE ADDRESS TO BE READ				       :
   473                              <1> ;		BIT    7 = 0 FOR NMI ENABLED AND 1 FOR NMI DISABLED ON EXIT    :
   474                              <1> ;		BITS 6-0 = ADDRESS OF TABLE LOCATION TO READ		       :
   475                              <1> ;									       :
   476                              <1> ; OUTPUT: (AL)	VALUE AT LOCATION (AL) MOVED INTO (AL). IF BIT 7 OF (AL) WAS   :
   477                              <1> ;		ON THEN NMI LEFT DISABLED, DURING THE CMOS READ BOTH NMI AND   :
   478                              <1> ;		NORMAL INTERRUPTS ARE DISABLED TO PROTECT CMOS DATA INTEGRITY. :
   479                              <1> ;		THE CMOS ADDRESS REGISTER IS POINTED TO A DEFAULT VALUE AND    :
   480                              <1> ;		THE INTERRUPT FLAG RESTORED TO THE ENTRY STATE ON RETURN.      :
   481                              <1> ;		ONLY THE (AL) REGISTER AND THE NMI STATE IS CHANGED.	       :
   482                              <1> ;-------------------------------------------------------------------------------
   483                              <1> 
   484                              <1> CMOS_READ:
   485 000053F6 9C                  <1> 	pushf				; SAVE INTERRUPT ENABLE STATUS AND FLAGS
   486 000053F7 D0C0                <1> 	rol	al, 1			; MOVE NMI BIT TO LOW POSITION
   487 000053F9 F9                  <1> 	stc				; FORCE NMI BIT ON IN CARRY FLAG
   488 000053FA D0D8                <1> 	rcr	al, 1			; HIGH BIT ON TO DISABLE NMI - OLD IN CY
   489 000053FC FA                  <1> 	cli				; DISABLE INTERRUPTS
   490 000053FD E670                <1> 	out	CMOS_PORT, al		; ADDRESS LOCATION AND DISABLE NMI
   491                              <1> 	; 29/05/2016
   492                              <1> 	;nop				; I/O DELAY
   493 000053FF E6EB                <1> 	out	0ebh,al	; NEWIODELAY ; AWARD BIOS 1999, ATIME.ASM
   494                              <1> 	;
   495 00005401 E471                <1> 	in	al, CMOS_DATA		; READ THE REQUESTED CMOS LOCATION
   496 00005403 6650                <1> 	push	ax			; SAVE (AH) REGISTER VALUE AND CMOS BYTE
   497                              <1> 	; 15/03/2015 ; IBM PC/XT Model 286 BIOS source code 
   498                              <1> 		     ; ----- 10/06/85 (test4.asm)
   499 00005405 B01E                <1> 	mov	al, CMOS_SHUT_DOWN*2 	; GET ADDRESS OF DEFAULT LOCATION
   500                              <1> 	;mov	al, CMOS_REG_D*2 	; GET ADDRESS OF DEFAULT LOCATION
   501 00005407 D0D8                <1> 	rcr	al, 1			; PUT ORIGINAL NMI MASK BIT INTO ADDRESS
   502 00005409 E670                <1> 	out	CMOS_PORT, al		; SET DEFAULT TO READ ONLY REGISTER
   503 0000540B 6658                <1> 	pop	ax			; RESTORE (AH) AND (AL), CMOS BYTE
   504 0000540D 9D                  <1> 	popf	
   505 0000540E C3                  <1> 	retn				; RETURN WITH FLAGS RESTORED
   506                              <1> 
   507                              <1> ; 17/01/2016 (TRDOS 386 = TRDOS v2.0)
   508                              <1> 
   509                              <1> ;--- CMOS_WRITE ----------------------------------------------------------------
   510                              <1> ;	WRITE BYTE TO CMOS SYSTEM CLOCK CONFIGURATION TABLE		       :
   511                              <1> ;									       :
   512                              <1> ; INPUT: (AL)=	CMOS TABLE ADDRESS TO BE WRITTEN TO			       :
   513                              <1> ;		BIT    7 = 0 FOR NMI ENABLED AND 1 FOR NMI DISABLED ON EXIT    :
   514                              <1> ;		BITS 6-0 = ADDRESS OF TABLE LOCATION TO WRITE		       :
   515                              <1> ;	 (AH)=	NEW VALUE TO BE PLACED IN THE ADDRESSED TABLE LOCATION	       :
   516                              <1> ;									       :
   517                              <1> ; OUTPUT:	VALUE IN (AH) PLACED IN LOCATION (AL) WITH NMI LEFT DISABLED   :
   518                              <1> ;		IF BIT 7 OF (AL) IS ON, DURING THE CMOS UPDATE BOTH NMI AND    :
   519                              <1> ;		NORMAL INTERRUPTS ARE DISABLED TO PROTECT CMOS DATA INTEGRITY. :
   520                              <1> ;		THE CMOS ADDRESS REGISTER IS POINTED TO A DEFAULT VALUE AND    :
   521                              <1> ;		THE INTERRUPT FLAG RESTORED TO THE ENTRY STATE ON RETURN.      :
   522                              <1> ;		ONLY THE CMOS LOCATION AND THE NMI STATE IS CHANGED.	       :
   523                              <1> ;-------------------------------------------------------------------------------
   524                              <1> 
   525                              <1> CMOS_WRITE:				; WRITE (AH) TO LOCATION (AL)
   526 0000540F 9C                  <1> 	pushf				; SAVE INTERRUPT ENABLE STATUS AND FLAGS
   527 00005410 6650                <1> 	push	ax			; SAVE WORK REGISTER VALUES
   528 00005412 D0C0                <1> 	rol	al, 1			; MOVE NMI BIT TO LOW POSITION
   529 00005414 F9                  <1> 	stc				; FORCE NMI BIT ON IN CARRY FLAG
   530 00005415 D0D8                <1> 	rcr	al, 1			; HIGH BIT ON TO DISABLE NMI - OLD IN CY
   531 00005417 FA                  <1> 	cli				; DISABLE INTERRUPTS
   532 00005418 E670                <1> 	out	CMOS_PORT, al		; ADDRESS LOCATION AND DISABLE NMI
   533 0000541A 88E0                <1> 	mov	al, ah			; GET THE DATA BYTE TO WRITE
   534 0000541C E671                <1> 	out	CMOS_DATA, al		; PLACE IN REQUESTED CMOS LOCATION
   535 0000541E B01E                <1> 	mov	al, CMOS_SHUT_DOWN*2	; GET ADDRESS OF DEFAULT LOCATION
   536                              <1> 	;mov	al, CMOS_REG_D*2 	; GET ADDRESS OF DEFAULT LOCATION
   537 00005420 D0D8                <1> 	rcr	al, 1			; PUT ORIGINAL NMI MASK BIT INTO ADDRESS
   538 00005422 E670                <1> 	out	CMOS_PORT, al		; SET DEFAULT TO READ ONLY REGISTER
   539 00005424 90                  <1> 	nop				; I/O DELAY
   540 00005425 E471                <1> 	in	al, CMOS_DATA		; OPEN STANDBY LATCH
   541 00005427 6658                <1> 	pop	ax			; RESTORE WORK REGISTERS
   542 00005429 9D                  <1> 	popf
   543 0000542A C3                  <1> 	retn
   544                              <1> 
   545                              <1> ; /// End Of TIMER FUNCTIONS ///
  1916                                  %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: 20/05/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 '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> ; 20/05/2016
    79                              <1> ; 19/05/2016
    80                              <1> ; 18/05/2016
    81                              <1> ; 29/04/2016 
    82                              <1> ; TRDOS 386 (TRDOS v2.0) system calls - temporary List 
    83                              <1> ; 14/07/2013 - 21/09/2015 (Retro UNIX 8086 & 386 system calls) 
    84                              <1> ; UNIX v1 system calls
    85                              <1> ;_rele	equ 0
    86                              <1> _ver 	equ 0 ; Get TRDOS version (v2.0)
    87                              <1> _exit 	equ 1
    88                              <1> _fork 	equ 2
    89                              <1> _read 	equ 3
    90                              <1> _write	equ 4
    91                              <1> _open	equ 5
    92                              <1> _close 	equ 6
    93                              <1> _wait 	equ 7
    94                              <1> _creat 	equ 8
    95                              <1> _link 	equ 9
    96                              <1> _unlink	equ 10
    97                              <1> _exec	equ 11
    98                              <1> _chdir	equ 12
    99                              <1> _time 	equ 13
   100                              <1> _mkdir 	equ 14
   101                              <1> _chmod	equ 15
   102                              <1> _chown	equ 16
   103                              <1> _break	equ 17
   104                              <1> _stat	equ 18
   105                              <1> _seek	equ 19
   106                              <1> _tell 	equ 20
   107                              <1> _mount	equ 21
   108                              <1> _umount	equ 22
   109                              <1> _setuid	equ 23
   110                              <1> _getuid	equ 24
   111                              <1> _stime	equ 25
   112                              <1> _quit	equ 26	
   113                              <1> _intr	equ 27
   114                              <1> _fstat	equ 28
   115                              <1> _emt 	equ 29
   116                              <1> _mdate 	equ 30
   117                              <1> ;_stty 	equ 31
   118                              <1> _video  equ 31 ; TRDOS 386 Video Functions (16/05/2016)
   119                              <1> ;_gtty	equ 32
   120                              <1> _audio	equ 32 ; TRDOS 386 Video Functions (16/05/2016)
   121                              <1> ;_ilgins equ 33
   122                              <1> _timer	equ 33 ; TRDOS 386 Timer Functions (18/05/2016)
   123                              <1> _sleep	equ 34 ; Retro UNIX 8086 v1 feature only !
   124                              <1> _msg	equ 35 ; Retro UNIX 386 v1 feature only !
   125                              <1> _geterr	equ 36 ; Retro UNIX 386 v1 feature only !
   126                              <1> _reserved1 equ 37 ;; TRDOS 386 (19/05/2016)
   127                              <1> _pri 	equ 38 ; change priority - TRDOS 386 (20/05/2016)
   128                              <1> _rele	equ 39 ; TRDOS 386 (19/05/2016)
   129                              <1> 
   130                              <1> %macro sys 1-4
   131                              <1>     ; 29/04/2016 - TRDOS 386 (TRDOS v2.0)	
   132                              <1>     ; 03/09/2015	
   133                              <1>     ; 13/04/2015
   134                              <1>     ; Retro UNIX 386 v1 system call.		
   135                              <1>     %if %0 >= 2   
   136                              <1>         mov ebx, %2
   137                              <1>         %if %0 >= 3    
   138                              <1>             mov ecx, %3
   139                              <1>             %if %0 = 4
   140                              <1>                mov edx, %4   
   141                              <1>             %endif
   142                              <1>         %endif
   143                              <1>     %endif
   144                              <1>     mov eax, %1
   145                              <1>     ;int 30h
   146                              <1>     int 40h ; TRDOS 386 (TRDOS v2.0)		   
   147                              <1> %endmacro
   148                              <1> 
   149                              <1> ; 13/05/2015 - ERROR CODES
   150                              <1> ERR_FILE_NOT_OPEN  equ 10 ; 'file not open !' error
   151                              <1> ERR_FILE_ACCESS    equ 11 ; 'permission denied !' error
   152                              <1> ; 14/05/2015
   153                              <1> ERR_DIR_ACCESS     equ 11 ; 'permission denied !' error
   154                              <1> ERR_FILE_NOT_FOUND equ 12 ; 'file not found !' error
   155                              <1> ERR_TOO_MANY_FILES equ 13 ; 'too many open files !' error
   156                              <1> ERR_DIR_EXISTS     equ 14 ; 'directory already exists !' error 	
   157                              <1> ; 16/05/2015		
   158                              <1> ERR_DRV_NOT_RDY    equ 15 ; 'drive not ready !' error
   159                              <1> ; 18/05/2015
   160                              <1> ERR_DEV_NOT_RDY    equ 15 ; 'device not ready !' error
   161                              <1> ERR_DEV_ACCESS     equ 11 ; 'permission denied !' error 
   162                              <1> ERR_DEV_NOT_OPEN   equ 10 ; 'device not open !' error	
   163                              <1> ; 07/06/2015
   164                              <1> ERR_FILE_EOF	   equ 16 ; 'end of file !' error
   165                              <1> ERR_DEV_VOL_SIZE   equ 16 ; 'out of volume' error
   166                              <1> ; 09/06/2015
   167                              <1> ERR_DRV_READ	   equ 17 ; 'disk read error !'
   168                              <1> ERR_DRV_WRITE	   equ 18 ; 'disk write error !'
   169                              <1> ; 16/06/2015
   170                              <1> ERR_NOT_DIR	   equ 19 ; 'not a (valid) directory !' error
   171                              <1> ERR_FILE_SIZE	   equ 20 ; 'file size error !'	
   172                              <1> ; 22/06/2015
   173                              <1> ERR_NOT_SUPERUSER  equ 11 ; 'permission denied !' error
   174                              <1> ERR_NOT_OWNER      equ 11 ; 'permission denied !' error
   175                              <1> ERR_NOT_FILE       equ 11 ; 'permission denied !' error	
   176                              <1> ; 23/06/2015
   177                              <1> ERR_FILE_EXISTS    equ 14 ; 'file already exists !' error
   178                              <1> ERR_DRV_NOT_SAME   equ 21 ; 'not same drive !' error
   179                              <1> ERR_DIR_NOT_FOUND  equ 12 ; 'directory not found !' error
   180                              <1> ERR_NOT_EXECUTABLE equ 22 ; 'not executable file !' error
   181                              <1> ; 27/06/2015
   182                              <1> ERR_INV_PARAMETER  equ 23 ; 'invalid parameter !' error
   183                              <1> ERR_INV_DEV_NAME   equ 24 ; 'invalid device name !' error
   184                              <1> ; 29/06/2015
   185                              <1> ERR_TIME_OUT	   equ 25 ; 'time out !' error			
   186                              <1> ERR_DEV_NOT_RESP   equ 25 ; 'device not responding !' error
   187                              <1> ; 18/05/2016
   188                              <1> ERR_MISC	   equ 26 ; miscellaneous/other errors		
   189                              <1> 
   190                              <1> ; 26/08/2015
   191                              <1> ; 24/07/2015
   192                              <1> ; 24/06/2015
   193                              <1> MAX_ARG_LEN	   equ 256 ; max. length of sys exec arguments
   194                              <1> ; 01/07/2015
   195                              <1> MAX_MSG_LEN	   equ 255 ; max. msg length for 'sysmsg'
   196                              <1> ;	 					 		
  1917                                  %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
  1918                                  %include 'trdosk1.s' ; 04/01/2016 
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.0) - SYS INIT : trdosk1.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 13/05/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> 
    16                              <1> sys_init:
    17                              <1> 	; 07/05/2016
    18                              <1> 	; 02/05/2016
    19                              <1> 	; 24/04/2016
    20                              <1> 	; 14/04/2016
    21                              <1> 	; 13/04/2016
    22                              <1> 	; 30/03/2016
    23                              <1> 	; 24/01/2016
    24                              <1> 	; 06/01/2016
    25                              <1> 	; 04/01/2016
    26                              <1> 
    27                              <1> 	; 30/03/2016
    28                              <1> 	; Clear Logical DOS Disk Description Tables Area
    29 0000542B 31C0                <1> 	xor	eax, eax
    30 0000542D BF00010900          <1> 	mov	edi, Logical_DOSDisks
    31 00005432 B980060000          <1> 	mov	ecx, 6656/4 ; 26*256 = 6656 bytes
    32 00005437 F3AB                <1> 	rep	stosd ; 1664 times 4 bytes
    33                              <1> 
    34 00005439 B83F3A2F00          <1> 	mov	eax, '?:/'
    35 0000543E A3[6F200100]        <1> 	mov	[Current_Dir_Drv], eax
    36                              <1> 
    37                              <1> 	; Logical DRV INIT (only for hard disks)
    38 00005443 E8B3010000          <1> 	call 	ldrv_init  ; trdosk2.s
    39                              <1> 	
    40                              <1> 	; When floppy_drv_init call is disabled
    41                              <1> 	; media changed sign is needed
    42                              <1> 	; for proper drive initialization
    43                              <1>         
    44 00005448 BE00010900          <1> 	mov 	esi, Logical_DOSDisks
    45 0000544D B001                <1> 	mov 	al, 1 ; Initialization sign (invalid_fd_parameter)
    46 0000544F 83C67E              <1> 	add 	esi, LD_MediaChanged ; Media Change Status = 1 (init needed)
    47 00005452 8806                <1> 	mov 	[esi], al ; A:
    48 00005454 81C600010000        <1> 	add 	esi, 100h 
    49 0000545A 8806                <1> 	mov 	[esi], al ; B: 
    50                              <1>            
    51                              <1> _current_drive_bootdisk:
    52 0000545C 8A15[F4EC0000]      <1> 	mov 	dl, [boot_drv] ; physical drive number
    53 00005462 80FAFF              <1> 	cmp 	dl, 0FFh
    54 00005465 740A                <1> 	je 	short _last_dos_diskno_check
    55                              <1> _boot_drive_check:
    56 00005467 80FA80              <1> 	cmp 	dl, 80h
    57 0000546A 7218                <1> 	jb 	short _current_drive_a
    58 0000546C 80EA7E              <1> 	sub 	dl, 7Eh ; C = 2 , D = 3
    59 0000546F EB13                <1> 	jmp 	short _current_drive_a 
    60                              <1> 
    61                              <1> _last_dos_diskno_check:
    62 00005471 8A15[E3DD0000]      <1> 	mov 	dl, [Last_DOS_DiskNo]
    63 00005477 80FA02              <1> 	cmp 	dl, 2
    64 0000547A 7706                <1> 	ja 	short _current_drive_c
    65 0000547C 7406                <1> 	je 	short _current_drive_a
    66 0000547E 30D2                <1> 	xor 	dl, dl ; A:
    67 00005480 EB02                <1> 	jmp 	short _current_drive_a
    68                              <1> 
    69                              <1> _current_drive_c:
    70 00005482 B202                <1> 	mov 	dl, 2 ; C:
    71                              <1> 
    72                              <1> _current_drive_a:
    73 00005484 8815[F5EC0000]      <1> 	mov	[drv], dl
    74 0000548A BE[E5DD0000]        <1>         mov     esi, msg_CRLF_temp
    75 0000548F E89E000000          <1> 	call 	print_msg
    76                              <1> 
    77 00005494 8A15[F5EC0000]      <1> 	mov	dl, [drv]
    78 0000549A E893090000          <1> 	call 	change_current_drive
    79 0000549F 730C                <1> 	jnc 	short _start_mainprog
    80                              <1> 
    81                              <1> _drv_not_ready_error: 
    82 000054A1 BE[A9E00000]        <1> 	mov 	esi, msgl_drv_not_ready
    83 000054A6 E887000000          <1> 	call 	print_msg
    84 000054AB EB63                <1>         jmp     _end_of_mainprog
    85                              <1> 
    86                              <1> _start_mainprog:
    87                              <1> 	; 07/05/2016
    88                              <1> 	; 02/05/2016
    89                              <1> 	; 24/04/2016
    90                              <1> 	; Retro UNIX 386 v1, 'sys_init' (u0.s)
    91                              <1> 	; 23/06/2015
    92                              <1> 
    93                              <1> 	; 02/05/2016
    94                              <1> 	; 24/04/2016
    95 000054AD 66B80100            <1> 	mov	ax, 1
    96 000054B1 A2[D7300100]        <1> 	mov	[u.uno], al
    97 000054B6 66A3[72300100]      <1> 	mov	[mpid], ax
    98 000054BC 66A3[6C2D0100]      <1> 	mov	[p.pid], ax
    99 000054C2 A2[FC2D0100]        <1> 	mov	[p.stat], al
   100 000054C7 B004                <1> 	mov	al, time_count
   101 000054C9 A2[CA300100]        <1> 	mov	[u.quant], al
   102                              <1> 	;
   103 000054CE A1[A81F0100]        <1> 	mov	eax, [k_page_dir]
   104 000054D3 A3[E1300100]        <1> 	mov	[u.pgdir], eax ; reset
   105                              <1> 	;
   106 000054D8 E8E5F0FFFF          <1> 	call	allocate_page
   107 000054DD 0F82A3000000        <1> 	jc	panic
   108 000054E3 A3[D8300100]        <1> 	mov	[u.upage], eax ; user structure page	
   109 000054E8 A3[0C2E0100]        <1> 	mov	[p.upage], eax
   110 000054ED E84AF1FFFF          <1> 	call	clear_page
   111                              <1> 	;
   112                              <1> 	; 24/08/2015
   113 000054F2 FE0D[7F300100]      <1> 	dec 	byte [sysflg] ; FFh = ready for system call
   114                              <1> 			      ; 0 = executing a system call
   115                              <1> 	; 13/04/2016
   116                              <1> 	; Clear Environment Variables Page/Area
   117 000054F8 BF00300900          <1> 	mov	edi, Env_Page ; 93000h
   118 000054FD B980000000          <1> 	mov	ecx, Env_Page_Size / 4 	; 512/4  (4096/4)				 	  		 	  
   119 00005502 31C0                <1> 	xor	eax, eax
   120 00005504 F3AB                <1> 	rep	stosd
   121                              <1> 
   122                              <1> 	; 14/04/2016
   123 00005506 E8BA320000          <1>  	call	mainprog_startup_configuration
   124                              <1> 
   125 0000550B E85E0A0000          <1>         call    dos_prompt
   126                              <1>               
   127                              <1> _end_of_mainprog:
   128 00005510 BE[E5DD0000]        <1>         mov     esi, msg_CRLF_temp
   129 00005515 E818000000          <1> 	call 	print_msg
   130 0000551A BE[EBDD0000]        <1> 	mov 	esi, mainprog_Version
   131 0000551F E80E000000          <1> 	call 	print_msg
   132                              <1> 	; 24/01/2016
   133 00005524 28E4                <1> 	sub	ah, ah
   134 00005526 E8A1B5FFFF          <1> 	call	int16h ; call getch
   135 0000552B E978BAFFFF          <1> 	jmp	cpu_reset
   136                              <1> 
   137 00005530 EBFE                <1> infinitiveloop: jmp short infinitiveloop
   138                              <1> 
   139                              <1> print_msg:
   140                              <1> 	; 13/05/2016
   141                              <1> 	; 04/01/2016
   142                              <1> 	; 01/07/2015
   143                              <1> 	; 13/03/2015 (Retro UNIX 386 v1)
   144                              <1> 	; 07/03/2014 (Retro UNIX 8086 v1)
   145                              <1> 	; (Modified registers: EAX, EBX, ECX, EDX, ESI, EDI)
   146                              <1> 	;
   147 00005532 8A3D[D61F0100]      <1> 	mov	bh, [ACTIVE_PAGE] ; 04/01/2016 (ptty)
   148                              <1> 	;mov	bl, 07h ; Black background, light gray forecolor
   149                              <1> 
   150 00005538 AC                  <1> 	lodsb
   151                              <1> pmsg1:
   152 00005539 56                  <1> 	push 	esi
   153                              <1> 	;mov	bh, [ACTIVE_PAGE] ; 04/01/2016 (ptty)
   154 0000553A B307                <1> 	mov	bl, 07h ; Black background, light gray forecolor
   155 0000553C E8DBC5FFFF          <1> 	call 	_write_tty
   156 00005541 5E                  <1> 	pop	esi
   157 00005542 AC                  <1> 	lodsb
   158 00005543 20C0                <1> 	and 	al, al
   159 00005545 75F2                <1> 	jnz 	short pmsg1
   160 00005547 C3                  <1> 	retn
   161                              <1> 
   162                              <1> clear_screen:
   163                              <1> 	; 13/05/2016
   164                              <1> 	; 30/01/2016
   165                              <1> 	; 24/01/2016
   166                              <1> 	; 04/01/2016
   167 00005548 0FB61D[D61F0100]    <1> 	movzx	ebx, byte [ACTIVE_PAGE] ; video page number (0 to 7)
   168 0000554F 8AA3[F7E80000]      <1> 	mov 	ah, [ebx+vmode] ; default = 03h (80x25 text)
   169 00005555 80FC04              <1> 	cmp	ah, 4
   170 00005558 7205                <1> 	jb	short cls1
   171 0000555A 80FC07              <1> 	cmp	ah, 7
   172 0000555D 7526                <1> 	jne	short vga_clear
   173                              <1> cls1:
   174                              <1> 	;mov	bh, bl
   175                              <1> 	;mov	bl, 7
   176 0000555F 3A25[E6E80000]      <1> 	cmp	ah, [CRT_MODE] ; current video mode ? 
   177                              <1> 	;je	short cls2 ; yes (current video mode = 3)
   178                              <1> 	;;call	set_mode_3 ; set video mode to 3 (& clear screen)
   179                              <1> 	;;retn
   180                              <1> 	;jmp	set_mode_3
   181 00005565 0F85BBC5FFFF        <1> 	jne	set_mode_3
   182                              <1> cls2:
   183 0000556B 88DF                <1> 	mov	bh, bl ; video page (0 to 7)
   184 0000556D B307                <1> 	mov	bl, 07h ; attribute to be used on blanked line
   185 0000556F 28C0                <1> 	sub 	al, al ; 0 =  entire window
   186 00005571 6631C9              <1> 	xor 	cx, cx
   187 00005574 66BA4F18            <1> 	mov 	dx, 184Fh
   188 00005578 E8F7C2FFFF          <1> 	call	_scroll_up ; 24/01/2016
   189                              <1> 	;
   190                              <1> 	;mov	bh, [ACTIVE_PAGE] ; video page number (0 to 7)
   191 0000557D 6631D2              <1> 	xor 	dx, dx
   192 00005580 E82DC6FFFF          <1> 	call	_set_cpos ; 24/01/2016 
   193                              <1> 	;retn
   194                              <1> vga_clear:
   195 00005585 C3                  <1> 	retn	
   196                              <1> 
   197                              <1> panic:
   198                              <1> 	; 13/05/2016 (TRDOS 386 = TRDOS v2)
   199                              <1> 	; 13/03/2015 (Retro UNIX 386 v1)
   200                              <1> 	; 07/03/2014 (Retro UNIX 8086 v1)
   201 00005586 BE[8EEE0000]        <1> 	mov 	esi, panic_msg
   202 0000558B E8A2FFFFFF          <1> 	call 	print_msg
   203                              <1> key_to_reboot:
   204                              <1>         ; 24/01/2016
   205 00005590 28E4                <1>         sub     ah, ah
   206 00005592 E835B5FFFF          <1>         call    int16h ; call   getch
   207                              <1>         ; wait for a character from the current tty
   208                              <1> 	;
   209 00005597 B00A                <1> 	mov	al, 0Ah
   210 00005599 8A3D[D61F0100]      <1> 	mov	bh, [ptty] ; [ACTIVE_PAGE]
   211 0000559F B307                <1> 	mov	bl, 07h ; Black background, 
   212                              <1> 			; light gray forecolor
   213 000055A1 E876C5FFFF          <1> 	call 	_write_tty
   214 000055A6 E9FDB9FFFF          <1> 	jmp	cpu_reset 
   215                              <1> 
   216                              <1> ctrlbrk:
   217                              <1> 	; 12/11/2015
   218                              <1> 	; 13/03/2015 (Retro UNIX 386 v1)
   219                              <1> 	; 06/12/2013 (Retro UNIX 8086 v1)
   220                              <1> 	;
   221                              <1> 	; INT 1Bh (control+break) handler		
   222                              <1> 	;
   223                              <1>       	; Retro Unix 8086 v1 feature only!
   224                              <1>       	;
   225 000055AB 66833D[CC300100]00  <1> 	cmp 	word [u.intr], 0
   226 000055B3 7645                <1> 	jna 	short cbrk4
   227                              <1> cbrk0:
   228                              <1> 	; 12/11/2015
   229                              <1> 	; 06/12/2013
   230 000055B5 66833D[CE300100]00  <1> 	cmp 	word [u.quit], 0
   231 000055BD 743B                <1> 	jz	short cbrk4
   232                              <1> 	;
   233                              <1> 	; 20/09/2013	
   234 000055BF 6650                <1> 	push 	ax
   235 000055C1 A0[D61F0100]        <1> 	mov	al, [ptty]
   236                              <1> 	;
   237                              <1> 	; 12/11/2015
   238                              <1> 	;
   239                              <1> 	; ctrl+break (EOT, CTRL+D) from serial port
   240                              <1> 	; or ctrl+break from console (pseudo) tty
   241                              <1> 	; (!redirection!)
   242                              <1> 	;
   243 000055C6 3C08                <1> 	cmp	al, 8 ; serial port tty nums > 7
   244 000055C8 7211                <1>         jb      short cbrk1 ; console (pseudo) tty
   245                              <1> 	;	
   246                              <1> 	; Serial port interrupt handler sets [ptty]
   247                              <1> 	; to the port's tty number (as temporary).
   248                              <1> 	;
   249                              <1> 	; If active process is using a stdin or 
   250                              <1> 	; stdout redirection (by the shell),
   251                              <1>         ; console tty keyboard must be available
   252                              <1> 	; to terminate running process,
   253                              <1> 	; in order to prevent a deadlock. 
   254                              <1> 	;
   255 000055CA 52                  <1> 	push	edx
   256 000055CB 0FB615[D7300100]    <1> 	movzx	edx, byte [u.uno]
   257 000055D2 3A82[CB2D0100]      <1> 	cmp     al, [edx+p.ttyc-1] ; console tty (rw)
   258 000055D8 5A                  <1> 	pop	edx
   259 000055D9 7412                <1> 	je	short cbrk2
   260                              <1> cbrk1:
   261 000055DB FEC0                <1> 	inc 	al  ; [u.ttyp] : 1 based tty number
   262                              <1> 	; 06/12/2013
   263 000055DD 3A05[B8300100]      <1> 	cmp	al, [u.ttyp] ; recent open tty (r)
   264 000055E3 7408                <1> 	je	short cbrk2	
   265 000055E5 3A05[B9300100]      <1>         cmp     al, [u.ttyp+1] ; recent open tty (w)
   266 000055EB 750B                <1> 	jne	short cbrk3	
   267                              <1> cbrk2:
   268                              <1> 	;; 06/12/2013
   269                              <1> 	;mov	ax, [u.quit]
   270                              <1> 	;and	ax, ax
   271                              <1> 	;jz	short cbrk3
   272                              <1> 	;
   273 000055ED 6631C0              <1> 	xor	ax, ax ; 0
   274 000055F0 6648                <1> 	dec	ax
   275                              <1> 	; 0FFFFh = 'ctrl+brk' keystroke
   276 000055F2 66A3[CE300100]      <1> 	mov	[u.quit], ax
   277                              <1> cbrk3:
   278 000055F8 6658                <1> 	pop	ax
   279                              <1> cbrk4:
   280 000055FA C3                  <1> 	retn
  1919                                  %include 'trdosk2.s' ; 04/01/2016
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.0) - DRV INIT : trdosk2.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 06/07/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> ; 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> 	; 12/02/2016
    18                              <1> 	; 06/01/2016
    19                              <1> 	;  	('diskinit.inc', 'diskio.inc' integration)
    20                              <1> 	; 04/01/2016 (TRDOS 386 = TRDOS v2.0)
    21                              <1> 	; 07/08/2011
    22                              <1> 	; 20/09/2009
    23                              <1> 	; 2005
    24 000055FB 0FB60D[44200100]    <1> 	movzx	ecx, byte [HF_NUM] ; number of fixed disks
    25 00005602 80F901              <1> 	cmp	cl, 1
    26 00005605 7301                <1> 	jnb	short load_hd_partition_tables
    27                              <1> 	; No hard disks
    28 00005607 C3                  <1> 	retn
    29                              <1> load_hd_partition_tables:
    30 00005608 8B35[48200100]      <1> 	mov	esi, [HDPM_TBL_VEC] ; primary master disk FDPT
    31 0000560E BF[6E240100]        <1> 	mov 	edi, PTable_hd0
    32 00005613 B280                <1> 	mov 	dl, 80h
    33                              <1> load_next_hd_partition_table:
    34 00005615 51                  <1> 	push	ecx
    35 00005616 57                  <1> 	push	edi
    36 00005617 56                  <1> 	push	esi ; FDPT (+ DPTE) address
    37 00005618 8A4614              <1> 	mov	al, [esi+20] ; DPTE offset 4
    38 0000561B 2440                <1> 	and	al, 40h ;  LBA bit (bit 6)
    39                              <1> 	;shr	al, 6
    40 0000561D A2[6F260100]        <1> 	mov 	[HD_LBA_yes], al
    41 00005622 E81C040000          <1> 	call	load_masterboot
    42 00005627 7275                <1> 	jc	short pass_pt_this_hard_disk
    43                              <1> 
    44 00005629 BE[2C240100]        <1> 	mov	esi, PartitionTable
    45 0000562E 89F3                <1> 	mov	ebx, esi
    46                              <1> 	;mov	ecx, 16
    47 00005630 B110                <1> 	mov	cl, 16
    48 00005632 F3A5                <1> 	rep 	movsd
    49 00005634 89DE                <1> 	mov 	esi, ebx 
    50 00005636 C605[F7EC0000]04    <1> 	mov 	byte [hdc], 4 ; 4 - partition index
    51                              <1> loc_validate_hdp_partition:
    52 0000563D 807E0400            <1> 	cmp 	byte [esi+ptFileSystemID], 0
    53 00005641 7641                <1> 	jna	short loc_validate_next_hdp_partition2
    54 00005643 56                  <1> 	push	esi ; Masterboot partition table offset
    55 00005644 52                  <1> 	push	edx ; dl = Physical drive number 
    56 00005645 FE05[70260100]      <1> 	inc	byte [PP_Counter]
    57 0000564B 31FF                <1>         xor	edi, edi ; 0  
    58                              <1> 	; Input -> ESI = PartitionTable offset
    59                              <1> 	; DL = Hard disk drive number 
    60                              <1> 	; EDI = 0 -> Primary Partition
    61                              <1> 	; EDI > 0 -> Extended Partition's Start Sector   
    62 0000564D E879010000          <1> 	call 	validate_hd_fat_partition
    63 00005652 730A                <1> 	jnc 	short loc_set_valid_hdp_partition_entry
    64                              <1> 	;pop	edx
    65                              <1> 	;push	edx
    66 00005654 8B1424              <1> 	mov	edx, [esp] 
    67 00005657 E8C5020000          <1> 	call	validate_hd_fs_partition
    68 0000565C 7224                <1> 	jc	short loc_validate_next_hdp_partition1
    69                              <1> loc_set_valid_hdp_partition_entry:
    70 0000565E 8A0D[E3DD0000]      <1> 	mov 	cl, [Last_DOS_DiskNo] 
    71 00005664 80C141              <1> 	add 	cl, 'A'
    72                              <1> 	; ESI = Logical dos drive description table address
    73 00005667 880E                <1> 	mov	[esi+LD_Name], cl
    74 00005669 8A6602              <1> 	mov	ah, [esi+LD_PhyDrvNo]
    75 0000566C 88E0                <1> 	mov	al, ah ; Physical drive number
    76 0000566E 2C80                <1> 	sub	al, 80h
    77 00005670 C0E002              <1> 	shl	al, 2
    78 00005673 0404                <1> 	add	al, 4 ; 0 Based
    79 00005675 2A05[F7EC0000]      <1> 	sub	al, [hdc] ; 4 - partition index
    80                              <1> 	; AL = Partition entry/index, 0 based
    81                              <1> 	;  0 -> hd 0, Partition Table offset = 0
    82                              <1> 	; 15 -> hd 3, Partition Table offset = 3
    83                              <1> 	;mov	[esi+LD_PartitionEntry], al 
    84 0000567B 80EC7E              <1> 	sub 	ah, 7Eh
    85                              <1> 	; AH = Physical drive index, zero based
    86                              <1> 	;  0 for drive A:, 2 for drive C:
    87                              <1> 	;mov 	[esi+LD_DParamEntry], ah 
    88 0000567E 6689467C            <1> 	mov 	[esi+LD_PartitionEntry], ax
    89                              <1> loc_validate_next_hdp_partition1:
    90 00005682 5A                  <1> 	pop 	edx ; dl = Physical drive number 
    91 00005683 5E                  <1> 	pop	esi ; Masterboot partition table offset
    92                              <1> loc_validate_next_hdp_partition2:
    93                              <1> 	; ESI = PartitionTable offset
    94                              <1> 	; DL = Hard/Fixed disk drive number
    95 00005684 FE0D[F7EC0000]      <1> 	dec	byte [hdc] ; 4 - partition index
    96 0000568A 7412                <1> 	jz	short pass_pt_this_hard_disk
    97 0000568C 83C610              <1> 	add	esi, 16 ; 10h
    98 0000568F EBAC                <1> 	jmp	short loc_validate_hdp_partition
    99                              <1> loc_next_hd_partition_table:
   100 00005691 FEC2                <1> 	inc	dl
   101 00005693 83C620              <1> 	add	esi, 32 ; next FDPT address
   102 00005696 83C740              <1> 	add	edi, 64 ; next partition table destination
   103 00005699 E977FFFFFF          <1>         jmp     load_next_hd_partition_table
   104                              <1> pass_pt_this_hard_disk:
   105 0000569E 5E                  <1> 	pop	esi ; FDPT (+ DPTE) address
   106 0000569F 5F                  <1> 	pop	edi ; Ptable_hd?
   107 000056A0 59                  <1> 	pop	ecx
   108 000056A1 E2EE                <1> 	loop	loc_next_hd_partition_table
   109 000056A3 803D[70260100]01    <1> 	cmp	byte [PP_Counter], 1
   110 000056AA 7301                <1> 	jnb	short load_extended_dos_partitions
   111                              <1> 	; Empty partition table
   112 000056AC C3                  <1> 	retn 
   113                              <1> load_extended_dos_partitions:
   114 000056AD BE[6E240100]        <1> 	mov	esi, PTable_hd0
   115 000056B2 BF[6E250100]        <1> 	mov	edi, PTable_ep0
   116 000056B7 C605[F7EC0000]80    <1> 	mov	byte [hdc], 80h
   117                              <1> next_hd_extd_partition:
   118 000056BE 56                  <1> 	push	esi ; PTable_hd? offset
   119 000056BF 57                  <1> 	push	edi ; PTable_ep?
   120                              <1> 	;mov	ecx, 4
   121 000056C0 B104                <1> 	mov	cl, 4
   122 000056C2 8A15[F7EC0000]      <1> 	mov	dl, byte [hdc]
   123                              <1> hd_check_fs_id_05h:
   124 000056C8 8A4604              <1> 	mov	al, [esi+ptFileSystemID]
   125 000056CB 3C05                <1> 	cmp	al, 05h ; Is it an extended dos partition ?
   126 000056CD 7404                <1> 	je	short loc_set_ep_start_sector
   127 000056CF 3C0F                <1> 	cmp	al, 0Fh ; Is it an extended win4 (LBA mode) partition ?
   128 000056D1 7546                <1> 	jne	short continue_to_check_ep
   129                              <1> loc_set_ep_start_sector:
   130 000056D3 FE05[71260100]      <1> 	inc	byte [EP_Counter]
   131 000056D9 88D4                <1> 	mov	ah, dl ; byte [hdc]
   132 000056DB 86E0                <1> 	xchg	ah, al ; al = Drv Number, ah = Partition Identifier
   133 000056DD 50                  <1> 	push	eax 
   134 000056DE 30E4                <1> 	xor	ah, ah  
   135 000056E0 2C80                <1> 	sub	al, 80h
   136 000056E2 50                  <1> 	push	eax
   137 000056E3 C0E002              <1> 	shl	al, 2 ; al = al * 4
   138 000056E6 0FB6D8              <1> 	movzx	ebx, al
   139 000056E9 81C3[72260100]      <1> 	add	ebx, EP_StartSector
   140 000056EF 8B4608              <1> 	mov	eax, [esi+ptStartSector]
   141                              <1>         ; EAX = Extended partition's start sector
   142 000056F2 8903                <1>         mov	[ebx], eax
   143 000056F4 58                  <1> 	pop	eax ; AL = Drv number - 80h, AH = 0 
   144 000056F5 5A                  <1> 	pop	edx ; DL = Drv number, DH = Partition ID
   145 000056F6 BB[6E220100]        <1> 	mov	ebx, MasterBootBuff
   146 000056FB 803D[6F260100]01    <1> 	cmp	byte [HD_LBA_yes], 1 ; LBA ready = Yes
   147 00005702 7240                <1> 	jb	short loc_hd_load_ep_05h
   148 00005704 80FE05              <1> 	cmp	dh, 05h
   149 00005707 743B                <1> 	je	short loc_hd_load_ep_05h
   150                              <1> loc_hd_load_ep_0Fh:
   151                              <1> 	; 04/01/2016
   152 00005709 51                  <1> 	push	ecx
   153 0000570A 8B4E08              <1> 	mov	ecx, [esi+ptStartSector] ; sector number
   154                              <1> 	;mov	ebx, MasterBootBuff ; buffer address
   155                              <1> 	; LBA read/write (with private LBA function) 
   156                              <1> 	;((Retro UNIX 386 v1 - DISK I/O code by Erdogan Tan))
   157                              <1> 	; dl = physical drive number (0,1, 80h, 81h, 82h, 83h)
   158 0000570D B41B                <1> 	mov	ah, 1Bh ; LBA read
   159 0000570F B001                <1> 	mov	al, 1 ; sector count
   160 00005711 E83BE5FFFF          <1> 	call	int13h
   161 00005716 59                  <1> 	pop	ecx
   162 00005717 733F                <1> 	jnc	short loc_hd_move_ep_table
   163                              <1> continue_to_check_ep:
   164 00005719 83C610              <1> 	add	esi, 16
   165 0000571C E2AA                <1> 	loop	hd_check_fs_id_05h
   166                              <1> continue_check_ep_next_disk:
   167 0000571E 5F                  <1> 	pop	edi ; PTable_ep?
   168 0000571F 5E                  <1> 	pop	esi ; PTable_hd?
   169 00005720 A0[44200100]        <1> 	mov	al, [HF_NUM] ; number of hard disks
   170 00005725 047F                <1> 	add	al, 7Fh
   171 00005727 3805[F7EC0000]      <1> 	cmp	[hdc], al
   172 0000572D 0F8392000000        <1> 	jnb	loc_validating_hd_partitions_ok
   173 00005733 83C640              <1> 	add	esi, 64
   174 00005736 83C740              <1> 	add	edi, 64
   175 00005739 FE05[F7EC0000]      <1> 	inc	byte [hdc]
   176 0000573F E97AFFFFFF          <1> 	jmp	next_hd_extd_partition
   177                              <1> loc_hd_load_ep_05h:
   178 00005744 51                  <1> 	push	ecx 
   179 00005745 8A7601              <1> 	mov	dh, [esi+ptBeginHead]
   180 00005748 668B4E02            <1>         mov     cx, word [esi+ptBeginSector]
   181 0000574C 66B80102            <1> 	mov	ax, 0201h ; Read 1 sector
   182                              <1> 	;mov	ebx, MasterBootBuff
   183 00005750 E8FCE4FFFF          <1> 	call	int13h
   184 00005755 59                  <1> 	pop	ecx  
   185 00005756 72C1                <1> 	jc	short continue_to_check_ep
   186                              <1> loc_hd_move_ep_table:
   187                              <1>         ;pop	edi
   188                              <1> 	;push	edi  ; PTable_ep?
   189 00005758 8B3C24              <1> 	mov	edi, [esp]        
   190 0000575B BE[2C240100]        <1>         mov	esi, PartitionTable ; Extended
   191 00005760 89F3                <1> 	mov	ebx, esi
   192                              <1> 	;mov	ecx, 16
   193 00005762 B110                <1> 	mov	cl, 16
   194 00005764 F3A5                <1>        	rep	movsd
   195 00005766 89DE                <1> 	mov	esi, ebx 
   196                              <1> loc_set_hde_sub_partition_count:
   197 00005768 C605[70260100]04    <1> 	mov	byte [PP_Counter], 4
   198                              <1> loc_validate_hde_partition:
   199 0000576F 807E0400            <1> 	cmp	byte [esi+ptFileSystemID], 0
   200 00005773 763F                <1> 	jna	short loc_validate_next_hde_partition2
   201 00005775 56                  <1> 	push	esi ; Extended partition table offset
   202 00005776 8A15[F7EC0000]      <1> 	mov	dl, byte [hdc]
   203 0000577C 0FB6C2              <1> 	movzx	eax, dl
   204 0000577F 2C80                <1> 	sub	al, 80h
   205 00005781 C0E002              <1> 	shl	al, 2
   206                              <1> 	; 06/01/2016 
   207                              <1> 	; (TRDOS v1.0 had a bug here, in 'DRV_INIT.ASM')
   208                              <1> 	; BUGFIX *
   209                              <1> 	;mov	ecx, eax
   210 00005784 88C1                <1> 	mov	cl, al
   211 00005786 80C104              <1> 	add	cl, 4
   212 00005789 2A0D[70260100]      <1> 	sub	cl, [PP_Counter] ; 4 to 1
   213                              <1> 	; CL = Partition entry/index, 0 based
   214                              <1>         ;  0 -> hd 0, Partition Table offset = 0
   215                              <1>         ; 15 -> hd 3, Partition Table offset = 3
   216 0000578F 88D5                <1>       	mov	ch, dl   
   217 00005791 80ED7E              <1> 	sub	ch, 7Eh ;
   218                              <1> 	; CH = Physical drive index, zero based
   219                              <1> 	;  0 for drive A:, 2 for drive C:	
   220                              <1> 	; BUGFIX *
   221 00005794 51                  <1> 	push	ecx ; *
   222 00005795 BF[72260100]        <1> 	mov	edi, EP_StartSector
   223 0000579A 01C7                <1> 	add	edi, eax
   224                              <1> 	; Input -> ESI = PartitionTable offset
   225                              <1> 	; DL = Hard disk drive number   
   226                              <1> 	; EDI = Extended partition start sector pointer
   227 0000579C E82A000000          <1> 	call	validate_hd_fat_partition
   228 000057A1 59                  <1> 	pop	ecx ; *
   229 000057A2 720F                <1> 	jc	short loc_validate_next_hde_partition1
   230                              <1> loc_set_valid_hde_partition_entry:
   231                              <1> 	; 06/01/2016 (TRDOS v2.0)
   232                              <1> 	; BUGFIX *
   233                              <1> 	;mov	[esi+LD_PartitionEntry], cl 
   234                              <1> 	;mov	[esi+LD_DParamEntry], ch 
   235 000057A4 66894E7C            <1> 	mov	[esi+LD_PartitionEntry], cx 
   236                              <1> 	;
   237 000057A8 8A0D[E3DD0000]      <1> 	mov	cl, [Last_DOS_DiskNo] 
   238 000057AE 80C141              <1> 	add	cl, 'A'
   239 000057B1 880E                <1> 	mov	[esi+LD_Name], cl
   240                              <1> loc_validate_next_hde_partition1:
   241 000057B3 5E                  <1> 	pop	esi ; Extended partition table offset
   242                              <1> loc_validate_next_hde_partition2:
   243                              <1> 	; ESI = Extended partition table offset
   244                              <1> 	; DL = Hard disk drive number
   245 000057B4 FE0D[70260100]      <1> 	dec	byte [PP_Counter]
   246 000057BA 0F845EFFFFFF        <1> 	jz	continue_check_ep_next_disk
   247 000057C0 83C610              <1> 	add 	esi, 16 ; 10h
   248 000057C3 EBAA                <1> 	jmp	short loc_validate_hde_partition
   249                              <1> loc_validating_hd_partitions_ok:
   250 000057C5 A0[E3DD0000]        <1> 	mov	al, [Last_DOS_DiskNo]
   251                              <1> loc_drv_init_retn:
   252 000057CA C3                  <1> 	retn
   253                              <1> 
   254                              <1> validate_hd_fat_partition:
   255                              <1> 	; 12/02/2016
   256                              <1> 	; 07/01/2016 (TRDOS 386 = TRDOS v2.0)
   257                              <1> 	; 07/08/2011
   258                              <1> 	; 23/07/2011
   259                              <1> 	; Input
   260                              <1> 	;   DL = Hard/Fixed Disk Drive Number
   261                              <1> 	;   ESI = PartitionTable offset
   262                              <1> 	;   EDI = Extend. Part. Start Sector Pointer
   263                              <1> 	;   EDI = 0 -> Primary Partition 
   264                              <1> 	;   byte [Last_DOS_DiskNo]
   265                              <1>  	; Output
   266                              <1> 	;  cf=0 -> Validated
   267                              <1> 	;   ESI = Logical dos drv desc. table
   268                              <1> 	;   EBX = FAT boot sector buffer
   269                              <1> 	;   byte [Last_DOS_DiskNo]
   270                              <1> 	;  cf=1 -> Not a valid FAT partition
   271                              <1> 	; EAX, EDX, ECX, EDI -> changed 
   272                              <1> 	
   273                              <1> 	;mov 	esi, PartitionTable
   274 000057CB 8A6604              <1> 	mov 	ah, [esi+ptFileSystemID]
   275 000057CE 80FC06              <1> 	cmp 	ah, 06h ; FAT16 CHS partition
   276                              <1> 	; 12/02/2016
   277                              <1> 	;jb	short loc_not_a_valid_fat_partition2
   278 000057D1 7305                <1>  	jnb	short vhdp_FAT16_32
   279                              <1> 	;
   280 000057D3 80FC04              <1> 	cmp	ah, 04h ; FAT16 CHS partition (< 32MB)		
   281 000057D6 7519                <1> 	jne	short loc_not_a_valid_fat_partition1
   282                              <1> vhdp_FAT16_32:
   283 000057D8 B002                <1> 	mov	al, 2
   284 000057DA 7417                <1> 	je	short loc_set_valid_hd_partition_params
   285 000057DC 80FC0E              <1> 	cmp	ah, 0Eh ; FAT16 LBA partition
   286 000057DF 7710                <1> 	ja	short loc_not_a_valid_fat_partition1
   287 000057E1 7410                <1> 	je	short loc_set_valid_hd_partition_params
   288                              <1> 
   289 000057E3 FEC0                <1> 	inc	al ; 3
   290 000057E5 80FC0B              <1> 	cmp	ah, 0Bh ; FAT32 CHS partition 
   291 000057E8 7409                <1> 	je	short loc_set_valid_hd_partition_params
   292 000057EA 7206                <1> 	jb	short loc_not_a_valid_fat_partition2
   293 000057EC 80FC0C              <1> 	cmp	ah, 0Ch ; FAT32 LBA partition
   294 000057EF 7402                <1> 	je	short loc_set_valid_hd_partition_params
   295                              <1> loc_not_a_valid_fat_partition1:
   296 000057F1 F9                  <1> 	stc
   297                              <1> loc_not_a_valid_fat_partition2:
   298 000057F2 C3                  <1> 	retn
   299                              <1> 
   300                              <1> loc_set_valid_hd_partition_params:
   301 000057F3 FE05[E3DD0000]      <1> 	inc 	byte [Last_DOS_DiskNo] ; > 1
   302                              <1> 	;
   303 000057F9 31DB                <1> 	xor	ebx, ebx
   304 000057FB 8A3D[E3DD0000]      <1> 	mov	bh, [Last_DOS_DiskNo] ; * 256	
   305 00005801 81C300010900        <1> 	add	ebx, Logical_DOSDisks
   306                              <1> 	;
   307 00005807 C6430102            <1> 	mov	byte [ebx+LD_DiskType], 2
   308 0000580B 885302              <1> 	mov	byte [ebx+LD_PhyDrvNo], dl
   309                              <1> 	;mov	byte [ebx+LD_FATType], al ; 2 or 3
   310                              <1> 	;mov	byte [ebx+LD_FSType], ah ; 06h, 0Eh, 0Bh, 0Ch
   311 0000580E 66894303            <1> 	mov	word [ebx+LD_FATType], ax
   312                              <1> 	;
   313 00005812 8B4E08              <1> 	mov	ecx, [esi+ptStartSector]
   314 00005815 09FF                <1> 	or	edi, edi 
   315 00005817 7402                <1> 	jz	short pass_hd_FAT_ep_start_sector_adding
   316                              <1> loc_add_hd_FAT_ep_start_sector:
   317 00005819 030F                <1> 	add	ecx, [edi]
   318                              <1> pass_hd_FAT_ep_start_sector_adding:
   319 0000581B 894B6C              <1> 	mov	[ebx+LD_StartSector], ecx
   320                              <1> loc_hd_FAT_logical_drv_init:
   321 0000581E 89DD                <1> 	mov	ebp, ebx
   322                              <1> 	;mov	dl, [ebx+LD_PhyDrvNo]
   323 00005820 A0[6F260100]        <1> 	mov	al, [HD_LBA_yes] ; 07/01/2016
   324 00005825 884305              <1> 	mov	[ebx+LD_LBAYes], al
   325 00005828 BB[82260100]        <1> 	mov	ebx, DOSBootSectorBuff ; buffer address
   326 0000582D 08C0                <1> 	or	al, al
   327 0000582F 740C                <1> 	jz	short loc_hd_FAT_drv_init_load_bs_chs
   328                              <1> loc_hd_FAT_drv_init_load_bs_lba:
   329                              <1> 	; DL = Physical drive number
   330                              <1>    	;mov	ecx, [esi+ptStartSector] ; sector number
   331                              <1> 	;mov	ebx, DOSBootSectorBuff ; buffer address
   332                              <1> 	; LBA read/write (with private LBA function) 
   333                              <1> 	;((Retro UNIX 386 v1 - DISK I/O code by Erdogan Tan))
   334                              <1> 	; dl = physical drive number (0,1, 80h, 81h, 82h, 83h)
   335 00005831 B41B                <1> 	mov	ah, 1Bh ; LBA read
   336 00005833 B001                <1> 	mov	al, 1 ; sector count
   337 00005835 E817E4FFFF          <1> 	call	int13h
   338 0000583A 7313                <1> 	jnc	short loc_hd_drv_FAT_boot_validation
   339                              <1> loc_not_a_valid_fat_partition3:
   340 0000583C C3                  <1> 	retn
   341                              <1> loc_hd_FAT_drv_init_load_bs_chs:
   342 0000583D 8A7601              <1> 	mov	dh, [esi+ptBeginHead]
   343 00005840 668B4E02            <1> 	mov	cx, [esi+ptBeginSector]
   344 00005844 66B80102            <1> 	mov	ax, 0201h ; Read 1 sector
   345                              <1> 	;mov	ebx, DOSBootSectorBuff
   346 00005848 E804E4FFFF          <1> 	call	int13h
   347 0000584D 72ED                <1> 	jc	short loc_not_a_valid_fat_partition3
   348                              <1> loc_hd_drv_FAT_boot_validation:
   349                              <1> 	;mov	esi, DOSBootSectorBuff
   350 0000584F 89DE                <1> 	mov	esi, ebx
   351 00005851 6681BEFE01000055AA  <1> 	cmp	word [esi+BS_Validation], 0AA55h
   352 0000585A 751A                <1> 	jne	short loc_not_a_valid_fat_partition4
   353 0000585C 807E15F8            <1> 	cmp	byte [esi+BPB_Media], 0F8h
   354 00005860 7514                <1> 	jne	short loc_not_a_valid_fat_partition4
   355 00005862 66837E1600          <1> 	cmp	word [esi+BPB_FATSz16], 0
   356 00005867 770F                <1> 	ja	short loc_hd_FAT16_BPB
   357 00005869 807E4229            <1> 	cmp	byte [esi+BS_FAT32_BootSig], 29h
   358 0000586D 7507                <1> 	jne	short loc_not_a_valid_fat_partition4
   359                              <1> loc_hd_FAT32_BPB:
   360 0000586F B92D000000          <1> 	mov	ecx, 45
   361 00005874 EB0D                <1> 	jmp	short loc_hd_move_FAT_BPB
   362                              <1> 	;
   363                              <1> loc_not_a_valid_fat_partition4:
   364 00005876 F9                  <1> 	stc
   365 00005877 C3                  <1> 	retn
   366                              <1> 	;
   367                              <1> loc_hd_FAT16_BPB:
   368 00005878 807E2629            <1> 	cmp	byte [esi+BS_BootSig], 29h
   369 0000587C 75F8                <1> 	jne	short loc_not_a_valid_fat_partition4
   370 0000587E B920000000          <1> 	mov	ecx, 32
   371                              <1> loc_hd_move_FAT_BPB:
   372 00005883 89EF                <1> 	mov 	edi, ebp
   373                              <1> 	;mov	esi, ebx ; Boot sector
   374 00005885 57                  <1> 	push	edi
   375 00005886 83C706              <1> 	add	edi, LD_BPB
   376 00005889 F366A5              <1> 	rep	movsw 
   377 0000588C 5E                  <1> 	pop	esi
   378 0000588D 0FB74614            <1> 	movzx	eax, word [esi+LD_BPB+BPB_RsvdSecCnt]
   379 00005891 03466C              <1> 	add	eax, [esi+LD_StartSector]
   380 00005894 894660              <1> 	mov	[esi+LD_FATBegin], eax
   381 00005897 807E0303            <1> 	cmp	byte [esi+LD_FATType], 3
   382 0000589B 7224                <1> 	jb	short loc_set_FAT16_RootDirLoc
   383                              <1> loc_set_FAT32_RootDirLoc:
   384 0000589D 8B462A              <1> 	mov	eax, [esi+LD_BPB+BPB_FATSz32]
   385 000058A0 0FB65E16            <1>         movzx	ebx, byte [esi+LD_BPB+BPB_NumFATs]
   386 000058A4 F7E3                <1> 	mul	ebx
   387 000058A6 034660              <1> 	add	eax, [esi+LD_FATBegin]
   388                              <1> loc_set_FAT32_data_begin:
   389 000058A9 894668              <1> 	mov	[esi+LD_DATABegin], eax
   390 000058AC 894664              <1> 	mov	[esi+LD_ROOTBegin], eax
   391                              <1> 	; If Root Directory Cluster <> 2 then
   392                              <1> 	; change the beginning sector value 
   393                              <1> 	; of the root dir by adding sector offset.
   394 000058AF 8B4632              <1> 	mov	eax, [esi+LD_BPB+BPB_RootClus]
   395 000058B2 83E802              <1> 	sub	eax, 2
   396 000058B5 7442                <1> 	jz	short short loc_set_32bit_FAT_total_sectors  
   397                              <1> 	;movzx	ebx, byte [esi+LD_BPB+BPB_SecPerClust]
   398 000058B7 8A5E13              <1> 	mov	bl, byte [esi+LD_BPB+BPB_SecPerClust] 
   399 000058BA F7E3                <1> 	mul	ebx
   400 000058BC 014664              <1> 	add	[esi+LD_ROOTBegin], eax
   401 000058BF EB38                <1> 	jmp	short loc_set_32bit_FAT_total_sectors
   402                              <1> 	;
   403                              <1> loc_set_FAT16_RootDirLoc:
   404 000058C1 0FB64616            <1> 	movzx	eax, byte [esi+LD_BPB+BPB_NumFATs]
   405 000058C5 0FB7561C            <1> 	movzx	edx, word [esi+LD_BPB+BPB_FATSz16]
   406 000058C9 F7E2                <1> 	mul	edx
   407 000058CB 034660              <1> 	add	eax, [esi+LD_FATBegin]  
   408 000058CE 894664              <1> 	mov	[esi+LD_ROOTBegin], eax
   409                              <1> loc_set_FAT16_data_begin:
   410 000058D1 894668              <1> 	mov	[esi+LD_DATABegin], eax 
   411 000058D4 B820000000          <1> 	mov	eax, 20h  ; Size of a directory entry
   412                              <1> 	;movzx	edx, word [esi+LD_BPB+BPB_RootEntCnt]
   413 000058D9 668B5617            <1>         mov     dx, [esi+LD_BPB+BPB_RootEntCnt]
   414 000058DD F7E2                <1>         mul	edx
   415                              <1> 	;mov	ecx, 511
   416 000058DF 66B9FF01            <1> 	mov	cx, 511
   417 000058E3 01C8                <1> 	add	eax, ecx
   418 000058E5 41                  <1> 	inc	ecx ; 512
   419 000058E6 F7F1                <1> 	div	ecx
   420 000058E8 014668              <1> 	add	[esi+LD_DATABegin], eax
   421 000058EB 0FB74619            <1> 	movzx	eax, word [esi+LD_BPB+BPB_TotalSec16]
   422 000058EF 6685C0              <1> 	test	ax, ax
   423 000058F2 7405                <1> 	jz	short loc_set_32bit_FAT_total_sectors
   424                              <1> loc_set_16bit_FAT_total_sectors:
   425 000058F4 894670              <1> 	mov	[esi+LD_TotalSectors], eax
   426 000058F7 EB06                <1> 	jmp	short loc_set_hd_FAT_cluster_count
   427                              <1> loc_set_32bit_FAT_total_sectors:
   428 000058F9 8B4626              <1> 	mov	eax, [esi+LD_BPB+BPB_TotalSec32]
   429 000058FC 894670              <1> 	mov	[esi+LD_TotalSectors], eax
   430                              <1> loc_set_hd_FAT_cluster_count:
   431 000058FF 8B5668              <1> 	mov	edx, [esi+LD_DATABegin]
   432 00005902 2B566C              <1> 	sub	edx, [esi+LD_StartSector]
   433 00005905 29D0                <1> 	sub	eax, edx
   434 00005907 31D2                <1> 	xor	edx, edx ; 0
   435 00005909 0FB64E13            <1>         movzx   ecx, byte [esi+LD_BPB+BPB_SecPerClust]
   436 0000590D F7F1                <1>         div	ecx 
   437 0000590F 894678              <1> 	mov	[esi+LD_Clusters], eax
   438                              <1> 	; Maximum Valid Cluster Number= EAX +1
   439                              <1> 	; with 2 reserved clusters= EAX +2
   440                              <1> loc_set_hd_FAT_fs_free_sectors:
   441                              <1> 	;mov	dword [esi+LD_FreeSectors], 0
   442 00005912 E859010000          <1> 	call	get_free_FAT_sectors
   443 00005917 7207                <1> 	jc	short loc_validate_hd_FAT_partition_retn
   444 00005919 894674              <1> 	mov	[esi+LD_FreeSectors], eax
   445 0000591C C6467E06            <1> 	mov	byte [esi+LD_MediaChanged], 6  ; Volume Name Reset
   446                              <1> 	;mov	cl, [Last_DOS_DiskNo] 
   447                              <1> 	;add	cl, 'A'
   448                              <1> 	;mov	[esi+LD_FS_Name], cl
   449                              <1> 
   450                              <1> loc_validate_hd_FAT_partition_retn:         
   451 00005920 C3                  <1> 	retn
   452                              <1> 
   453                              <1> validate_hd_fs_partition:
   454                              <1> 	; 13/02/2016
   455                              <1> 	; 10/01/2016 (TRDOS 386 = TRDOS v2.0)
   456                              <1> 	; 29/01/2011
   457                              <1> 	; 23/07/2011
   458                              <1> 	; Input
   459                              <1> 	;   DL = Hard/Fixed Disk Drive Number
   460                              <1> 	;   ESI = PartitionTable offset
   461                              <1> 	;   byte [Last_DOS_DiskNo]
   462                              <1> 	; Output
   463                              <1> 	;  cf=0 -> Validated
   464                              <1> 	;   ESI = Logical dos drv desc. table
   465                              <1> 	;   EBX = Singlix FS boot sector buffer
   466                              <1> 	;   byte [Last_DOS_DiskNo]
   467                              <1> 	;  cf=1 -> Not a valid 'Singlix FS' partition
   468                              <1> 	; EAX, EDX, ECX, EDI -> changed 
   469                              <1> 
   470                              <1> 	;mov	esi, PartitionTable
   471 00005921 8A6604              <1> 	mov	ah, [esi+ptFileSystemID]
   472 00005924 80FCA1              <1> 	cmp	ah, 0A1h ; SINGLIX FS1 (trfs1) partition
   473 00005927 7549                <1> 	jne	short loc_validate_hd_fs_partition_stc_retn
   474                              <1> loc_set_valid_hd_fs_partition_params:
   475 00005929 FE05[E3DD0000]      <1> 	inc	byte [Last_DOS_DiskNo] ; > 1
   476 0000592F 30C0                <1> 	xor	al, al ; mov al, 0
   477                              <1> 	;mov	[drv], dl
   478 00005931 29DB                <1> 	sub	ebx, ebx ; 0
   479 00005933 8A3D[E3DD0000]      <1> 	mov	bh, [Last_DOS_DiskNo] 
   480 00005939 81C300010900        <1> 	add	ebx, Logical_DOSDisks
   481 0000593F C6430102            <1> 	mov	byte [ebx+LD_DiskType], 2
   482 00005943 885302              <1> 	mov	[ebx+LD_PhyDrvNo], dl
   483                              <1> 	;mov	[ebx+LD_FATType], al ; 0
   484                              <1> 	;mov	[ebx+LD_FSType], ah
   485 00005946 66894303            <1> 	mov	[ebx+LD_FATType], ax
   486                              <1> 	;mov	eax, [esi+ptStartSector]
   487                              <1> 	;mov	[ebx+LD_StartSector], eax
   488                              <1> loc_hd_fs_logical_drv_init:
   489 0000594A 89DD                <1> 	mov	ebp, ebx ; 10/01/2016
   490                              <1> 	;mov	dl, [ebx+LD_PhyDrvNo]
   491 0000594C A0[6F260100]        <1> 	mov	al, [HD_LBA_yes] ; 10/01/2016
   492 00005951 884305              <1> 	mov	[ebx+LD_LBAYes], al
   493 00005954 89DE                <1> 	mov	esi, ebx
   494 00005956 BB[82260100]        <1> 	mov	ebx, DOSBootSectorBuff ; buffer address
   495 0000595B 08C0                <1> 	or	al, al
   496 0000595D 7515                <1> 	jnz	short loc_hd_fs_drv_init_load_bs_lba
   497                              <1> loc_hd_fs_drv_init_load_bs_chs:
   498 0000595F 8A7601              <1> 	mov	dh, [esi+ptBeginHead]
   499 00005962 668B4E02            <1> 	mov	cx, [esi+ptBeginSector]
   500 00005966 66B80102            <1> 	mov	ax, 0201h ; Read 1 sector
   501                              <1> 	;mov	ebx, DOSBootSectorBuff
   502 0000596A E8E2E2FFFF          <1> 	call	int13h
   503 0000596F 7311                <1> 	jnc	short loc_hd_drv_fs_boot_validation
   504                              <1> loc_validate_hd_fs_partition_err_retn:
   505 00005971 C3                  <1> 	retn
   506                              <1> loc_validate_hd_fs_partition_stc_retn:
   507 00005972 F9                  <1> 	stc
   508 00005973 C3                  <1> 	retn
   509                              <1> loc_hd_fs_drv_init_load_bs_lba:
   510                              <1> 	; DL = Physical drive number
   511                              <1> 	;mov	esi, ebx
   512 00005974 8B4E08              <1>    	mov	ecx, [esi+ptStartSector] ; sector number
   513                              <1> 	;mov	ebx, DOSBootSectorBuff ; buffer address
   514                              <1> 	; LBA read/write (with private LBA function) 
   515                              <1> 	;((Retro UNIX 386 v1 - DISK I/O code by Erdogan Tan))
   516                              <1> 	; dl = physical drive number (0,1, 80h, 81h, 82h, 83h)
   517 00005977 B41B                <1> 	mov	ah, 1Bh ; LBA read
   518 00005979 B001                <1> 	mov	al, 1 ; sector count
   519 0000597B E8D1E2FFFF          <1> 	call	int13h
   520 00005980 72EF                <1> 	jc	short loc_validate_hd_fs_partition_err_retn
   521                              <1> loc_hd_drv_fs_boot_validation:
   522                              <1> 	;mov	esi, DOSBootSectorBuff
   523 00005982 89DE                <1> 	mov	esi, ebx ; Boot sector buffer
   524 00005984 6681BEFE01000055AA  <1> 	cmp	word [esi+BS_Validation], 0AA55h
   525 0000598D 75E3                <1> 	jne	short loc_validate_hd_fs_partition_stc_retn
   526                              <1>         ;
   527                              <1> 	;Singlix FS Extensions to TR-DOS (7/6/2009) 
   528 0000598F 66817E035346        <1> 	cmp	word [esi+bs_FS_Identifier], 'SF'
   529 00005995 75DB                <1> 	jne	short loc_validate_hd_fs_partition_stc_retn
   530                              <1>         ;'A1h' check is not necessary
   531                              <1> 	;  if 'FS' check is passed as OK/Yes.
   532 00005997 807E09A1            <1> 	cmp	byte [esi+bs_FS_PartitionID], 0A1h
   533 0000599B 75D5                <1> 	jne	short loc_validate_hd_fs_partition_stc_retn
   534                              <1> 	;
   535 0000599D 89EF                <1> 	mov	edi, ebp ; 10/01/2016
   536                              <1> 	;
   537 0000599F 8A462D              <1> 	mov	al, byte [esi+bs_FS_LBA_Ready]
   538 000059A2 884705              <1> 	mov	[edi+LD_FS_LBAYes], al
   539                              <1> 	;
   540                              <1> 	; 03/01/2010 CHS -> DOS FAT/BPB compatibility fix
   541 000059A5 8A4608              <1> 	mov	al, [esi+bs_FS_MediaAttrib]
   542 000059A8 884706              <1> 	mov	byte [edi+LD_FS_MediaAttrib], al
   543                              <1> 	;
   544 000059AB 8A460A              <1> 	mov	al, [esi+bs_FS_VersionMaj]
   545 000059AE 884707              <1> 	mov	[edi+LD_FS_VersionMajor], al
   546                              <1> 	;
   547 000059B1 668B4606            <1> 	mov	ax, [esi+bs_FS_BytesPerSec]
   548 000059B5 66894711            <1> 	mov	[edi+LD_FS_BytesPerSec], ax
   549 000059B9 8A462E              <1> 	mov	al, [esi+bs_FS_SecPerTrack]
   550 000059BC 6698                <1> 	cbw
   551 000059BE 6689471E            <1> 	mov	[edi+LD_FS_SecPerTrack], ax
   552 000059C2 8A462F              <1> 	mov	al, [esi+bs_FS_Heads]
   553                              <1> 	;cbw
   554 000059C5 66894720            <1> 	mov	[edi+LD_FS_NumHeads], ax
   555                              <1> 	;
   556 000059C9 8B4628              <1> 	mov	eax, [esi+bs_FS_UnDelDirD]
   557 000059CC 894722              <1> 	mov	[edi+LD_FS_UnDelDirD], eax
   558 000059CF 8B5618              <1> 	mov	edx, [esi+bs_FS_MATLocation]
   559 000059D2 89570C              <1> 	mov	[edi+LD_FS_MATLocation], edx
   560 000059D5 8B461C              <1> 	mov	eax, [esi+bs_FS_RootDirD]
   561 000059D8 894708              <1> 	mov	[edi+LD_FS_RootDirD], eax
   562 000059DB 8B460C              <1> 	mov	eax, [esi+bs_FS_BeginSector]
   563 000059DE 89476C              <1> 	mov	[edi+LD_FS_BeginSector], eax
   564 000059E1 8B4710              <1> 	mov	eax, [edi+bs_FS_VolumeSize]
   565 000059E4 894770              <1> 	mov	[edi+LD_FS_VolumeSize], eax
   566                              <1> 	;
   567 000059E7 89D0                <1> 	mov	eax, edx ; [edi+LD_FS_MATLocation]
   568 000059E9 03476C              <1> 	add	eax, [edi+LD_FS_BeginSector]
   569 000059EC 89FE                <1> 	mov	esi, edi
   570                              <1> mread_hd_fs_MAT_sector:
   571                              <1>        ;mov	ebx, DOSBootSectorBuff
   572 000059EE B901000000          <1> 	mov	ecx, 1
   573 000059F3 E800800000          <1> 	call	disk_read
   574 000059F8 7248                <1> 	jc	short loc_validate_hd_fs_partition_retn
   575                              <1> 	; EDI will not be changed
   576 000059FA 89DE                <1> 	mov	esi, ebx
   577                              <1> use_hdfs_mat_sector_params:
   578 000059FC 8B460C              <1> 	mov	eax, [esi+FS_MAT_DATLocation]
   579 000059FF 894714              <1> 	mov	[edi+LD_FS_DATLocation], eax
   580 00005A02 8B4610              <1> 	mov	eax, [esi+FS_MAT_DATScount]
   581 00005A05 894718              <1> 	mov	[edi+LD_FS_DATSectors], eax
   582 00005A08 8B4614              <1> 	mov	eax, [esi+FS_MAT_FreeSectors]
   583 00005A0B 894774              <1>         mov     [edi+LD_FS_FreeSectors], eax
   584 00005A0E 8B4618              <1> 	mov	eax, [esi+FS_MAT_FirstFreeSector]
   585 00005A11 894778              <1> 	mov	[edi+LD_FS_FirstFreeSector], eax
   586 00005A14 8B4708              <1> 	mov	eax, [edi+LD_FS_RootDirD]
   587 00005A17 03476C              <1> 	add	eax, [edi+LD_FS_BeginSector]
   588 00005A1A 89FE                <1> 	mov	esi, edi   
   589                              <1> read_hd_fs_RDT_sector:
   590 00005A1C BB[82260100]        <1> 	mov	ebx, DOSBootSectorBuff
   591                              <1> 	;mov	ecx, 1
   592 00005A21 B101                <1> 	mov	cl, 1
   593 00005A23 E8D07F0000          <1> 	call	disk_read
   594 00005A28 7218                <1> 	jc	short loc_validate_hd_fs_partition_retn
   595                              <1> 	; EDI will not be changed
   596 00005A2A 89DE                <1> 	mov	esi, ebx
   597                              <1> use_hdfs_RDT_sector_params:
   598 00005A2C 8B461C              <1> 	mov	eax, [esi+FS_RDT_VolumeSerialNo]
   599 00005A2F 894728              <1> 	mov	[edi+LD_FS_VolumeSerial], eax
   600 00005A32 57                  <1> 	push	edi
   601                              <1> 	;mov	ecx, 16
   602 00005A33 B110                <1> 	mov	cl, 16
   603 00005A35 83C640              <1> 	add	esi, FS_RDT_VolumeName
   604 00005A38 83C72C              <1> 	add	edi, LD_FS_VolumeName
   605 00005A3B F3A5                <1> 	rep	movsd ; 64 bytes
   606 00005A3D 5E                  <1> 	pop	esi
   607                              <1> 		; Volume Name Reset
   608 00005A3E C6467E06            <1>         mov     byte [esi+LD_FS_MediaChanged], 6
   609                              <1> 	;
   610                              <1>         ;mov	cl, [Last_DOS_DiskNo] 
   611                              <1> 	;add	cl, 'A'
   612                              <1> 	;mov	[esi+LD_FS_Name], cl
   613                              <1> 
   614                              <1> loc_validate_hd_fs_partition_retn:
   615 00005A42 C3                  <1> 	retn
   616                              <1> 
   617                              <1> load_masterboot:
   618                              <1> 	; 10/01/2016 (TRDOS 386 = TRDOS v2.0)
   619                              <1> 	; 2005 - 2011
   620                              <1> 	; input -> DL = drive number
   621 00005A43 B40D                <1> 	mov	ah, 0Dh ; Alternate disk reset
   622 00005A45 E807E2FFFF          <1> 	call	int13h
   623 00005A4A 7301                <1> 	jnc	short pass_reset_error
   624                              <1> harddisk_error:
   625 00005A4C C3                  <1>   	retn
   626                              <1> pass_reset_error:
   627 00005A4D BB[6E220100]        <1> 	mov	ebx, MasterBootBuff
   628 00005A52 66B80102            <1> 	mov	ax, 0201h
   629 00005A56 66B90100            <1> 	mov	cx, 1
   630 00005A5A 30F6                <1> 	xor	dh, dh
   631 00005A5C E8F0E1FFFF          <1>  	call	int13h
   632 00005A61 72E9                <1> 	jc	short harddisk_error
   633                              <1> 	;
   634 00005A63 66813D[6C240100]55- <1> 	cmp	word [MBIDCode], 0AA55h
   634 00005A6B AA                  <1>
   635 00005A6C 7401                <1> 	je	short load_masterboot_ok
   636 00005A6E F9                  <1> 	stc
   637                              <1> load_masterboot_ok:
   638 00005A6F C3                  <1> 	retn
   639                              <1> 
   640                              <1> get_free_FAT_sectors:
   641                              <1> 	; 29/02/2016
   642                              <1> 	; 13/02/2016
   643                              <1> 	; 04/02/2016
   644                              <1> 	; 07/01/2016 (TRDOS 386 = TRDOS v2.0)
   645                              <1> 	; 11/07/2010
   646                              <1> 	; 21/06/2009
   647                              <1> 	; INPUT: ESI = Logical DOS Drive Description Table address
   648                              <1> 	; OUTPUT: STC => Error
   649                              <1>         ;	cf = 0 and EAX = Free FAT sectors
   650                              <1> 	; Also, related parameters and FAT buffer will be reset and updated
   651                              <1> 
   652 00005A70 31C0                <1> 	xor	eax, eax
   653                              <1> 	;mov	[esi+LD_FreeSectors], eax ; Reset
   654                              <1> 	
   655 00005A72 807E0302            <1>         cmp     byte [esi+LD_FATType], 2
   656 00005A76 7650                <1> 	jna	short loc_gfc_get_fat_free_clusters
   657                              <1> 
   658                              <1> 	; 29/02/2016
   659 00005A78 48                  <1> 	dec	eax ; 0FFFFFFFFh
   660 00005A79 89463A              <1> 	mov	[esi+LD_BPB+BPB_Reserved], eax ; Free cluster count (reset)
   661 00005A7C 89463E              <1> 	mov	[esi+LD_BPB+BPB_Reserved+4], eax ; First Free Cluster (reset)
   662 00005A7F 40                  <1> 	inc	eax ; 0
   663                              <1> 	;
   664 00005A80 668B4636            <1> 	mov	ax, [esi+LD_BPB+BPB_FSInfo]
   665 00005A84 03466C              <1> 	add	eax, [esi+LD_StartSector]
   666                              <1> 
   667 00005A87 BB[82260100]        <1> 	mov	ebx, DOSBootSectorBuff
   668 00005A8C B901000000          <1> 	mov	ecx, 1
   669 00005A91 E8627F0000          <1>  	call	disk_read
   670 00005A96 7301                <1> 	jnc	short loc_gfc_check_fsinfo_signs
   671                              <1> retn_gfc_get_fsinfo_sec:
   672 00005A98 C3                  <1> 	retn
   673                              <1> 
   674                              <1> loc_gfc_check_fsinfo_signs:
   675 00005A99 BB[82260100]        <1> 	mov 	ebx, DOSBootSectorBuff ; 13/02/2016
   676 00005A9E 813B52526141        <1>         cmp     dword [ebx], 41615252h
   677 00005AA4 7520                <1> 	jne	short retn_gfc_get_fsinfo_stc
   678                              <1> 	;add	ebx, 484
   679                              <1> 	;cmp	dword [ebx], 61417272h
   680 00005AA6 81BBE4010000727241- <1> 	cmp	dword [ebx+484], 61417272h
   680 00005AAF 61                  <1>
   681 00005AB0 7514                <1> 	jne	short retn_gfc_get_fsinfo_stc
   682                              <1> 	;add	ebx, 4
   683                              <1> 	;mov	eax, [ebx]
   684 00005AB2 8B83E8010000        <1> 	mov	eax, [ebx+488]
   685                              <1> 	; 29/02/2016
   686 00005AB8 89463A              <1> 	mov	[esi+LD_BPB+BPB_Reserved], eax ; Free cluster count
   687 00005ABB 8B93EC010000        <1> 	mov	edx,  [ebx+492] 
   688 00005AC1 89463E              <1> 	mov	[esi+LD_BPB+BPB_Reserved+4], eax ; First Free Cluster
   689                              <1> 	;
   690 00005AC4 EB12                <1> 	jmp	short retn_from_get_free_fat32_clusters
   691                              <1> 
   692                              <1> retn_gfc_get_fsinfo_stc:
   693 00005AC6 F9                  <1> 	stc
   694 00005AC7 C3                  <1> 	retn
   695                              <1> 
   696                              <1> loc_gfc_get_fat_free_clusters:
   697                              <1> 	;mov	eax, 2
   698 00005AC8 B002                <1> 	mov	al, 2
   699                              <1> 	;mov	[FAT_CurrentCluster], eax
   700                              <1> loc_gfc_loop_get_next_cluster:
   701 00005ACA E800500000          <1> 	call	get_next_cluster
   702 00005ACF 730E                <1> 	jnc	short loc_gfc_free_fat_clusters_cont
   703 00005AD1 21C0                <1> 	and	eax, eax
   704 00005AD3 7411                <1> 	jz	short loc_gfc_pass_inc_free_cluster_count
   705                              <1>  
   706                              <1> retn_from_get_free_fat_clusters:
   707 00005AD5 8B4674              <1> 	mov	eax, [esi+LD_FreeSectors] ; Free clusters !
   708                              <1> retn_from_get_free_fat32_clusters:
   709 00005AD8 0FB65E13            <1>         movzx	ebx, byte [esi+LD_BPB+BPB_SecPerClust]
   710 00005ADC F7E3                <1>       	mul	ebx
   711                              <1> 	;mov	[esi+LD_FreeSectors], eax ; Free sectors
   712                              <1> retn_get_free_sectors_calc:
   713 00005ADE C3                  <1> 	retn
   714                              <1> 
   715                              <1> loc_gfc_free_fat_clusters_cont:
   716 00005ADF 09C0                <1> 	or	eax, eax
   717 00005AE1 7503                <1> 	jnz	short loc_gfc_pass_inc_free_cluster_count
   718 00005AE3 FF4674              <1> 	inc	dword [esi+LD_FreeSectors] ; Free clusters !
   719                              <1>    
   720                              <1> loc_gfc_pass_inc_free_cluster_count:
   721                              <1> 	;mov	eax, [FAT_CurrentCluster]
   722 00005AE6 89C8                <1> 	mov	eax, ecx ; [FAT_CurrentCluster]
   723 00005AE8 3B4678              <1> 	cmp	eax, [esi+LD_Clusters]
   724 00005AEB 77E8                <1> 	ja	short retn_from_get_free_fat_clusters
   725 00005AED 40                  <1> 	inc	eax
   726                              <1> 	;mov	[FAT_CurrentCluster], eax
   727 00005AEE EBDA                <1> 	jmp	short loc_gfc_loop_get_next_cluster
   728                              <1> 
   729                              <1> floppy_drv_init:
   730                              <1> 	; 06/07/2016
   731                              <1> 	; 10/01/2016 (TRDOS 386 = TRDOS v2.0)
   732                              <1> 	; 24/07/2011
   733                              <1> 	; 04/07/2009
   734                              <1> 	; INPUT ->
   735                              <1> 	;	DL = Drive number (0,1)
   736                              <1> 	; OUTPUT ->
   737                              <1> 	;	BL = drive name
   738                              <1> 	;	BH = drive number
   739                              <1> 	;	ESI = Logical DOS drv description table
   740                              <1> 	;	EAX = Volume serial number
   741                              <1>  
   742 00005AF0 BE[F8EC0000]        <1> 	mov	esi, fd0_type ; 10/01/2016
   743 00005AF5 BF00010900          <1> 	mov	edi, Logical_DOSDisks
   744 00005AFA 08D2                <1> 	or	dl, dl
   745 00005AFC 7407                <1> 	jz	short loc_drv_init_fd0_fd1
   746 00005AFE 81C700010000        <1> 	add	edi, 100h
   747 00005B04 46                  <1> 	inc	esi ; fd1_type ; 10/01/2016
   748                              <1> loc_drv_init_fd0_fd1:
   749 00005B05 C6477E00            <1> 	mov	byte [edi+LD_MediaChanged], 0
   750 00005B09 803E01              <1> 	cmp	byte [esi], 1 ; type (>0 if it is existing) 
   751                              <1> 		; 4 = 1.44 MB, 80 track, 3 1/2"
   752 00005B0C 7221                <1> 	jb	short read_fd_boot_sector_retn
   753 00005B0E 885702              <1> 	mov	[edi+LD_PhyDrvNo], dl
   754                              <1> read_fd_boot_sector:
   755 00005B11 30F6                <1> 	xor	dh, dh
   756 00005B13 B904000000          <1> 	mov	ecx, 4 ; Retry Count
   757                              <1> read_fd_boot_sector_again:
   758 00005B18 51                  <1> 	push 	ecx
   759                              <1> 	;mov	cx, 1
   760 00005B19 B101                <1> 	mov	cl, 1
   761 00005B1B 66B80102            <1> 	mov	ax, 0201h ; Read 1 sector
   762 00005B1F BB[82260100]        <1> 	mov	ebx, DOSBootSectorBuff
   763 00005B24 E828E1FFFF          <1> 	call	int13h
   764 00005B29 59                  <1> 	pop	ecx
   765 00005B2A 7304                <1> 	jnc	short use_fd_boot_sector_params
   766 00005B2C E2EA                <1> 	loop	read_fd_boot_sector_again
   767                              <1> 
   768                              <1> read_fd_boot_sector_stc_retn:
   769 00005B2E F9                  <1> 	stc
   770                              <1> read_fd_boot_sector_retn:
   771 00005B2F C3                  <1> 	retn
   772                              <1> 
   773                              <1> use_fd_boot_sector_params:
   774                              <1> 	;mov	esi, DOSBootSectorBuff
   775 00005B30 89DE                <1> 	mov	esi, ebx
   776 00005B32 6681BEFE01000055AA  <1> 	cmp	word [esi+BS_Validation], 0AA55h
   777 00005B3B 75F1                <1> 	jne	short read_fd_boot_sector_stc_retn
   778 00005B3D 66817E035346        <1>         cmp     word [esi+bs_FS_Identifier], 'SF'
   779 00005B43 0F85A2000000        <1>         jne     use_fd_fatfs_boot_sector_params
   780                              <1> 	;
   781 00005B49 8A462D              <1> 	mov	al, [esi+bs_FS_LBA_Ready]
   782 00005B4C 884705              <1> 	mov	[edi+LD_FS_LBAYes], al
   783                              <1> 	;
   784                              <1> 	; 03/01/2010 CHS -> DOS FAT/BPB compatibility fix
   785 00005B4F 8A4608              <1> 	mov	al, [esi+bs_FS_MediaAttrib]
   786 00005B52 884706              <1> 	mov	[edi+LD_FS_MediaAttrib], al
   787                              <1> 	;
   788 00005B55 8A460A              <1>         mov	al, [esi+bs_FS_VersionMaj]
   789 00005B58 884707              <1> 	mov	byte [edi+LD_FS_VersionMajor], al
   790 00005B5B 668B4606            <1> 	mov	ax, [esi+bs_FS_BytesPerSec]
   791 00005B5F 66894711            <1> 	mov	[edi+LD_FS_BytesPerSec], ax
   792 00005B63 8A462E              <1> 	mov	al, [esi+bs_FS_SecPerTrack]
   793 00005B66 6698                <1> 	cbw
   794 00005B68 6689471E            <1> 	mov	[edi+LD_FS_SecPerTrack], ax
   795 00005B6C 8A462F              <1> 	mov	al, [esi+bs_FS_Heads]
   796                              <1> 	;cbw
   797 00005B6F 66894720            <1> 	mov	[edi+LD_FS_NumHeads], ax
   798                              <1> 	;
   799 00005B73 8B4628              <1> 	mov	eax, [esi+bs_FS_UnDelDirD]
   800 00005B76 894722              <1> 	mov	[edi+LD_FS_UnDelDirD], eax
   801 00005B79 8B4618              <1> 	mov	eax, [esi+bs_FS_MATLocation]
   802 00005B7C 89470C              <1> 	mov	[edi+LD_FS_MATLocation], eax
   803 00005B7F 8B461C              <1> 	mov	eax, [esi+bs_FS_RootDirD]
   804 00005B82 894708              <1> 	mov	[edi+LD_FS_RootDirD], eax
   805 00005B85 8B460C              <1> 	mov	eax, [esi+bs_FS_BeginSector]
   806 00005B88 89476C              <1> 	mov	[edi+LD_FS_BeginSector], eax
   807 00005B8B 8B4610              <1> 	mov	eax, [esi+bs_FS_VolumeSize]
   808 00005B8E 894770              <1> 	mov	[edi+LD_FS_VolumeSize], eax
   809                              <1> 	;		
   810 00005B91 89FE                <1> 	mov	esi, edi
   811 00005B93 8B460C              <1>  	mov	eax, [esi+LD_FS_MATLocation]
   812                              <1> 	;add	eax, [edi+LD_FS_BeginSector]
   813                              <1> read_fd_MAT_sector_again:
   814                              <1> 	;mov	ebx, DOSBootSectorBuff
   815                              <1> 	;mov	ecx, 1
   816 00005B96 B101                <1> 	mov	cl, 1
   817 00005B98 E8617E0000          <1> 	call	chs_read
   818 00005B9D 89DE                <1> 	mov	esi, ebx
   819 00005B9F 7301                <1> 	jnc	short use_fdfs_mat_sector_params
   820                              <1> 	;jmp	short read_fd_boot_sector_retn
   821 00005BA1 C3                  <1> 	retn
   822                              <1> use_fdfs_mat_sector_params:
   823 00005BA2 8B460C              <1> 	mov	eax, [esi+FS_MAT_DATLocation]
   824 00005BA5 894714              <1> 	mov	[edi+LD_FS_DATLocation], eax
   825 00005BA8 8B4610              <1> 	mov	eax, [esi+FS_MAT_DATScount]
   826 00005BAB 894718              <1> 	mov	[edi+LD_FS_DATSectors], eax
   827 00005BAE 8B4714              <1> 	mov	eax, [edi+FS_MAT_FreeSectors]
   828 00005BB1 894774              <1> 	mov	[edi+LD_FS_FreeSectors], eax
   829 00005BB4 8B4618              <1> 	mov	eax, [esi+FS_MAT_FirstFreeSector]
   830 00005BB7 894778              <1> 	mov	[edi+LD_FS_FirstFreeSector], eax
   831                              <1> 	;
   832 00005BBA 89FE                <1> 	mov	esi, edi
   833 00005BBC 8B4608              <1>  	mov	eax, [esi+LD_FS_RootDirD]
   834                              <1> read_fd_RDT_sector_again:
   835                              <1> 	;mov	ebx, DOSBootSectorBuff
   836                              <1> 	;mov	cx, 1
   837 00005BBF B101                <1> 	mov	cl, 1
   838 00005BC1 E8387E0000          <1> 	call	chs_read
   839 00005BC6 89DE                <1> 	mov	esi, ebx
   840 00005BC8 7220                <1> 	jc	short read_fd_RDT_sector_retn
   841                              <1> use_fdfs_RDT_sector_params:
   842 00005BCA 8B461C              <1> 	mov	eax, [esi+FS_RDT_VolumeSerialNo]
   843 00005BCD 894728              <1> 	mov	[edi+LD_FS_VolumeSerial], eax
   844 00005BD0 57                  <1> 	push	edi
   845                              <1> 	;mov	ecx, 16
   846 00005BD1 B110                <1> 	mov	cl, 16	
   847 00005BD3 83C640              <1> 	add	esi, FS_RDT_VolumeName
   848 00005BD6 83C72C              <1> 	add	edi, LD_FS_VolumeName
   849 00005BD9 F3A5                <1> 	rep	movsd ; 64 bytes
   850 00005BDB 5E                  <1> 	pop	esi
   851 00005BDC C6460300            <1> 	mov	byte [esi+LD_FATType], 0
   852 00005BE0 C64604A1            <1> 	mov	byte [esi+LD_FSType], 0A1h  
   853 00005BE4 E9A5000000          <1>         jmp     loc_cont_use_fd_boot_sector_params
   854                              <1> 
   855                              <1> read_fd_RDT_sector_stc_retn:
   856 00005BE9 F9                  <1> 	stc
   857                              <1> read_fd_RDT_sector_retn:
   858 00005BEA C3                  <1> 	retn
   859                              <1> 
   860                              <1> use_fd_fatfs_boot_sector_params:
   861 00005BEB 807E2629            <1> 	cmp	byte [esi+BS_BootSig], 29h
   862 00005BEF 75F8                <1> 	jne	short read_fd_RDT_sector_stc_retn
   863 00005BF1 807E15F0            <1> 	cmp	byte [esi+BPB_Media], 0F0h
   864 00005BF5 72F3                <1> 	jb	short read_fd_RDT_sector_retn
   865 00005BF7 57                  <1> 	push	edi
   866 00005BF8 83C706              <1> 	add	edi, LD_BPB
   867                              <1> 	;mov	ecx, 16
   868 00005BFB B110                <1> 	mov	cl, 16
   869 00005BFD F3A5                <1> 	rep	movsd ; 64 bytes 
   870 00005BFF 5E                  <1> 	pop	esi
   871 00005C00 31C0                <1> 	xor	eax, eax
   872 00005C02 89466C              <1> 	mov	[esi+LD_StartSector], eax ; 0
   873 00005C05 668B461C            <1> 	mov	ax, [esi+LD_BPB+BPB_FATSz16]
   874 00005C09 8A4E16              <1> 	mov	cl, [esi+LD_BPB+BPB_NumFATs] 
   875 00005C0C F7E1                <1>   	mul	ecx
   876                              <1> 	; edx = 0 !
   877 00005C0E 668B5614            <1> 	mov	dx, [esi+LD_BPB+BPB_RsvdSecCnt]
   878 00005C12 66895660            <1> 	mov	[esi+LD_FATBegin], dx
   879                              <1> 	;add	eax, edx
   880 00005C16 6601D0              <1> 	add	ax, dx
   881 00005C19 894664              <1> 	mov	[esi+LD_ROOTBegin], eax
   882 00005C1C 894668              <1> 	mov	[esi+LD_DATABegin], eax 
   883 00005C1F 668B5617            <1> 	mov	dx, [esi+LD_BPB+BPB_RootEntCnt]
   884                              <1> 	;;shl	edx, 5 ; * 32 (Size of a directory entry)
   885                              <1> 	;shl	dx, 5
   886                              <1> 	;;add	edx, 511
   887                              <1> 	;add	dx, 511
   888                              <1> 	;;shr	edx, 9 ; edx = ((edx*32)+511) / 512
   889                              <1> 	;shr	dx, 9
   890 00005C23 6683C20F            <1> 	add	dx, 15 ; 06/07/2016 (+(512/32)-1)
   891 00005C27 66C1EA04            <1> 	shr	dx, 4 ; / 16 (==16 entries per sector)
   892 00005C2B 015668              <1> 	add 	[esi+LD_DATABegin], edx ; + rd sectors
   893                              <1> 	;movzx	eax, word [esi+LD_BPB+BPB_TotalSec16]
   894 00005C2E 668B4619            <1> 	mov	ax, [esi+LD_BPB+BPB_TotalSec16]
   895 00005C32 894670              <1> 	mov	[esi+LD_TotalSectors], eax
   896 00005C35 2B4668              <1> 	sub	eax, [esi+LD_DATABegin]
   897                              <1>   	;movzx	ecx, byte [esi+LD_BPB+BPB_SecPerClust]
   898 00005C38 8A4E13              <1> 	mov	cl, [esi+LD_BPB+BPB_SecPerClust]  
   899 00005C3B 80F901              <1> 	cmp	cl, 1
   900 00005C3E 7605                <1> 	jna	short save_fd_fatfs_cluster_count
   901                              <1> 	;sub	edx, edx
   902 00005C40 6629D2              <1> 	sub	dx, dx ; 0
   903                              <1> 	;sub	dl, dl ; 06/07/2016
   904 00005C43 F7F1                <1> 	div	ecx
   905                              <1> save_fd_fatfs_cluster_count:
   906 00005C45 894678              <1> 	mov	[esi+LD_Clusters], eax
   907                              <1> 
   908                              <1>       ; Maximum Valid Cluster Number = EAX +1
   909                              <1>       ; with 2 reserved clusters= EAX +2
   910                              <1>  
   911                              <1> reset_FAT_buffer_decriptors:
   912 00005C48 29C0                <1> 	sub	eax, eax ; 0  
   913 00005C4A A2[86280100]        <1> 	mov	[FAT_BuffValidData], al ; 0
   914 00005C4F A2[87280100]        <1> 	mov	[FAT_BuffDrvName], al ; 0
   915 00005C54 A3[8A280100]        <1> 	mov	[FAT_BuffSector], eax ; 0
   916                              <1> 
   917                              <1> read_fd_FAT_sectors:
   918 00005C59 BB001C0900          <1>   	mov	ebx, FAT_Buffer
   919 00005C5E 668B4614            <1> 	mov	ax, [esi+LD_BPB+BPB_RsvdSecCnt]
   920                              <1> 	;mov	ecx, 3
   921 00005C62 B103                <1> 	mov	cl, 3 ; 3 sectors
   922 00005C64 E8957D0000          <1> 	call	chs_read
   923 00005C69 7240                <1> 	jc	short read_fd_FAT_sectors_retn
   924                              <1> use_fd_FAT_sectors:
   925 00005C6B 8A4602              <1> 	mov	al, [esi+LD_PhyDrvNo]
   926 00005C6E 0441                <1> 	add	al, 'A' 
   927 00005C70 A2[87280100]        <1> 	mov	[FAT_BuffDrvName], al 
   928 00005C75 C605[86280100]01    <1>  	mov	byte [FAT_BuffValidData], 1
   929 00005C7C E82B000000          <1> 	call	fd_init_calculate_free_clusters
   930 00005C81 7228                <1> 	jc	short read_fd_FAT_sectors_retn
   931                              <1>   
   932                              <1> loc_use_fd_boot_sector_params_FAT:
   933 00005C83 C6460301            <1> 	mov	byte [esi+LD_FATType], 1 ; FAT 12
   934 00005C87 C6460401            <1> 	mov	byte [esi+LD_FSType], 1
   935 00005C8B 8B462D              <1>         mov     eax, [esi+LD_BPB+VolumeID]
   936                              <1> loc_cont_use_fd_boot_sector_params:
   937 00005C8E 8A7E02              <1> 	mov	bh, [esi+LD_PhyDrvNo]
   938 00005C91 887E7D              <1> 	mov	[esi+LD_DParamEntry], bh
   939 00005C94 88FB                <1> 	mov	bl, bh
   940 00005C96 80C341              <1> 	add	bl, 'A'
   941 00005C99 881E                <1> 	mov	byte [esi+LD_Name], bl
   942 00005C9B C6460101            <1> 	mov	byte [esi+LD_DiskType], 1
   943 00005C9F C6460500            <1> 	mov	byte [esi+LD_LBAYes], 0
   944 00005CA3 C6467C00            <1> 	mov	byte [esi+LD_PartitionEntry], 0
   945 00005CA7 C6467E06            <1> 	mov	byte [esi+LD_MediaChanged], 6 ; Volume Name Reset
   946                              <1> 
   947                              <1> read_fd_FAT_sectors_retn:
   948 00005CAB C3                  <1> 	retn   
   949                              <1> 
   950                              <1> fd_init_calculate_free_clusters:
   951                              <1> 	; 10/01/2016 (TRDOS 386 = TRDOS v2.0)
   952                              <1> 	; 04/07/2009
   953                              <1> 	; INPUT ->
   954                              <1> 	;     ESI = Logical DOS drive description table address
   955                              <1> 	; OUTPUT ->
   956                              <1> 	;    [ESI+LD_FreeSectors] will be set
   957                              <1> 	
   958 00005CAC 29C0                <1> 	sub	eax, eax
   959 00005CAE 894674              <1> 	mov	[esi+LD_FreeSectors], eax ; 0
   960 00005CB1 B002                <1> 	mov	al, 2 ; eax = 2
   961                              <1> 
   962                              <1> fd_init_loop_get_next_cluster:
   963 00005CB3 E830000000          <1> 	call	fd_init_get_next_cluster
   964 00005CB8 722D                <1> 	jc	short fd_init_calculate_free_clusters_retn
   965                              <1> 
   966                              <1> fd_init_free_fat_clusters:
   967                              <1> 	;cmp 	eax, 0
   968                              <1> 	;ja	short fd_init_pass_inc_free_cluster_count
   969                              <1> 	;and	eax, eax
   970                              <1> 	;jnz	short fd_init_pass_inc_free_cluster_count
   971 00005CBA 6621C0              <1> 	and	ax, ax
   972 00005CBD 7504                <1> 	jnz	short fd_init_pass_inc_free_cluster_count
   973                              <1> 	;inc	dword [esi+LD_FreeSectors]
   974 00005CBF 66FF4674            <1>         inc	word [esi+LD_FreeSectors]
   975                              <1>     
   976                              <1> fd_init_pass_inc_free_cluster_count:
   977                              <1>   	;mov	eax, [FAT_CurrentCluster]
   978 00005CC3 66A1[82280100]      <1> 	mov	ax, [FAT_CurrentCluster]
   979                              <1> 	;cmp	eax, [esi+LD_Clusters]
   980 00005CC9 663B4678            <1> 	cmp	ax, [esi+LD_Clusters]
   981 00005CCD 7704                <1> 	ja	short short retn_from_fd_init_calculate_free_clusters
   982                              <1> 	;inc	eax
   983 00005CCF 6640                <1> 	inc	ax
   984 00005CD1 EBE0                <1> 	jmp	short fd_init_loop_get_next_cluster
   985                              <1> 
   986                              <1> retn_from_fd_init_calculate_free_clusters:
   987 00005CD3 8A4613              <1>   	mov	al, [esi+LD_BPB+BPB_SecPerClust]
   988 00005CD6 3C01                <1>   	cmp	al, 1
   989 00005CD8 760D                <1> 	jna	short fd_init_calculate_free_clusters_retn
   990                              <1> 	;movzx	eax, al
   991 00005CDA 6698                <1> 	cbw
   992                              <1> 	;mov	ecx, [esi+LD_FreeSectors]
   993 00005CDC 668B4E74            <1> 	mov	cx, [esi+LD_FreeSectors] ; Count of free clusters
   994                              <1>   	;mul	ecx
   995 00005CE0 66F7E1              <1> 	mul	cx
   996                              <1> 	;mov	[esi+LD_FreeSectors], eax
   997 00005CE3 66894674            <1> 	mov	[esi+LD_FreeSectors], ax
   998                              <1> fd_init_calculate_free_clusters_retn:
   999 00005CE7 C3                  <1> 	retn
  1000                              <1> 
  1001                              <1> fd_init_get_next_cluster:
  1002                              <1> 	; 04/02/2016
  1003                              <1> 	; 02/02/2016
  1004                              <1> 	; 10/01/2016 (TRDOS 386 = TRDOS v2.0)
  1005                              <1> 	; 04/07/2009
  1006                              <1> 	; INPUT ->
  1007                              <1> 	;    EAX = Current cluster
  1008                              <1> 	;    ESI = Logical DOS drive description table address
  1009                              <1> 	;    EDX = 0
  1010                              <1> 	; OUTPUT ->
  1011                              <1> 	;    EAX = Next cluster
  1012                              <1> 
  1013 00005CE8 A3[82280100]        <1> 	mov	[FAT_CurrentCluster], eax
  1014                              <1> fd_init_get_next_cluster_readnext:
  1015 00005CED 29D2                <1> 	sub	edx, edx ; 0
  1016 00005CEF BB00040000          <1>   	mov	ebx, 1024 ; 400h
  1017 00005CF4 F7F3                <1>   	div	ebx
  1018                              <1>   	; EAX = Count of 3 FAT sectors
  1019                              <1>   	; EDX = Buffer entry index
  1020 00005CF6 89C1                <1> 	mov	ecx, eax
  1021                              <1> 	;mov	eax, 3
  1022 00005CF8 B003                <1> 	mov	al, 3
  1023 00005CFA F7E2                <1> 	mul	edx ; Multiply by 3
  1024 00005CFC 66D1E8              <1> 	shr	ax, 1 ; Divide by 2
  1025 00005CFF 89C3                <1> 	mov	ebx, eax ; Buffer byte offset
  1026 00005D01 81C3001C0900        <1> 	add	ebx, FAT_Buffer
  1027 00005D07 89C8                <1> 	mov	eax, ecx
  1028                              <1> 	;mov	edx, 3
  1029 00005D09 66BA0300            <1> 	mov	dx, 3
  1030 00005D0D F7E2                <1> 	mul	edx 
  1031                              <1>   	; EAX = FAT Beginning Sector
  1032                              <1> 	; EDX = 0
  1033 00005D0F 8A0E                <1> 	mov	cl, [esi+LD_Name]
  1034                              <1> 	;cmp	byte [FAT_BuffValidData], 0
  1035                              <1> 	;jna	short fd_init_load_FAT_sectors0
  1036 00005D11 3A0D[87280100]      <1> 	cmp	cl, [FAT_BuffDrvName]
  1037 00005D17 751E                <1> 	jne	short fd_init_load_FAT_sectors0
  1038 00005D19 3B05[8A280100]      <1> 	cmp	eax, [FAT_BuffSector]
  1039 00005D1F 751C                <1> 	jne	short fd_init_load_FAT_sectors1
  1040                              <1> 	;mov	eax, [FAT_CurrentCluster]
  1041 00005D21 A0[82280100]        <1> 	mov	al, [FAT_CurrentCluster]
  1042                              <1> 	;shr	eax, 1
  1043 00005D26 D0E8                <1> 	shr	al, 1
  1044 00005D28 668B03              <1> 	mov	ax, [ebx]
  1045 00005D2B 7306                <1>   	jnc	short fd_init_gnc_even
  1046 00005D2D 66C1E804            <1> 	shr	ax, 4
  1047                              <1> fd_init_gnc_clc_retn:
  1048 00005D31 F8                  <1> 	clc
  1049 00005D32 C3                  <1> 	retn
  1050                              <1> 
  1051                              <1> fd_init_gnc_even:
  1052 00005D33 80E40F              <1> 	and	ah, 0Fh
  1053 00005D36 C3                  <1> 	retn
  1054                              <1> 
  1055                              <1> fd_init_load_FAT_sectors0:
  1056 00005D37 880D[87280100]      <1> 	mov 	[FAT_BuffDrvName], cl
  1057                              <1> fd_init_load_FAT_sectors1:
  1058 00005D3D C605[86280100]00    <1> 	mov	byte [FAT_BuffValidData], 0
  1059 00005D44 A3[8A280100]        <1> 	mov	[FAT_BuffSector], eax
  1060 00005D49 034660              <1> 	add	eax, [esi+LD_FATBegin]
  1061 00005D4C BB001C0900          <1>  	mov	ebx, FAT_Buffer
  1062                              <1> 	;movzx	ecx, word [esi+LD_BPB+BPB_FATSz16]
  1063 00005D51 668B4E1C            <1> 	mov	cx, [esi+LD_BPB+BPB_FATSz16]
  1064 00005D55 662B0D[8A280100]    <1> 	sub	cx, [FAT_BuffSector]
  1065                              <1>         ;cmp	ecx, 3
  1066 00005D5C 6683F903            <1> 	cmp	cx, 3
  1067 00005D60 7605                <1> 	jna	short fdinit_pass_fix_sector_count_3
  1068                              <1> 	;mov	ecx, 3
  1069 00005D62 B903000000          <1> 	mov	ecx, 3
  1070                              <1> fdinit_pass_fix_sector_count_3:  
  1071 00005D67 E8927C0000          <1> 	call	chs_read
  1072 00005D6C 730D                <1> 	jnc	short fd_init_FAT_sectors_no_load_error
  1073 00005D6E C605[86280100]00    <1> 	mov	byte [FAT_BuffValidData], 0
  1074                              <1> 		; Drv not ready or read Error !
  1075 00005D75 B80F000000          <1> 	mov	eax, ERR_DRV_NOT_RDY ; 15
  1076                              <1> 	;xor	edx, edx
  1077 00005D7A C3                  <1> 	retn
  1078                              <1> 
  1079                              <1> fd_init_FAT_sectors_no_load_error:
  1080 00005D7B C605[86280100]01    <1> 	mov	byte [FAT_BuffValidData], 1
  1081 00005D82 A1[82280100]        <1> 	mov	eax, [FAT_CurrentCluster]
  1082 00005D87 E961FFFFFF          <1>         jmp     fd_init_get_next_cluster_readnext
  1083                              <1> 
  1084                              <1> get_FAT_volume_name:
  1085                              <1> 	; 10/01/2016 (TRDOS 386 = TRDOS v2.0)
  1086                              <1> 	; 12/09/2009
  1087                              <1> 	; INPUT ->
  1088                              <1> 	;	BH = Logical DOS drive number (0,1,2,3,4 ...)
  1089                              <1> 	;       BL = 0
  1090                              <1> 	; OUTPUT ->
  1091                              <1> 	;	CF = 0 -> ESI = Volume name address
  1092                              <1> 	; 	CF = 1 -> Root volume name not found
  1093                              <1> 
  1094                              <1> 	;mov 	ah, 0FFh
  1095                              <1> 	;mov 	al, [Last_Dos_DiskNo]
  1096                              <1> 	;cmp 	al, bh
  1097                              <1> 	;jb     short loc_gfvn_dir_load_err
  1098                              <1> 
  1099 00005D8C 89DE                <1> 	mov	esi, ebx
  1100 00005D8E 81E600FF0000        <1> 	and	esi, 0FF00h ; esi = bh
  1101 00005D94 81C600010900        <1> 	add	esi, Logical_DOSDisks
  1102 00005D9A 8A06                <1> 	mov     al, [esi+LD_Name]
  1103 00005D9C 8A6603              <1> 	mov     ah, [esi+LD_FATType]
  1104 00005D9F 80FC01              <1> 	cmp     ah, 1
  1105 00005DA2 7210                <1> 	jb    	short loc_gfvn_dir_load_err
  1106 00005DA4 3C41                <1> 	cmp 	al, 'A'
  1107 00005DA6 720C                <1> 	jb      short loc_gfvn_dir_load_err
  1108 00005DA8 80FC02              <1> 	cmp 	ah, 2 
  1109 00005DAB 7708                <1> 	ja      short get_FAT32_root_cluster
  1110                              <1> 	
  1111 00005DAD E8784E0000          <1> 	call    load_FAT_root_directory
  1112 00005DB2 730B                <1> 	jnc     short loc_get_volume_name
  1113                              <1> 
  1114                              <1> loc_gfvn_dir_load_err:
  1115 00005DB4 C3                  <1> 	retn
  1116                              <1> 
  1117                              <1> get_FAT32_root_cluster:
  1118 00005DB5 8B4632              <1> 	mov	eax, [esi+LD_BPB+BPB_RootClus]
  1119 00005DB8 E8F84E0000          <1> 	call    load_FAT_sub_directory
  1120 00005DBD 7224                <1> 	jc	short loc_get_volume_name_retn
  1121                              <1> 
  1122                              <1> loc_get_volume_name:
  1123 00005DBF BE00000800          <1>         mov     esi, Directory_Buffer
  1124 00005DC4 6631C9              <1> 	xor	cx, cx ; 0
  1125                              <1> check_root_volume_name:
  1126 00005DC7 8A06                <1> 	mov	al, [esi]
  1127 00005DC9 08C0                <1> 	or      al, al
  1128 00005DCB 7416                <1> 	jz      short loc_get_volume_name_retn
  1129 00005DCD 807E0B08            <1> 	cmp     byte [esi+0Bh], 08h
  1130 00005DD1 7410                <1> 	je      short loc_get_volume_name_retn
  1131 00005DD3 663B0D[9B280100]    <1> 	cmp     cx, [DirBuff_LastEntry]
  1132 00005DDA 7308                <1> 	jnb     short pass_check_root_volume_name
  1133 00005DDC 6641                <1> 	inc     cx
  1134 00005DDE 83C620              <1> 	add     esi, 32
  1135 00005DE1 EBE4                <1> 	jmp     short check_root_volume_name
  1136                              <1> 
  1137                              <1> loc_get_volume_name_retn:
  1138 00005DE3 C3                  <1> 	retn
  1139                              <1>     
  1140                              <1> pass_check_root_volume_name:
  1141 00005DE4 803D[97280100]03    <1> 	cmp	byte [DirBuff_FATType], 3
  1142 00005DEB 7230                <1> 	jb	short loc_get_volume_name_retn_xor
  1143                              <1> 
  1144 00005DED BB001C0900          <1> 	mov	ebx, FAT_Buffer
  1145 00005DF2 BE00010900          <1> 	mov	esi, Logical_DOSDisks
  1146 00005DF7 31C0                <1> 	xor	eax, eax
  1147 00005DF9 8A25[96280100]      <1> 	mov	ah, [DirBuff_DRV]
  1148 00005DFF 80EC41              <1> 	sub	ah, 'A' 
  1149 00005E02 01C6                <1> 	add	esi, eax
  1150 00005E04 A1[9D280100]        <1> 	mov	eax, [DirBuff_Cluster]
  1151 00005E09 E8C14C0000          <1> 	call	get_next_cluster
  1152 00005E0E 7305                <1> 	jnc 	short loc_gfvn_load_FAT32_dir_cluster
  1153                              <1>   	
  1154 00005E10 83F801              <1> 	cmp     eax, 1
  1155 00005E13 F5                  <1> 	cmc
  1156 00005E14 C3                  <1> 	retn
  1157                              <1>   
  1158                              <1> loc_gfvn_load_FAT32_dir_cluster:
  1159 00005E15 E89B4E0000          <1> 	call	load_FAT_sub_directory
  1160 00005E1A 73A3                <1> 	jnc	short loc_get_volume_name
  1161 00005E1C C3                  <1> 	retn
  1162                              <1> 
  1163                              <1> loc_get_volume_name_retn_xor:
  1164 00005E1D 31C0                <1> 	xor 	eax, eax
  1165 00005E1F C3                  <1> 	retn
  1166                              <1> 
  1167                              <1> get_media_change_status:
  1168                              <1> 	; 10/01/2016 (TRDOS 386 = TRDOS v2.0)
  1169                              <1> 	; 09/09/2009
  1170                              <1> 	; INPUT:
  1171                              <1> 	;     DL = Drive number (physical)
  1172                              <1> 	; OUTPUT: clc & AH = 6 media changed
  1173                              <1> 	;     clc & AH = 0 media not changed         
  1174                              <1> 	;     stc -> Drive not ready or an error 
  1175                              <1>   
  1176 00005E20 B416                <1> 	mov	ah, 16h
  1177 00005E22 E82ADEFFFF          <1>   	call	int13h
  1178 00005E27 80FC06              <1> 	cmp	ah, 06h
  1179 00005E2A 7405                <1> 	je	short loc_gmc_status_retn
  1180 00005E2C 08E4                <1> 	or	ah, ah
  1181 00005E2E 7401                <1> 	jz	short loc_gmc_status_retn
  1182                              <1> loc_gmc_status_stc_retn:    
  1183 00005E30 F9                  <1> 	stc
  1184                              <1> loc_gmc_status_retn:
  1185 00005E31 C3                  <1> 	retn
  1920                                  %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: 13/05/2016
     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> 	; 02/02/2016
    21                              <1> 	; 15/01/2016 (TRDOS 386 = TRDOS v2.0)
    22                              <1> 	; 18/08/2011
    23                              <1> 	; 09/09/2009
    24                              <1> 	; INPUT:
    25                              <1> 	;   DL = Logical DOS Drive Number
    26                              <1> 	; OUTPUT:
    27                              <1> 	;  cf=1 -> Not successful
    28                              <1> 	;   EAX = Error code
    29                              <1> 	;  cf=0 ->
    30                              <1> 	;   EAX = 0 (successful)
    31                              <1> 
    32 00005E32 31DB                <1> 	xor	ebx, ebx
    33 00005E34 88D7                <1> 	mov	bh, dl
    34                              <1> 
    35                              <1> 	;cmp	dl, 1
    36                              <1> 	;jna	short loc_ccdrv_initial_media_change_check
    37                              <1> 	;cmp	bh, [Last_Dos_DiskNo]
    38                              <1> 	;ja	short loc_ccdrv_drive_not_ready_err
    39                              <1> 
    40                              <1> loc_ccdrv_initial_media_change_check:
    41 00005E36 BE00010900          <1> 	mov	esi, Logical_DOSDisks
    42 00005E3B 01DE                <1> 	add	esi, ebx
    43                              <1> loc_ccdrv_dos_drive_name_check:
    44 00005E3D 80FA02              <1> 	cmp	dl, 2
    45 00005E40 720F                <1> 	jb	short loc_ccdrv_dos_drive_name_check_ok
    46                              <1> 
    47 00005E42 8A06                <1> 	mov	al, [esi+LD_Name]
    48 00005E44 2C41                <1> 	sub	al, 'A'
    49 00005E46 38D0                <1> 	cmp	al, dl
    50 00005E48 7407                <1> 	je	short loc_ccdrv_dos_drive_name_check_ok
    51                              <1> 
    52                              <1> loc_ccdrv_drive_not_ready_err:
    53 00005E4A B815000000          <1> 	mov	eax, 15h ; Drive not ready
    54                              <1> loc_change_current_drive_stc_retn:
    55 00005E4F F9                  <1> 	stc
    56 00005E50 C3                  <1> 	retn  
    57                              <1> 
    58                              <1> loc_ccdrv_dos_drive_name_check_ok:
    59 00005E51 8A667E              <1> 	mov	ah, [esi+LD_MediaChanged]
    60 00005E54 80FC06              <1> 	cmp	ah, 6  ; VOLUME NAME CHECK/MOVE SIGN
    61 00005E57 7450                <1> 	je	short loc_ccdrv_get_FAT_volume_name_0
    62                              <1> 
    63 00005E59 80FA01              <1> 	cmp	dl, 1
    64 00005E5C 7778                <1> 	ja	short loc_gmcs_init_drv_hd
    65                              <1> 
    66                              <1> loc_gmcs_init_drv_fd:
    67 00005E5E 08E4                <1> 	or	ah, ah 
    68                              <1> 	; AH = 1 is initialization sign (invalid_fd_parameter)
    69 00005E60 7517                <1> 	jnz	short loc_ccdrv_call_fd_init
    70                              <1> 
    71 00005E62 E8B9FFFFFF          <1> 	call	get_media_change_status
    72 00005E67 72E1                <1> 	jc	short loc_ccdrv_drive_not_ready_err
    73                              <1> 
    74 00005E69 20E4                <1> 	and	ah, ah
    75 00005E6B 7471                <1> 	jz	short loc_change_current_drv3
    76                              <1> 
    77 00005E6D 80F406              <1> 	xor	ah, 6
    78 00005E70 75D8                <1> 	jnz	short loc_ccdrv_drive_not_ready_err
    79                              <1> 
    80                              <1> loc_ccdrv_call_fd_init_check_vol_id:
    81 00005E72 E8440A0000          <1> 	call	get_volume_serial_number
    82 00005E77 7308                <1> 	jnc	short loc_ccdrv_check_vol_serial
    83                              <1> 
    84                              <1> loc_ccdrv_call_fd_init:
    85 00005E79 E872FCFFFF          <1> 	call	floppy_drv_init
    86 00005E7E 7315                <1> 	jnc	short loc_reset_drv_fd_current_dir
    87                              <1> 
    88                              <1> loc_ccdrv_fdinit_fail_retn:
    89 00005E80 C3                  <1> 	retn
    90                              <1> 
    91                              <1> loc_ccdrv_check_vol_serial:
    92 00005E81 A3[64200100]        <1> 	mov	[Current_VolSerial], eax
    93                              <1> 	;mov	dl, bh
    94 00005E86 E865FCFFFF          <1> 	call	floppy_drv_init
    95 00005E8B 72F3                <1> 	jc	short loc_ccdrv_fdinit_fail_retn
    96                              <1> 
    97 00005E8D 3B05[64200100]      <1> 	cmp	eax, [Current_VolSerial]
    98 00005E93 7445                <1> 	je	short loc_change_current_drv2
    99                              <1> 
   100                              <1> loc_reset_drv_fd_current_dir:
   101 00005E95 31C0                <1> 	xor	eax, eax              
   102 00005E97 88467F              <1>         mov	[esi+LD_CDirLevel], al
   103 00005E9A 89F7                <1> 	mov	edi, esi
   104 00005E9C 81C780000000        <1> 	add	edi, LD_CurrentDirectory
   105 00005EA2 B920000000          <1> 	mov	ecx, 32
   106 00005EA7 F3AB                <1> 	rep	stosd   
   107                              <1>  
   108                              <1> loc_ccdrv_get_FAT_volume_name_0:
   109 00005EA9 8A4603              <1> 	mov	al, [esi+LD_FATType]
   110 00005EAC 08C0                <1> 	or	al, al
   111 00005EAE 742A                <1> 	jz	short loc_change_current_drv2
   112                              <1> 
   113 00005EB0 56                  <1> 	push	esi 
   114 00005EB1 3C02                <1> 	cmp	al, 2
   115 00005EB3 7705                <1> 	ja	short loc_ccdrv_get_FAT32_vol_name
   116                              <1>              
   117                              <1> loc_ccdrv_get_FAT2_16_vol_name:
   118 00005EB5 83C631              <1> 	add	esi, LD_BPB + VolumeLabel
   119 00005EB8 EB03                <1> 	jmp	short loc_ccdrv_get_FAT_volume_name_1
   120                              <1> 
   121                              <1> loc_ccdrv_get_FAT32_vol_name:
   122 00005EBA 83C64D              <1> 	add	esi, LD_BPB + FAT32_VolLab
   123                              <1> loc_ccdrv_get_FAT_volume_name_1:
   124 00005EBD 53                  <1> 	push	ebx
   125 00005EBE 56                  <1> 	push	esi
   126 00005EBF E8C8FEFFFF          <1> 	call	get_FAT_volume_name
   127 00005EC4 5F                  <1> 	pop	edi
   128 00005EC5 5B                  <1> 	pop	ebx
   129                              <1> 	; BL = 0
   130 00005EC6 720B                <1> 	jc	short loc_change_current_drv1
   131 00005EC8 20C0                <1> 	and	al, al
   132 00005ECA 7407                <1> 	jz	short loc_change_current_drv1
   133                              <1> 
   134                              <1> loc_ccdrv_move_FAT_volume_name:
   135 00005ECC B90B000000          <1> 	mov	ecx, 11
   136 00005ED1 F3A4                <1> 	rep	movsb
   137                              <1> 
   138                              <1> loc_change_current_drv1:
   139 00005ED3 5E                  <1> 	pop	esi
   140 00005ED4 EB04                <1> 	jmp	short loc_change_current_drv2
   141                              <1> 
   142                              <1> loc_gmcs_init_drv_hd:
   143 00005ED6 08E4                <1> 	or	ah, ah
   144 00005ED8 7404                <1> 	jz	short loc_change_current_drv3
   145                              <1> 	; BL = 0, BH = Logical DOS drive number
   146                              <1> loc_change_current_drv2:
   147 00005EDA C6467E00            <1> 	mov	byte [esi+LD_MediaChanged], 0
   148                              <1> loc_change_current_drv3:
   149 00005EDE 883D[6E200100]      <1> 	mov	[Current_Drv], bh
   150                              <1> 
   151                              <1> 	;call	restore_current_directory
   152                              <1> 	;retn
   153                              <1> 
   154                              <1> restore_current_directory:
   155                              <1> 	; 11/02/2016
   156                              <1> 	; 15/01/2016 (TRDOS 386 = TRDOS v2.0)
   157                              <1> 	; 25/01/2010
   158                              <1> 	; 12/10/2009
   159                              <1> 	;
   160                              <1> 	; INPUT:
   161                              <1> 	;   ESI = Logical DOS Drive Description Table
   162                              <1> 	;
   163                              <1> 	; OUTPUT:
   164                              <1> 	;   ESI = Logical DOS Drive Description Table
   165                              <1> 	;   EDI = offset Current_Dir_Drv 
   166                              <1> 
   167 00005EE4 8A4603              <1> 	mov	al, [esi+LD_FATType]
   168 00005EE7 A2[6D200100]        <1> 	mov	[Current_FATType], al
   169                              <1> 
   170 00005EEC 8A26                <1> 	mov	ah, [esi+LD_Name] 
   171 00005EEE 8825[6F200100]      <1> 	mov	[Current_Dir_Drv], ah
   172                              <1> 
   173 00005EF4 20C0                <1> 	and	al, al
   174 00005EF6 741D                <1> 	jz	short loc_restore_FS_current_directory
   175                              <1> 
   176                              <1> loc_restore_FAT_current_directory:
   177 00005EF8 8A667F              <1> 	mov	ah, [esi+LD_CDirLevel]
   178 00005EFB 8825[6C200100]      <1> 	mov	[Current_Dir_Level], ah
   179 00005F01 08E4                <1> 	or	ah, ah
   180 00005F03 7416                <1>         jz	short loc_ccdrv_reset_cdir_FAT_12_16_32_fcluster
   181                              <1> 
   182 00005F05 0FB6D4              <1> 	movzx	edx, ah
   183 00005F08 C0E204              <1> 	shl	dl, 4 ; * 16
   184 00005F0B 01F2                <1>         add	edx, esi
   185 00005F0D 8B828C000000        <1> 	mov	eax, [edx+LD_CurrentDirectory+12]
   186 00005F13 EB2C                <1> 	jmp	short loc_ccdrv_reset_cdir_FAT_fcluster
   187                              <1> 
   188                              <1> loc_restore_FS_current_directory:
   189 00005F15 E8D64D0000          <1> 	call	load_current_FS_directory 
   190 00005F1A C3                  <1> 	retn 
   191                              <1> 
   192                              <1> loc_ccdrv_reset_cdir_FAT_12_16_32_fcluster:
   193 00005F1B 3C03                <1> 	cmp	al, 3
   194 00005F1D 7205                <1> 	jb	short loc_ccdrv_reset_cdir_FAT_12_16_fcluster
   195                              <1> loc_ccdrv_reset_cdir_FAT32_fcluster:
   196 00005F1F 8B4632              <1> 	mov	eax, [esi+LD_BPB+FAT32_RootFClust]
   197 00005F22 EB04                <1> 	jmp	short loc_ccdrv_check_rootdir_sign
   198                              <1> loc_ccdrv_reset_cdir_FAT_12_16_fcluster:   
   199 00005F24 30C0                <1> 	xor	al, al  ; xor eax, eax
   200 00005F26 31D2                <1> 	xor	edx, edx
   201                              <1> loc_ccdrv_check_rootdir_sign:
   202 00005F28 80BE8000000000      <1> 	cmp	byte [esi+LD_CurrentDirectory], 0
   203 00005F2F 7510                <1> 	jne	short loc_ccdrv_reset_cdir_FAT_fcluster
   204                              <1> loc_ccdrv_set_rootdir_FAT_fcluster:
   205 00005F31 89868C000000        <1>         mov     [esi+LD_CurrentDirectory+12], eax
   206 00005F37 C78680000000524F4F- <1> 	mov	dword [esi+LD_CurrentDirectory], 'ROOT'
   206 00005F40 54                  <1>
   207                              <1> 
   208                              <1> loc_ccdrv_reset_cdir_FAT_fcluster:
   209 00005F41 A3[68200100]        <1> 	mov	[Current_Dir_FCluster], eax
   210                              <1> 
   211 00005F46 BF[CF280100]        <1> 	mov	edi, PATH_Array
   212 00005F4B 89F2                <1> 	mov	edx, esi
   213 00005F4D 81C680000000        <1> 	add	esi, LD_CurrentDirectory
   214 00005F53 B920000000          <1> 	mov	ecx, 32
   215 00005F58 F3A5                <1> 	rep	movsd
   216                              <1> 
   217 00005F5A E8852D0000          <1> 	call	change_prompt_dir_string
   218                              <1> 	
   219 00005F5F 89D6                <1> 	mov	esi, edx
   220                              <1> 	
   221 00005F61 29C0                <1>         sub	eax, eax
   222                              <1>        ;sub	edx, edx
   223 00005F63 BF[6F200100]        <1> 	mov	edi, Current_Dir_Drv
   224                              <1> 
   225 00005F68 A2[E4DD0000]        <1> 	mov	[Restore_CDIR], al ; 0
   226 00005F6D C3                  <1> 	retn
   227                              <1> 
   228                              <1> dos_prompt:
   229                              <1> 	; 06/05/2016
   230                              <1> 	; 30/01/2016
   231                              <1> 	; 29/01/2016
   232                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
   233                              <1> 	; 15/09/2011
   234                              <1> 	; 13/09/2009
   235                              <1> 	; 2004-2005
   236                              <1> 
   237                              <1> 	; 06/05/2016
   238 00005F6E C705[1C2D0100]-     <1> 	mov	dword [mainprog_return_addr], return_from_command_intepreter
   238 00005F74 [22600000]          <1>
   239                              <1> 
   240                              <1> loc_TRDOS_prompt:
   241 00005F78 BF[6E210100]        <1> 	mov	edi, TextBuffer
   242 00005F7D C6075B              <1> 	mov	byte [edi], "["
   243 00005F80 47                  <1> 	inc	edi
   244 00005F81 BE[37DE0000]        <1> 	mov	esi, TRDOSPromptLabel
   245                              <1> get_next_prompt_label_char:
   246 00005F86 803E20              <1> 	cmp	byte [esi], 20h
   247 00005F89 7203                <1> 	jb	short pass_prompt_label
   248 00005F8B A4                  <1> 	movsb
   249 00005F8C EBF8                <1> 	jmp	short get_next_prompt_label_char
   250                              <1> pass_prompt_label:
   251 00005F8E C6075D              <1> 	mov	byte [edi], "]"
   252 00005F91 47                  <1> 	inc	edi
   253 00005F92 C60720              <1> 	mov	byte [edi], 20h
   254 00005F95 47                  <1> 	inc	edi
   255 00005F96 BE[6F200100]        <1> 	mov	esi, Current_Dir_Drv
   256 00005F9B 66A5                <1> 	movsw
   257 00005F9D A4                  <1> 	movsb 
   258                              <1> loc_prompt_current_directory:
   259 00005F9E 803E20              <1> 	cmp	byte [esi], 20h
   260 00005FA1 7203                <1> 	jb	short pass_prompt_current_directory
   261 00005FA3 A4                  <1> 	movsb
   262 00005FA4 EBF8                <1> 	jmp	short loc_prompt_current_directory  
   263                              <1> pass_prompt_current_directory:
   264 00005FA6 C6073E              <1> 	mov	byte [edi], '>'
   265 00005FA9 47                  <1> 	inc	edi
   266 00005FAA C60700              <1> 	mov	byte [edi], 0  
   267 00005FAD BE[6E210100]        <1> 	mov	esi, TextBuffer
   268 00005FB2 E87BF5FFFF          <1> 	call	print_msg
   269                              <1>         
   270                              <1> 	;sub	bh, bh ; video page = 0
   271                              <1> 	;call	get_cpos ; get cursor position
   272 00005FB7 668B15[C61F0100]    <1> 	mov	dx, [CURSOR_POSN] ; video page 0
   273 00005FBE 8815[CE200100]      <1> 	mov	[CursorColumn], dl
   274                              <1> 
   275                              <1> 	; 30/01/2016 (to show cursor on the row, again)
   276                              <1> 	; (Initial color attributes of video page 0 is 0)
   277                              <1> 	; (see: 'StartPMP' in trdos386.s)
   278                              <1> 	; 
   279                              <1> 	;mov	edi, 0B8000h ; start of video page 0
   280                              <1> 	;movzx	ecx, dl ; column	 
   281                              <1> 	;mov	al, 80
   282                              <1> 	;mul	dh
   283                              <1> 	;add	ax, cx
   284                              <1> 	;shl	ax, 1 ; character + attribute
   285                              <1> 	;add	di, ax ; (2*80*row) + (2*column)
   286                              <1> 	;neg	cl
   287                              <1> 	;add	cl, 80
   288                              <1> 	;mov	ax, 700h ;  ah = 7 (color attribute)
   289                              <1> 	;rep	stosw	
   290                              <1> 
   291                              <1> loc_rw_char:
   292 00005FC4 E899000000          <1> 	call	rw_char
   293                              <1> loc_move_command:
   294 00005FC9 BE[1E210100]        <1> 	mov	esi, CommandBuffer
   295 00005FCE 89F7                <1> 	mov	edi, esi
   296 00005FD0 31C9                <1> 	xor	ecx, ecx
   297                              <1> first_command_char:
   298 00005FD2 AC                  <1> 	lodsb
   299 00005FD3 3C20                <1> 	cmp	al, 20h
   300 00005FD5 772E                <1> 	ja	short pass_space_control
   301 00005FD7 7241                <1> 	jb	short loc_move_cmd_arguments_ok
   302 00005FD9 81FE[6D210100]      <1> 	cmp	esi, CommandBuffer + 79
   303 00005FDF 72F1                <1> 	jb	short first_command_char
   304 00005FE1 EB37                <1> 	jmp	short loc_move_cmd_arguments_ok
   305                              <1> 
   306                              <1> next_command_char:
   307 00005FE3 AC                  <1> 	lodsb
   308 00005FE4 3C20                <1> 	cmp	al, 20h
   309 00005FE6 771D                <1> 	ja	short pass_space_control
   310 00005FE8 7230                <1> 	jb	short loc_move_cmd_arguments_ok
   311                              <1> 
   312                              <1> loc_1st_cmd_arg: ; 30/01/2016
   313 00005FEA AC                  <1> 	lodsb
   314 00005FEB 3C20                <1> 	cmp	al, 20h
   315 00005FED 74FB                <1> 	je	short loc_1st_cmd_arg
   316 00005FEF 7229                <1> 	jb	short loc_move_cmd_arguments_ok
   317                              <1> 	
   318 00005FF1 C60700              <1>         mov     byte [edi], 0
   319 00005FF4 47                  <1> 	inc	edi
   320                              <1> 
   321                              <1> loc_move_cmd_arguments:
   322 00005FF5 AA                  <1> 	stosb
   323 00005FF6 81FE[6D210100]      <1> 	cmp	esi, CommandBuffer + 79
   324 00005FFC 731C                <1> 	jnb	short loc_move_cmd_arguments_ok
   325 00005FFE AC                  <1>         lodsb
   326 00005FFF 3C20                <1> 	cmp	al, 20h
   327 00006001 73F2                <1> 	jnb	short loc_move_cmd_arguments
   328 00006003 EB15                <1> 	jmp	short loc_move_cmd_arguments_ok
   329                              <1> 
   330                              <1> pass_space_control:
   331 00006005 3C61                <1> 	cmp	al, 61h
   332 00006007 7206                <1> 	jb	short pass_capitalize
   333 00006009 3C7A                <1> 	cmp	al, 7Ah
   334 0000600B 7702                <1> 	ja	short pass_capitalize
   335 0000600D 24DF                <1> 	and	al, 0DFh
   336                              <1> pass_capitalize:
   337 0000600F AA                  <1> 	stosb   
   338 00006010 FEC1                <1> 	inc     cl
   339 00006012 81FE[6D210100]      <1>         cmp     esi, CommandBuffer + 79
   340 00006018 72C9                <1> 	jb      short next_command_char 
   341                              <1> 
   342                              <1> loc_move_cmd_arguments_ok:
   343 0000601A C60700              <1>         mov     byte [edi], 0
   344                              <1>        
   345                              <1> call_command_intepreter:
   346 0000601D E8D4080000          <1> 	call    command_interpreter
   347                              <1> 
   348                              <1> return_from_command_intepreter:
   349 00006022 B950000000          <1>         mov	ecx, 80
   350                              <1> 	;mov	cx, 80
   351 00006027 BF[1E210100]        <1> 	mov	edi, CommandBuffer
   352 0000602C 30C0                <1> 	xor	al, al
   353 0000602E F3AA                <1> 	rep	stosb
   354                              <1> 	;cmp	byte [Program_Exit], 0
   355                              <1> 	;ja	short loc_terminate_trdos
   356                              <1>         
   357                              <1> 	; 16/01/2016
   358 00006030 803D[E6E80000]03    <1> 	cmp	byte [CRT_MODE], 3 ; 80*25 color
   359 00006037 741D                <1> 	je	short pass_set_txt_mode
   360                              <1> 
   361 00006039 E8D0B3FFFF          <1> 	call	set_txt_mode ; set vide mode to 03h
   362                              <1> 
   363                              <1> loc_check_active_page:
   364 0000603E 30C0                <1> 	xor	al, al
   365 00006040 3805[D61F0100]      <1> 	cmp	[ACTIVE_PAGE], al ; 0
   366 00006046 0F842CFFFFFF        <1>         je      loc_TRDOS_prompt 
   367                              <1> 	; AL = 0 = video page 0
   368 0000604C E895B7FFFF          <1> 	call	set_active_page
   369 00006051 E922FFFFFF          <1>         jmp     loc_TRDOS_prompt ; infinitive loop
   370                              <1> 
   371                              <1> pass_set_txt_mode: 
   372 00006056 BE[8BEE0000]        <1> 	mov	esi, nextline
   373 0000605B E8D2F4FFFF          <1> 	call	print_msg
   374 00006060 EBDC                <1> 	jmp     short loc_check_active_page
   375                              <1> 
   376                              <1> rw_char:
   377                              <1> 	; 13/05/2016
   378                              <1> 	; 30/01/2016
   379                              <1> 	; 29/01/2016
   380                              <1> 	; 17/01/2016 (TRDOS 386 = TRDOS v2.0)
   381                              <1> 	; 2004-2005
   382                              <1> 	
   383                              <1> 	; DH = cursor row, DL = cursor column
   384                              <1> 	; BH = 0 = video page number (active page)
   385                              <1> 
   386                              <1> 	;xor	bh, bh ; 0 = video page 0
   387                              <1> 
   388                              <1> readnextchar:
   389 00006062 30E4                <1> 	xor     ah, ah
   390 00006064 E863AAFFFF          <1> 	call	int16h
   391 00006069 20C0                <1> 	and	al, al
   392 0000606B 7434                <1> 	jz	short loc_arrow    
   393 0000606D 3CE0                <1> 	cmp	al, 0E0h          
   394 0000606F 7430                <1> 	je	short loc_arrow
   395 00006071 3C08                <1> 	cmp	al, 08h             
   396 00006073 7544                <1> 	jne	short char_return
   397                              <1> loc_back:
   398 00006075 3A15[CE200100]      <1> 	cmp	dl, [CursorColumn]
   399 0000607B 76E5                <1> 	jna     short readnextchar
   400                              <1> prev_column:
   401 0000607D FECA                <1> 	dec	dl
   402                              <1> set_cursor_pos:
   403 0000607F 6652                <1> 	push	dx
   404                              <1> 	;xor	bh, bh ; 0 = video page 0
   405                              <1> 	; DH = Row, DL = Column
   406 00006081 E82CBBFFFF          <1> 	call	_set_cpos ; 17/01/2016
   407 00006086 665A                <1>         pop	dx
   408                              <1> 	;movzx	ebx, dl
   409 00006088 88D3                <1> 	mov	bl, dl
   410 0000608A 2A1D[CE200100]      <1> 	sub	bl, [CursorColumn] 
   411 00006090 B020                <1> 	mov	al, 20h
   412 00006092 8883[1E210100]      <1> 	mov	[CommandBuffer+ebx], al
   413                              <1> 	;sub	bh, bh ; video page 0
   414                              <1> 	;mov	cx, 1
   415 00006098 B307                <1> 	mov	bl, 7 ; color attribute
   416 0000609A E804BAFFFF          <1> 	call	_write_c_current ; 17/01/2016
   417                              <1> 	;mov	dx, [CURSOR_POSN]
   418 0000609F EBC1                <1> 	jmp	short readnextchar
   419                              <1> loc_arrow:    
   420 000060A1 80FC4B              <1> 	cmp	ah, 4Bh
   421 000060A4 74CF                <1> 	je	short loc_back
   422 000060A6 80FC53              <1> 	cmp	ah, 53h
   423 000060A9 74CA                <1> 	je      short loc_back
   424 000060AB 80FC4D              <1> 	cmp	ah, 4Dh
   425 000060AE 75B2                <1> 	jne	short readnextchar
   426 000060B0 80FA4F              <1> 	cmp	dl, 79
   427 000060B3 73AD                <1> 	jnb	short readnextchar
   428 000060B5 FEC2                <1> 	inc	dl
   429 000060B7 EBC6                <1> 	jmp	short set_cursor_pos
   430                              <1> char_return:
   431 000060B9 0FB6DA              <1> 	movzx	ebx, dl
   432 000060BC 2A1D[CE200100]      <1> 	sub	bl, [CursorColumn] 
   433 000060C2 3C20                <1> 	cmp	al, 20h
   434 000060C4 7220                <1> 	jb	short loc_escape
   435 000060C6 8883[1E210100]      <1> 	mov	[CommandBuffer+ebx], al
   436 000060CC 80FA4F              <1> 	cmp	dl, 79
   437 000060CF 7391                <1> 	jnb	short readnextchar
   438 000060D1 66BB0700            <1> 	mov	bx, 7 ; color attribute
   439 000060D5 E842BAFFFF          <1> 	call	_write_tty
   440 000060DA 668B15[C61F0100]    <1> 	mov	dx, [CURSOR_POSN] ; video page 0
   441 000060E1 E97CFFFFFF          <1>         jmp     readnextchar
   442                              <1> loc_escape:
   443 000060E6 3C1B                <1> 	cmp	al, 1Bh
   444 000060E8 7418                <1> 	je	short rw_char_retn
   445                              <1> 	;
   446 000060EA 3C0D                <1> 	cmp	al, 0Dh ; CR
   447 000060EC 0F8570FFFFFF        <1>         jne     readnextchar
   448                              <1> 	; 13/05/2016
   449 000060F2 66BB0700            <1> 	mov	bx, 7 ; attribute/color (bl)
   450                              <1> 		      ; video page 0 (bh=0)	
   451 000060F6 E821BAFFFF          <1> 	call	_write_tty
   452                              <1> 	;mov	bx, 7  ; attribute/color
   453                              <1> 		      ; video page 0 (bh=0)
   454 000060FB B00A                <1> 	mov	al, 0Ah ; LF
   455 000060FD E81ABAFFFF          <1> 	call	_write_tty
   456                              <1> rw_char_retn:
   457 00006102 C3                  <1> 	retn
   458                              <1> 
   459                              <1> show_date:
   460                              <1> 	; 18/01/2016 (TRDOS 386 = TRDOS v2.0)
   461                              <1>         ; 2004-2005
   462                              <1> 
   463                              <1> 	;mov	ah, 04h
   464                              <1> 	;call	int1Ah
   465 00006103 E854F1FFFF          <1> 	call	RTC_40	; GET RTC DATE
   466                              <1> 
   467 00006108 88D0                <1> 	mov	al, dl
   468 0000610A E8B4A9FFFF          <1>   	call	bcd_to_ascii
   469 0000610F 66A3[2CDF0000]      <1> 	mov	[Day], ax
   470                              <1> 
   471 00006115 88F0                <1> 	mov	al, dh
   472 00006117 E8A7A9FFFF          <1>   	call	bcd_to_ascii
   473 0000611C 66A3[2FDF0000]      <1> 	mov	[Month], ax
   474                              <1> 
   475 00006122 88E8                <1> 	mov	al, ch
   476 00006124 E89AA9FFFF          <1>   	call	bcd_to_ascii
   477 00006129 66A3[32DF0000]      <1> 	mov	[Century], ax
   478                              <1> 
   479 0000612F 88C8                <1> 	mov	al, cl
   480 00006131 E88DA9FFFF          <1>   	call	bcd_to_ascii
   481 00006136 66A3[34DF0000]      <1> 	mov	word [Year], ax
   482                              <1> 
   483 0000613C BE[1CDF0000]        <1> 	mov	esi, Msg_Show_Date
   484 00006141 E8ECF3FFFF          <1> 	call	print_msg
   485                              <1> 
   486 00006146 C3                  <1> 	retn
   487                              <1> 
   488                              <1> set_date:
   489                              <1> 	; 13/05/2016
   490                              <1> 	; 18/01/2016 (TRDOS 386 = TRDOS v2.0)
   491                              <1>         ; 2004-2005
   492                              <1> 
   493 00006147 BE[00DF0000]        <1> 	mov	esi, Msg_Enter_Date
   494 0000614C E8E1F3FFFF          <1> 	call	print_msg
   495                              <1> 
   496                              <1> loc_enter_day_1:
   497 00006151 30E4                <1> 	xor     ah, ah
   498 00006153 E874A9FFFF          <1> 	call	int16h
   499                              <1> 	; AL = ASCII Code of the Character
   500 00006158 3C0D                <1> 	cmp	al, 13
   501 0000615A 0F84B7010000        <1> 	je	loc_set_date_retn
   502 00006160 3C1B                <1> 	cmp	al, 27
   503 00006162 0F84AF010000        <1> 	je	loc_set_date_retn
   504 00006168 A2[2CDF0000]        <1> 	mov	[Day], al
   505 0000616D 3C30                <1> 	cmp	al, '0'
   506 0000616F 0F82AD010000        <1> 	jb	loc_set_date_stc_0
   507 00006175 3C33                <1> 	cmp	al, '3'
   508 00006177 0F87A5010000        <1> 	ja	loc_set_date_stc_0
   509                              <1> 	; 13/05/2016
   510                              <1> 	;mov	bx, 7 ; attribute/color (bl)
   511                              <1> 		      ; video page 0 (bh)	
   512 0000617D B307                <1> 	mov	bl, 7
   513 0000617F E898B9FFFF          <1> 	call	_write_tty
   514                              <1> loc_enter_day_2:
   515 00006184 30E4                <1> 	xor     ah, ah
   516 00006186 E841A9FFFF          <1> 	call	int16h
   517                              <1> 	; AL = ASCII Code of the Character
   518 0000618B 3C1B                <1> 	cmp	al, 27
   519 0000618D 0F8484010000        <1>         je      loc_set_date_retn
   520 00006193 A2[2DDF0000]        <1> 	mov	[Day+1], al
   521 00006198 3C30                <1> 	cmp	al, '0'
   522 0000619A 0F828C010000        <1>         jb      loc_set_date_stc_1
   523 000061A0 3C39                <1> 	cmp	al, '9'
   524 000061A2 0F8784010000        <1>         ja      loc_set_date_stc_1
   525 000061A8 803D[2CDF0000]33    <1> 	cmp	byte [Day], '3'
   526 000061AF 7208                <1> 	jb	short pass_set_day_31
   527 000061B1 3C31                <1> 	cmp	al, '1'
   528 000061B3 0F8773010000        <1>         ja      loc_set_date_stc_1
   529                              <1> pass_set_day_31:
   530                              <1> 	; 13/05/2016
   531                              <1> 	;mov	bx, 7 ; attribute/color (bl)
   532                              <1> 		      ; video page 0 (bh)	
   533 000061B9 B307                <1> 	mov	bl, 7
   534 000061BB E85CB9FFFF          <1> 	call	_write_tty
   535                              <1> loc_enter_separator_1:
   536 000061C0 28E4                <1> 	sub     ah, ah ; 0
   537 000061C2 E805A9FFFF          <1> 	call	int16h
   538                              <1> 	; AL = ASCII Code of the Character
   539 000061C7 3C1B                <1> 	cmp	al, 27
   540 000061C9 0F8448010000        <1>         je      loc_set_date_retn
   541 000061CF 3C2D                <1> 	cmp	al, '-'
   542 000061D1 7408                <1> 	je	short pass_set_date_separator_1
   543 000061D3 3C2F                <1> 	cmp	al, '/'
   544 000061D5 0F856C010000        <1>         jne     loc_set_date_stc_2
   545                              <1> pass_set_date_separator_1:
   546                              <1> 	; 13/05/2016
   547                              <1> 	;mov	bx, 7 ; attribute/color (bl)
   548                              <1> 		      ; video page 0 (bh)
   549 000061DB B307                <1> 	mov	bl, 7	
   550 000061DD E83AB9FFFF          <1> 	call	_write_tty
   551                              <1> loc_enter_month_1:
   552 000061E2 30E4                <1> 	xor     ah, ah ; 0
   553 000061E4 E8E3A8FFFF          <1> 	call	int16h
   554                              <1> 	; AL = ASCII Code of the Character
   555 000061E9 3C1B                <1> 	cmp	al, 27
   556 000061EB 0F8426010000        <1>         je      loc_set_date_retn
   557 000061F1 A2[2FDF0000]        <1> 	mov	[Month], al
   558 000061F6 3C30                <1> 	cmp	al, '0'
   559 000061F8 0F8264010000        <1>         jb      loc_set_date_stc_3
   560 000061FE 3C31                <1> 	cmp	al, '1'
   561 00006200 0F875C010000        <1>         ja      loc_set_date_stc_3
   562                              <1> 	; 13/05/2016
   563                              <1> 	;mov	bx, 7 ; attribute/color (bl)
   564                              <1> 		      ; video page 0 (bh)	
   565 00006206 B307                <1> 	mov	bl, 7
   566 00006208 E80FB9FFFF          <1> 	call	_write_tty
   567                              <1> loc_enter_month_2:
   568 0000620D 30E4                <1> 	xor     ah, ah
   569 0000620F E8B8A8FFFF          <1> 	call	int16h
   570                              <1> 	; AL = ASCII Code of the Character
   571 00006214 3C1B                <1> 	cmp	al, 27
   572 00006216 0F84FB000000        <1>         je      loc_set_date_retn
   573 0000621C A2[30DF0000]        <1> 	mov	[Month+1], al
   574 00006221 3C30                <1> 	cmp	al, '0'
   575 00006223 0F8254010000        <1>         jb      loc_set_date_stc_4
   576 00006229 3C39                <1> 	cmp	al, '9'
   577 0000622B 0F874C010000        <1>         ja      loc_set_date_stc_4
   578 00006231 803D[2FDF0000]31    <1> 	cmp	byte [Month], '1'
   579 00006238 7208                <1> 	jb	short pass_set_month_12
   580 0000623A 3C32                <1> 	cmp	al, '2'
   581 0000623C 0F873B010000        <1>         ja      loc_set_date_stc_4
   582                              <1> pass_set_month_12:
   583                              <1> 	; 13/05/2016
   584                              <1> 	;mov	bx, 7 ; attribute/color (bl)
   585                              <1> 		      ; video page 0 (bh)
   586 00006242 B307                <1> 	mov	bl, 7	
   587 00006244 E8D3B8FFFF          <1> 	call	_write_tty
   588                              <1> loc_enter_separator_2:
   589 00006249 28E4                <1> 	sub     ah, ah
   590 0000624B E87CA8FFFF          <1> 	call	int16h
   591                              <1> 	; AL = ASCII Code of the Character
   592 00006250 3C1B                <1> 	cmp	al, 27
   593 00006252 0F84BF000000        <1>         je      loc_set_date_retn
   594 00006258 3C2D                <1> 	cmp	al, '-'
   595 0000625A 7408                <1> 	je	short pass_set_date_separator_2
   596 0000625C 3C2F                <1> 	cmp	al, '/'
   597 0000625E 0F8534010000        <1>         jne     loc_set_date_stc_5
   598                              <1> pass_set_date_separator_2:
   599                              <1> 	; 13/05/2016
   600                              <1> 	;mov	bx, 7 ; attribute/color (bl)
   601                              <1> 		      ; video page 0 (bh)	
   602 00006264 B307                <1> 	mov	bl, 7
   603 00006266 E8B1B8FFFF          <1> 	call	_write_tty
   604                              <1> loc_enter_year_1:
   605 0000626B 30E4                <1> 	xor    ah, ah
   606 0000626D E85AA8FFFF          <1> 	call	int16h
   607                              <1> 	; AL = ASCII Code of the Character
   608 00006272 3C1B                <1> 	cmp	al, 27
   609 00006274 0F849D000000        <1>         je      loc_set_date_retn
   610 0000627A A2[34DF0000]        <1> 	mov	[Year], al
   611 0000627F 3C30                <1> 	cmp	al, '0'
   612 00006281 0F822C010000        <1>         jb      loc_set_date_stc_6
   613 00006287 3C39                <1> 	cmp	al, '9'
   614 00006289 0F8724010000        <1>         ja      loc_set_date_stc_6
   615                              <1> 	; 13/05/2016
   616                              <1> 	;mov	bx, 7 ; attribute/color (bl)
   617                              <1> 		      ; video page 0 (bh)
   618 0000628F B307                <1> 	mov	bl, 7	
   619 00006291 E886B8FFFF          <1> 	call	_write_tty
   620                              <1> loc_enter_year_2:
   621 00006296 30E4                <1> 	xor	ah, ah
   622 00006298 E82FA8FFFF          <1> 	call	int16h
   623                              <1> 	; AL = ASCII Code of the Character
   624 0000629D 3C1B                <1> 	cmp	al, 27
   625 0000629F 7476                <1> 	je	short loc_set_date_retn
   626 000062A1 A2[35DF0000]        <1> 	mov	byte [Year+1], al
   627 000062A6 3C30                <1> 	cmp	al, '0'
   628 000062A8 0F8220010000        <1>         jb      loc_set_date_stc_7
   629 000062AE 3C39                <1> 	cmp	al, '9'
   630 000062B0 0F8718010000        <1>         ja      loc_set_date_stc_7
   631                              <1> 	; 13/05/2016
   632                              <1> 	;mov	bx, 7 ; attribute/color (bl)
   633                              <1> 		      ; video page 0 (bh)
   634 000062B6 B307                <1> 	mov	bl, 7	
   635 000062B8 E85FB8FFFF          <1> 	call	_write_tty
   636                              <1> loc_set_date_get_lchar_again:
   637 000062BD 28E4                <1> 	sub	ah, ah ; 0
   638 000062BF E808A8FFFF          <1> 	call	int16h
   639                              <1> 	; AL = ASCII Code of the Character
   640 000062C4 3C0D                <1> 	cmp	al, 13 ; ENTER key
   641 000062C6 7412                <1> 	je	short loc_set_date_progress
   642 000062C8 3C1B                <1> 	cmp	al, 27 ; ESC key
   643 000062CA 744B                <1> 	je	short loc_set_date_retn
   644                              <1> 	;
   645 000062CC E82A010000          <1> 	call	check_for_backspace
   646 000062D1 75EA                <1> 	jne	short loc_set_date_get_lchar_again
   647                              <1> 
   648                              <1> loc_set_date_bs_8:
   649 000062D3 E811010000          <1> 	call	write_backspace
   650 000062D8 EBBC                <1> 	jmp	short loc_enter_year_2
   651                              <1> 
   652                              <1> loc_set_date_progress:
   653                              <1> 	; Get Current Date
   654                              <1> 	;mov	ah, 04h
   655                              <1> 	;call	int1Ah
   656 000062DA E87DEFFFFF          <1> 	call	RTC_40	; GET RTC DATE
   657                              <1> 	; CH = century (in BCD)
   658                              <1> 
   659 000062DF 66A1[34DF0000]      <1> 	mov	ax, [Year]
   660 000062E5 662D3030            <1> 	sub	ax, '00'
   661 000062E9 C0E004              <1> 	shl	al, 4 ; * 16
   662 000062EC 88C1                <1> 	mov	cl, al
   663 000062EE 00E1                <1> 	add	cl, ah
   664 000062F0 66A1[2FDF0000]      <1> 	mov	ax, [Month]
   665 000062F6 662D3030            <1> 	sub	ax, '00'
   666 000062FA C0E004              <1> 	shl	al, 4 ; * 16
   667 000062FD 88C6                <1> 	mov	dh, al
   668 000062FF 00E6                <1> 	add	dh, ah
   669 00006301 66A1[2CDF0000]      <1> 	mov	ax, [Day]
   670 00006307 662D3030            <1> 	sub	ax, '00'
   671 0000630B C0E004              <1> 	shl	al, 4 ; * 16
   672 0000630E 88C2                <1> 	mov	dl, al
   673 00006310 00E2                <1> 	add	dl, ah
   674                              <1> 
   675                              <1> 	;mov	ah, 05h
   676                              <1> 	;call	int1Ah
   677 00006312 E872EFFFFF          <1> 	call	RTC_50	; SET RTC DATE
   678                              <1> 
   679                              <1> loc_set_date_retn:
   680 00006317 BE[8BEE0000]        <1> 	mov	esi, nextline
   681 0000631C E811F2FFFF          <1> 	call	print_msg
   682 00006321 C3                  <1> 	retn
   683                              <1> 
   684                              <1> loc_set_date_stc_0:
   685                              <1> 	;xor	bh, bh ; video page 0
   686 00006322 E8D5B8FFFF          <1> 	call	beeper ; BEEP !
   687 00006327 E925FEFFFF          <1>         jmp     loc_enter_day_1
   688                              <1> loc_set_date_stc_1:
   689 0000632C E8CA000000          <1> 	call	check_for_backspace
   690 00006331 740A                <1> 	je	short loc_set_date_bs_1
   691                              <1> 	;xor	bh, bh ; video page 0
   692 00006333 E8C4B8FFFF          <1> 	call	beeper ; BEEP !
   693 00006338 E947FEFFFF          <1>         jmp     loc_enter_day_2
   694                              <1> loc_set_date_bs_1:
   695 0000633D E8A7000000          <1> 	call	write_backspace
   696 00006342 E90AFEFFFF          <1>         jmp     loc_enter_day_1
   697                              <1> loc_set_date_stc_2:
   698 00006347 E8AF000000          <1> 	call	check_for_backspace
   699 0000634C 740A                <1> 	je	short loc_set_date_bs_2
   700                              <1> 	;xor	bh, bh ; video page 0
   701 0000634E E8A9B8FFFF          <1> 	call	beeper ; BEEP !
   702 00006353 E968FEFFFF          <1>         jmp     loc_enter_separator_1
   703                              <1> loc_set_date_bs_2:
   704 00006358 E88C000000          <1> 	call	write_backspace
   705 0000635D E922FEFFFF          <1>         jmp     loc_enter_day_2
   706                              <1> loc_set_date_stc_3:
   707 00006362 E894000000          <1> 	call	check_for_backspace	
   708 00006367 740A                <1> 	je short loc_set_date_bs_3
   709                              <1> 	;xor	bh, bh ; video page 0
   710 00006369 E88EB8FFFF          <1> 	call	beeper ; BEEP !
   711 0000636E E96FFEFFFF          <1>         jmp     loc_enter_month_1
   712                              <1> loc_set_date_bs_3:
   713 00006373 E871000000          <1> 	call	write_backspace
   714 00006378 E943FEFFFF          <1>         jmp     loc_enter_separator_1
   715                              <1> loc_set_date_stc_4:
   716 0000637D E879000000          <1> 	call	check_for_backspace	
   717 00006382 740A                <1> 	je	short loc_set_date_bs_4
   718                              <1> 	;xor	bh, bh ; video page 0
   719 00006384 E873B8FFFF          <1> 	call	beeper ; BEEP !
   720 00006389 E97FFEFFFF          <1>         jmp     loc_enter_month_2
   721                              <1> loc_set_date_bs_4:
   722 0000638E E856000000          <1> 	call	write_backspace
   723 00006393 E94AFEFFFF          <1>         jmp     loc_enter_month_1
   724                              <1> loc_set_date_stc_5:
   725 00006398 E85E000000          <1> 	call	check_for_backspace
   726 0000639D 740A                <1> 	je	short loc_set_date_bs_5
   727                              <1> 	;xor	bh, bh ; video page 0
   728 0000639F E858B8FFFF          <1> 	call	beeper ; BEEP !
   729 000063A4 E9A0FEFFFF          <1>         jmp     loc_enter_separator_2
   730                              <1> loc_set_date_bs_5:
   731 000063A9 E83B000000          <1> 	call	write_backspace
   732 000063AE E95AFEFFFF          <1>         jmp     loc_enter_month_2
   733                              <1> loc_set_date_stc_6:
   734 000063B3 E843000000          <1> 	call	check_for_backspace
   735 000063B8 740A                <1>         je      short  loc_set_date_bs_6
   736                              <1> 	;xor	bh, bh ; video page 0
   737 000063BA E83DB8FFFF          <1> 	call	beeper ; BEEP !
   738 000063BF E9A7FEFFFF          <1>         jmp     loc_enter_year_1
   739                              <1> loc_set_date_bs_6:
   740 000063C4 E820000000          <1> 	call	write_backspace
   741 000063C9 E97BFEFFFF          <1>         jmp     loc_enter_separator_2
   742                              <1> loc_set_date_stc_7:
   743 000063CE E828000000          <1> 	call	check_for_backspace
   744 000063D3 740A                <1> 	je	short loc_set_date_bs_7
   745                              <1> 	;xor	bh, bh ; video page 0
   746 000063D5 E822B8FFFF          <1> 	call	beeper ; BEEP !
   747 000063DA E9B7FEFFFF          <1>         jmp     loc_enter_year_2
   748                              <1> loc_set_date_bs_7:
   749 000063DF E805000000          <1> 	call	write_backspace
   750 000063E4 E982FEFFFF          <1>         jmp     loc_enter_year_1
   751                              <1> 
   752                              <1> write_backspace:
   753                              <1> 	; 18/01/2016 (TRDOS 386 = TRDOS v2.0)
   754 000063E9 B008                <1> 	mov	al, 08h ; BACKSPACE
   755                              <1> 	; 13/05/2016
   756 000063EB 66BB0700            <1> 	mov	bx, 7 ; bl = attribute/color
   757                              <1> 		      ; bh = video page = 0	
   758 000063EF E828B7FFFF          <1> 	call	_write_tty
   759 000063F4 B020                <1> 	mov	al, 20h ; BLANK/SPACE char 
   760                              <1> 	;mov	bx, 7 ; attribute/color
   761                              <1> 	;call	_write_c_current
   762                              <1> 	;retn
   763 000063F6 E9A8B6FFFF          <1> 	jmp	_write_c_current
   764                              <1> 
   765                              <1> check_for_backspace:
   766                              <1> 	; 18/01/2016 (TRDOS 386 = TRDOS v2.0)
   767 000063FB 663D080E            <1> 	cmp	ax, 0E08h
   768 000063FF 7410                <1> 	je	short cfbs_retn
   769 00006401 663DE04B            <1> 	cmp	ax, 4BE0h
   770 00006405 740A                <1> 	je	short cfbs_retn
   771 00006407 663D004B            <1> 	cmp	ax, 4B00h
   772 0000640B 7404                <1> 	je	short cfbs_retn
   773 0000640D 663DE053            <1> 	cmp	ax, 53E0h
   774                              <1> cfbs_retn:
   775 00006411 C3                  <1> 	retn
   776                              <1> 
   777                              <1> show_time:
   778                              <1> 	; 18/01/2016 (TRDOS 386 = TRDOS v2.0)
   779                              <1>         ; 2004-2005
   780                              <1> 
   781                              <1> 	;mov	ah, 02h
   782                              <1> 	;call	int1Ah
   783 00006412 E8D4EDFFFF          <1> 	call	RTC_20	; GET RTC TIME
   784                              <1> 	
   785 00006417 88E8                <1> 	mov	al, ch
   786 00006419 E8A5A6FFFF          <1> 	call	bcd_to_ascii
   787 0000641E 66A3[5ADF0000]      <1> 	mov	[Hour], ax
   788                              <1> 
   789 00006424 88C8                <1> 	mov	al, cl
   790 00006426 E898A6FFFF          <1> 	call	bcd_to_ascii
   791 0000642B 66A3[5DDF0000]      <1> 	mov	[Minute], ax
   792                              <1> 
   793 00006431 88F0                <1> 	mov	al, dh
   794 00006433 E88BA6FFFF          <1> 	call	bcd_to_ascii
   795 00006438 66A3[60DF0000]      <1> 	mov	[Second], ax
   796                              <1> 
   797 0000643E BE[4ADF0000]        <1> 	mov	esi, Msg_Show_Time
   798 00006443 E8EAF0FFFF          <1> 	call	print_msg
   799 00006448 C3                  <1> 	retn
   800                              <1> 
   801                              <1> set_time:
   802                              <1> 	; 13/05/2016
   803                              <1> 	; 18/01/2016 (TRDOS 386 = TRDOS v2.0)
   804                              <1>         ; 2004-2005
   805                              <1> 
   806 00006449 BE[39DF0000]        <1> 	mov 	esi, Msg_Enter_Time
   807 0000644E E8DFF0FFFF          <1> 	call	print_msg
   808                              <1> 
   809                              <1> loc_enter_hour_1:
   810 00006453 30E4                <1> 	xor     ah, ah
   811 00006455 E872A6FFFF          <1> 	call	int16h
   812                              <1> 	; AL = ASCII Code of the Character
   813 0000645A 3C0D                <1> 	cmp	al, 13 ; ENTER key
   814 0000645C 0F84AE010000        <1>         je      loc_set_time_retn
   815 00006462 3C1B                <1> 	cmp	al, 27 ; ESC key
   816 00006464 0F84A6010000        <1>         je      loc_set_time_retn
   817 0000646A A2[5ADF0000]        <1> 	mov	[Hour], al
   818 0000646F 3C30                <1> 	cmp	al, '0'
   819 00006471 0F82A4010000        <1>         jb      loc_set_time_stc_0
   820 00006477 3C32                <1> 	cmp	al, '2'
   821 00006479 0F879C010000        <1>         ja      loc_set_time_stc_0
   822                              <1> 	; 13/05/2016
   823                              <1> 	;mov	bx, 7 ; attribute/color (bl)
   824                              <1> 		      ; video page 0 (bh)
   825 0000647F B307                <1> 	mov	bl, 7	
   826 00006481 E896B6FFFF          <1> 	call	_write_tty
   827                              <1> loc_enter_hour_2:
   828 00006486 30E4                <1> 	xor     ah, ah
   829 00006488 E83FA6FFFF          <1> 	call	int16h
   830                              <1> 	; AL = ASCII Code of the Character
   831 0000648D 3C1B                <1> 	cmp	al, 27
   832 0000648F 0F847B010000        <1>         je      loc_set_time_retn
   833 00006495 A2[5BDF0000]        <1> 	mov	[Hour+1], al
   834 0000649A 3C30                <1> 	cmp	al, '0'
   835 0000649C 0F8283010000        <1>         jb      loc_set_time_stc_1
   836 000064A2 3C39                <1> 	cmp	al, '9'
   837 000064A4 0F877B010000        <1> 	ja	loc_set_time_stc_1
   838 000064AA 803D[5ADF0000]32    <1>         cmp     byte [Hour], '2'
   839 000064B1 7208                <1> 	jb	short pass_set_time_24
   840 000064B3 3C34                <1> 	cmp	al, '4'
   841 000064B5 0F876A010000        <1>         ja      loc_set_time_stc_1
   842                              <1> pass_set_time_24:
   843                              <1> 	; 13/05/2016
   844                              <1> 	;mov	bx, 7 ; attribute/color (bl)
   845                              <1> 		      ; video page 0 (bh)
   846 000064BB B307                <1> 	mov	bl, 7	
   847 000064BD E85AB6FFFF          <1> 	call	_write_tty
   848                              <1> loc_enter_time_separator_1:
   849 000064C2 28E4                <1> 	sub    ah, ah ; 0
   850 000064C4 E803A6FFFF          <1> 	call	int16h
   851                              <1> 	; AL = ASCII Code of the Character
   852 000064C9 3C1B                <1> 	cmp	al, 27
   853 000064CB 0F843F010000        <1>         je      loc_set_time_retn
   854 000064D1 3C3A                <1> 	cmp	al, ':'
   855 000064D3 0F8567010000        <1>         jne     loc_set_time_stc_2
   856                              <1> 	; 13/05/2016
   857                              <1> 	;mov	bx, 7 ; attribute/color (bl)
   858                              <1> 		      ; video page 0 (bh)
   859 000064D9 B307                <1> 	mov	bl, 7	
   860 000064DB E83CB6FFFF          <1> 	call	_write_tty
   861                              <1> loc_enter_minute_1:
   862 000064E0 30E4                <1> 	xor     ah, ah
   863 000064E2 E8E5A5FFFF          <1> 	call	int16h
   864                              <1> 	; AL = ASCII Code of the Character
   865 000064E7 3C1B                <1> 	cmp	al, 27
   866 000064E9 0F8421010000        <1>         je      loc_set_time_retn
   867 000064EF A2[5DDF0000]        <1> 	mov	[Minute], al
   868 000064F4 3C30                <1> 	cmp	al, '0'
   869 000064F6 0F825F010000        <1>         jb      loc_set_time_stc_3
   870 000064FC 3C35                <1> 	cmp	al, '5'
   871 000064FE 0F8757010000        <1>         ja      loc_set_time_stc_3
   872                              <1> 	; 13/05/2016
   873                              <1> 	;mov	bx, 7 ; attribute/color (bl)
   874                              <1> 		      ; video page 0 (bh)
   875 00006504 B307                <1> 	mov	bl, 7	
   876 00006506 E811B6FFFF          <1> 	call	_write_tty
   877                              <1> loc_enter_minute_2:
   878 0000650B 30E4                <1> 	xor     ah, ah
   879 0000650D E8BAA5FFFF          <1> 	call	int16h
   880                              <1> 	; AL = ASCII Code of the Character
   881 00006512 3C1B                <1> 	cmp	al, 27
   882 00006514 0F84F6000000        <1>         je      loc_set_time_retn
   883 0000651A A2[5EDF0000]        <1> 	mov	[Minute+1], al
   884 0000651F 3C30                <1> 	cmp	al, '0'
   885 00006521 0F824F010000        <1>         jb      loc_set_time_stc_4
   886 00006527 3C39                <1> 	cmp	al, '9'
   887 00006529 0F8747010000        <1>         ja      loc_set_time_stc_4
   888                              <1> 	; 13/05/2016
   889                              <1> 	;mov	bx, 7 ; attribute/color (bl)
   890                              <1> 		      ; video page 0 (bh)
   891 0000652F B307                <1> 	mov	bl, 7	
   892 00006531 E8E6B5FFFF          <1> 	call	_write_tty
   893                              <1> loc_enter_time_separator_2:
   894 00006536 66C705[60DF0000]30- <1> 	mov	word [Second], 3030h
   894 0000653E 30                  <1>
   895 0000653F 28E4                <1> 	sub     ah, ah
   896 00006541 E886A5FFFF          <1> 	call	int16h
   897                              <1> 	; AL = ASCII Code of the Character
   898 00006546 3C0D                <1> 	cmp	al, 13
   899 00006548 0F8485000000        <1>         je      loc_set_time_progress
   900 0000654E 3C1B                <1> 	cmp	al, 27
   901 00006550 0F84BA000000        <1>         je      loc_set_time_retn
   902 00006556 3C3A                <1> 	cmp	al, ':'
   903 00006558 0F8533010000        <1>         jne     loc_set_time_stc_5
   904                              <1> 	; 13/05/2016
   905                              <1> 	;mov	bx, 7 ; attribute/color (bl)
   906                              <1> 		      ; video page 0 (bh)
   907 0000655E B307                <1> 	mov	bl, 7	
   908 00006560 E8B7B5FFFF          <1> 	call	_write_tty
   909                              <1> loc_enter_second_1:
   910 00006565 30E4                <1> 	xor     ah, ah
   911 00006567 E860A5FFFF          <1> 	call	int16h
   912                              <1> 	; AL = ASCII Code of the Character
   913 0000656C 3C0D                <1> 	cmp	al, 13
   914 0000656E 7463                <1> 	je	short loc_set_time_progress
   915 00006570 3C1B                <1> 	cmp	al, 27
   916 00006572 0F8498000000        <1>         je      loc_set_time_retn
   917 00006578 A2[60DF0000]        <1> 	mov	[Second], al
   918 0000657D 3C30                <1> 	cmp	al, '0'
   919 0000657F 0F8227010000        <1>         jb      loc_set_time_stc_6
   920 00006585 3C35                <1> 	cmp	al, '5'
   921 00006587 0F871F010000        <1>         ja      loc_set_time_stc_6
   922                              <1> 	; 13/05/2016
   923                              <1> 	;mov	bx, 7 ; attribute/color (bl)
   924                              <1> 		      ; video page 0 (bh)
   925 0000658D B307                <1> 	mov	bl, 7	
   926 0000658F E888B5FFFF          <1> 	call	_write_tty
   927                              <1> loc_enter_second_2:
   928 00006594 30E4                <1> 	xor     ah, ah
   929 00006596 E831A5FFFF          <1> 	call	int16h
   930                              <1> 	; AL = ASCII Code of the Character
   931 0000659B 3C1B                <1> 	cmp	al, 27
   932 0000659D 7471                <1> 	je	short loc_set_time_retn
   933 0000659F 3C30                <1> 	cmp	al, '0'
   934 000065A1 0F8229010000        <1>         jb      loc_set_time_stc_7
   935 000065A7 3C39                <1> 	cmp	al, '9'
   936 000065A9 0F8721010000        <1>         ja      loc_set_time_stc_7
   937                              <1> 	; 13/05/2016
   938                              <1> 	;mov	bx, 7 ; attribute/color (bl)
   939                              <1> 		      ; video page 0 (bh)
   940 000065AF B307                <1> 	mov	bl, 7	
   941 000065B1 E866B5FFFF          <1> 	call	_write_tty
   942                              <1> loc_set_time_get_lchar_again:
   943 000065B6 28E4                <1> 	sub	ah, ah ; 0
   944 000065B8 E80FA5FFFF          <1> 	call	int16h
   945                              <1> 	; AL = ASCII Code of the Character
   946 000065BD 3C0D                <1> 	cmp	al, 13
   947 000065BF 7412                <1> 	je	short loc_set_time_progress
   948 000065C1 3C1B                <1> 	cmp	al, 27
   949 000065C3 744B                <1> 	je	short loc_set_time_retn
   950                              <1> 	;
   951 000065C5 E831FEFFFF          <1> 	call	check_for_backspace
   952 000065CA 75EA                <1> 	jne	short loc_set_time_get_lchar_again
   953                              <1> 
   954                              <1> loc_set_time_bs_8:
   955 000065CC E818FEFFFF          <1> 	call	write_backspace
   956 000065D1 EBC1                <1> 	jmp	short loc_enter_second_2
   957                              <1> 
   958                              <1> loc_set_time_progress:
   959                              <1> 	; Get Current Time
   960                              <1> 	;mov 	ah, 02h
   961                              <1> 	;call	int1Ah
   962 000065D3 E813ECFFFF          <1> 	call	RTC_20	; GET RTC TIME
   963                              <1> 	;DL = Daylight Savings Enable option (0-1)	
   964                              <1> 
   965 000065D8 66A1[5ADF0000]      <1> 	mov	ax, [Hour]
   966 000065DE 662D3030            <1> 	sub	ax, '00'
   967 000065E2 C0E004              <1> 	shl	al, 4 ; * 16
   968 000065E5 88C5                <1> 	mov	ch, al
   969 000065E7 00E5                <1> 	add	ch, ah
   970 000065E9 66A1[5DDF0000]      <1> 	mov	ax, [Minute]
   971 000065EF 662D3030            <1> 	sub	ax, '00'
   972 000065F3 C0E004              <1> 	shl	al, 4 ; * 16
   973 000065F6 88C1                <1> 	mov	cl, al
   974 000065F8 00E1                <1> 	add	cl, ah
   975 000065FA 66A1[60DF0000]      <1> 	mov	ax, [Second]
   976 00006600 662D3030            <1> 	sub	ax, '00'
   977 00006604 C0E004              <1> 	shl	al, 4 ; * 16
   978 00006607 88C6                <1> 	mov	dh, al
   979 00006609 00E6                <1> 	add	dh, ah
   980                              <1> 	
   981                              <1> 	;mov	ah, 03h
   982                              <1> 	;call	int1Ah
   983 0000660B E80AECFFFF          <1> 	call	RTC_30	; SET RTC TIME
   984                              <1> 
   985                              <1> loc_set_time_retn:
   986 00006610 BE[8BEE0000]        <1> 	mov 	esi, nextline
   987 00006615 E818EFFFFF          <1> 	call	print_msg
   988 0000661A C3                  <1> 	retn
   989                              <1> 
   990                              <1> loc_set_time_stc_0:
   991                              <1> 	;xor	bh, bh ; video page 0
   992 0000661B E8DCB5FFFF          <1> 	call	beeper ; BEEP !
   993 00006620 E92EFEFFFF          <1>         jmp     loc_enter_hour_1
   994                              <1> loc_set_time_stc_1:
   995 00006625 E8D1FDFFFF          <1> 	call	check_for_backspace
   996 0000662A 740A                <1> 	je	short loc_set_time_bs_1
   997                              <1> 	;xor	bh, bh ; video page 0
   998 0000662C E8CBB5FFFF          <1> 	call	beeper ; BEEP !
   999 00006631 E950FEFFFF          <1>         jmp     loc_enter_hour_2
  1000                              <1> loc_set_time_bs_1:
  1001 00006636 E8AEFDFFFF          <1> 	call	write_backspace
  1002 0000663B E913FEFFFF          <1>         jmp     loc_enter_hour_1
  1003                              <1> loc_set_time_stc_2:
  1004 00006640 E8B6FDFFFF          <1> 	call	check_for_backspace
  1005 00006645 740A                <1> 	je	short loc_set_time_bs_2
  1006                              <1> 	;xor	bh, bh ; video page 0
  1007 00006647 E8B0B5FFFF          <1> 	call	beeper ; BEEP !
  1008 0000664C E971FEFFFF          <1>         jmp     loc_enter_time_separator_1
  1009                              <1> loc_set_time_bs_2:
  1010 00006651 E893FDFFFF          <1> 	call	write_backspace
  1011 00006656 E92BFEFFFF          <1>         jmp     loc_enter_hour_2
  1012                              <1> loc_set_time_stc_3:
  1013 0000665B E89BFDFFFF          <1> 	call	check_for_backspace
  1014 00006660 740A                <1> 	je	short loc_set_time_bs_3
  1015                              <1> 	;xor	bh, bh ; video page 0
  1016 00006662 E895B5FFFF          <1> 	call	beeper ; BEEP !6
  1017 00006667 E974FEFFFF          <1>         jmp     loc_enter_minute_1
  1018                              <1> loc_set_time_bs_3:
  1019 0000666C E878FDFFFF          <1> 	call	write_backspace
  1020 00006671 E94CFEFFFF          <1>         jmp     loc_enter_time_separator_1
  1021                              <1> loc_set_time_stc_4:
  1022 00006676 E880FDFFFF          <1> 	call	check_for_backspace
  1023 0000667B 740A                <1> 	je	short loc_set_time_bs_4
  1024                              <1> 	;xor	bh, bh ; video page 0
  1025 0000667D E87AB5FFFF          <1> 	call	beeper ; BEEP !
  1026 00006682 E984FEFFFF          <1>         jmp     loc_enter_minute_2
  1027                              <1> loc_set_time_bs_4:
  1028 00006687 E85DFDFFFF          <1> 	call	write_backspace
  1029 0000668C E94FFEFFFF          <1>         jmp     loc_enter_minute_1
  1030                              <1> loc_set_time_stc_5:
  1031 00006691 E865FDFFFF          <1> 	call	check_for_backspace
  1032 00006696 740A                <1> 	je	short loc_set_time_bs_5
  1033                              <1> 	;xor	bh, bh ; video page 0
  1034 00006698 E85FB5FFFF          <1> 	call	beeper ; BEEP !
  1035 0000669D E994FEFFFF          <1>         jmp     loc_enter_time_separator_2
  1036                              <1> loc_set_time_bs_5:
  1037 000066A2 E842FDFFFF          <1> 	call	write_backspace
  1038 000066A7 E95FFEFFFF          <1>         jmp     loc_enter_minute_2
  1039                              <1> loc_set_time_stc_6:
  1040 000066AC E84AFDFFFF          <1> 	call	check_for_backspace
  1041 000066B1 7413                <1> 	je	short loc_set_time_bs_6
  1042                              <1> 	;xor	bh, bh ; video page 0
  1043 000066B3 E844B5FFFF          <1> 	call	beeper ; BEEP !
  1044 000066B8 66C705[60DF0000]30- <1> 	mov	word [Second], 3030h
  1044 000066C0 30                  <1>
  1045 000066C1 E99FFEFFFF          <1>         jmp     loc_enter_second_1
  1046                              <1> loc_set_time_bs_6:
  1047 000066C6 E81EFDFFFF          <1> 	call	write_backspace
  1048 000066CB E966FEFFFF          <1>         jmp     loc_enter_time_separator_2
  1049                              <1> loc_set_time_stc_7:
  1050 000066D0 E826FDFFFF          <1> 	call	check_for_backspace
  1051 000066D5 740A                <1> 	je	short loc_set_time_bs_7
  1052                              <1> 	;xor	bh, bh ; video page 0
  1053 000066D7 E820B5FFFF          <1> 	call	beeper ; BEEP !
  1054 000066DC E9B3FEFFFF          <1>         jmp     loc_enter_second_2
  1055                              <1> loc_set_time_bs_7:
  1056 000066E1 E803FDFFFF          <1> 	call	write_backspace
  1057 000066E6 E97AFEFFFF          <1>         jmp     loc_enter_second_1
  1058                              <1> 
  1059                              <1> print_volume_info:
  1060                              <1> 	; 01/03/2016
  1061                              <1> 	; 08/02/2016
  1062                              <1> 	; 06/02/2016
  1063                              <1> 	; 04/02/2016
  1064                              <1> 	; 18/01/2016 (TRDOS 386 = TRDOS v2.0)
  1065                              <1> 	; 25/10/2009
  1066                              <1> 	;
  1067                              <1> 	; "Volume Serial No: "
  1068                              <1>  	;
  1069                              <1> 	; INPUT  : AL = DOS Drive Number
  1070                              <1> 	; OUTPUT : AH = FS Type
  1071                              <1> 	;          AL = DOS Drive Name
  1072                              <1> 	; CF = 0 -> OK
  1073                              <1> 	; CF = 1 -> Drive not ready 
  1074                              <1> 
  1075 000066EB 88C4                <1> 	mov	ah, al
  1076 000066ED 28C0                <1> 	sub	al, al
  1077 000066EF 0FB7F0              <1> 	movzx	esi, ax	
  1078 000066F2 81C600010900        <1> 	add	esi, Logical_DOSDisks
  1079 000066F8 8A06                <1> 	mov	al, [esi]
  1080 000066FA 3C41                <1> 	cmp	al, 'A'  
  1081 000066FC 7304                <1> 	jnb	short loc_pvi_set_vol_name
  1082 000066FE 8A6604              <1> 	mov	ah, [esi+LD_FSType]
  1083 00006701 C3                  <1> 	retn
  1084                              <1> 
  1085                              <1> loc_pvi_set_vol_name:
  1086 00006702 A2[94DF0000]        <1> 	mov	[Vol_Drv_Name], al
  1087 00006707 56                  <1> 	push	esi
  1088 00006708 E858010000          <1> 	call	move_volume_name_and_serial_no ;;;
  1089 0000670D 7302                <1> 	jnc	short loc_pvi_mvn_ok
  1090 0000670F 5E                  <1> 	pop	esi
  1091 00006710 C3                  <1> 	retn
  1092                              <1> 
  1093                              <1> loc_pvi_mvn_ok:
  1094 00006711 8B3424              <1> 	mov	esi, [esp]
  1095 00006714 807E04A1            <1> 	cmp	byte [esi+LD_FSType], 0A1h
  1096 00006718 7509                <1> 	jne	short loc_pvi_fat_vol_size
  1097 0000671A 8B4670              <1> 	mov	eax, [esi+LD_FS_VolumeSize]
  1098 0000671D 0FB75E11            <1> 	movzx	ebx, word [esi+LD_FS_BytesPerSec]
  1099 00006721 EB07                <1> 	jmp	short loc_vol_size_mul32
  1100                              <1> loc_pvi_fat_vol_size:
  1101 00006723 8B4670              <1> 	mov	eax, [esi+LD_TotalSectors]
  1102 00006726 0FB75E11            <1> 	movzx	ebx, word [esi+LD_BPB+BPB_BytsPerSec]
  1103                              <1> loc_vol_size_mul32:
  1104 0000672A F7E3                <1> 	mul	ebx
  1105 0000672C 09D2                <1> 	or	edx, edx
  1106 0000672E 7507                <1> 	jnz	short loc_vol_size_in_kbytes
  1107                              <1> loc_vol_size_in_bytes:
  1108 00006730 B9[72DF0000]        <1> 	mov	ecx, VolSize_Bytes
  1109 00006735 EB0D                <1> 	jmp	short loc_write_vol_size_str
  1110                              <1> loc_vol_size_in_kbytes:
  1111 00006737 66BB0004            <1> 	mov	bx, 1024
  1112 0000673B F7F3                <1> 	div	ebx
  1113 0000673D B9[65DF0000]        <1> 	mov 	ecx, VolSize_KiloBytes
  1114 00006742 31D2                <1> 	xor	edx, edx ; 0
  1115                              <1> loc_write_vol_size_str:
  1116 00006744 890D[A7280100]      <1> 	mov	[VolSize_Unit1], ecx
  1117                              <1> 	; 
  1118 0000674A BF[BD280100]        <1> 	mov	edi, Vol_Tot_Sec_Str_End
  1119                              <1>         ;mov	byte [edi], 0
  1120 0000674F B90A000000          <1> 	mov	ecx, 10
  1121                              <1> loc_write_vol_size_chr:
  1122 00006754 F7F1                <1> 	div	ecx
  1123 00006756 80C230              <1> 	add	dl, '0'
  1124 00006759 4F                  <1> 	dec	edi	
  1125 0000675A 8817                <1> 	mov	[edi], dl
  1126 0000675C 85C0                <1> 	test	eax, eax
  1127 0000675E 7404                <1> 	jz	short loc_write_vol_size_str_ok
  1128 00006760 28D2                <1> 	sub	dl, dl ; 0
  1129 00006762 EBF0                <1> 	jmp	short loc_write_vol_size_chr
  1130                              <1> 
  1131                              <1> loc_write_vol_size_str_ok:
  1132 00006764 893D[AF280100]      <1> 	mov	[Vol_Tot_Sec_Str_Start], edi
  1133                              <1> 	;
  1134 0000676A BF[7DDF0000]        <1> 	mov	edi, Vol_FS_Name
  1135 0000676F 8A4E03              <1> 	mov	cl, [esi+LD_FATType]
  1136 00006772 20C9                <1> 	and	cl, cl ; 0 ?
  1137 00006774 7515                <1> 	jnz	short loc_write_vol_FAT_str_1
  1138 00006776 66C7075452          <1> 	mov	word [edi], 'TR'
  1139 0000677B C7470420465331      <1> 	mov	dword [edi+4], ' FS1'
  1140                              <1> 	;movzx	ebx, word [esi+LD_FS_BytesPerSec]
  1141 00006782 668B5E11            <1> 	mov	bx, [esi+LD_FS_BytesPerSec]
  1142 00006786 8B4674              <1> 	mov	eax, [esi+LD_FS_FreeSectors]
  1143 00006789 EB36                <1> 	jmp	short loc_vol_freespace_mul32
  1144                              <1> 
  1145                              <1> loc_write_vol_FAT_str_1:
  1146 0000678B 66B83332            <1> 	mov	ax, '32' ; FAT32
  1147 0000678F 80F902              <1> 	cmp	cl, 2 ; [esi+LD_FATType]
  1148 00006792 7708                <1> 	ja	short loc_write_vol_FAT_str_2
  1149 00006794 66B83132            <1> 	mov	ax, '12' ; FAT12
  1150 00006798 7202                <1> 	jb	short loc_write_vol_FAT_str_2
  1151 0000679A B436                <1> 	mov	ah, '6'  ; FAT16
  1152                              <1> loc_write_vol_FAT_str_2:
  1153 0000679C C70746415420        <1> 	mov	dword [edi], 'FAT '
  1154 000067A2 66894704            <1> 	mov	word [edi+4], ax
  1155                              <1> 	;
  1156                              <1> 	;movzx	ebx, word [esi+LD_BPB+BPB_BytsPerSec]
  1157 000067A6 668B5E11            <1> 	mov	bx, [esi+LD_BPB+BPB_BytsPerSec]
  1158 000067AA 8B4674              <1> 	mov	eax, [esi+LD_FreeSectors]
  1159                              <1> 
  1160                              <1> loc_vol_freespace_recalc0:
  1161                              <1> 	; 01/03/2016
  1162 000067AD 83F8FF              <1> 	cmp	eax, 0FFFFFFFFh
  1163 000067B0 720F                <1> 	jb	short loc_vol_freespace_mul32
  1164                              <1> 	;inc	eax ; 0
  1165 000067B2 20C9                <1> 	and	cl, cl ; byte [esi+LD_FATType]
  1166 000067B4 740B                <1> 	jz	short loc_vol_freespace_mul32 	
  1167 000067B6 53                  <1> 	push	ebx
  1168 000067B7 66BB00FF            <1> 	mov	bx, 0FF00h ; recalculate free sectors
  1169 000067BB E88B490000          <1> 	call	calculate_fat_freespace
  1170 000067C0 5B                  <1> 	pop	ebx
  1171                              <1> 
  1172                              <1> loc_vol_freespace_mul32:
  1173 000067C1 F7E3                <1> 	mul	ebx
  1174 000067C3 09D2                <1> 	or	edx, edx
  1175 000067C5 7507                <1> 	jnz	short loc_vol_fspace_in_kbytes
  1176                              <1> loc_vol_fspace_in_bytes:
  1177 000067C7 B9[72DF0000]        <1> 	mov	ecx, VolSize_Bytes
  1178 000067CC EB0D                <1> 	jmp	short loc_write_vol_fspace_str
  1179                              <1> loc_vol_fspace_in_kbytes:
  1180 000067CE 66BB0004            <1> 	mov	bx, 1024
  1181 000067D2 F7F3                <1> 	div	ebx
  1182 000067D4 B9[65DF0000]        <1> 	mov 	ecx, VolSize_KiloBytes
  1183 000067D9 31D2                <1> 	xor	edx, edx ; 0
  1184                              <1> loc_write_vol_fspace_str:
  1185 000067DB 890D[AB280100]      <1> 	mov	[VolSize_Unit2], ecx
  1186                              <1> 	;	
  1187 000067E1 BF[CD280100]        <1> 	mov	edi, Vol_Free_Sectors_Str_End
  1188                              <1>         ;mov	byte [edi], 0
  1189 000067E6 B90A000000          <1> 	mov	ecx, 10
  1190                              <1> loc_write_vol_fspace_chr:
  1191 000067EB F7F1                <1> 	div	ecx
  1192 000067ED 80C230              <1> 	add	dl, '0'
  1193 000067F0 4F                  <1> 	dec	edi	
  1194 000067F1 8817                <1> 	mov	[edi], dl
  1195 000067F3 85C0                <1> 	test	eax, eax
  1196 000067F5 7404                <1> 	jz	short loc_write_vol_fspace_str_ok
  1197 000067F7 28D2                <1> 	sub	dl, dl ; 0
  1198 000067F9 EBF0                <1> 	jmp	short loc_write_vol_fspace_chr
  1199                              <1> 
  1200                              <1> loc_write_vol_fspace_str_ok:
  1201 000067FB 893D[BF280100]      <1> 	mov	[Vol_Free_Sectors_Str_Start], edi
  1202                              <1> 	;
  1203 00006801 BE[7BDF0000]        <1> 	mov	esi, Volume_in_drive
  1204 00006806 E827EDFFFF          <1> 	call	print_msg
  1205 0000680B BE[BBDF0000]        <1> 	mov	esi, Vol_Name
  1206 00006810 E81DEDFFFF          <1> 	call	print_msg
  1207 00006815 BE[8BEE0000]        <1> 	mov	esi, nextline
  1208 0000681A E813EDFFFF          <1> 	call	print_msg
  1209                              <1> 	;
  1210 0000681F BE[1CE00000]        <1> 	mov	esi, Vol_Total_Sector_Header
  1211 00006824 E809EDFFFF          <1> 	call	print_msg
  1212 00006829 8B35[AF280100]      <1> 	mov	esi, [Vol_Tot_Sec_Str_Start]
  1213 0000682F E8FEECFFFF          <1> 	call	print_msg
  1214 00006834 8B35[A7280100]      <1> 	mov	esi, [VolSize_Unit1]
  1215 0000683A E8F3ECFFFF          <1> 	call	print_msg
  1216                              <1> 	;
  1217 0000683F BE[2DE00000]        <1> 	mov	esi, Vol_Free_Sectors_Header
  1218 00006844 E8E9ECFFFF          <1> 	call	print_msg
  1219 00006849 8B35[BF280100]      <1> 	mov	esi, [Vol_Free_Sectors_Str_Start]
  1220 0000684F E8DEECFFFF          <1> 	call	print_msg
  1221 00006854 8B35[AB280100]      <1> 	mov	esi, [VolSize_Unit2]
  1222 0000685A E8D3ECFFFF          <1> 	call	print_msg
  1223                              <1> 	;
  1224 0000685F 5E                  <1> 	pop	esi
  1225                              <1> 	
  1226                              <1> 	;mov	ah, [esi+LD_FSType]
  1227                              <1> 	;mov	al, [esi+LD_FATType]
  1228 00006860 668B4603            <1> 	mov	ax, [esi+LD_FATType]
  1229                              <1> 
  1230 00006864 C3                  <1> 	retn
  1231                              <1> 
  1232                              <1> move_volume_name_and_serial_no:
  1233                              <1> 	; 08/02/2016  (TRDOS 386 = TRDOS v2.0)
  1234                              <1> 	; this routine will be called by
  1235                              <1> 	; "print_volume_info" and "print_directory"
  1236                              <1> 	; INPUT ->
  1237                              <1> 	;	ESI = Logical DOS drv descripton table address
  1238                              <1> 	; OUTPUT ->
  1239                              <1> 	;	*Volume name will be moved to text area
  1240                              <1> 	;	*Volume serial number will be converted to
  1241                              <1> 	;	 text and will be moved to text area
  1242                              <1> 	;   cf = 1 -> invalid/unknown dos drive
  1243                              <1> 	;   cf = 0 -> ecx = 0
  1244                              <1> 	;
  1245                              <1> 	; (eax, edx, ecx, esi, edi will be changed)
  1246                              <1> 
  1247 00006865 BF[BBDF0000]        <1> 	mov 	edi, Vol_Name
  1248                              <1> 
  1249                              <1> 	;mov	ah, [esi+LD_FSType]
  1250                              <1> 	;mov	al, [esi+LD_FATType]
  1251 0000686A 668B4603            <1> 	mov	ax, [esi+LD_FATType]
  1252 0000686E 80FCA1              <1> 	cmp	ah, 0A1h
  1253 00006871 7418                <1> 	je	short mvn_2
  1254 00006873 08E4                <1> 	or	ah, ah
  1255 00006875 7404                <1> 	jz	short mvn_0
  1256 00006877 08C0                <1> 	or	al, al
  1257 00006879 7504                <1> 	jnz	short mvn_1
  1258                              <1> mvn_0:
  1259 0000687B 8A06                <1> 	mov	al, [esi]
  1260 0000687D F9                  <1> 	stc
  1261 0000687E C3                  <1> 	retn
  1262                              <1> mvn_1:
  1263 0000687F 3C02                <1> 	cmp	al, 2
  1264 00006881 7717                <1> 	ja	short mvn_3 
  1265                              <1> 	;or	al, al
  1266                              <1> 	;jz	short mvn_2
  1267 00006883 8B462D              <1> 	mov	eax, [esi+LD_BPB+VolumeID]
  1268 00006886 83C631              <1> 	add	esi, LD_BPB+VolumeLabel
  1269 00006889 EB15                <1> 	jmp	short mvn_4
  1270                              <1> mvn_2:
  1271 0000688B 8B4628              <1> 	mov	eax, [esi+LD_FS_VolumeSerial]
  1272 0000688E 83C62C              <1> 	add	esi, LD_FS_VolumeName
  1273 00006891 B910000000          <1> 	mov	ecx, 16
  1274 00006896 F3A5                <1> 	rep	movsd
  1275 00006898 EB10                <1> 	jmp	short mvn_5
  1276                              <1> mvn_3:
  1277 0000689A 8B4649              <1> 	mov	eax, [esi+LD_BPB+FAT32_VolID]
  1278 0000689D 83C64D              <1> 	add	esi, LD_BPB+FAT32_VolLab
  1279                              <1> mvn_4:
  1280 000068A0 B90B000000          <1> 	mov	ecx, 11
  1281 000068A5 F3A4                <1> 	rep	movsb
  1282 000068A7 C60700              <1> 	mov	byte [edi], 0
  1283                              <1> mvn_5:
  1284                              <1> 	;mov	[Current_VolSerial], eax  
  1285 000068AA E8A5C4FFFF          <1> 	call	dwordtohex
  1286 000068AF 8915[10E00000]      <1> 	mov	[Vol_Serial1], edx
  1287 000068B5 A3[15E00000]        <1> 	mov	[Vol_Serial2], eax
  1288                              <1> 	; ecx = 0
  1289 000068BA C3                  <1> 	retn
  1290                              <1> 
  1291                              <1> get_volume_serial_number:
  1292                              <1> 	; 19/01/2016 (TRDOS 386 = TRDOS v2.0)
  1293                              <1> 	; 08/08/2010
  1294                              <1> 	;
  1295                              <1> 	; INPUT -> DL = Logical DOS Drive number
  1296                              <1> 	; OUTPUT -> EAX = Volume serial number
  1297                              <1> 	;          BL= FAT Type	    
  1298                              <1> 	;          BH = Logical DOS drv Number (DL input)
  1299                              <1> 	; cf = 1 -> Drive not ready
  1300                              <1> 
  1301 000068BB 31DB                <1> 	xor	ebx, ebx
  1302 000068BD 88D7                <1> 	mov	bh, dl
  1303 000068BF 3815[E3DD0000]      <1> 	cmp	[Last_DOS_DiskNo], dl
  1304 000068C5 7304                <1> 	jnb	short loc_gvsn_start
  1305                              <1> loc_gvsn_stc_retn:
  1306 000068C7 31C0                <1> 	xor	eax, eax
  1307 000068C9 F9                  <1> 	stc 
  1308 000068CA C3                  <1>         retn 
  1309                              <1> loc_gvsn_start:
  1310 000068CB 56                  <1> 	push	esi
  1311 000068CC BE00010900          <1> 	mov	esi, Logical_DOSDisks
  1312 000068D1 01DE                <1> 	add	esi, ebx
  1313 000068D3 8A5E03              <1> 	mov	bl, [esi+LD_FATType]
  1314 000068D6 20DB                <1> 	and	bl, bl
  1315 000068D8 740F                <1> 	jz	short loc_gvsn_fs
  1316 000068DA 80FB02              <1> 	cmp	bl, 2
  1317 000068DD 7705                <1> 	ja	short loc_gvsn_fat32
  1318                              <1> loc_gvsn_fat:
  1319 000068DF 83C62D              <1> 	add	esi, LD_BPB + VolumeID
  1320 000068E2 EB0E                <1> 	jmp	short loc_gvsn_return
  1321                              <1> loc_gvsn_fat32: 
  1322 000068E4 83C649              <1> 	add	esi, LD_BPB + FAT32_VolID
  1323 000068E7 EB09                <1> 	jmp	short loc_gvsn_return 
  1324                              <1> loc_gvsn_fs:
  1325 000068E9 807E04A1            <1> 	cmp	byte [esi+LD_FSType], 0A1h
  1326 000068ED 75D8                <1> 	jne	short loc_gvsn_stc_retn 
  1327 000068EF 83C628              <1> 	add	esi, LD_FS_VolumeSerial
  1328                              <1> loc_gvsn_return:
  1329 000068F2 8B06                <1> 	mov	eax, [esi]
  1330 000068F4 5E                  <1> 	pop	esi
  1331 000068F5 C3                  <1> 	retn
  1332                              <1> 
  1333                              <1> ; CMD_INTR.ASM [ TRDOS Command Interpreter Procedure ]
  1334                              <1> ; 09/11/2011
  1335                              <1> ; 29/01/2005
  1336                              <1> 
  1337                              <1> command_interpreter:
  1338                              <1> 	; 13/05/2016
  1339                              <1> 	; 07/05/2016
  1340                              <1> 	; 04/03/2016
  1341                              <1> 	; 04/02/2016
  1342                              <1> 	; 03/02/2016
  1343                              <1> 	; 30/01/2016
  1344                              <1> 	; 29/01/2016 (TRDOS 386 = TRDOS 2.0)
  1345                              <1> 	; 15/09/2011         
  1346                              <1> 	; 29/01/2005
  1347                              <1>         
  1348                              <1> 	; Input: ecx = command word length (CL)
  1349                              <1> 	;	 CommandBuffer = Command string offset
  1350                              <1>  
  1351 000068F6 C605[60290100]00    <1> 	mov	byte [Program_Exit],0
  1352 000068FD 80F904              <1> 	cmp	cl, 4
  1353 00006900 0F87AE020000        <1>         ja      c_6
  1354 00006906 0F822E010000        <1>         jb      c_2
  1355                              <1> c_4:
  1356                              <1> 
  1357                              <1> cmp_cmd_exit:
  1358 0000690C BF[51DE0000]        <1> 	mov	edi, Cmd_Exit
  1359 00006911 E8C9030000          <1> 	call	cmp_cmd	
  1360 00006916 7208                <1> 	jc	short cmp_cmd_date
  1361                              <1> 
  1362 00006918 C605[60290100]01    <1>         mov     byte [Program_Exit], 1
  1363 0000691F C3                  <1>         retn
  1364                              <1> 
  1365                              <1> cmp_cmd_date:
  1366 00006920 B104                <1> 	mov	cl, 4
  1367 00006922 BF[6DDE0000]        <1> 	mov	edi, Cmd_Date
  1368 00006927 E8B3030000          <1> 	call	cmp_cmd	
  1369 0000692C 720B                <1>         jc	short cmp_cmd_time
  1370                              <1> 	
  1371 0000692E E8D0F7FFFF          <1> 	call	show_date
  1372 00006933 E80FF8FFFF          <1> 	call	set_date
  1373 00006938 C3                  <1> 	retn
  1374                              <1> 
  1375                              <1> cmp_cmd_time:
  1376 00006939 B104                <1> 	mov	cl, 4
  1377 0000693B BF[72DE0000]        <1> 	mov	edi, Cmd_Time
  1378 00006940 E89A030000          <1>    	call	cmp_cmd	
  1379 00006945 720B                <1> 	jc	short cmp_cmd_show
  1380                              <1> 
  1381 00006947 E8C6FAFFFF          <1> 	call	show_time
  1382 0000694C E8F8FAFFFF          <1> 	call	set_time
  1383 00006951 C3                  <1> 	retn
  1384                              <1> 
  1385                              <1> cmp_cmd_show:
  1386 00006952 B104                <1> 	mov	cl, 4
  1387 00006954 BF[83DE0000]        <1> 	mov	edi, Cmd_Show
  1388 00006959 E881030000          <1>    	call	cmp_cmd	
  1389 0000695E 0F83F6090000        <1>         jnc     show_file
  1390                              <1> 
  1391                              <1> cmp_cmd_echo:
  1392 00006964 B104                <1> 	mov	cl, 4
  1393 00006966 BF[C8DE0000]        <1> 	mov	edi, Cmd_Echo
  1394 0000696B E86F030000          <1>    	call	cmp_cmd	
  1395 00006970 721B                <1> 	jc	short cmp_cmd_copy
  1396                              <1> 
  1397                              <1> 	; 14/04/2016
  1398 00006972 56                  <1> 	push	esi
  1399                              <1> cmd_echo_asciiz:
  1400 00006973 46                  <1>         inc	esi
  1401 00006974 8A06                <1> 	mov	al, [esi]
  1402 00006976 3C20                <1> 	cmp	al, 20h
  1403 00006978 73F9                <1> 	jnb	short cmd_echo_asciiz
  1404 0000697A C60600              <1> 	mov	byte [esi], 0                 
  1405 0000697D 5E                  <1> 	pop	esi  
  1406 0000697E E8AFEBFFFF          <1> 	call	print_msg
  1407 00006983 BE[FDEE0000]        <1> 	mov	esi, NextLine
  1408                              <1> 	;call	print_msg   
  1409                              <1> 	;retn
  1410 00006988 E9A5EBFFFF          <1> 	jmp	print_msg
  1411                              <1> 
  1412                              <1> cmp_cmd_copy:
  1413 0000698D B104                <1> 	mov	cl, 4
  1414 0000698F BF[A6DE0000]        <1> 	mov	edi, Cmd_Copy
  1415 00006994 E846030000          <1>    	call	cmp_cmd	
  1416 00006999 0F8301180000        <1> 	jnc	copy_file
  1417                              <1> 
  1418                              <1> cmp_cmd_move:
  1419 0000699F B104                <1> 	mov	cl, 4
  1420 000069A1 BF[ABDE0000]        <1> 	mov	edi, Cmd_Move
  1421 000069A6 E834030000          <1>    	call	cmp_cmd	
  1422 000069AB 0F8395160000        <1> 	jnc	move_file
  1423                              <1> 
  1424                              <1> cmp_cmd_path:
  1425 000069B1 B104                <1> 	mov	cl, 4
  1426 000069B3 BF[B0DE0000]        <1> 	mov	edi, Cmd_Path
  1427 000069B8 E822030000          <1>    	call	cmp_cmd	
  1428 000069BD 0F83351A0000        <1> 	jnc	set_get_path
  1429                              <1> 
  1430                              <1> cmp_cmd_beep:
  1431 000069C3 B104                <1> 	mov	cl, 4
  1432 000069C5 BF[E6DE0000]        <1> 	mov	edi, Cmd_Beep
  1433 000069CA E810030000          <1>    	call	cmp_cmd	
  1434 000069CF 720B                <1> 	jc	short cmp_cmd_find
  1435                              <1> 	; 13/05/2016
  1436 000069D1 8A3D[D61F0100]      <1> 	mov	bh, [ptty] ; [ACTIVE_PAGE]
  1437 000069D7 E920B2FFFF          <1> 	jmp	beeper
  1438                              <1> 
  1439                              <1> cmp_cmd_find:
  1440 000069DC B104                <1> 	mov	cl, 4
  1441 000069DE BF[BADE0000]        <1> 	mov	edi, Cmd_Find
  1442 000069E3 E8F7020000          <1>    	call	cmp_cmd	
  1443 000069E8 0F82D4020000        <1>         jc      cmp_cmd_external
  1444                              <1> 
  1445                              <1> 	;call	find_and_list_files
  1446 000069EE E9EC220000          <1> 	jmp	find_and_list_files
  1447                              <1> 	;retn
  1448                              <1> 
  1449                              <1> c_1:
  1450 000069F3 AD                  <1> 	lodsd
  1451                              <1> cmp_cmd_help:
  1452 000069F4 3C3F                <1> 	cmp	al, '?'
  1453 000069F6 751D                <1>         jne     short cmp_cmd_remark
  1454                              <1> 
  1455 000069F8 BE[43DE0000]        <1> 	mov	esi, Command_List
  1456                              <1> cmd_help_next_w:
  1457 000069FD E830EBFFFF          <1> 	call	print_msg
  1458                              <1> 
  1459 00006A02 803E20              <1> 	cmp	byte [esi], 20h ; 0
  1460 00006A05 7232                <1> 	jb	short cmd_help_retn
  1461                              <1> 	
  1462 00006A07 56                  <1> 	push	esi
  1463 00006A08 BE[8BEE0000]        <1> 	mov	esi, nextline
  1464 00006A0D E820EBFFFF          <1> 	call	print_msg
  1465 00006A12 5E                  <1> 	pop	esi
  1466 00006A13 EBE8                <1> 	jmp	short cmd_help_next_w	
  1467                              <1> 
  1468                              <1> cmp_cmd_remark:
  1469 00006A15 3C2A                <1> 	cmp	al, '*'
  1470 00006A17 0F85A5020000        <1>         jne     cmp_cmd_external
  1471 00006A1D 46                  <1> 	inc	esi
  1472 00006A1E BF[D0200100]        <1> 	mov	edi, Remark
  1473 00006A23 8A06                <1> 	mov	al, [esi]
  1474 00006A25 3C20                <1> 	cmp	al, 20h
  1475 00006A27 7707                <1> 	ja	short cmd_remark_write
  1476 00006A29 89FE                <1> 	mov	esi, edi ; Remark
  1477 00006A2B E902EBFFFF          <1> 	jmp	print_msg
  1478                              <1> 
  1479                              <1> cmd_remark_write:
  1480 00006A30 AA                  <1> 	stosb
  1481 00006A31 AC                  <1> 	lodsb
  1482 00006A32 3C20                <1> 	cmp	al, 20h
  1483 00006A34 73FA                <1> 	jnb	short cmd_remark_write
  1484 00006A36 C60700              <1> 	mov	byte [edi], 0
  1485                              <1> 
  1486                              <1> cmd_help_retn:
  1487                              <1> cmd_remark_retn:
  1488                              <1> cd_retn:
  1489 00006A39 C3                  <1> 	retn
  1490                              <1> 
  1491                              <1> c_2:
  1492 00006A3A 80F902              <1> 	cmp	cl, 2
  1493 00006A3D 0F87B1000000        <1>         ja      c_3
  1494 00006A43 BE[1E210100]        <1> 	mov	esi, CommandBuffer
  1495 00006A48 72A9                <1> 	jb	short c_1
  1496                              <1> 
  1497                              <1> cmp_cmd_cd:
  1498 00006A4A 66AD                <1> 	lodsw
  1499 00006A4C 663D4344            <1> 	cmp	ax, 'CD'
  1500 00006A50 7553                <1> 	jne	short cmp_cmd_drive
  1501 00006A52 46                  <1>         inc	esi
  1502                              <1> cd_0:
  1503 00006A53 668B06              <1> 	mov	ax, [esi]	
  1504 00006A56 3C20                <1> 	cmp	al, 20h
  1505 00006A58 76DF                <1> 	jna	short cd_retn
  1506                              <1> 	; 10/02/2016
  1507 00006A5A 80FC3A              <1> 	cmp	ah, ':'
  1508 00006A5D 7504                <1> 	jne	short cd_1
  1509 00006A5F 46                  <1> 	inc	esi
  1510 00006A60 46                  <1> 	inc	esi
  1511 00006A61 EB4B                <1> 	jmp	short cd_2
  1512                              <1> 
  1513                              <1> cd_1:	; change current directory
  1514                              <1> 	; 29/11/2009
  1515                              <1> 	; AH = CDh	; to separate 'CD' command from others
  1516                              <1> 			; for restoring current directory
  1517                              <1> 			; 0CDh sign is for saving cdir into 
  1518                              <1> 			; DOS drv description table cdir area
  1519                              <1> 	
  1520 00006A63 B4CD                <1> 	mov	ah, 0CDh ; mov byte [CD_COMMAND], 0CDh 
  1521                              <1> 
  1522 00006A65 E85A230000          <1> 	call	change_current_directory
  1523 00006A6A 0F8374220000        <1>         jnc     change_prompt_dir_string
  1524                              <1> 
  1525                              <1> cd_error_messages:
  1526 00006A70 3C03                <1> 	cmp	al, 3
  1527 00006A72 740C                <1> 	je	short cd_path_not_found
  1528 00006A74 3C15                <1> 	cmp	al, 15h 
  1529 00006A76 745B                <1> 	je	short cd_drive_not_ready
  1530 00006A78 3C18                <1> 	cmp	al, 18h ; Bad request structure length 
  1531 00006A7A 746C                <1> 	je	short cd_command_failed
  1532 00006A7C 3C1A                <1> 	cmp	al, 1Ah ; Unknown media type, non-DOS disk
  1533 00006A7E 7468                <1>         je      short cd_command_failed
  1534                              <1> 
  1535                              <1> cd_path_not_found:
  1536 00006A80 6650                <1> 	push	ax	
  1537 00006A82 BE[EFE00000]        <1> 	mov	esi, Msg_Dir_Not_Found
  1538 00006A87 E8A6EAFFFF          <1> 	call	print_msg
  1539 00006A8C 6658                <1> 	pop	ax
  1540 00006A8E 3A25[6C200100]      <1> 	cmp	ah, [Current_Dir_Level]
  1541 00006A94 0F834A220000        <1>         jnb     change_prompt_dir_string
  1542 00006A9A 8825[6C200100]      <1> 	mov	[Current_Dir_Level], ah
  1543 00006AA0 E93F220000          <1>         jmp     change_prompt_dir_string   
  1544                              <1> 
  1545                              <1> cmp_cmd_drive: ; change current drive
  1546                              <1> 	; C:, D:, E: etc.
  1547 00006AA5 80FC3A              <1> 	cmp	ah, ':'
  1548 00006AA8 0F8514020000        <1>         jne     cmp_cmd_external
  1549                              <1> 
  1550                              <1> cd_2:	; 'CD C:', 'CD D:' ...
  1551 00006AAE 803E20              <1> 	cmp	byte [esi], 20h
  1552 00006AB1 0F8715020000        <1>         ja      loc_cmd_failed
  1553                              <1> 
  1554 00006AB7 24DF                <1> 	and	al, 0DFh
  1555 00006AB9 2C41                <1> 	sub	al, 'A'
  1556 00006ABB 0F820B020000        <1>         jc      loc_cmd_failed
  1557                              <1> 
  1558 00006AC1 3A05[E3DD0000]      <1>         cmp     al, [Last_DOS_DiskNo]
  1559 00006AC7 770A                <1>         ja	short cd_drive_not_ready
  1560                              <1> 	
  1561 00006AC9 88C2                <1> 	mov	dl, al
  1562 00006ACB E862F3FFFF          <1> 	call 	change_current_drive
  1563 00006AD0 7201                <1> 	jc	short cd_drive_not_ready	
  1564 00006AD2 C3                  <1> 	retn
  1565                              <1> 
  1566                              <1> cd_drive_not_ready:
  1567 00006AD3 BE[ACE00000]        <1> 	mov	esi, Msg_Not_Ready_Read_Err
  1568 00006AD8 E855EAFFFF          <1> 	call	print_msg
  1569                              <1> 
  1570                              <1> cd_fail_drive_restart:
  1571 00006ADD 8A15[6E200100]      <1> 	mov	dl, [Current_Drv]
  1572                              <1> 	;call 	change_current_drive
  1573 00006AE3 E94AF3FFFF          <1>         jmp     change_current_drive
  1574                              <1> 	;retn
  1575                              <1> 
  1576                              <1> cd_command_failed:
  1577 00006AE8 BE[8DE00000]        <1> 	mov	esi, Msg_Bad_Command
  1578 00006AED E840EAFFFF          <1> 	call	print_msg
  1579 00006AF2 EBE9                <1> 	jmp	short cd_fail_drive_restart
  1580                              <1> 
  1581                              <1> c_3:
  1582                              <1> cmp_cmd_dir:
  1583 00006AF4 BF[43DE0000]        <1> 	mov	edi, Cmd_Dir
  1584 00006AF9 E8E1010000          <1> 	call	cmp_cmd	
  1585 00006AFE 0F8380020000        <1> 	jnc	print_directory_list
  1586                              <1> 
  1587                              <1> cmp_cmd_cls:
  1588 00006B04 B103                <1> 	mov	cl, 3
  1589 00006B06 BF[7FDE0000]        <1> 	mov	edi, Cmd_Cls
  1590 00006B0B E8CF010000          <1> 	call	cmp_cmd	
  1591 00006B10 0F8332EAFFFF        <1>         jnc	clear_screen
  1592                              <1> 
  1593                              <1> cmp_cmd_ver:
  1594 00006B16 B103                <1> 	mov	cl, 3
  1595 00006B18 BF[4DDE0000]        <1> 	mov	edi, Cmd_Ver
  1596 00006B1D E8BD010000          <1> 	call	cmp_cmd	
  1597 00006B22 720A                <1> 	jc	short cmp_cmd_mem
  1598                              <1> 
  1599 00006B24 BE[EBDD0000]        <1> 	mov	esi, mainprog_Version
  1600                              <1> 	;call	print_msg
  1601 00006B29 E904EAFFFF          <1> 	jmp	print_msg
  1602                              <1> 	;retn
  1603                              <1> 
  1604                              <1> cmp_cmd_mem:
  1605 00006B2E B103                <1> 	mov	cl, 3
  1606 00006B30 BF[B5DE0000]        <1> 	mov	edi, Cmd_Mem
  1607 00006B35 E8A5010000          <1> 	call	cmp_cmd	
  1608 00006B3A 0F835FC1FFFF        <1> 	jnc	memory_info
  1609                              <1> 
  1610                              <1> cmp_cmd_del:
  1611 00006B40 B103                <1> 	mov	cl, 3
  1612 00006B42 BF[88DE0000]        <1> 	mov	edi, Cmd_Del
  1613 00006B47 E893010000          <1> 	call	cmp_cmd	
  1614 00006B4C 0F83340F0000        <1>         jnc     delete_file
  1615                              <1> 
  1616                              <1> cmp_cmd_set:
  1617 00006B52 B103                <1> 	mov	cl, 3
  1618 00006B54 BF[7BDE0000]        <1> 	mov	edi, Cmd_Set
  1619 00006B59 E881010000          <1> 	call	cmp_cmd	
  1620 00006B5E 0F830C180000        <1>         jnc     set_get_env
  1621                              <1> 
  1622                              <1> cmp_cmd_run:
  1623 00006B64 B103                <1> 	mov	cl, 3
  1624 00006B66 BF[77DE0000]        <1> 	mov	edi, Cmd_Run
  1625 00006B6B E86F010000          <1> 	call	cmp_cmd	
  1626                              <1> 	; 07/05/2016
  1627 00006B70 0F824C010000        <1>         jc      cmp_cmd_external
  1628 00006B76 E9431E0000          <1> 	jmp	load_and_execute_file
  1629                              <1> c_5:
  1630                              <1> cmp_cmd_mkdir:
  1631 00006B7B BF[A0DE0000]        <1> 	mov	edi, Cmd_Mkdir
  1632 00006B80 E85A010000          <1> 	call	cmp_cmd	
  1633 00006B85 0F83930A0000        <1>         jnc     make_directory
  1634                              <1> 
  1635                              <1> cmp_cmd_rmdir:
  1636 00006B8B B105                <1> 	mov	cl, 5
  1637 00006B8D BF[9ADE0000]        <1> 	mov	edi, Cmd_Rmdir
  1638 00006B92 E848010000          <1> 	call	cmp_cmd	
  1639 00006B97 0F83A00B0000        <1>         jnc     delete_directory
  1640                              <1> 
  1641                              <1> cmp_cmd_chdir:
  1642 00006B9D B105                <1> 	mov	cl, 5
  1643 00006B9F BF[E0DE0000]        <1> 	mov	edi, Cmd_Chdir
  1644 00006BA4 E836010000          <1> 	call	cmp_cmd	
  1645 00006BA9 0F8213010000        <1>         jc      cmp_cmd_external
  1646                              <1> 
  1647 00006BAF E99FFEFFFF          <1> 	jmp	cd_0
  1648                              <1> 
  1649                              <1> c_6:
  1650 00006BB4 80F906              <1> 	cmp	cl, 6
  1651 00006BB7 0F87DF000000        <1>         ja      c_8
  1652 00006BBD 72BC                <1> 	jb	short c_5
  1653                              <1> cmp_cmd_prompt:
  1654 00006BBF BF[56DE0000]        <1> 	mov	edi, Cmd_Prompt
  1655 00006BC4 E816010000          <1> 	call	cmp_cmd	
  1656 00006BC9 722E                <1>         jc	short cmp_cmd_volume
  1657                              <1> get_prompt_name_fchar:
  1658 00006BCB AC                  <1> 	lodsb
  1659 00006BCC 3C20                <1> 	cmp	al, 20h
  1660 00006BCE 74FB                <1> 	je	short get_prompt_name_fchar
  1661 00006BD0 7712                <1> 	ja	short loc_change_prompt_label
  1662 00006BD2 BE[37DE0000]        <1> 	mov	esi, TRDOSPromptLabel
  1663 00006BD7 C7065452444F        <1> 	mov	dword [esi], "TRDO"
  1664 00006BDD 66C746045300        <1>        	mov	word [esi+4], "S" 
  1665                              <1> loc_cmd_prompt_return:
  1666 00006BE3 C3                  <1> 	retn
  1667                              <1> loc_change_prompt_label:
  1668 00006BE4 66B90B00            <1> 	mov	cx, 11
  1669 00006BE8 BF[37DE0000]        <1> 	mov	edi, TRDOSPromptLabel
  1670                              <1> put_char_new_prompt_label:
  1671 00006BED AA                  <1> 	stosb
  1672 00006BEE AC                  <1> 	lodsb
  1673 00006BEF 3C20                <1> 	cmp	al, 20h
  1674 00006BF1 7202                <1> 	jb	short pass_put_new_prompt_label
  1675 00006BF3 E2F8                <1> 	loop	put_char_new_prompt_label
  1676                              <1> pass_put_new_prompt_label:
  1677 00006BF5 C60700              <1> 	mov	byte [edi], 0
  1678 00006BF8 C3                  <1> 	retn
  1679                              <1> 
  1680                              <1> cmp_cmd_volume:
  1681 00006BF9 B106                <1> 	mov	cl, 6
  1682 00006BFB BF[5DDE0000]        <1> 	mov	edi, Cmd_Volume
  1683 00006C00 E8DA000000          <1> 	call	cmp_cmd	
  1684 00006C05 7255                <1>         jc	short cmp_cmd_attrib
  1685                              <1> 
  1686                              <1> cmd_vol1:
  1687 00006C07 AC                  <1> 	lodsb
  1688 00006C08 3C20                <1> 	cmp	al, 20h
  1689 00006C0A 7707                <1> 	ja	short cmd_vol2
  1690 00006C0C A0[6E200100]        <1> 	mov	al, [Current_Drv]
  1691 00006C11 EB3D                <1> 	jmp	short cmd_vol4
  1692                              <1> cmd_vol2:
  1693 00006C13 3C41                <1> 	cmp	al, 'A'
  1694 00006C15 0F82B1000000        <1>         jb      loc_cmd_failed
  1695 00006C1B 3C7A                <1> 	cmp	al, 'z'
  1696 00006C1D 0F87A9000000        <1>         ja      loc_cmd_failed
  1697 00006C23 3C5A                <1> 	cmp	al, 'Z'
  1698 00006C25 760A                <1> 	jna	short cmd_vol3
  1699 00006C27 3C61                <1> 	cmp	al, 'a'
  1700 00006C29 0F829D000000        <1>         jb      loc_cmd_failed
  1701 00006C2F 24DF                <1> 	and	al, 0DFh
  1702                              <1> cmd_vol3:
  1703 00006C31 8A26                <1> 	mov	ah, [esi]
  1704 00006C33 80FC3A              <1> 	cmp	ah, ':'
  1705 00006C36 0F8590000000        <1>         jne     loc_cmd_failed
  1706 00006C3C 2C41                <1> 	sub	al, 'A'
  1707 00006C3E 3A05[E3DD0000]      <1>         cmp     al, [Last_DOS_DiskNo]
  1708 00006C44 760A                <1> 	jna	short cmd_vol4
  1709                              <1> 
  1710 00006C46 BE[ACE00000]        <1> 	mov	esi, Msg_Not_Ready_Read_Err
  1711 00006C4B E9E2E8FFFF          <1> 	jmp	print_msg
  1712                              <1> 	
  1713                              <1> cmd_vol4:
  1714 00006C50 E896FAFFFF          <1> 	call	print_volume_info
  1715 00006C55 0F8278FEFFFF        <1>         jc      cd_drive_not_ready
  1716 00006C5B C3                  <1> 	retn
  1717                              <1> 
  1718                              <1> cmp_cmd_attrib:
  1719 00006C5C B106                <1> 	mov	cl, 6
  1720 00006C5E BF[8CDE0000]        <1> 	mov	edi, Cmd_Attrib
  1721 00006C63 E877000000          <1> 	call	cmp_cmd	
  1722 00006C68 0F83380F0000        <1>         jnc     set_file_attributes
  1723                              <1> 
  1724                              <1> cmp_cmd_rename:
  1725 00006C6E B106                <1> 	mov	cl, 6
  1726 00006C70 BF[93DE0000]        <1> 	mov	edi, Cmd_Rename
  1727 00006C75 E865000000          <1> 	call	cmp_cmd	
  1728 00006C7A 0F836E110000        <1>         jnc     rename_file
  1729                              <1> 
  1730                              <1> cmp_cmd_device:
  1731 00006C80 B106                <1> 	mov	cl, 6
  1732 00006C82 BF[D1DE0000]        <1> 	mov	edi, Cmd_Device
  1733 00006C87 E853000000          <1> 	call	cmp_cmd	
  1734 00006C8C 7234                <1>         jc	short cmp_cmd_external
  1735                              <1> 
  1736 00006C8E C3                  <1> 	retn
  1737                              <1> 
  1738                              <1> c_7:
  1739                              <1> cmp_cmd_devlist:
  1740 00006C8F BF[D8DE0000]        <1> 	mov	edi, Cmd_DevList
  1741 00006C94 E846000000          <1> 	call	cmp_cmd	
  1742 00006C99 7227                <1>         jc	short cmp_cmd_external
  1743                              <1> 
  1744 00006C9B C3                  <1> 	retn
  1745                              <1> 
  1746                              <1> c_8:
  1747 00006C9C 80F908              <1>         cmp	cl, 8
  1748 00006C9F 7721                <1> 	ja	short cmp_cmd_external
  1749 00006CA1 72EC                <1> 	jb	short c_7
  1750                              <1> 
  1751                              <1> cmp_cmd_longname:
  1752 00006CA3 BF[64DE0000]        <1> 	mov	edi, Cmd_LongName
  1753 00006CA8 E832000000          <1> 	call	cmp_cmd	
  1754 00006CAD 0F8351060000        <1>         jnc     get_and_print_longname
  1755                              <1> 
  1756                              <1> cmp_cmd_readfile:
  1757 00006CB3 B108                <1> 	mov	cl, 8
  1758 00006CB5 BF[BFDE0000]        <1> 	mov	edi, Cmd_ReadFile
  1759 00006CBA E820000000          <1> 	call	cmp_cmd	
  1760 00006CBF 7201                <1>         jc	short cmp_cmd_external
  1761                              <1> 
  1762                              <1> loc_cmd_return:
  1763 00006CC1 C3                  <1> 	retn
  1764                              <1> 
  1765                              <1> cmp_cmd_external:
  1766                              <1> 	; 07/05/2016
  1767                              <1> 	; 22/04/2016
  1768 00006CC2 BE[1E210100]        <1> 	mov	esi, CommandBuffer
  1769 00006CC7 E9F21C0000          <1> 	jmp	loc_run_check_filename 
  1770                              <1> 
  1771                              <1> loc_cmd_failed:
  1772 00006CCC 803D[1E210100]20    <1> 	cmp	byte [CommandBuffer], 20h
  1773 00006CD3 76EC                <1> 	jna	short loc_cmd_return
  1774 00006CD5 BE[8DE00000]        <1> 	mov	esi, Msg_Bad_Command
  1775                              <1> ;	call	print_msg
  1776                              <1> ;loc_cmd_return:
  1777                              <1> ;	retn
  1778 00006CDA E953E8FFFF          <1> 	jmp	print_msg
  1779                              <1> 
  1780                              <1> cmp_cmd:
  1781                              <1> 	 ; 29/01/2016 (TRDOS 386 = TRDOS v2.0)
  1782 00006CDF BE[1E210100]        <1>          mov	esi, CommandBuffer
  1783                              <1>          ; edi = internal command word (ASCIIZ)
  1784                              <1> 	 ; ecx = command length (<=8)
  1785                              <1> cmp_cmd_1:
  1786 00006CE4 AC                  <1> 	lodsb
  1787 00006CE5 AE                  <1> 	scasb
  1788 00006CE6 750D                <1> 	jne	short cmp_cmd_3
  1789 00006CE8 E2FA                <1> 	loop	cmp_cmd_1
  1790 00006CEA AC                  <1>  	lodsb
  1791 00006CEB 3C20                <1> 	cmp	al, 20h
  1792 00006CED 7703                <1> 	ja	short cmp_cmd_2
  1793 00006CEF 30C0                <1> 	xor	al, al
  1794                              <1> 	; ZF = 1 -> internal command word matches
  1795 00006CF1 C3                  <1> 	retn
  1796                              <1> cmp_cmd_2:
  1797                              <1> 	; ZF = 0 (CF = 0) -> external command word 	
  1798 00006CF2 58                  <1> 	pop	eax ; no return to the caller from here 
  1799 00006CF3 EBCD                <1> 	jmp	cmp_cmd_external	
  1800                              <1> cmp_cmd_3:
  1801 00006CF5 F9                  <1> 	stc
  1802                              <1> 	; CF = 1 -> internal command word does not match
  1803 00006CF6 C3                  <1> 	retn
  1804                              <1> 
  1805                              <1> loc_run_cmd_failed:
  1806                              <1> 	; 15/03/2016
  1807                              <1> 	; 15/02/2016 (TRDOS 386 =  TRDOS v2.0)
  1808                              <1> 	; 07/12/2009 (CMD_INTR.ASM)	
  1809                              <1> 	; 29/11/2009
  1810                              <1> 
  1811 00006CF7 E855000000          <1> 	call	restore_cdir_after_cmd_fail
  1812                              <1> 
  1813                              <1> loc_run_cmd_failed_cmp_al:
  1814                              <1> 	; End of Restore_CDIR code (29/11/2009)
  1815                              <1> 
  1816 00006CFC 3C01                <1> 	cmp	al, 1
  1817 00006CFE 74CC                <1> 	je	loc_cmd_failed
  1818                              <1> loc_run_dir_not_found:
  1819 00006D00 3C03                <1> 	cmp	al, 3
  1820 00006D02 750A                <1> 	jne	short loc_run_file_notfound_msg
  1821                              <1> 	; Path not found (MS-DOS Error Code = 3)
  1822 00006D04 BE[EFE00000]        <1> 	mov	esi, Msg_Dir_Not_Found
  1823 00006D09 E924E8FFFF          <1> 	jmp	print_msg
  1824                              <1> 
  1825                              <1> loc_run_file_notfound_msg:
  1826 00006D0E 3C02                <1> 	cmp	al, 2 ; File not found
  1827 00006D10 750A                <1> 	jne	short loc_run_file_drv_read_err
  1828                              <1> 
  1829                              <1> loc_print_file_notfound_msg: 
  1830 00006D12 BE[06E10000]        <1>         mov     esi, Msg_File_Not_Found
  1831                              <1> 	;call	proc_printmsg
  1832                              <1> 	;retn
  1833 00006D17 E916E8FFFF          <1> 	jmp	print_msg
  1834                              <1> 
  1835                              <1> loc_run_file_drv_read_err:
  1836                              <1> 	; Err: 1Eh (Read fault)
  1837 00006D1C 3C1E                <1> 	cmp	al, 1Eh ; Drive not ready or read error
  1838 00006D1E 7404                <1> 	je	short loc_run_file_print_drv_read_err
  1839                              <1> 	;
  1840 00006D20 3C15                <1> 	cmp	al, 15h ; Drive not ready (or read error)
  1841 00006D22 750A                <1> 	jne	short loc_run_file_toobig
  1842                              <1> 
  1843                              <1> loc_run_file_print_drv_read_err:
  1844 00006D24 BE[ACE00000]        <1> 	mov	esi, Msg_Not_Ready_Read_Err
  1845 00006D29 E904E8FFFF          <1> 	jmp	print_msg
  1846                              <1> 
  1847                              <1> loc_run_file_toobig:
  1848 00006D2E 3C08                <1> 	cmp	al, 8 ; Not enough free memory to load&run file
  1849 00006D30 750A                <1> 	jne	short loc_run_misc_error
  1850 00006D32 BE[4EE10000]        <1> 	mov	esi, Msg_Insufficient_Memory
  1851 00006D37 E9F6E7FFFF          <1> 	jmp	print_msg
  1852                              <1> 
  1853                              <1> 	; 15/03/2016
  1854                              <1> print_misc_error_msg:
  1855                              <1> loc_run_misc_error:
  1856                              <1> 	; AL = Error code
  1857 00006D3C E8D3BFFFFF          <1> 	call	bytetohex
  1858 00006D41 66A3[82E10000]      <1>         mov     [error_code_hex], ax
  1859                              <1> 	
  1860 00006D47 BE[65E10000]        <1> 	mov	esi, Msg_Error_Code 
  1861                              <1> 	;call	print_msg 
  1862                              <1> 	;retn
  1863                              <1> 
  1864 00006D4C E9E1E7FFFF          <1> 	jmp	print_msg
  1865                              <1> 
  1866                              <1> restore_cdir_after_cmd_fail:
  1867                              <1> 	; 15/02/2016 (TRDOS 386 =  TRDOS v2.0)
  1868 00006D51 50                  <1> 	push	eax
  1869 00006D52 8A3D[CE280100]      <1> 	mov	bh, [RUN_CDRV] ; it is set at the beginning
  1870                              <1> 				; of the 'run' command.
  1871 00006D58 3A3D[6E200100]      <1> 	cmp	bh, [Current_Drv]
  1872 00006D5E 7409                <1> 	je	short loc_run_restore_cdir
  1873 00006D60 88FA                <1> 	mov	dl, bh
  1874 00006D62 E8CBF0FFFF          <1> 	call	change_current_drive 
  1875 00006D67 EB19                <1> 	jmp	short loc_run_err_pass_restore_cdir
  1876                              <1> 
  1877                              <1> loc_run_restore_cdir:
  1878 00006D69 803D[E4DD0000]00    <1> 	cmp	byte [Restore_CDIR], 0
  1879 00006D70 7610                <1> 	jna	short loc_run_err_pass_restore_cdir
  1880 00006D72 30DB                <1> 	xor	bl, bl
  1881 00006D74 0FB7F3              <1> 	movzx	esi, bx
  1882 00006D77 81C600010900        <1> 	add	esi, Logical_DOSDisks
  1883 00006D7D E862F1FFFF          <1> 	call	restore_current_directory
  1884                              <1> 
  1885                              <1> loc_run_err_pass_restore_cdir:
  1886 00006D82 58                  <1> 	pop	eax
  1887 00006D83 C3                  <1> 	retn
  1888                              <1> 
  1889                              <1> print_directory_list:
  1890                              <1> 	; 10/02/2016
  1891                              <1> 	; 08/02/2016 (TRDOS 386 =  TRDOS v2.0)
  1892                              <1> 	; 06/12/2009 ('cmp_cmd_dir')	
  1893                              <1> 	;
  1894 00006D84 66C705[102A0100]00- <1> 	mov	word [AttributesMask], 0800h ; ..except volume names..
  1894 00006D8C 08                  <1>
  1895 00006D8D A0[6E200100]        <1> 	mov	al, [Current_Drv]
  1896 00006D92 A2[CE280100]        <1> 	mov	[RUN_CDRV], al
  1897                              <1> get_dfname_fchar:
  1898 00006D97 AC                  <1> 	lodsb
  1899 00006D98 3C20                <1> 	cmp	al, 20h
  1900 00006D9A 74FB                <1> 	je	short get_dfname_fchar
  1901 00006D9C 0F82A4000000        <1>         jb      loc_print_dir_call_all
  1902 00006DA2 3C2D                <1> 	cmp	al, '-'
  1903 00006DA4 7542                <1> 	jne	short loc_print_dir_call_flt
  1904                              <1> get_next_attr_char:
  1905 00006DA6 AC                  <1> 	lodsb
  1906 00006DA7 3C20                <1> 	cmp	al, 20h
  1907 00006DA9 74FB                <1> 	je	short get_next_attr_char
  1908 00006DAB 0F821BFFFFFF        <1>         jb      loc_cmd_failed
  1909 00006DB1 24DF                <1> 	and	al, 0DFh
  1910 00006DB3 3C44                <1> 	cmp	al, 'D' ; directories only ?
  1911 00006DB5 7512                <1> 	jne	short pass_only_directories
  1912 00006DB7 AC                  <1> 	lodsb
  1913 00006DB8 3C20                <1> 	cmp	al, 20h
  1914 00006DBA 0F870CFFFFFF        <1>         ja      loc_cmd_failed
  1915 00006DC0 800D[102A0100]10    <1> 	or	byte [AttributesMask], 10h ; ..directory..
  1916 00006DC7 EB18                <1> 	jmp	short get_dfname_fchar_attr
  1917                              <1> pass_only_directories:
  1918 00006DC9 3C46                <1> 	cmp	al, 'F'	; files only ?
  1919 00006DCB 0F85B0000000        <1>         jne     check_attr_s
  1920 00006DD1 AC                  <1> 	lodsb
  1921 00006DD2 3C20                <1> 	cmp	al, 20h
  1922 00006DD4 0F87F2FEFFFF        <1>         ja      loc_cmd_failed
  1923 00006DDA 800D[112A0100]10    <1> 	or	byte [AttributesMask+1], 10h ; ..except directories..
  1924                              <1> get_dfname_fchar_attr:
  1925 00006DE1 AC                  <1> 	lodsb
  1926 00006DE2 3C20                <1> 	cmp	al, 20h
  1927 00006DE4 74FB                <1> 	je	short get_dfname_fchar_attr
  1928 00006DE6 725E                <1> 	jb	short loc_print_dir_call_all
  1929                              <1> 
  1930                              <1> loc_print_dir_call_flt:
  1931 00006DE8 4E                  <1> 	dec	esi
  1932 00006DE9 BF[122A0100]        <1> 	mov	edi, FindFile_Drv
  1933 00006DEE E8E5250000          <1> 	call	parse_path_name
  1934 00006DF3 7308                <1>  	jnc	short loc_print_dir_change_drv_1
  1935 00006DF5 3C01                <1> 	cmp	al, 1
  1936 00006DF7 0F87FAFEFFFF        <1>         ja      loc_run_cmd_failed
  1937                              <1> 
  1938                              <1> loc_print_dir_change_drv_1:
  1939 00006DFD 8A15[122A0100]      <1> 	mov	dl, [FindFile_Drv]
  1940                              <1> loc_print_dir_change_drv_2:
  1941 00006E03 3A15[CE280100]      <1> 	cmp	dl, [RUN_CDRV]
  1942 00006E09 740B                <1> 	je	short loc_print_dir_change_directory 
  1943 00006E0B E822F0FFFF          <1> 	call	change_current_drive
  1944 00006E10 0F82E1FEFFFF        <1>         jc      loc_run_cmd_failed
  1945                              <1> loc_print_dir_change_directory:
  1946 00006E16 803D[132A0100]20    <1> 	cmp	byte [FindFile_Directory], 20h ; 0 or 20h ?
  1947 00006E1D 761D                <1> 	jna	short pass_print_dir_change_directory
  1948                              <1> 
  1949 00006E1F FE05[E4DD0000]      <1> 	inc	byte [Restore_CDIR]
  1950 00006E25 BE[132A0100]        <1> 	mov	esi, FindFile_Directory
  1951 00006E2A 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
  1952 00006E2C E8931F0000          <1> 	call	change_current_directory
  1953 00006E31 0F82C0FEFFFF        <1>         jc      loc_run_cmd_failed
  1954                              <1> 
  1955                              <1> loc_print_dir_change_prompt_dir_string:
  1956 00006E37 E8A81E0000          <1> 	call	change_prompt_dir_string
  1957                              <1> 
  1958                              <1> pass_print_dir_change_directory:
  1959 00006E3C BE[542A0100]        <1> 	mov	esi, FindFile_Name
  1960 00006E41 803E20              <1> 	cmp	byte [esi], 20h ; ; 0 or 20h ?
  1961 00006E44 7706                <1> 	ja	short loc_print_dir_call
  1962                              <1> 
  1963                              <1> loc_print_dir_call_all:
  1964 00006E46 C7062A2E2A00        <1> 	mov	dword [esi], '*.*'
  1965                              <1> loc_print_dir_call:
  1966 00006E4C E87E000000          <1> 	call	print_directory
  1967                              <1> 
  1968 00006E51 8A15[CE280100]      <1> 	mov	dl, [RUN_CDRV]  ; it is set at the beginning
  1969 00006E57 3A15[6E200100]      <1> 	cmp	dl, [Current_Drv]
  1970 00006E5D 7406                <1> 	je	short loc_print_dir_call_restore_cdir_retn
  1971 00006E5F E8CEEFFFFF          <1> 	call	change_current_drive 
  1972 00006E64 C3                  <1> 	retn
  1973                              <1> 
  1974                              <1> loc_print_dir_call_restore_cdir_retn:
  1975 00006E65 803D[E4DD0000]00    <1> 	cmp	byte [Restore_CDIR], 0
  1976 00006E6C 7610                <1> 	jna	short pass_print_dir_call_restore_cdir_retn
  1977                              <1> 
  1978 00006E6E BE00010900          <1> 	mov	esi, Logical_DOSDisks
  1979 00006E73 31C0                <1> 	xor	eax, eax
  1980 00006E75 88D4                <1> 	mov	ah, dl
  1981 00006E77 01C6                <1> 	add	esi, eax
  1982                              <1> 
  1983 00006E79 E866F0FFFF          <1> 	call	restore_current_directory
  1984                              <1> 
  1985                              <1> pass_print_dir_call_restore_cdir_retn:
  1986 00006E7E C3                  <1> 	retn
  1987                              <1> 
  1988                              <1> check_attr_s_cap:
  1989 00006E7F 24DF                <1> 	and	al, 0DFh
  1990                              <1> check_attr_s:
  1991 00006E81 3C53                <1> 	cmp	al, 'S'
  1992 00006E83 7514                <1> 	jne	short pass_attr_s
  1993 00006E85 800D[102A0100]04    <1> 	or	byte [AttributesMask], 4 ; system
  1994 00006E8C AC                  <1> 	lodsb
  1995 00006E8D 3C20                <1> 	cmp	al, 20h
  1996 00006E8F 0F844CFFFFFF        <1>         je      get_dfname_fchar_attr
  1997 00006E95 72AF                <1> 	jb	short loc_print_dir_call_all
  1998 00006E97 24DF                <1> 	and	al, 0DFh
  1999                              <1> pass_attr_s:
  2000 00006E99 3C48                <1> 	cmp	al, 'H'
  2001 00006E9B 7514                <1> 	jne	short pass_attr_h
  2002 00006E9D 800D[102A0100]02    <1> 	or	byte [AttributesMask], 2 ; hidden
  2003                              <1> pass_attr_shr:
  2004 00006EA4 AC                  <1> 	lodsb
  2005 00006EA5 3C20                <1> 	cmp	al, 20h
  2006 00006EA7 0F8434FFFFFF        <1>         je      get_dfname_fchar_attr
  2007 00006EAD 7297                <1> 	jb	short loc_print_dir_call_all
  2008 00006EAF EBCE                <1> 	jmp	short check_attr_s_cap
  2009                              <1> 
  2010                              <1> pass_attr_h:
  2011 00006EB1 3C52                <1> 	cmp	al, 'R'
  2012 00006EB3 7509                <1> 	jne	short pass_attr_r
  2013 00006EB5 800D[102A0100]01    <1> 	or	byte [AttributesMask], 1 ; read only
  2014 00006EBC EBE6                <1> 	jmp	short pass_attr_shr
  2015                              <1> 
  2016                              <1> pass_attr_r:
  2017 00006EBE 3C41                <1> 	cmp	al, 'A'
  2018 00006EC0 0F8506FEFFFF        <1>         jne     loc_cmd_failed
  2019 00006EC6 800D[102A0100]20    <1> 	or	byte [AttributesMask], 20h ; archive
  2020 00006ECD EBD5                <1> 	jmp	short pass_attr_shr
  2021                              <1> 
  2022                              <1> print_directory:
  2023                              <1> 	; 13/05/2016
  2024                              <1> 	; 11/02/2016
  2025                              <1> 	; 10/02/2016
  2026                              <1> 	; 08/02/2016 (TRDOS 386 =  TRDOS v2.0)
  2027                              <1> 	; 30/10/2010 ('proc_print_directory')	
  2028                              <1> 	; 19/09/2009
  2029                              <1> 	; 2005 
  2030                              <1> 	; INPUT ->
  2031                              <1> 	;	ESI = Asciiz File/Dir Name Address
  2032                              <1> 
  2033 00006ECF 56                  <1> 	push	esi
  2034                              <1> 
  2035 00006ED0 29C0                <1> 	sub	eax, eax
  2036                              <1> 
  2037 00006ED2 66A3[9C2A0100]      <1> 	mov	word [Dir_Count], ax ; 0
  2038 00006ED8 66A3[9A2A0100]      <1> 	mov 	word [File_Count], ax ; 0
  2039 00006EDE A3[9E2A0100]        <1> 	mov 	dword [Total_FSize], eax ; 0
  2040                              <1> 
  2041 00006EE3 E860E6FFFF          <1> 	call    clear_screen
  2042                              <1> 	
  2043 00006EE8 31C9                <1> 	xor	ecx, ecx	
  2044 00006EEA 8A2D[6E200100]      <1> 	mov     ch, [Current_Drv] ; DirBuff_Drv - 'A'
  2045 00006EF0 A0[6F200100]        <1> 	mov     al, [Current_Dir_Drv] 
  2046 00006EF5 A2[AADF0000]        <1> 	mov     [Dir_Drive_Name], al
  2047 00006EFA BE00010900          <1> 	mov	esi, Logical_DOSDisks
  2048 00006EFF 01CE                <1> 	add	esi, ecx
  2049                              <1> 
  2050 00006F01 E85FF9FFFF          <1> 	call	move_volume_name_and_serial_no
  2051 00006F06 730C                <1> 	jnc	short print_dir_strlen_check
  2052                              <1> 
  2053 00006F08 5E                  <1> 	pop	esi
  2054 00006F09 8A3D[D61F0100]      <1> 	mov	bh, [ptty] ; [ACTIVE_PAGE]
  2055                              <1> 	;call	beeper
  2056                              <1> 	;retn
  2057 00006F0F E9E8ACFFFF          <1> 	jmp	beeper  ; beep ! and return
  2058                              <1> 
  2059                              <1> print_dir_strlen_check:
  2060 00006F14 BE[71200100]        <1> 	mov	esi, Current_Dir_Root
  2061 00006F19 BF[47E00000]        <1> 	mov	edi, Dir_Str_Root
  2062                              <1> 	
  2063                              <1> 	;xor	ecx, ecx
  2064 00006F1E 8A0D[CD200100]      <1>         mov     cl, [Current_Dir_StrLen]
  2065 00006F24 FEC1                <1> 	inc	cl
  2066 00006F26 80F940              <1> 	cmp	cl, 64
  2067 00006F29 760D                <1> 	jna	short pass_print_dir_strlen_shorting
  2068 00006F2B 46                  <1> 	inc	esi
  2069 00006F2C 01CE                <1> 	add	esi, ecx
  2070 00006F2E 83EE40              <1> 	sub	esi, 64 
  2071 00006F31 47                  <1> 	inc	edi
  2072 00006F32 B82E2E2E20          <1> 	mov	eax, '... ' 
  2073 00006F37 AB                  <1> 	stosd
  2074                              <1>  
  2075                              <1> pass_print_dir_strlen_shorting:
  2076 00006F38 F3A4                <1> 	rep	movsb
  2077                              <1> 
  2078 00006F3A BE[9DDF0000]        <1> 	mov	esi, Dir_Drive_Str
  2079 00006F3F E8EEE5FFFF          <1> 	call	print_msg
  2080                              <1> 
  2081 00006F44 BE[FCDF0000]        <1> 	mov	esi, Vol_Serial_Header
  2082 00006F49 E8E4E5FFFF          <1> 	call	print_msg
  2083                              <1> 
  2084 00006F4E BE[3CE00000]        <1> 	mov	esi, Dir_Str_Header
  2085 00006F53 E8DAE5FFFF          <1> 	call	print_msg
  2086                              <1> 	
  2087 00006F58 BE[89EE0000]        <1> 	mov	esi, next2line
  2088 00006F5D E8D0E5FFFF          <1> 	call	print_msg
  2089                              <1> 
  2090                              <1> loc_print_dir_first_file:
  2091 00006F62 C605[B12A0100]10    <1> 	mov	byte [PrintDir_RowCounter], 16
  2092 00006F69 66A1[102A0100]      <1> 	mov	ax, [AttributesMask]
  2093 00006F6F 5E                  <1> 	pop	esi
  2094                              <1> 
  2095 00006F70 E859020000          <1> 	call	find_first_file
  2096 00006F75 0F826F010000        <1>         jc      loc_dir_ok
  2097                              <1> 	 
  2098                              <1> loc_dfname_use_this:
  2099                              <1> 	; bl =	File Attributes (bh = Long Name Entry Length)
  2100 00006F7B F6C310              <1> 	test	bl, 10h  ; Is it a directory?
  2101 00006F7E 741B                <1> 	jz	short loc_not_dir
  2102                              <1> 
  2103 00006F80 66FF05[9C2A0100]    <1> 	inc	word [Dir_Count]
  2104 00006F87 89F2                <1> 	mov	edx, esi 	; FindFile_DirEntry address
  2105 00006F89 BE[88E10000]        <1>  	mov	esi, Type_Dir	; '<DIR>     '
  2106 00006F8E BF[9FE10000]        <1> 	mov	edi, Dir_Or_FileSize
  2107                              <1> 	; move 10 bytes
  2108 00006F93 A5                  <1> 	movsd
  2109 00006F94 A5                  <1> 	movsd
  2110 00006F95 66A5                <1> 	movsw	    	
  2111 00006F97 89D6                <1> 	mov	esi, edx
  2112 00006F99 EB36                <1> 	jmp     short loc_dir_attribute
  2113                              <1> 
  2114                              <1> loc_not_dir:
  2115 00006F9B 66FF05[9A2A0100]    <1> 	inc	word [File_Count]
  2116 00006FA2 0105[9E2A0100]      <1> 	add	[Total_FSize], eax
  2117                              <1> 
  2118 00006FA8 B90A000000          <1> 	mov	ecx, 10  ; 32 bit divisor
  2119 00006FAD 89CF                <1> 	mov	edi, ecx
  2120 00006FAF 81C7[9FE10000]      <1> 	add	edi, Dir_Or_FileSize
  2121                              <1> loc_dir_rdivide:
  2122 00006FB5 29D2                <1> 	sub	edx, edx
  2123 00006FB7 F7F1                <1> 	div	ecx 	 ; remainder in dl (< 10)
  2124 00006FB9 80C230              <1> 	add     dl, '0'	 ; to make visible (ascii)
  2125 00006FBC 4F                  <1> 	dec	edi
  2126 00006FBD 8817                <1> 	mov     [edi], dl
  2127 00006FBF 21C0                <1> 	and	eax, eax
  2128 00006FC1 75F2                <1> 	jnz	short loc_dir_rdivide
  2129                              <1> 
  2130                              <1> loc_dir_fill_space:
  2131 00006FC3 81FF[9FE10000]      <1> 	cmp     edi, Dir_Or_FileSize
  2132 00006FC9 7606                <1> 	jna     short loc_dir_attribute
  2133 00006FCB 4F                  <1> 	dec     edi
  2134 00006FCC C60720              <1> 	mov     byte [edi], 20h
  2135 00006FCF EBF2                <1> 	jmp     short loc_dir_fill_space
  2136                              <1> 
  2137                              <1> loc_dir_attribute:
  2138 00006FD1 C705[AAE10000]2020- <1> 	mov	dword [File_Attribute], 20202020h
  2138 00006FD9 2020                <1>
  2139                              <1> 
  2140 00006FDB 80FB20              <1> 	cmp	bl, 20h  ; Is it an archive file?
  2141 00006FDE 7207                <1> 	jb	short loc_dir_pass_arch
  2142 00006FE0 C605[ADE10000]41    <1> 	mov	byte [File_Attribute+3], 'A'
  2143                              <1> 
  2144                              <1> loc_dir_pass_arch:
  2145 00006FE7 80E307              <1> 	and	bl, 7
  2146 00006FEA 7428                <1> 	jz	short loc_dir_file_name
  2147 00006FEC 88DF                <1> 	mov	bh, bl
  2148 00006FEE 80E303              <1> 	and	bl, 3
  2149 00006FF1 38DF                <1> 	cmp	bh, bl
  2150 00006FF3 7607                <1> 	jna	short loc_dir_pass_s
  2151 00006FF5 C605[AAE10000]53    <1> 	mov	byte [File_Attribute], 'S'
  2152                              <1> 
  2153                              <1> loc_dir_pass_s:
  2154 00006FFC 80E302              <1> 	and     bl,2
  2155 00006FFF 7407                <1> 	jz      short loc_dir_pass_h
  2156 00007001 C605[ABE10000]48    <1> 	mov     byte [File_Attribute+1], 'H'
  2157                              <1> loc_dir_pass_h:
  2158 00007008 80E701              <1> 	and     bh,1
  2159 0000700B 7407                <1> 	jz      short loc_dir_file_name
  2160 0000700D C605[ACE10000]52    <1> 	mov     byte [File_Attribute+2], 'R'
  2161                              <1> loc_dir_file_name:
  2162                              <1> 	;mov     bx, [esi+18h] ; Date
  2163                              <1> 	;mov     dx, [esi+16h] ; Time
  2164 00007014 8B5E16              <1> 	mov	ebx, [esi+16h]
  2165 00007017 89F1                <1> 	mov	ecx, esi ; FindFile_DirEntry address
  2166 00007019 BF[92E10000]        <1> 	mov     edi, File_Name
  2167                              <1> 	; move 8 bytes
  2168 0000701E A5                  <1> 	movsd
  2169 0000701F A5                  <1> 	movsd
  2170 00007020 C60720              <1> 	mov	byte [edi], 20h
  2171 00007023 47                  <1> 	inc	edi
  2172                              <1> 	; move 3 bytes
  2173 00007024 66A5                <1> 	movsw
  2174 00007026 A4                  <1> 	movsb
  2175 00007027 89CE                <1> 	mov	esi, ecx
  2176                              <1> 
  2177                              <1> Dir_Time_start:
  2178                              <1> 	;mov	ax, dx		; Time
  2179 00007029 6689D8              <1> 	mov	ax, bx
  2180 0000702C 66C1E805            <1> 	shr	ax, 5		; shift right 5 times
  2181 00007030 6683E03F            <1> 	and	ax, 0000111111b	; Minute Mask
  2182 00007034 D40A                <1> 	aam			; Q([AL]/10)->AH
  2183                              <1> 				; R([AL]/10)->AL
  2184                              <1> 				; [AL]+[AH]= Minute as BCD
  2185 00007036 660D3030            <1> 	or	ax, '00'	; Convert to ASCII
  2186 0000703A 86E0                <1> 	xchg	ah, al
  2187 0000703C 66A3[BDE10000]      <1> 	mov	[File_Minute], ax
  2188                              <1> 
  2189                              <1> 	;mov	al, dh
  2190 00007042 88F8                <1> 	mov	al, bh
  2191 00007044 C0E803              <1> 	shr	al, 3		; shift right 3 times
  2192 00007047 D40A                <1> 	aam			; [AL]+[AH]= Hours as BCD
  2193 00007049 660D3030            <1> 	or	ax, '00'
  2194 0000704D 86E0                <1> 	xchg	ah, al
  2195 0000704F 66A3[BAE10000]      <1> 	mov     [File_Hour], ax
  2196                              <1> 
  2197 00007055 C1EB10              <1> 	shr	ebx, 16		; BX = Date
  2198                              <1> 	
  2199                              <1> Dir_Date_start:
  2200 00007058 6689D8              <1> 	mov	ax, bx		; Date
  2201 0000705B 6683E01F            <1> 	and	ax, 00011111b	; Day Mask
  2202 0000705F D40A                <1> 	aam			; Q([AL]/10)->AH
  2203                              <1> 				; R([AL]/10)->AL
  2204                              <1> 				; [AL]+[AH]= Day as BCD
  2205 00007061 660D3030            <1> 	or	ax, '00'	; Convert to ASCII
  2206 00007065 86C4                <1> 	xchg	al, ah
  2207                              <1> 
  2208 00007067 66A3[AFE10000]      <1> 	mov	[File_Day], ax
  2209                              <1> 
  2210 0000706D 6689D8              <1> 	mov	ax, bx
  2211 00007070 66C1E805            <1> 	shr	ax, 5		; shift right 5 times
  2212 00007074 6683E00F            <1> 	and	ax, 00001111b	; Month Mask
  2213 00007078 D40A                <1> 	aam
  2214 0000707A 660D3030            <1> 	or	ax, '00'
  2215 0000707E 86E0                <1> 	xchg	ah, al
  2216 00007080 66A3[B2E10000]      <1> 	mov	[File_Month], ax
  2217                              <1> 
  2218 00007086 6689D8              <1> 	mov	ax, bx
  2219 00007089 66C1E809            <1> 	shr     ax, 9
  2220 0000708D 6683E07F            <1> 	and	ax, 01111111b	; Result = Year - 1980
  2221 00007091 6605BC07            <1> 	add	ax, 1980
  2222                              <1> 
  2223 00007095 B10A                <1> 	mov	cl, 10
  2224 00007097 F6F1                <1> 	div	cl		; Q -> AL, R -> AH 
  2225 00007099 80CC30              <1> 	or	ah, '0'
  2226 0000709C 8825[B8E10000]      <1> 	mov	[File_Year+3], ah
  2227 000070A2 D40A                <1> 	aam
  2228 000070A4 86E0                <1> 	xchg	ah, al
  2229 000070A6 80CC30              <1> 	or	ah, '0'	  ; Convert to ASCII
  2230 000070A9 8825[B7E10000]      <1> 	mov	[File_Year+2], ah
  2231 000070AF D40A                <1> 	aam
  2232 000070B1 86C4                <1> 	xchg	al, ah
  2233 000070B3 660D3030            <1> 	or	ax, '00'
  2234 000070B7 66A3[B5E10000]      <1> 	mov	[File_Year], ax
  2235                              <1> 
  2236                              <1> loc_show_line:
  2237 000070BD 56                  <1> 	push	esi
  2238 000070BE BE[92E10000]        <1> 	mov     esi, File_Name
  2239 000070C3 E86AE4FFFF          <1> 	call	print_msg
  2240 000070C8 BE[8BEE0000]        <1> 	mov	esi, nextline
  2241 000070CD E860E4FFFF          <1> 	call	print_msg
  2242 000070D2 5E                  <1> 	pop	esi
  2243                              <1> 
  2244 000070D3 FE0D[B12A0100]      <1> 	dec	byte [PrintDir_RowCounter]
  2245 000070D9 0F84D4000000        <1>         jz      pause_dir_scroll
  2246                              <1> 
  2247                              <1> loc_next_entry:
  2248 000070DF E899010000          <1> 	call	find_next_file
  2249 000070E4 0F8391FEFFFF        <1>         jnc     loc_dfname_use_this
  2250                              <1> 
  2251                              <1> loc_dir_ok:
  2252 000070EA B90A000000          <1> 	mov     ecx, 10
  2253 000070EF 66A1[9C2A0100]      <1> 	mov	ax, [Dir_Count]
  2254 000070F5 BF[D3E10000]        <1> 	mov	edi, Decimal_Dir_Count
  2255 000070FA 6639C8              <1> 	cmp	ax, cx ; 10
  2256 000070FD 7216                <1> 	jb	short pass_ddc
  2257 000070FF 47                  <1> 	inc	edi
  2258 00007100 6683F864            <1> 	cmp	ax, 100
  2259 00007104 720F                <1> 	jb	short pass_ddc
  2260 00007106 47                  <1> 	inc	edi
  2261 00007107 663DE803            <1> 	cmp	ax, 1000
  2262 0000710B 7208                <1> 	jb	short pass_ddc
  2263 0000710D 47                  <1> 	inc	edi
  2264 0000710E 663D1027            <1> 	cmp	ax, 10000
  2265 00007112 7201                <1> 	jb	short pass_ddc
  2266 00007114 47                  <1> 	inc	edi
  2267                              <1> pass_ddc:
  2268 00007115 886F01              <1> 	mov     [edi+1], ch ; 0
  2269                              <1> loc_ddc_rediv:
  2270 00007118 31D2                <1> 	xor     edx, edx
  2271 0000711A 66F7F1              <1> 	div     cx	; 10
  2272 0000711D 80C230              <1> 	add     dl, '0'
  2273 00007120 8817                <1> 	mov     [edi], dl
  2274 00007122 4F                  <1> 	dec     edi
  2275 00007123 6609C0              <1> 	or	ax, ax
  2276 00007126 75F0                <1> 	jnz	short loc_ddc_rediv
  2277                              <1> 
  2278 00007128 66A1[9A2A0100]      <1> 	mov     ax, [File_Count]
  2279 0000712E BF[C2E10000]        <1> 	mov     edi, Decimal_File_Count
  2280 00007133 6639C8              <1> 	cmp     ax, cx ; 10
  2281 00007136 7216                <1> 	jb      short pass_dfc
  2282 00007138 47                  <1> 	inc     edi
  2283 00007139 6683F864            <1> 	cmp     ax, 100
  2284 0000713D 720F                <1> 	jb      short pass_dfc
  2285 0000713F 47                  <1> 	inc     edi
  2286 00007140 663DE803            <1> 	cmp     ax, 1000
  2287 00007144 7208                <1> 	jb      short pass_dfc
  2288 00007146 47                  <1> 	inc     edi
  2289 00007147 663D1027            <1> 	cmp     ax, 10000
  2290 0000714B 7201                <1> 	jb      short pass_dfc
  2291 0000714D 47                  <1> 	inc     edi
  2292                              <1> pass_dfc:
  2293                              <1> 	;mov    cx, 10
  2294 0000714E 886F01              <1> 	mov     [edi+1], ch ; 00
  2295                              <1> loc_dfc_rediv:
  2296                              <1> 	;xor	dx, dx
  2297 00007151 30D2                <1> 	xor	dl, dl
  2298 00007153 66F7F1              <1> 	div	cx
  2299 00007156 80C230              <1> 	add	dl, '0'
  2300 00007159 8817                <1> 	mov	[edi], dl
  2301 0000715B 4F                  <1> 	dec	edi
  2302 0000715C 6609C0              <1> 	or	ax, ax
  2303 0000715F 75F0                <1> 	jnz	short loc_dfc_rediv
  2304                              <1> 
  2305 00007161 BF[B02A0100]        <1> 	mov     edi, TFS_Dec_End
  2306                              <1>         ;mov    byte [edi], 0
  2307 00007166 A1[9E2A0100]        <1> 	mov     eax, [Total_FSize]
  2308                              <1> 	;mov    ecx, 10
  2309                              <1> rediv_tfs_hex:
  2310                              <1> 	;sub	edx, edx
  2311 0000716B 28D2                <1> 	sub	dl, dl
  2312 0000716D F7F1                <1> 	div	ecx
  2313 0000716F 80C230              <1> 	add	dl, '0'
  2314 00007172 4F                  <1> 	dec     edi
  2315 00007173 8817                <1> 	mov     [edi], dl
  2316 00007175 21C0                <1> 	and	eax, eax
  2317 00007177 75F2                <1> 	jnz	short rediv_tfs_hex
  2318                              <1> 	
  2319 00007179 893D[A22A0100]      <1> 	mov	[TFS_Dec_Begin], edi
  2320 0000717F BE[C0E10000]        <1> 	mov	esi, Decimal_File_Count_Header
  2321 00007184 E8A9E3FFFF          <1> 	call	print_msg
  2322 00007189 BE[C8E10000]        <1> 	mov	esi, str_files
  2323 0000718E E89FE3FFFF          <1> 	call	print_msg
  2324 00007193 BE[D9E10000]        <1> 	mov	esi, str_dirs
  2325 00007198 E895E3FFFF          <1> 	call	print_msg
  2326 0000719D 8B35[A22A0100]      <1> 	mov	esi, [TFS_Dec_Begin]
  2327 000071A3 E88AE3FFFF          <1> 	call	print_msg
  2328 000071A8 BE[EAE10000]        <1> 	mov	esi, str_bytes
  2329 000071AD E880E3FFFF          <1> 	call	print_msg
  2330                              <1> 
  2331 000071B2 C3                  <1> 	retn
  2332                              <1> 
  2333                              <1> pause_dir_scroll:
  2334 000071B3 28E4                <1> 	sub	ah, ah           
  2335 000071B5 E81299FFFF          <1> 	call	int16h
  2336 000071BA 3C1B                <1> 	cmp	al, 1Bh
  2337 000071BC 0F8428FFFFFF        <1>         je      loc_dir_ok
  2338 000071C2 C605[B12A0100]10    <1> 	mov	byte [PrintDir_RowCounter], 16 ; Reset counter
  2339 000071C9 E911FFFFFF          <1>         jmp     loc_next_entry
  2340                              <1> 
  2341                              <1> find_first_file:
  2342                              <1> 	; 11/02/2015
  2343                              <1> 	; 10/02/2016
  2344                              <1> 	; 08/02/2016 (TRDOS 386 =  TRDOS v2.0)
  2345                              <1> 	; 09/10/2011
  2346                              <1> 	; 17/09/2009
  2347                              <1> 	; 2005
  2348                              <1> 	; INPUT ->
  2349                              <1> 	;	ESI = ASCIIZ File/Dir Name Address (in Current Directory)
  2350                              <1> 	;	AL = Attributes AND mask (The AND result must be equal to AL)
  2351                              <1> 	;	      bit 0 = Read Only
  2352                              <1> 	;	      bir 1 = Hidden
  2353                              <1> 	;	      bit 2 = System
  2354                              <1> 	;	      bit 3 = Volume Label
  2355                              <1> 	;	      bit 4 = Directory
  2356                              <1> 	;	      bit 5 = Archive
  2357                              <1> 	;	      bit 6 = Reserved, must be 0
  2358                              <1> 	;	      bit 7 = Reserved, must be 0
  2359                              <1> 	;       AH = Attributes Negative AND mask (The AND result must be ZERO)
  2360                              <1> 	;
  2361                              <1> 	; OUTPUT ->
  2362                              <1> 	;	CF = 1 -> Error, Error Code in EAX (AL)
  2363                              <1> 	;	CF = 0 ->
  2364                              <1> 	;	     ESI = Directory Entry (FindFile_DirEntry) Location
  2365                              <1> 	;	     EDI = Directory Buffer Directory Entry Location
  2366                              <1> 	;	     EAX = File Size
  2367                              <1> 	;	      BL = Attributes of The File/Directory
  2368                              <1> 	;	      BH = Long Name Yes/No Status (>0 is YES)
  2369                              <1> 	;             DX > 0 : Ambiguous filename chars are used
  2370                              <1> 	;
  2371                              <1> 	; (EAX, EBX, ECX, EDX, ESI, EDI will be changed)
  2372                              <1> 
  2373 000071CE 66A3[622A0100]      <1> 	mov	[FindFile_AttributesMask], ax
  2374 000071D4 BF[642A0100]        <1> 	mov	edi, FindFile_DirEntry ; TR-DOS Fullfilename formatted buffer
  2375 000071D9 31C0                <1> 	xor	eax, eax
  2376 000071DB B90B000000          <1> 	mov	ecx, 11
  2377 000071E0 F3AB                <1> 	rep	stosd	; 44 bytes
  2378                              <1> 	;stosw		; +2 bytes 
  2379                              <1> 	    
  2380 000071E2 BF[542A0100]        <1> 	mov	edi, FindFile_Name ; FFF structure, offset 66
  2381 000071E7 39FE                <1> 	cmp	esi, edi
  2382 000071E9 7408                <1> 	je	short loc_fff_mfn_ok
  2383 000071EB 89FA                <1> 	mov	edx, edi 
  2384                              <1> 	 ; move 13 bytes
  2385 000071ED A5                  <1> 	movsd
  2386 000071EE A5                  <1> 	movsd
  2387 000071EF A5                  <1> 	movsd
  2388 000071F0 AA                  <1> 	stosb
  2389 000071F1 89D6                <1> 	mov	esi, edx
  2390                              <1> loc_fff_mfn_ok:
  2391 000071F3 BF[032A0100]        <1> 	mov	edi, Dir_Entry_Name ; Dir Entry Format File Name
  2392 000071F8 E810210000          <1> 	call	convert_file_name
  2393 000071FD 89FE                <1> 	mov	esi, edi ; offset Dir_Entry_Name
  2394                              <1> 
  2395 000071FF 66A1[622A0100]      <1> 	mov	ax, [FindFile_AttributesMask]
  2396                              <1> 	;xor	ecx, ecx
  2397 00007205 30C9                <1> 	xor	cl, cl  
  2398 00007207 E80C1E0000          <1> 	call	locate_current_dir_file
  2399 0000720C 726E                <1> 	jc	short loc_fff_retn
  2400                              <1> 	; EDI = Directory Entry
  2401                              <1> 	; EBX = Directory Buffer Entry Index/Number
  2402                              <1> 
  2403                              <1> loc_fff_fnf_ln_check:
  2404 0000720E 30ED                <1> 	xor	ch, ch 
  2405 00007210 80F60F              <1> 	xor	dh, 0Fh
  2406 00007213 7408                <1> 	jz	short loc_fff_longname_yes
  2407 00007215 882D[612A0100]      <1> 	mov	[FindFile_LongNameYes], ch ; 0
  2408 0000721B EB0C                <1> 	jmp	short loc_fff_longname_no
  2409                              <1> 
  2410                              <1> loc_fff_longname_yes:
  2411                              <1> 	;inc	byte [FindFile_LongNameYes]
  2412 0000721D 8A0D[6E290100]      <1> 	mov	cl, [LFN_EntryLength]  
  2413 00007223 880D[612A0100]      <1> 	mov	[FindFile_LongNameEntryLength], cl ; FindFile_LongNameYes
  2414                              <1> 
  2415                              <1> loc_fff_longname_no:
  2416                              <1> 	;mov	bx, [DirBuff_CurrentEntry]
  2417 00007229 66891D[8C2A0100]    <1> 	mov	[FindFile_DirEntryNumber], bx
  2418 00007230 6689C2              <1> 	mov	dx, ax ; Ambigouos Filename chars used sign > 0
  2419                              <1> 
  2420 00007233 A0[6E200100]        <1> 	mov	al, [Current_Drv]
  2421 00007238 A2[122A0100]        <1> 	mov	[FindFile_Drv], al 
  2422                              <1> 
  2423 0000723D A1[68200100]        <1> 	mov	eax, [Current_Dir_FCluster]
  2424 00007242 A3[842A0100]        <1> 	mov	[FindFile_DirFirstCluster], eax
  2425                              <1> 
  2426 00007247 A1[9D280100]        <1> 	mov	eax, [DirBuff_Cluster]
  2427 0000724C A3[882A0100]        <1> 	mov	[FindFile_DirCluster], eax
  2428                              <1> 
  2429 00007251 66FF05[8E2A0100]    <1> 	inc	word [FindFile_MatchCounter]
  2430                              <1> 
  2431 00007258 89FB                <1> 	mov	ebx, edi
  2432 0000725A 89FE                <1> 	mov	esi, edi
  2433 0000725C BF[642A0100]        <1> 	mov	edi, FindFile_DirEntry
  2434 00007261 89F8                <1> 	mov	eax, edi
  2435 00007263 B108                <1> 	mov	cl, 8
  2436 00007265 F3A5                <1> 	rep	movsd
  2437 00007267 89C6                <1> 	mov	esi, eax
  2438 00007269 89DF                <1> 	mov	edi, ebx
  2439                              <1> 
  2440 0000726B A1[802A0100]        <1> 	mov	eax, [FindFile_DirEntry+28] ; File Size
  2441                              <1> 
  2442 00007270 8A1D[6F2A0100]      <1> 	mov	bl, [FindFile_DirEntry+11] ; File Attributes 
  2443 00007276 8A3D[612A0100]      <1> 	mov	bh, [FindFile_LongNameYes]
  2444                              <1> 
  2445                              <1> 	;mov	cx, [DirBuff_EntryCounter]
  2446                              <1> 	;mov	[FindFile_DirEntryNumber], cx
  2447                              <1> 	;mov	cx, [FindFile_DirEntryNumber]
  2448                              <1> 	; ecx = 0
  2449                              <1> 
  2450                              <1> loc_fff_retn:
  2451 0000727C C3                  <1> 	retn
  2452                              <1> 
  2453                              <1> find_next_file:
  2454                              <1> 	; 10/02/2016
  2455                              <1> 	; 08/02/2016 (TRDOS 386 =  TRDOS v2.0)
  2456                              <1> 	; 06/02/2011
  2457                              <1> 	; 17/09/2009
  2458                              <1> 	; 2005
  2459                              <1> 	; INPUT ->
  2460                              <1> 	;	NONE, Find First File Parameters
  2461                              <1> 	; OUTPUT ->
  2462                              <1> 	;	CF = 1 -> Error, Error Code in EAX (AL)
  2463                              <1> 	;	CF = 0 -> 
  2464                              <1> 	;	    ESI = Directory Entry (FindFile_DirEntry) Location
  2465                              <1> 	;	    EDI = Directory Buffer Directory Entry Location
  2466                              <1> 	;	    EAX = File Size
  2467                              <1> 	;	      BL = Attributes of The File/Directory
  2468                              <1> 	;	      BH = Long Name Yes/No Status (>0 is YES)
  2469                              <1> 	;             DX > 0 : Ambiguous filename chars are used 
  2470                              <1> 	;
  2471                              <1> 	; (EAX, EBX, ECX, EDX, ESI, EDI will be changed)
  2472                              <1> 
  2473 0000727D 66833D[8E2A0100]00  <1> 	cmp	word [FindFile_MatchCounter], 0
  2474 00007285 7707                <1> 	ja	short loc_start_search_next_file
  2475                              <1> 
  2476                              <1> loc_fnf_stc_retn:
  2477 00007287 F9                  <1> 	stc
  2478                              <1> loc_fnf_ax12h_retn:
  2479 00007288 B812000000          <1> 	mov	eax, 12h ; 18, No More files
  2480                              <1> ;loc_fnf_retn:
  2481 0000728D C3                  <1> 	retn
  2482                              <1> 
  2483                              <1> loc_start_search_next_file:
  2484 0000728E 668B1D[8C2A0100]    <1> 	mov	bx, [FindFile_DirEntryNumber]
  2485 00007295 6643                <1> 	inc	bx
  2486 00007297 663B1D[9B280100]    <1> 	cmp	bx, [DirBuff_LastEntry]
  2487 0000729E 7719                <1> 	ja	short loc_cont_search_next_file
  2488                              <1> 
  2489                              <1> loc_fnf_search:
  2490 000072A0 BE[032A0100]        <1> 	mov	esi, Dir_Entry_Name
  2491 000072A5 66A1[622A0100]      <1> 	mov	ax, [FindFile_AttributesMask]
  2492 000072AB 6631C9              <1> 	xor	cx, cx
  2493 000072AE E8671E0000          <1> 	call	find_directory_entry
  2494 000072B3 0F8355FFFFFF        <1>         jnc     loc_fff_fnf_ln_check
  2495                              <1> 
  2496                              <1> loc_cont_search_next_file:
  2497 000072B9 31DB                <1> 	xor	ebx, ebx
  2498 000072BB 8A3D[6E200100]      <1> 	mov	bh, [Current_Drv]
  2499 000072C1 BE00010900          <1> 	mov	esi, Logical_DOSDisks
  2500 000072C6 01DE                <1> 	add	esi, ebx
  2501                              <1> 
  2502 000072C8 803D[6C200100]00    <1> 	cmp	byte [Current_Dir_Level], 0
  2503 000072CF 7608                <1> 	jna	short loc_fnf_check_FAT_type
  2504 000072D1 807E0301            <1> 	cmp	byte [esi+LD_FATType], 1
  2505 000072D5 72B1                <1> 	jb	short loc_fnf_ax12h_retn
  2506 000072D7 EB06                <1> 	jmp	short loc_fnf_check_next_cluster
  2507                              <1>  
  2508                              <1> loc_fnf_check_FAT_type:
  2509 000072D9 807E0303            <1> 	cmp	byte [esi+LD_FATType], 3
  2510 000072DD 72A9                <1> 	jb	short loc_fnf_ax12h_retn
  2511                              <1> 
  2512                              <1> loc_fnf_check_next_cluster:
  2513 000072DF A1[9D280100]        <1> 	mov	eax, [DirBuff_Cluster]
  2514 000072E4 E8E6370000          <1> 	call	get_next_cluster
  2515 000072E9 7306                <1> 	jnc	short loc_fnf_load_next_dir_cluster
  2516 000072EB 09C0                <1> 	or	eax, eax
  2517 000072ED 7498                <1> 	jz	short loc_fnf_stc_retn
  2518                              <1> 	;mov	eax, 15h ;Drive not ready or read error
  2519 000072EF F5                  <1>  	cmc	;stc
  2520                              <1> loc_fnf_retn:
  2521 000072F0 C3                  <1> 	retn
  2522                              <1> 
  2523                              <1> loc_fnf_load_next_dir_cluster:
  2524 000072F1 E8BF390000          <1> 	call	load_FAT_sub_directory
  2525 000072F6 72F8                <1> 	jc	short loc_fnf_retn
  2526 000072F8 6631DB              <1> 	xor	bx, bx
  2527 000072FB 66891D[8C2A0100]    <1> 	mov	[FindFile_DirEntryNumber], bx
  2528 00007302 EB9C                <1> 	jmp	short loc_fnf_search
  2529                              <1> 
  2530                              <1> get_and_print_longname:
  2531                              <1> 	; 13/02/2016 (TRDOS 386 =  TRDOS v2.0)
  2532                              <1> 	; 24/01/2010
  2533                              <1> 	; 17/10/2009 (CMD_INTR.ASM, 'cmp_cmd_longname')
  2534                              <1> get_longname_fchar:
  2535 00007304 803E20              <1> 	cmp	byte [esi], 20h
  2536 00007307 7701                <1> 	ja	short loc_find_longname
  2537                              <1> 	;jb	short loc_longname_retn
  2538                              <1> 	;inc	esi
  2539                              <1> 	;je	short get_longname_fchar
  2540                              <1> ;loc_longname_retn:
  2541 00007309 C3                  <1> 	retn
  2542                              <1> loc_find_longname:
  2543 0000730A E872210000          <1> 	call	find_longname
  2544 0000730F 7320                <1> 	jnc	short loc_print_longname
  2545                              <1> 	
  2546 00007311 08C0                <1> 	or	al, al
  2547 00007313 7412                <1> 	jz	short loc_longname_not_found
  2548                              <1> 	  
  2549 00007315 3C15                <1> 	cmp	al, 15h
  2550 00007317 0F84B6F7FFFF        <1> 	je	cd_drive_not_ready
  2551                              <1> 
  2552                              <1> loc_ln_file_dir_not_found:
  2553 0000731D BE[18E10000]        <1> 	mov	esi, Msg_File_Directory_Not_Found
  2554                              <1> 	;call	print_msg	
  2555                              <1>         ;retn
  2556 00007322 E90BE2FFFF          <1> 	jmp	print_msg
  2557                              <1> 
  2558                              <1> loc_longname_not_found:
  2559 00007327 BE[37E10000]        <1>         mov     esi, Msg_LongName_Not_Found
  2560                              <1> 	;call	print_msg	
  2561                              <1>         ;retn
  2562 0000732C E901E2FFFF          <1> 	jmp	print_msg
  2563                              <1> 
  2564                              <1> loc_print_longname:
  2565                              <1> 	;mov	esi, LongFileName
  2566 00007331 BF[6E210100]        <1> 	mov	edi, TextBuffer
  2567 00007336 57                  <1> 	push	edi 
  2568 00007337 3C00                <1> 	cmp	al, 0
  2569 00007339 7708                <1> 	ja	short loc_print_longname_1
  2570                              <1> loc_print_FS_longname: ; Singlix FS (64 byte ASCIIZ file name)
  2571 0000733B AC                  <1> 	lodsb
  2572 0000733C AA                  <1> 	stosb  
  2573 0000733D 08C0                <1> 	or	al, al
  2574 0000733F 75FA                <1> 	jnz	short loc_print_FS_longname
  2575 00007341 EB07                <1> 	jmp	short loc_print_longname_2
  2576                              <1> 	;
  2577                              <1> loc_print_longname_1: ; MS Windows long name (UNICODE chars)
  2578 00007343 66AD                <1> 	lodsw
  2579 00007345 AA                  <1> 	stosb  
  2580 00007346 08C0                <1> 	or	al, al
  2581 00007348 75F9                <1> 	jnz	short loc_print_longname_1
  2582                              <1> 	;
  2583                              <1> loc_print_longname_2:	
  2584 0000734A 5E                  <1> 	pop	esi
  2585 0000734B E8E2E1FFFF          <1> 	call	print_msg
  2586 00007350 BE[8BEE0000]        <1>   	mov	esi, nextline
  2587                              <1> 	;call	print_msg
  2588                              <1> 	;retn
  2589 00007355 E9D8E1FFFF          <1> 	jmp	print_msg	
  2590                              <1> 
  2591                              <1> show_file:
  2592                              <1> 	; 18/02/2016
  2593                              <1> 	; 17/02/2016
  2594                              <1> 	; 15/02/2016 (TRDOS 386 =  TRDOS v2.0)
  2595                              <1> 	; 13/09/2011 (CMD_INTR.ASM, 'cmp_cmd_show')
  2596                              <1> 	; 08/11/2009
  2597                              <1> 
  2598                              <1> loc_show_parse_path_name:
  2599 0000735A BF[122A0100]        <1> 	mov	edi, FindFile_Drv
  2600 0000735F E874200000          <1> 	call	parse_path_name
  2601 00007364 0F8262F9FFFF        <1> 	jc	loc_cmd_failed
  2602                              <1> 
  2603                              <1> loc_show_check_filename_exists:
  2604 0000736A BE[542A0100]        <1> 	mov	esi, FindFile_Name
  2605 0000736F 803E20              <1> 	cmp	byte [esi], 20h
  2606 00007372 0F8654F9FFFF        <1> 	jna	loc_cmd_failed
  2607                              <1> 
  2608                              <1> 	; 15/02/2016 (invalid file name check)
  2609 00007378 E809020000          <1> 	call	check_filename 	
  2610 0000737D 730A                <1> 	jnc	short loc_show_change_drv
  2611                              <1> 
  2612 0000737F BE[00E20000]        <1> 	mov	esi, Msg_invalid_name_chars
  2613 00007384 E9A9E1FFFF          <1> 	jmp	print_msg
  2614                              <1>    
  2615                              <1> loc_show_change_drv:
  2616 00007389 8A35[6E200100]      <1> 	mov	dh, [Current_Drv]
  2617 0000738F 8835[CE280100]      <1> 	mov	[RUN_CDRV], dh
  2618 00007395 8A15[122A0100]      <1> 	mov	dl, [FindFile_Drv]
  2619 0000739B 38F2                <1> 	cmp	dl, dh
  2620 0000739D 740B                <1> 	je	short loc_show_change_directory
  2621 0000739F E88EEAFFFF          <1> 	call	change_current_drive
  2622                              <1> 	;jc	loc_file_rw_cmd_failed
  2623 000073A4 0F824DF9FFFF        <1> 	jc	loc_run_cmd_failed
  2624                              <1> 
  2625                              <1> loc_show_change_directory:
  2626 000073AA 803D[132A0100]20    <1> 	cmp	byte [FindFile_Directory], 20h
  2627 000073B1 7618                <1> 	jna	short loc_findload_showfile
  2628                              <1> 
  2629 000073B3 FE05[E4DD0000]      <1> 	inc	byte [Restore_CDIR]
  2630 000073B9 BE[132A0100]        <1> 	mov	esi, FindFile_Directory
  2631 000073BE 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
  2632 000073C0 E8FF190000          <1> 	call	change_current_directory
  2633                              <1> 	;jc	loc_file_rw_cmd_failed
  2634 000073C5 0F822CF9FFFF        <1> 	jc	loc_run_cmd_failed
  2635                              <1> 
  2636                              <1> ;loc_show_change_prompt_dir_string:
  2637                              <1> 	;call	change_prompt_dir_string
  2638                              <1> 
  2639                              <1> loc_findload_showfile:
  2640                              <1> 	; 15/02/2016
  2641 000073CB BE[542A0100]        <1> 	mov	esi, FindFile_Name
  2642 000073D0 BF[032A0100]        <1> 	mov	edi, Dir_Entry_Name ; Dir Entry Format File Name
  2643 000073D5 E8331F0000          <1> 	call	convert_file_name
  2644 000073DA 89FE                <1> 	mov	esi, edi ; offset Dir_Entry_Name
  2645                              <1> 
  2646 000073DC 28C0                <1> 	sub	al, al	; Attrib AND mask = 0
  2647                              <1> 	; Directory attribute : 10h
  2648                              <1> 	; Volume name attribute: 8h
  2649 000073DE B418                <1> 	mov	ah, 00011000b ; 18h (Attrib NAND, AND --> zero mask)
  2650                              <1> 	;
  2651 000073E0 6631C9              <1> 	xor	cx, cx  
  2652 000073E3 E8301C0000          <1> 	call	locate_current_dir_file
  2653                              <1> 	;jc	loc_file_rw_cmd_failed
  2654 000073E8 0F8209F9FFFF        <1> 	jc	loc_run_cmd_failed
  2655                              <1> 
  2656                              <1> loc_show_load_file:
  2657                              <1> 	; EDI = Directory Entry
  2658 000073EE 668B4714            <1> 	mov	ax, [edi+DirEntry_FstClusHI] ; First Cluster High Word
  2659 000073F2 C1E010              <1> 	shl	eax, 16
  2660 000073F5 668B471A            <1> 	mov	ax, [edi+DirEntry_FstClusLO] ; First Cluster Low Word
  2661 000073F9 A3[BC2A0100]        <1> 	mov	[Show_Cluster], eax
  2662 000073FE 8B471C              <1> 	mov	eax, [edi+DirEntry_FileSize] ; File Size
  2663 00007401 21C0                <1> 	and	eax, eax ; Empty file !
  2664 00007403 0F8491000000        <1>         jz      end_of_show_file 
  2665 00007409 A3[C02A0100]        <1> 	mov	[Show_FileSize], eax
  2666 0000740E 31C0                <1> 	xor	eax, eax
  2667 00007410 A3[C42A0100]        <1> 	mov	[Show_FilePointer], eax ; 0
  2668 00007415 66A3[C82A0100]      <1> 	mov	[Show_ClusterPointer], ax ; 0
  2669 0000741B 29DB                <1> 	sub	ebx, ebx
  2670 0000741D 8A3D[6E200100]      <1> 	mov	bh, [Current_Drv]
  2671 00007423 BE00010900          <1> 	mov	esi, Logical_DOSDisks
  2672 00007428 01DE                <1> 	add	esi, ebx
  2673 0000742A 8935[B82A0100]      <1> 	mov	[Show_LDDDT], esi ; Logical DOS Drv Description Table addr
  2674                              <1> 
  2675 00007430 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0	
  2676 00007434 7713                <1> 	ja	short loc_show_calculate_cluster_size
  2677                              <1> 	; Singlix FS
  2678                              <1> 	; First Cluster Number is FDT number (in compatibility buffer)
  2679 00007436 8B15[BC2A0100]      <1> 	mov	edx, [Show_Cluster] ; Compatibility dir. buffer value (FDT)	
  2680 0000743C 8915[B42A0100]      <1> 	mov	[Show_FDT], edx
  2681 00007442 31C0                <1> 	xor	eax, eax
  2682 00007444 A3[BC2A0100]        <1> 	mov	[Show_Cluster], eax ; Sector index  = 0
  2683                              <1> 				    ; (next time it will be 1)			
  2684                              <1> loc_show_calculate_cluster_size:
  2685 00007449 668B5E11            <1> 	mov	bx, [esi+LD_BPB+BPB_BytsPerSec] ; FAT 12-16-32 (512)
  2686                              <1> 	; BX = 512 = [esi+LD_FS_BytesPerSec] ; Singlix FS	
  2687 0000744D 8A4613              <1> 	mov	al, [esi+LD_BPB+BPB_SecPerClust] ; FAT 12-16-32 (<= 128)
  2688                              <1> 	; AL = 1 = [esi+LD_FS_Reserved2] ; SectPerClust for Singlix FS
  2689 00007450 F7E3                <1> 	mul	ebx	
  2690                              <1> 
  2691                              <1> 	;cmp	eax, 65536 ; non-compatible (very big) cluster size
  2692                              <1> 	;ja	short end_of_show_file	
  2693 00007452 66A3[CA2A0100]      <1> 	mov	[Show_ClusterSize], ax
  2694                              <1> 
  2695                              <1> loc_start_show_file:
  2696 00007458 BE[8BEE0000]        <1> 	mov	esi, nextline
  2697 0000745D E8D0E0FFFF          <1> 	call	print_msg
  2698                              <1> 
  2699 00007462 A1[BC2A0100]        <1> 	mov	eax, [Show_Cluster]
  2700 00007467 C605[CC2A0100]17    <1> 	mov	byte [Show_RowCount], 23
  2701                              <1> 
  2702                              <1> 	; 17/02/2016
  2703 0000746E 8B35[B82A0100]      <1> 	mov	esi, [Show_LDDDT]
  2704                              <1> 
  2705                              <1> loc_show_next_cluster:
  2706                              <1> 	; 15/02/2016
  2707 00007474 BB00000700          <1> 	mov	ebx, Cluster_Buffer ; 70000h (for current TRDOS 386 version)
  2708                              <1> 	; ESI = Logical DOS drv description table address
  2709 00007479 E875380000          <1> 	call	read_cluster
  2710                              <1> 	;jc	loc_file_rw_cmd_failed
  2711 0000747E 0F8273F8FFFF        <1> 	jc	loc_run_cmd_failed
  2712                              <1> 
  2713 00007484 31DB                <1> 	xor 	ebx, ebx
  2714                              <1> loc_show_next_byte:
  2715 00007486 803D[CC2A0100]00    <1> 	cmp	byte [Show_RowCount], 0
  2716 0000748D 7521                <1> 	jne	short pass_show_wait_for_key
  2717 0000748F 30E4                <1> 	xor	ah, ah
  2718 00007491 E83696FFFF          <1> 	call	int16h
  2719 00007496 3C1B                <1> 	cmp	al, 1Bh
  2720 00007498 750F                <1> 	jne	short pass_exit_show
  2721                              <1> end_of_show_file:
  2722                              <1> pass_show_file:
  2723 0000749A BE[8BEE0000]        <1> 	mov	esi, nextline
  2724 0000749F E88EE0FFFF          <1> 	call	print_msg
  2725 000074A4 E94D010000          <1> 	jmp	loc_file_rw_restore_retn
  2726                              <1> 
  2727                              <1> pass_exit_show:
  2728 000074A9 C605[CC2A0100]14    <1> 	mov	byte [Show_RowCount], 20
  2729                              <1> pass_show_wait_for_key:
  2730 000074B0 81C300000700        <1> 	add	ebx, Cluster_Buffer
  2731 000074B6 8A03                <1> 	mov	al, [ebx]
  2732 000074B8 3C0D                <1> 	cmp	al, 0Dh
  2733 000074BA 0F8590000000        <1>         jne     loc_show_check_tab_space
  2734 000074C0 FE0D[CC2A0100]      <1> 	dec	byte [Show_RowCount]
  2735                              <1> pass_show_dec_rowcount:
  2736 000074C6 B307                <1> 	mov	bl, 7 ; (light gray character color, black background)
  2737 000074C8 8A3D[D61F0100]      <1> 	mov	bh, [ACTIVE_PAGE] ; [ptty]
  2738 000074CE E849A6FFFF          <1> 	call	_write_tty
  2739                              <1> loc_show_check_eof:
  2740 000074D3 FF05[C42A0100]      <1> 	inc	dword [Show_FilePointer]
  2741 000074D9 A1[C42A0100]        <1> 	mov	eax, [Show_FilePointer]
  2742 000074DE 3B05[C02A0100]      <1> 	cmp	eax, [Show_FileSize]
  2743 000074E4 73B4                <1> 	jnb	short end_of_show_file
  2744 000074E6 66FF05[C82A0100]    <1> 	inc	word [Show_ClusterPointer]
  2745 000074ED 0FB71D[C82A0100]    <1> 	movzx	ebx, word [Show_ClusterPointer]
  2746                              <1> 
  2747                              <1> 	; 17/02/2016
  2748                              <1> 	; (sector boundary -9 bits- check, 512 = 0)
  2749 000074F4 66F7C3FF01          <1>         test    bx, 1FFh ;  1 to 511
  2750 000074F9 758B                <1> 	jnz	short loc_show_next_byte
  2751                              <1> 
  2752                              <1> 	; 16/02/2016
  2753 000074FB 8B35[B82A0100]      <1> 	mov	esi, [Show_LDDDT]
  2754                              <1> 	;
  2755 00007501 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
  2756 00007505 7719                <1> 	ja	short loc_show_check_fat_cluster_size
  2757                              <1> 
  2758                              <1> 	; Singlix FS
  2759                              <1> 	; 1 sector, more... (cluster size = 1 sector)
  2760 00007507 A1[BC2A0100]        <1> 	mov	eax, [Show_Cluster]
  2761 0000750C 40                  <1> 	inc	eax
  2762 0000750D A3[BC2A0100]        <1> 	mov	[Show_Cluster], eax
  2763                              <1> 
  2764 00007512 6621DB              <1> 	and	bx, bx ; 65536 -> 0
  2765 00007515 0F856BFFFFFF        <1>         jnz	loc_show_next_byte
  2766 0000751B E954FFFFFF          <1> 	jmp     loc_show_next_cluster
  2767                              <1> 	 
  2768                              <1> loc_show_check_fat_cluster_size:
  2769                              <1> 	; 17/02/2016
  2770 00007520 663B1D[CA2A0100]    <1> 	cmp	bx, [Show_ClusterSize] ; cluster size in bytes
  2771 00007527 0F8259FFFFFF        <1>         jb	loc_show_next_byte
  2772 0000752D 66C705[C82A0100]00- <1> 	mov	word [Show_ClusterPointer], 0
  2772 00007535 00                  <1>
  2773                              <1> 
  2774 00007536 A1[BC2A0100]        <1> 	mov	eax, [Show_Cluster]
  2775                              <1> 	;mov	esi, [Show_LDDDT]
  2776                              <1> loc_show_get_next_cluster:
  2777 0000753B E88F350000          <1> 	call	get_next_cluster
  2778                              <1> 	;jc	loc_file_rw_cmd_failed
  2779 00007540 0F82B1F7FFFF        <1> 	jc	loc_run_cmd_failed
  2780                              <1> loc_show_update_ccluster:
  2781 00007546 A3[BC2A0100]        <1> 	mov	[Show_Cluster], eax			
  2782 0000754B E924FFFFFF          <1>         jmp     loc_show_next_cluster
  2783                              <1> 
  2784                              <1> loc_show_check_tab_space:
  2785 00007550 3C09                <1> 	cmp	al, 09h
  2786 00007552 0F856EFFFFFF        <1>         jne     pass_show_dec_rowcount
  2787                              <1> loc_show_put_tab_space:
  2788 00007558 8A3D[D61F0100]      <1> 	mov	bh, [ACTIVE_PAGE] ; [ptty]
  2789 0000755E E853A2FFFF          <1> 	call	get_cpos
  2790                              <1> 	; dl = cursor column
  2791 00007563 80E207              <1> 	and	dl, 7 ; 18/02/2016
  2792                              <1> 	;shr	bh, 1 ; [ACTIVE_PAGE]
  2793 00007566 8A3D[D61F0100]      <1> 	mov	bh, [ACTIVE_PAGE]
  2794 0000756C B307                <1> 	mov	bl, 7 ; color attribute
  2795                              <1> loc_show_put_space_chars:
  2796 0000756E B020                <1> 	mov	al, 20h ; space
  2797                              <1> 	;mov	bh, [ACTIVE_PAGE] ; [ptty]
  2798                              <1> 	;mov	bl, 7 ; color attribute
  2799 00007570 6652                <1> 	push	dx
  2800 00007572 E8A5A5FFFF          <1> 	call	_write_tty
  2801 00007577 665A                <1> 	pop	dx
  2802                              <1> 	; 18/02/2016
  2803 00007579 80FA07              <1> 	cmp	dl, 7
  2804 0000757C 0F8351FFFFFF        <1> 	jnb	loc_show_check_eof
  2805 00007582 FEC2                <1> 	inc	dl
  2806 00007584 EBE8                <1> 	jmp	short loc_show_put_space_chars
  2807                              <1> 
  2808                              <1> check_filename:
  2809                              <1> 	; 15/02/2016 (TRDOS 386 =  TRDOS v2.0)
  2810                              <1> 	; 07/08/2010 (FILE.ASM, 'proc_check_filename')
  2811                              <1> 	; 10/07/2010
  2812                              <1> 	; Derived from 'proc_check_filename'
  2813                              <1> 	; in the old TRDOS.ASM (09/02/2005).
  2814                              <1> 	;
  2815                              <1> 	; INPUT -> 
  2816                              <1> 	;	ESI = Dot File Name Location
  2817                              <1> 	; OUTPUT ->
  2818                              <1> 	;	cf = 1 -> error code in AL
  2819                              <1> 	;	     AL = 0Bh -> Invalid file name   
  2820                              <1> 	;	cf = 0 -> valid file name
  2821                              <1> 	; 
  2822                              <1> 	;(EAX, ECX, EDI will be changed)
  2823                              <1> 
  2824                              <1> check_invalid_filename_chars:
  2825                              <1> 	; 15/02/2016 (TRDOS 386 =  TRDOS v2.0)
  2826                              <1> 	; 10/07/2010 (FILE.ASM, 'proc_check_invalid_filename_chars')
  2827                              <1> 	; 10/02/2010
  2828                              <1> 	; Derived from 'proc_check_invalid_filename_chars'
  2829                              <1> 	; in the old TRDOS.ASM (09/02/2005).
  2830                              <1> 	;
  2831                              <1> 	; INPUT -> 
  2832                              <1> 	;	ESI = ASCIIZ FileName
  2833                              <1> 	; OUTPUT ->
  2834                              <1> 	;	cf = 1 -> invalid
  2835                              <1> 	;	cf = 0 -> valid
  2836                              <1> 	; 
  2837                              <1> 	;(EAX, ECX, ESI, EDI will be changed)
  2838                              <1>   
  2839 00007586 56                  <1> 	push	esi
  2840                              <1> 
  2841 00007587 BF[ECDE0000]        <1>         mov     edi, invalid_fname_chars
  2842 0000758C AC                  <1> 	lodsb
  2843                              <1> check_filename_next_char:
  2844 0000758D B914000000          <1> 	mov	ecx, sizeInvFnChars
  2845 00007592 BF[ECDE0000]        <1> 	mov	edi, invalid_fname_chars
  2846                              <1> loc_scan_invalid_filename_char:
  2847 00007597 AE                  <1> 	scasb 
  2848 00007598 741F                <1> 	je	short loc_invalid_filename_stc 
  2849 0000759A E2FB                <1> 	loop	loc_scan_invalid_filename_char
  2850 0000759C AC                  <1> 	lodsb
  2851 0000759D 3C1F                <1> 	cmp	al, 1Fh  ; 20h and above 
  2852 0000759F 77EC                <1> 	ja	short check_filename_next_char
  2853                              <1> 
  2854                              <1> check_filename_dot:
  2855 000075A1 8B3424              <1> 	mov	esi, [esp]
  2856                              <1> 
  2857 000075A4 B421                <1> 	mov	ah, 21h
  2858 000075A6 B908000000          <1> 	mov	ecx, 8
  2859                              <1> loc_check_filename_next_char:
  2860 000075AB AC                  <1> 	lodsb
  2861 000075AC 3C2E                <1> 	cmp	al, 2Eh
  2862 000075AE 7511                <1> 	jne	short pass_check_fn_dot_check
  2863                              <1> loc_check_filename_ext_0:
  2864 000075B0 AC                  <1> 	lodsb
  2865 000075B1 38E0                <1> 	cmp	al, ah ; 21h
  2866 000075B3 7205                <1> 	jb	short loc_invalid_filename
  2867 000075B5 3C2E                <1> 	cmp	al, 2Eh
  2868 000075B7 7519                <1> 	jne	short loc_check_filename_ext_1
  2869                              <1> 
  2870                              <1> loc_invalid_filename_stc:
  2871                              <1> loc_check_fn_stc_rtn:
  2872 000075B9 F9                  <1> 	stc
  2873                              <1> loc_invalid_filename:
  2874 000075BA B80B000000          <1> 	mov	eax, 0Bh ; Invalid format
  2875                              <1> 	; Invalid file name chars
  2876                              <1> loc_check_fn_rtn:
  2877 000075BF 5E                  <1> 	pop	esi
  2878 000075C0 C3                  <1> 	retn
  2879                              <1> 
  2880                              <1> pass_check_fn_dot_check:
  2881 000075C1 38E0                <1> 	cmp	al, ah ; 21h
  2882 000075C3 7224                <1> 	jb	short loc_check_fn_clc_rtn
  2883 000075C5 E2E4                <1> 	loop	loc_check_filename_next_char
  2884 000075C7 AC                  <1> 	lodsb
  2885 000075C8 38E0                <1> 	cmp	al, ah ; 21h
  2886 000075CA 721D                <1> 	jb	short loc_check_fn_clc_rtn
  2887 000075CC 3C2E                <1> 	cmp	al, 2Eh
  2888 000075CE 75E9                <1> 	jne	short loc_check_fn_stc_rtn
  2889 000075D0 EBDE                <1> 	jmp	short loc_check_filename_ext_0
  2890                              <1> 
  2891                              <1> loc_check_filename_ext_1:
  2892 000075D2 AC                  <1> 	lodsb
  2893 000075D3 38E0                <1> 	cmp	al, ah ; 21h
  2894 000075D5 7212                <1> 	jb	short loc_check_fn_clc_rtn
  2895 000075D7 3C2E                <1> 	cmp	al, 2Eh
  2896 000075D9 74DE                <1> 	je	short loc_check_fn_stc_rtn
  2897 000075DB AC                  <1> 	lodsb
  2898 000075DC 38E0                <1> 	cmp	al, ah ; 21h
  2899 000075DE 7209                <1> 	jb	short loc_check_fn_clc_rtn
  2900 000075E0 3C2E                <1> 	cmp	al, 2Eh
  2901 000075E2 74D5                <1> 	je	short loc_check_fn_stc_rtn
  2902 000075E4 AC                  <1> 	lodsb
  2903 000075E5 38E0                <1> 	cmp	al, ah ; 21h
  2904 000075E7 73D0                <1> 	jnb	short loc_check_fn_stc_rtn
  2905                              <1> 
  2906                              <1> loc_check_fn_clc_rtn:
  2907 000075E9 5E                  <1> 	pop	esi
  2908 000075EA F8                  <1> 	clc
  2909 000075EB C3                  <1> 	retn
  2910                              <1> 
  2911                              <1> loc_print_deleted_message:
  2912 000075EC BE[D5E20000]        <1> 	mov	esi, Msg_Deleted
  2913 000075F1 E83CDFFFFF          <1> 	call	print_msg
  2914                              <1> 
  2915                              <1> 	;clc
  2916                              <1> 
  2917                              <1> loc_file_rw_restore_retn:
  2918                              <1> 	; 15/02/2016 (TRDOS 386 =  TRDOS v2.0)
  2919                              <1> 	; 28/02/2010 (CMD_INTR.ASM)
  2920                              <1> loc_file_rw_cmd_failed:
  2921 000075F6 9C                  <1> 	pushf 
  2922 000075F7 E855F7FFFF          <1> 	call	restore_cdir_after_cmd_fail	
  2923 000075FC 9D                  <1> 	popf
  2924 000075FD 720D                <1> 	jc	short loc_file_rw_check_write_fault
  2925 000075FF C3                  <1> 	retn
  2926                              <1> 
  2927                              <1> loc_permission_denied:
  2928                              <1> 	; 27/02/2016
  2929 00007600 BE[E2E20000]        <1> 	mov	esi, Msg_Permission_Denied
  2930 00007605 E828DFFFFF          <1> 	call	print_msg
  2931 0000760A EBEA                <1> 	jmp	short loc_file_rw_restore_retn
  2932                              <1> 
  2933                              <1> loc_file_rw_check_write_fault:
  2934 0000760C 3C1D                <1> 	cmp	al, 1Dh ; Write Fault
  2935 0000760E 0F85E8F6FFFF        <1>         jne     loc_run_cmd_failed_cmp_al
  2936 00007614 BE[CDE00000]        <1> 	mov	esi, Msg_Not_Ready_Write_Err
  2937                              <1> 	;call	print_msg
  2938                              <1> 	;retn
  2939 00007619 E914DFFFFF          <1> 	jmp	print_msg
  2940                              <1> 
  2941                              <1> make_directory:
  2942                              <1> 	; 21/02/2016 (TRDOS 386 =  TRDOS v2.0)
  2943                              <1> 	; 12/03/2011 (CMD_INTR.ASM, 'cmp_cmd_mkdir')
  2944                              <1> 	; 14/08/2010
  2945                              <1> 	; 10/07/2010
  2946                              <1> 	; 29/11/2009
  2947                              <1> 	;
  2948                              <1> get_mkdir_fchar:
  2949                              <1> 	; esi = directory name
  2950 0000761E 803E20              <1> 	cmp	byte [esi], 20h
  2951 00007621 7701                <1>         ja	short loc_mkdir_parse_path_name
  2952                              <1> 
  2953                              <1> loc_mkdir_nodirname_retn:
  2954 00007623 C3                  <1> 	retn
  2955                              <1> 
  2956                              <1> loc_mkdir_parse_path_name:
  2957 00007624 BF[122A0100]        <1> 	mov	edi, FindFile_Drv
  2958 00007629 E8AA1D0000          <1>         call    parse_path_name
  2959 0000762E 0F8298F6FFFF        <1> 	jc	loc_cmd_failed
  2960                              <1> 
  2961                              <1> loc_mkdir_check_dirname_exists:
  2962 00007634 BE[542A0100]        <1> 	mov	esi, FindFile_Name
  2963 00007639 803E20              <1> 	cmp	byte [esi], 20h
  2964 0000763C 0F868AF6FFFF        <1> 	jna	loc_cmd_failed
  2965 00007642 8935[D02A0100]      <1> 	mov	[DelFile_FNPointer], esi
  2966 00007648 E839FFFFFF          <1> 	call	check_filename
  2967 0000764D 7259                <1> 	jc	short loc_mkdir_invalid_dir_name_chars
  2968                              <1> 
  2969                              <1> loc_mkdir_drv:
  2970 0000764F 8A35[6E200100]      <1> 	mov	dh, [Current_Drv]
  2971 00007655 8835[CE280100]      <1> 	mov	[RUN_CDRV], dh
  2972                              <1> 	
  2973 0000765B 8A15[122A0100]      <1> 	mov	dl, [FindFile_Drv]
  2974 00007661 38F2                <1> 	cmp	dl, dh
  2975 00007663 7407                <1> 	je	short loc_mkdir_change_directory
  2976                              <1> 
  2977 00007665 E8C8E7FFFF          <1> 	call	change_current_drive
  2978 0000766A 728A                <1> 	jc	loc_file_rw_cmd_failed
  2979                              <1> 
  2980                              <1> loc_mkdir_change_directory:
  2981 0000766C 803D[132A0100]20    <1> 	cmp	byte [FindFile_Directory], 20h
  2982 00007673 7614                <1> 	jna	short loc_mkdir_find_directory
  2983                              <1> 
  2984 00007675 FE05[E4DD0000]      <1> 	inc	byte [Restore_CDIR]
  2985 0000767B BE[132A0100]        <1> 	mov	esi, FindFile_Directory
  2986 00007680 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
  2987 00007682 E83D170000          <1> 	call	change_current_directory
  2988 00007687 722E                <1> 	jc	short loc_mkdir_check_error_code
  2989                              <1> 
  2990                              <1> ;loc_mkdir_change_prompt_dir_string:
  2991                              <1> 	;call	change_prompt_dir_string
  2992                              <1> 
  2993                              <1> loc_mkdir_find_directory:
  2994                              <1> 	;mov	esi, FindFile_Name
  2995 00007689 8B35[D02A0100]      <1> 	mov	esi, [DelFile_FNPointer]
  2996                              <1> 	;xor	eax, eax
  2997 0000768F 6631C0              <1> 	xor	ax, ax ; any name (dir, file, volume)
  2998 00007692 E837FBFFFF          <1> 	call	find_first_file
  2999 00007697 721E                <1> 	jc	short loc_mkdir_check_error_code
  3000                              <1> 
  3001                              <1> loc_mkdir_directory_found:
  3002 00007699 BE[2DE20000]        <1> 	mov	esi, Msg_Name_Exists
  3003 0000769E E88FDEFFFF          <1> 	call	print_msg
  3004                              <1> 
  3005 000076A3 E94EFFFFFF          <1>         jmp     loc_file_rw_restore_retn
  3006                              <1> 
  3007                              <1> loc_mkdir_invalid_dir_name_chars:
  3008 000076A8 BE[00E20000]        <1> 	mov	esi, Msg_invalid_name_chars
  3009 000076AD E880DEFFFF          <1> 	call	print_msg
  3010                              <1> 
  3011 000076B2 E93FFFFFFF          <1>         jmp     loc_file_rw_restore_retn
  3012                              <1> 
  3013                              <1> loc_mkdir_check_error_code:
  3014 000076B7 3C02                <1> 	cmp	al, 2
  3015                              <1> 	;je	short loc_mkdir_directory_not_found
  3016 000076B9 7406                <1> 	je	short loc_mkdir_ask_for_yes_no
  3017 000076BB F9                  <1> 	stc
  3018 000076BC E935FFFFFF          <1>         jmp     loc_file_rw_cmd_failed
  3019                              <1> 
  3020                              <1> loc_mkdir_directory_not_found:
  3021                              <1> loc_mkdir_ask_for_yes_no:
  3022 000076C1 BE[4EE20000]        <1> 	mov	esi, Msg_DoYouWantMkdir
  3023 000076C6 E867DEFFFF          <1> 	call	print_msg
  3024 000076CB 8B35[D02A0100]      <1> 	mov	esi, [DelFile_FNPointer]
  3025 000076D1 E85CDEFFFF          <1> 	call	print_msg
  3026 000076D6 BE[6DE20000]        <1> 	mov	esi, Msg_YesNo
  3027 000076DB E852DEFFFF          <1> 	call	print_msg
  3028                              <1> 
  3029 000076E0 C605[77E20000]20    <1> 	mov	byte [Y_N_nextline], 20h
  3030                              <1> 
  3031                              <1> loc_mkdir_ask_again:
  3032 000076E7 30E4                <1> 	xor	ah, ah
  3033 000076E9 E8DE93FFFF          <1> 	call	int16h
  3034 000076EE 3C1B                <1> 	cmp	al, 1Bh
  3035                              <1> 	;je	short loc_do_not_make_directory
  3036 000076F0 7447                <1> 	je	short loc_mkdir_y_n_escape
  3037 000076F2 24DF                <1> 	and	al, 0DFh ; y -> Y, n -> N
  3038 000076F4 3C59                <1> 	cmp	al, 'Y' ; 'yes'
  3039 000076F6 7404                <1> 	je	short loc_mkdir_yes_make_directory
  3040 000076F8 3C4E                <1> 	cmp	al, 'N' ; 'no'
  3041 000076FA 75EB                <1> 	jne	short loc_mkdir_ask_again
  3042                              <1> 
  3043                              <1> loc_do_not_make_directory:
  3044                              <1> loc_mkdir_yes_make_directory:
  3045 000076FC A2[77E20000]        <1> 	mov	[Y_N_nextline], al
  3046 00007701 6650                <1> 	push	ax
  3047 00007703 BE[77E20000]        <1> 	mov	esi, Y_N_nextline
  3048 00007708 E825DEFFFF          <1> 	call	print_msg
  3049 0000770D 6658                <1> 	pop	ax
  3050                              <1> 	;cmp	al, 'Y' ; 'yes'
  3051                              <1> 	;cmc
  3052                              <1>         ;jnc	loc_file_rw_restore_retn
  3053 0000770F 3C4E                <1> 	cmp	al, 'N' ; 'no'
  3054 00007711 0F84DFFEFFFF        <1>         je	loc_file_rw_restore_retn  
  3055                              <1> 
  3056                              <1> loc_mkdir_call_make_sub_directory:
  3057 00007717 8B35[D02A0100]      <1> 	mov	esi, [DelFile_FNPointer]
  3058 0000771D B110                <1> 	mov	cl, 10h ; Directory attributes 
  3059 0000771F E8B31D0000          <1> 	call	make_sub_directory
  3060                              <1> loc_rename_file_ok: ; 06/03/2016
  3061 00007724 0F82CCFEFFFF        <1>         jc	loc_file_rw_cmd_failed
  3062                              <1> move_source_file_to_destination_OK:
  3063 0000772A BE[7BE20000]        <1> 	mov	esi, Msg_OK
  3064 0000772F E8FEDDFFFF          <1> 	call	print_msg
  3065 00007734 E9BDFEFFFF          <1> 	jmp	loc_file_rw_restore_retn
  3066                              <1> 
  3067                              <1> loc_mkdir_y_n_escape:
  3068 00007739 B04E                <1> 	mov	al, 'N' ; 'no'
  3069 0000773B EBBF                <1> 	jmp	short loc_do_not_make_directory
  3070                              <1> 
  3071                              <1> delete_directory:
  3072                              <1> 	; 06/03/2016
  3073                              <1> 	; 01/03/2016
  3074                              <1> 	; 29/02/2016
  3075                              <1> 	; 28/02/2016
  3076                              <1> 	; 27/02/2016
  3077                              <1> 	; 26/02/2016 (TRDOS 386 =  TRDOS v2.0)
  3078                              <1> 	; 16/10/2010 (CMD_INTR.ASM, 'cmp_cmd_rmdir')
  3079                              <1> 	; 05/06/2010
  3080                              <1> 	;
  3081                              <1> get_rmdir_fchar:
  3082                              <1> 	; esi = directory name
  3083 0000773D 803E20              <1> 	cmp	byte [esi], 20h
  3084 00007740 7701                <1>         ja	short loc_rmdir_parse_path_name
  3085                              <1> 
  3086                              <1> loc_rmdir_nodirname_retn:
  3087 00007742 C3                  <1> 	retn
  3088                              <1> 
  3089                              <1> loc_rmdir_parse_path_name:
  3090 00007743 BF[122A0100]        <1> 	mov	edi, FindFile_Drv
  3091 00007748 E88B1C0000          <1> 	call	parse_path_name
  3092 0000774D 0F8279F5FFFF        <1> 	jc	loc_cmd_failed
  3093                              <1> 
  3094                              <1> loc_rmdir_check_dirname_exists:
  3095 00007753 BE[542A0100]        <1> 	mov	esi, FindFile_Name
  3096 00007758 803E20              <1> 	cmp	byte [esi], 20h
  3097 0000775B 0F866BF5FFFF        <1> 	jna	loc_cmd_failed
  3098 00007761 8935[D02A0100]      <1> 	mov	[DelFile_FNPointer], esi 
  3099                              <1> 
  3100                              <1> loc_rmdir_drv:
  3101 00007767 8A35[6E200100]      <1> 	mov	dh, [Current_Drv]
  3102 0000776D 8835[CE280100]      <1> 	mov	[RUN_CDRV], dh
  3103                              <1> 
  3104 00007773 8A15[122A0100]      <1> 	mov	dl, [FindFile_Drv]
  3105 00007779 38F2                <1> 	cmp	dl, dh
  3106 0000777B 740B                <1> 	je	short loc_rmdir_change_directory
  3107                              <1> 
  3108 0000777D E8B0E6FFFF          <1> 	call	change_current_drive
  3109 00007782 0F826EFEFFFF        <1> 	jc	loc_file_rw_cmd_failed
  3110                              <1> 
  3111                              <1> loc_rmdir_change_directory:
  3112 00007788 803D[132A0100]20    <1> 	cmp	byte [FindFile_Directory], 20h
  3113 0000778F 7614                <1> 	jna	short loc_rmdir_find_directory
  3114                              <1> 
  3115 00007791 FE05[E4DD0000]      <1> 	inc	byte [Restore_CDIR]
  3116 00007797 BE[132A0100]        <1> 	mov	esi, FindFile_Directory
  3117 0000779C 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
  3118 0000779E E821160000          <1> 	call	change_current_directory
  3119 000077A3 7211                <1> 	jc	short loc_rmdir_check_error_code
  3120                              <1> 
  3121                              <1> ;loc_rmdir_change_prompt_dir_string:
  3122                              <1> 	;call	change_prompt_dir_string
  3123                              <1> 
  3124                              <1> loc_rmdir_find_directory:
  3125                              <1> 	;mov	esi, FindFile_Name
  3126 000077A5 8B35[D02A0100]      <1> 	mov	esi, [DelFile_FNPointer]
  3127 000077AB 66B81008            <1> 	mov	ax, 0810h ; Only directories
  3128 000077AF E81AFAFFFF          <1> 	call	find_first_file
  3129 000077B4 730A                <1> 	jnc	short loc_rmdir_ambgfn_check
  3130                              <1> 
  3131                              <1> loc_rmdir_check_error_code:
  3132 000077B6 3C02                <1> 	cmp	al, 2
  3133 000077B8 740B                <1> 	je	short loc_rmdir_directory_not_found
  3134 000077BA F9                  <1> 	stc
  3135 000077BB E936FEFFFF          <1> 	jmp	loc_file_rw_cmd_failed
  3136                              <1> 
  3137                              <1> loc_rmdir_ambgfn_check:
  3138 000077C0 6621D2              <1> 	and	dx, dx ; Ambiguous filename chars used sign (DX>0)
  3139 000077C3 740F                <1> 	jz	short loc_rmdir_directory_found
  3140                              <1> 
  3141                              <1> loc_rmdir_directory_not_found:
  3142 000077C5 BE[EFE00000]        <1> 	mov	esi, Msg_Dir_Not_Found
  3143 000077CA E863DDFFFF          <1> 	call	print_msg
  3144                              <1> 
  3145 000077CF E922FEFFFF          <1> 	jmp	loc_file_rw_restore_retn
  3146                              <1> 
  3147                              <1> loc_rmdir_directory_found:
  3148 000077D4 80E307              <1> 	and	bl, 07h ; Attributes
  3149 000077D7 0F8523FEFFFF        <1> 	jnz	loc_permission_denied
  3150                              <1> 
  3151                              <1> loc_rmdir_save_lnel: ; 28/02/2016
  3152                              <1>        ;mov	bh, [LongName_EntryLength]
  3153 000077DD 883D[DA2A0100]      <1> 	mov	[DelFile_LNEL], bh ; Long name entry length (if > 0)
  3154                              <1> 	; edi = Directory Entry Offset (DirBuff)
  3155                              <1> 	; esi = Directory Entry (FFF Structure)
  3156                              <1> 	;mov	[DelFile_DirEntryAddr], edi ; not required
  3157                              <1> 	;mov	ax, [edi+20] ; First Cluster High Word
  3158                              <1>         ;shl	eax, 16
  3159                              <1> 	;mov	ax, [edi+26] ; First Cluster Low Word
  3160                              <1> 	; ROOT Dir First Cluster = 0
  3161                              <1>         ;cmp	eax, 2
  3162                              <1> 	;jb	loc_update_direntry_1
  3163                              <1> 
  3164                              <1> pass_rmdir_fc_check:
  3165 000077E3 57                  <1> 	push	edi ; * (29/02/2016)
  3166                              <1> 
  3167 000077E4 BE[81E20000]        <1> 	mov	esi, Msg_DoYouWantRmDir
  3168 000077E9 E844DDFFFF          <1> 	call	print_msg
  3169 000077EE 8B35[D02A0100]      <1> 	mov	esi, [DelFile_FNPointer]
  3170 000077F4 E839DDFFFF          <1> 	call	print_msg
  3171 000077F9 BE[6DE20000]        <1> 	mov	esi, Msg_YesNo
  3172 000077FE E82FDDFFFF          <1> 	call	print_msg
  3173                              <1> 
  3174                              <1> loc_rmdir_ask_again:
  3175 00007803 30E4                <1> 	xor	ah, ah
  3176 00007805 E8C292FFFF          <1> 	call	int16h
  3177 0000780A 3C1B                <1> 	cmp	al, 1Bh
  3178                              <1> 	;je	short loc_do_not_delete_directory
  3179 0000780C 0F8498000000        <1>         je      loc_rmdir_y_n_escape ; 06/03/2016
  3180 00007812 24DF                <1> 	and	al, 0DFh
  3181 00007814 A2[77E20000]        <1> 	mov	[Y_N_nextline], al
  3182 00007819 3C59                <1> 	cmp	al, 'Y'
  3183 0000781B 7404                <1> 	je	short loc_rmdir_yes_delete_directory
  3184 0000781D 3C4E                <1> 	cmp	al, 'N'
  3185 0000781F 75E2                <1> 	jne	short loc_rmdir_ask_again
  3186                              <1> 
  3187                              <1> loc_do_not_delete_directory:
  3188                              <1> loc_rmdir_yes_delete_directory:
  3189 00007821 A2[77E20000]        <1> 	mov	[Y_N_nextline], al
  3190 00007826 6650                <1> 	push	ax
  3191 00007828 BE[77E20000]        <1> 	mov	esi, Y_N_nextline
  3192 0000782D E800DDFFFF          <1> 	call	print_msg
  3193 00007832 6658                <1> 	pop	ax
  3194 00007834 5F                  <1> 	pop	edi ; * (29/02/2016)
  3195                              <1> 	;cmp	al, 'Y' ; 'yes'
  3196                              <1> 	;cmc
  3197                              <1>         ;jnc	loc_file_rw_restore_retn
  3198 00007835 3C4E                <1> 	cmp	al, 'N' ; 'no'
  3199 00007837 0F84B9FDFFFF        <1>         je	loc_file_rw_restore_retn  
  3200                              <1> 
  3201                              <1> loc_rmdir_delete_short_name_check_dir_empty:
  3202                              <1> 	; EDI = Directory buffer entry offset/address 
  3203 0000783D 668B4714            <1> 	mov	ax, [edi+20] ; First Cluster High Word
  3204 00007841 C1E010              <1>         shl	eax, 16
  3205 00007844 668B471A            <1> 	mov	ax, [edi+26] ; First Cluster Low Word
  3206                              <1> 
  3207 00007848 A3[D42A0100]        <1> 	mov 	[DelFile_FCluster], eax
  3208                              <1> 
  3209                              <1> 	;mov	bx, [DirBuff_EntryCounter]
  3210 0000784D 668B1D[8C2A0100]    <1> 	mov	bx, [FindFile_DirEntryNumber] ; 27/02/2016
  3211 00007854 66891D[D82A0100]    <1> 	mov	[DelFile_EntryCounter], bx
  3212                              <1> 
  3213 0000785B 29DB                <1>     	sub	ebx, ebx
  3214 0000785D 8A3D[122A0100]      <1> 	mov	bh, [FindFile_Drv]
  3215 00007863 BE00010900          <1> 	mov	esi, Logical_DOSDisks
  3216 00007868 01DE                <1> 	add	esi, ebx
  3217                              <1> 
  3218 0000786A 66817F0CA101        <1> 	cmp	word [edi+DirEntry_NTRes], 01A1h
  3219 00007870 743F                <1> 	je	short loc_rmdir_delete_fs_directory
  3220                              <1> 
  3221                              <1> 	;cmp	byte [esi+LD_FATType], 1
  3222                              <1> 	;jnb	short loc_rmdir_get__last_cluster_0
  3223                              <1> 	;mov	eax, 0Bh ; Invalid Format
  3224                              <1> 	;jmp	loc_file_rw_cmd_failed
  3225                              <1>   
  3226                              <1> ;loc_rmdir_get_last_cluster_0:
  3227 00007872 8B15[9D280100]      <1> 	mov	edx, [DirBuff_Cluster]
  3228 00007878 8915[042B0100]      <1> 	mov	[RmDir_ParentDirCluster], edx
  3229                              <1> 
  3230 0000787E 893D[002B0100]      <1> 	mov	[RmDir_DirEntryOffset], edi
  3231                              <1> 
  3232                              <1> 	; 01/03/2016
  3233 00007884 C705[8E280100]0000- <1> 	mov	dword [FAT_ClusterCounter], 0 ; Reset
  3233 0000788C 0000                <1>
  3234                              <1> 
  3235                              <1> loc_rmdir_get_last_cluster:
  3236 0000788E E8373A0000          <1> 	call	get_last_cluster
  3237 00007893 0F82B8000000        <1>         jc      loc_rmdir_cmd_failed
  3238                              <1> 	
  3239 00007899 3B05[D42A0100]      <1> 	cmp	eax, [DelFile_FCluster]
  3240 0000789F 752F                <1> 	jne	short loc_rmdir_multi_dir_clusters
  3241                              <1> 
  3242 000078A1 C605[FF2A0100]00    <1> 	mov	byte [RmDir_MultiClusters], 0
  3243 000078A8 EB2D                <1> 	jmp	short pass_rmdir_multi_dir_clusters
  3244                              <1> 
  3245                              <1> loc_rmdir_y_n_escape:
  3246 000078AA B04E                <1> 	mov	al, 'N' ; 'no'
  3247 000078AC E970FFFFFF          <1>         jmp     loc_do_not_delete_directory
  3248                              <1> 
  3249                              <1> loc_rmdir_delete_fs_directory:
  3250 000078B1 807E04A1            <1> 	cmp	byte [esi+LD_FSType], 0A1h
  3251 000078B5 0F8545FDFFFF        <1> 	jne	loc_permission_denied
  3252                              <1> 
  3253 000078BB E821140000          <1> 	call	delete_fs_directory
  3254 000078C0 0F8326FDFFFF        <1> 	jnc	loc_print_deleted_message
  3255                              <1> 
  3256 000078C6 09C0                <1> 	or	eax, eax
  3257 000078C8 745D                <1> 	jz	loc_rmdir_directory_not_empty_2         
  3258 000078CA F9                  <1> 	stc
  3259 000078CB E926FDFFFF          <1> 	jmp	loc_file_rw_cmd_failed
  3260                              <1>  
  3261                              <1> loc_rmdir_multi_dir_clusters:
  3262 000078D0 C605[FF2A0100]01    <1> 	mov	byte [RmDir_MultiClusters], 1
  3263                              <1> 
  3264                              <1> pass_rmdir_multi_dir_clusters:
  3265 000078D7 A3[082B0100]        <1> 	mov 	[RmDir_DirLastCluster], eax
  3266 000078DC 890D[0C2B0100]      <1> 	mov	[RmDir_PreviousCluster], ecx
  3267                              <1> 
  3268                              <1> loc_rmdir_load_fat_sub_directory:
  3269 000078E2 E8CE330000          <1> 	call	load_FAT_sub_directory
  3270 000078E7 7268                <1> 	jc	loc_rmdir_cmd_failed
  3271                              <1> 
  3272                              <1> loc_rmdir_find_last_dir_entry:
  3273 000078E9 56                  <1> 	push	esi
  3274 000078EA BE[F6290100]        <1> 	mov	esi, Dir_File_Name
  3275 000078EF C6062A              <1> 	mov	byte [esi], '*'
  3276 000078F2 C646082A            <1> 	mov	byte [esi+8], '*'
  3277 000078F6 31DB                <1> 	xor	ebx, ebx ; Entry offset  = 0
  3278                              <1> loc_rmdir_find_last_dir_entry_next:
  3279 000078F8 66B80008            <1> 	mov	ax, 0800h ; Except volume/long names
  3280 000078FC 6631C9              <1> 	xor	cx, cx ; 0 = Find a valid file or dir name
  3281 000078FF E816180000          <1> 	call	find_directory_entry
  3282 00007904 7271                <1> 	jc	short loc_rmdir_empty_dir_cluster
  3283 00007906 83FB01              <1> 	cmp	ebx, 1
  3284 00007909 771B                <1> 	ja	short loc_rmdir_directory_not_empty_1
  3285                              <1> loc_rmdir_dot_entry_check:
  3286 0000790B 80FD2E              <1> 	cmp	ch, '.' ; The first char of the dir entry
  3287 0000790E 7516                <1> 	jne	short loc_rmdir_directory_not_empty_1
  3288 00007910 08DB                <1> 	or	bl, bl
  3289 00007912 7506                <1> 	jnz	short loc_rmdir_dotdot_entry_check
  3290 00007914 807F0120            <1> 	cmp	byte [edi+1], 20h
  3291 00007918 EB06                <1> 	jmp	short pass_rmdir_dot_entry_check
  3292                              <1> 
  3293                              <1> loc_rmdir_dotdot_entry_check:
  3294 0000791A 66817F012E20        <1> 	cmp	word [edi+1], '. '
  3295                              <1> pass_rmdir_dot_entry_check:	
  3296 00007920 7504                <1> 	jne	short loc_rmdir_directory_not_empty_1 
  3297 00007922 FEC3                <1> 	inc	bl
  3298 00007924 EBD2                <1> 	jmp	short loc_rmdir_find_last_dir_entry_next 
  3299                              <1> 
  3300                              <1> 
  3301                              <1> loc_rmdir_directory_not_empty_1:
  3302 00007926 58                  <1> 	pop	eax ; pushed esi 
  3303                              <1> 
  3304                              <1> loc_rmdir_directory_not_empty_2:
  3305 00007927 BE[A2E20000]        <1> 	mov	esi, Msg_Dir_Not_Empty
  3306 0000792C E801DCFFFF          <1> 	call	print_msg
  3307                              <1> 	; 01/03/2016
  3308 00007931 A1[8E280100]        <1> 	mov	eax, [FAT_ClusterCounter]
  3309 00007936 09C0                <1> 	or	eax, eax ; 0 ?
  3310 00007938 0F84B8FCFFFF        <1> 	jz	loc_file_rw_restore_retn
  3311                              <1> 	; ESI = Logical DOS Drive Description Table address	
  3312                              <1> 
  3313 0000793E 66BB01FF            <1> 	mov	bx, 0FF01h ; BH = FFh -> use ESI for Drive parameters
  3314                              <1> 	           ; BL = 1 -> add free clusters
  3315 00007942 E804380000          <1> 	call	calculate_fat_freespace
  3316 00007947 09C9                <1> 	or	ecx, ecx
  3317 00007949 0F84A7FCFFFF        <1>         jz      loc_file_rw_restore_retn ; ecx = 0 -> OK
  3318                              <1> 	; ecx > 0 -> Error (Recalculation is neeeded)
  3319 0000794F EB0E                <1> 	jmp	short loc_rmdir_cmd_return
  3320                              <1> 
  3321                              <1> 
  3322                              <1> loc_rmdir_cmd_failed:
  3323 00007951 833D[8E280100]01    <1> 	cmp	dword [FAT_ClusterCounter], 1
  3324 00007958 0F8298FCFFFF        <1> 	jb	loc_file_rw_cmd_failed	
  3325 0000795E F9                  <1> 	stc
  3326                              <1> loc_rmdir_cmd_return:
  3327                              <1> 	; 01/03/2016
  3328 0000795F 9C                  <1> 	pushf
  3329                              <1> 	; ESI = Logical DOS Drive Description Table address	
  3330 00007960 66BB00FF            <1> 	mov	bx, 0FF00h ; BH = FFh -> use ESI for Drive parameters
  3331                              <1> 	           ; BL = 0 -> Recalculate free cluster count
  3332 00007964 50                  <1> 	push	eax
  3333 00007965 E8E1370000          <1> 	call	calculate_fat_freespace	
  3334 0000796A 58                  <1> 	pop	eax
  3335 0000796B 9D                  <1> 	popf
  3336 0000796C 0F8284FCFFFF        <1> 	jc	loc_file_rw_cmd_failed
  3337 00007972 E97FFCFFFF          <1> 	jmp	loc_file_rw_restore_retn
  3338                              <1> 
  3339                              <1> 
  3340                              <1> loc_rmdir_empty_dir_cluster:
  3341 00007977 5E                  <1> 	pop	esi
  3342                              <1> 
  3343                              <1> loc_rmdir_set_prev_cluster_dir_last_cluster:
  3344 00007978 803D[FF2A0100]00    <1> 	cmp	byte [RmDir_MultiClusters], 0
  3345 0000797F 761D                <1> 	jna	short loc_rmdir_unlink_dir_last_cluster
  3346                              <1> 
  3347 00007981 A1[0C2B0100]        <1> 	mov	eax, [RmDir_PreviousCluster]
  3348                              <1> 	;xor	ecx, ecx
  3349 00007986 49                  <1> 	dec	ecx ; FFFFFFFFh
  3350 00007987 E86D340000          <1> 	call	update_cluster
  3351 0000798C 7310                <1> 	jnc	short loc_rmdir_unlink_dir_last_cluster
  3352                              <1> 
  3353                              <1> loc_rmdir_unlink_stc_retn:
  3354                              <1> 	; 01/03/2016
  3355 0000798E 83F801              <1> 	cmp	eax, 1  ; eax = 0 -> end of cluster chain
  3356 00007991 F5                  <1> 	cmc 
  3357 00007992 72BD                <1> 	jc	short loc_rmdir_cmd_failed
  3358 00007994 EB1D                <1> 	jmp	short loc_rmdir_save_fat_buffer 
  3359                              <1> 	
  3360                              <1> loc_rmdir_unlink_stc_retn_0Bh:
  3361 00007996 B80B000000          <1> 	mov	eax, 0Bh ; Invalid format
  3362 0000799B F9                  <1> 	stc
  3363 0000799C EBB3                <1> 	jmp	short loc_rmdir_cmd_failed
  3364                              <1>  
  3365                              <1> loc_rmdir_unlink_dir_last_cluster:
  3366 0000799E A1[082B0100]        <1> 	mov	eax, [RmDir_DirLastCluster]
  3367 000079A3 31C9                <1> 	xor	ecx, ecx ; 0
  3368 000079A5 E84F340000          <1> 	call	update_cluster
  3369 000079AA 73EA                <1> 	jnc	short loc_rmdir_unlink_stc_retn_0Bh
  3370                              <1> 	; Because of it is the last cluster
  3371                              <1> 	; 'update_cluster' must return with eocc error 
  3372 000079AC 09C0                <1> 	or	eax, eax
  3373 000079AE 7403                <1> 	jz	short loc_rmdir_save_fat_buffer ; eocc	
  3374 000079B0 F9                  <1> 	stc
  3375 000079B1 EB9E                <1>         jmp     short loc_rmdir_cmd_failed
  3376                              <1> 	 
  3377                              <1> loc_rmdir_save_fat_buffer:
  3378 000079B3 803D[86280100]02    <1> 	cmp	byte [FAT_BuffValidData], 2
  3379 000079BA 7525                <1> 	jne	short loc_rmdir_calculate_FAT_freespace
  3380 000079BC E8F5360000          <1> 	call	save_fat_buffer
  3381 000079C1 728E                <1> 	jc	short loc_rmdir_cmd_failed
  3382                              <1> 
  3383                              <1> 	; 01/03/2016
  3384 000079C3 803D[FF2A0100]00    <1> 	cmp	byte [RmDir_MultiClusters], 0
  3385 000079CA 7615                <1> 	jna	short loc_rmdir_calculate_FAT_freespace
  3386                              <1> 
  3387 000079CC A1[D42A0100]        <1> 	mov	eax, [DelFile_FCluster]
  3388 000079D1 E9B8FEFFFF          <1>         jmp     loc_rmdir_get_last_cluster
  3389                              <1> 
  3390                              <1> loc_rmdir_delete_short_name_invalid_data:
  3391 000079D6 B80D000000          <1> 	mov	eax, 0Dh ; Invalid data
  3392 000079DB F9                  <1> 	stc
  3393 000079DC E970FFFFFF          <1>         jmp     loc_rmdir_cmd_failed
  3394                              <1> 
  3395                              <1> loc_rmdir_calculate_FAT_freespace:
  3396 000079E1 A1[8E280100]        <1> 	mov	eax, [FAT_ClusterCounter]
  3397 000079E6 66BB01FF            <1> 	mov	bx, 0FF01h
  3398                              <1> 	; BL = 1 -> Add EAX to free space count
  3399                              <1> 	; BH = FFh ->
  3400                              <1> 	; ESI = Logical DOS Drive Description Table address
  3401 000079EA E85C370000          <1> 	call	calculate_fat_freespace
  3402                              <1> 
  3403 000079EF 21C9                <1> 	and	ecx, ecx ; ecx = 0 -> valid free sector count
  3404 000079F1 7409                <1> 	jz 	short loc_rmdir_delete_short_name_continue
  3405                              <1> 
  3406                              <1> loc_rmdir_recalculate_FAT_freespace:
  3407 000079F3 66BB00FF            <1>         mov     bx, 0FF00h ; BL = 0 -> Recalculate free space
  3408 000079F7 E84F370000          <1> 	call	calculate_fat_freespace
  3409                              <1> 	          
  3410                              <1> loc_rmdir_delete_short_name_continue:
  3411 000079FC A1[042B0100]        <1> 	mov	eax, [RmDir_ParentDirCluster]
  3412 00007A01 83F802              <1> 	cmp	eax, 2
  3413 00007A04 730D                <1> 	jnb	short loc_rmdir_del_short_name_load_sub_dir
  3414 00007A06 E81F320000          <1> 	call	load_FAT_root_directory
  3415 00007A0B 0F82E5FBFFFF        <1> 	jc	loc_file_rw_cmd_failed
  3416 00007A11 EB0B                <1> 	jmp	short loc_rmdir_del_short_name_ld_chk_fclust
  3417                              <1> 
  3418                              <1> loc_rmdir_del_short_name_load_sub_dir:	
  3419 00007A13 E89D320000          <1> 	call	load_FAT_sub_directory
  3420 00007A18 0F82D8FBFFFF        <1> 	jc	loc_file_rw_cmd_failed
  3421                              <1> 
  3422                              <1> loc_rmdir_del_short_name_ld_chk_fclust:
  3423 00007A1E 0FB73D[002B0100]    <1> 	movzx	edi, word [RmDir_DirEntryOffset]
  3424 00007A25 81C700000800        <1> 	add	edi, Directory_Buffer
  3425                              <1> 
  3426 00007A2B 668B4714            <1> 	mov	ax, [edi+20] ; First Cluster High Word
  3427 00007A2F C1E010              <1> 	shl	eax, 16
  3428 00007A32 668B471A            <1> 	mov	ax, [edi+26] ; First Cluster Low Word
  3429                              <1>         ; Not necessary... 
  3430 00007A36 3B05[D42A0100]      <1> 	cmp	eax, [DelFile_FCluster]
  3431 00007A3C 7598                <1> 	jne	short loc_rmdir_delete_short_name_invalid_data
  3432                              <1> 	;
  3433 00007A3E C607E5              <1> 	mov	byte [edi], 0E5h ; 'Deleted' sign
  3434                              <1> 	; 27/02/2016
  3435                              <1> 	; TRDOS v1 has a bug here! it does not set
  3436                              <1> 	; 'DirBuff_ValidData' to 2; as result of this bug,
  3437                              <1> 	; 'save_directory_buffer' would not save the change ! 
  3438 00007A41 C605[98280100]02    <1>   	mov	byte [DirBuff_ValidData], 2 ; change sign
  3439                              <1> 	;
  3440 00007A48 E8EF1D0000          <1> 	call	save_directory_buffer
  3441 00007A4D 0F82A3FBFFFF        <1> 	jc	loc_file_rw_cmd_failed 
  3442                              <1> 
  3443                              <1> loc_rmdir_del_long_name:
  3444 00007A53 0FB615[DA2A0100]    <1> 	movzx	edx, byte [DelFile_LNEL]
  3445 00007A5A 08D2                <1> 	or	dl, dl
  3446 00007A5C 7414                <1> 	jz	short loc_rmdir_update_parent_dir_lmdt
  3447                              <1>              
  3448 00007A5E 0FB705[D82A0100]    <1> 	movzx	eax, word [DelFile_EntryCounter]
  3449 00007A65 29D0                <1> 	sub	eax, edx
  3450 00007A67 0F8289FBFFFF        <1> 	jc	loc_file_rw_cmd_failed
  3451                              <1>  
  3452                              <1>  	; EAX = Directory Entry Number of the long name last entry
  3453 00007A6D E82A1F0000          <1> 	call	delete_longname
  3454                              <1> 	;jc	short loc_file_rw_cmd_failed
  3455                              <1> 
  3456                              <1> loc_rmdir_update_parent_dir_lmdt:
  3457 00007A72 E8601E0000          <1> 	call	update_parent_dir_lmdt
  3458                              <1> 	;jc	short loc_file_rw_cmd_failed
  3459                              <1> 
  3460                              <1> loc_rmdir_ok:
  3461 00007A77 BE[7BE20000]        <1> 	mov	esi, Msg_OK
  3462 00007A7C E8B1DAFFFF          <1> 	call	print_msg
  3463 00007A81 E970FBFFFF          <1> 	jmp	loc_file_rw_restore_retn
  3464                              <1> 
  3465                              <1> 
  3466                              <1> delete_file:
  3467                              <1> 	; 29/02/2016
  3468                              <1> 	; 28/02/2016 (TRDOS 386 =  TRDOS v2.0)
  3469                              <1> 	; 09/08/2010 (CMD_INTR.ASM, 'cmp_cmd_del')
  3470                              <1> 	; 28/02/2010
  3471                              <1> 
  3472                              <1> get_delfile_fchar:
  3473                              <1> 	; esi = file name
  3474 00007A86 803E20              <1> 	cmp	byte [esi], 20h
  3475 00007A89 7701                <1>         ja	short loc_delfile_parse_path_name
  3476                              <1> 
  3477                              <1> loc_delfile_nofilename_retn:
  3478 00007A8B C3                  <1> 	retn
  3479                              <1> 
  3480                              <1> loc_delfile_parse_path_name:
  3481 00007A8C BF[122A0100]        <1> 	mov	edi, FindFile_Drv
  3482 00007A91 E842190000          <1> 	call	parse_path_name
  3483 00007A96 0F8230F2FFFF        <1> 	jc	loc_cmd_failed
  3484                              <1> 
  3485                              <1> loc_delfile_check_filename_exists:
  3486 00007A9C BE[542A0100]        <1> 	mov	esi, FindFile_Name
  3487 00007AA1 803E20              <1> 	cmp	byte [esi], 20h
  3488 00007AA4 0F8622F2FFFF        <1> 	jna	loc_cmd_failed
  3489 00007AAA 8935[D02A0100]      <1> 	mov	[DelFile_FNPointer], esi 
  3490                              <1> 
  3491                              <1> loc_delfile_drv:
  3492 00007AB0 8A15[122A0100]      <1> 	mov	dl, [FindFile_Drv]
  3493 00007AB6 8A35[6E200100]      <1> 	mov	dh, [Current_Drv]
  3494 00007ABC 8835[CE280100]      <1> 	mov	[RUN_CDRV], dh
  3495 00007AC2 38F2                <1> 	cmp	dl, dh
  3496 00007AC4 740B                <1> 	je	short loc_delfile_change_directory
  3497                              <1> 
  3498 00007AC6 E867E3FFFF          <1> 	call	change_current_drive
  3499 00007ACB 0F8225FBFFFF        <1> 	jc	loc_file_rw_cmd_failed
  3500                              <1> 
  3501                              <1> loc_delfile_change_directory:
  3502 00007AD1 803D[132A0100]20    <1> 	cmp	byte [FindFile_Directory], 20h
  3503 00007AD8 7618                <1> 	jna	short loc_delfile_find
  3504                              <1> 
  3505 00007ADA FE05[E4DD0000]      <1> 	inc	byte [Restore_CDIR]
  3506 00007AE0 BE[132A0100]        <1> 	mov	esi, FindFile_Directory
  3507 00007AE5 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
  3508 00007AE7 E8D8120000          <1> 	call	change_current_directory
  3509 00007AEC 0F8204FBFFFF        <1> 	jc	loc_file_rw_cmd_failed
  3510                              <1> 
  3511                              <1> ;loc_delfile_change_prompt_dir_string:
  3512                              <1> 	;call	change_prompt_dir_string
  3513                              <1> 
  3514                              <1> loc_delfile_find:
  3515                              <1> 	;mov	esi, FindFile_Name
  3516 00007AF2 8B35[D02A0100]      <1> 	mov	esi, [DelFile_FNPointer]
  3517 00007AF8 66B80018            <1> 	mov	ax, 1800h ; Except volume label and dirs
  3518 00007AFC E8CDF6FFFF          <1> 	call	find_first_file
  3519 00007B01 0F82EFFAFFFF        <1> 	jc	loc_file_rw_cmd_failed
  3520                              <1> 
  3521                              <1> loc_delfile_ambgfn_check:
  3522 00007B07 6621D2              <1> 	and	dx, dx ; Ambiguous filename chars used sign (DX>0)
  3523 00007B0A 740B                <1> 	jz	short loc_delfile_found
  3524                              <1> 
  3525                              <1> loc_file_not_found:
  3526 00007B0C B802000000          <1> 	mov	eax, 2 ; File not found sign
  3527 00007B11 F9                  <1> 	stc
  3528 00007B12 E9DFFAFFFF          <1> 	jmp	loc_file_rw_cmd_failed   
  3529                              <1> 
  3530                              <1> loc_delfile_found:
  3531 00007B17 80E307              <1> 	and	bl, 07h ; Attributes
  3532 00007B1A 0F85E0FAFFFF        <1>         jnz     loc_permission_denied
  3533                              <1> 
  3534                              <1> ;loc_delfile_found_save_lnel:
  3535                              <1> ;	mov	[DelFile_LNEL], bh ; Long name entry length (if > 0)
  3536                              <1> 
  3537                              <1> loc_delfile_ask_for_delete:
  3538 00007B20 57                  <1> 	push	edi ; * (29/02/2016)
  3539                              <1> 
  3540 00007B21 BE[B9E20000]        <1> 	mov	esi, Msg_DoYouWantDelete
  3541 00007B26 E807DAFFFF          <1> 	call	print_msg
  3542 00007B2B 8B35[D02A0100]      <1> 	mov	esi, [DelFile_FNPointer]
  3543 00007B31 E8FCD9FFFF          <1> 	call	print_msg
  3544 00007B36 BE[6DE20000]        <1> 	mov	esi, Msg_YesNo
  3545 00007B3B E8F2D9FFFF          <1> 	call	print_msg
  3546                              <1> 
  3547                              <1> loc_delfile_ask_again:
  3548 00007B40 30E4                <1> 	xor	ah, ah
  3549 00007B42 E8858FFFFF          <1> 	call	int16h
  3550 00007B47 3C1B                <1> 	cmp	al, 1Bh
  3551                              <1> 	;je	short loc_do_not_delete_file
  3552 00007B49 7457                <1> 	je	short loc_delfile_y_n_escape ; 06/03/2016
  3553 00007B4B 24DF                <1> 	and	al, 0DFh
  3554 00007B4D A2[77E20000]        <1> 	mov	[Y_N_nextline], al
  3555 00007B52 3C59                <1> 	cmp	al, 'Y'
  3556 00007B54 7404                <1> 	je	short loc_yes_delete_file
  3557 00007B56 3C4E                <1> 	cmp	al, 'N'
  3558 00007B58 75E6                <1> 	jne	short loc_delfile_ask_again
  3559                              <1> 
  3560                              <1> loc_do_not_delete_file:
  3561                              <1> loc_yes_delete_file:
  3562 00007B5A A2[77E20000]        <1> 	mov	[Y_N_nextline], al
  3563 00007B5F 6650                <1> 	push	ax
  3564 00007B61 BE[77E20000]        <1> 	mov	esi, Y_N_nextline
  3565 00007B66 E8C7D9FFFF          <1> 	call	print_msg
  3566 00007B6B 6658                <1> 	pop	ax
  3567 00007B6D 5F                  <1> 	pop	edi ; * (29/02/2016)
  3568                              <1> 	;cmp	al, 'Y' ; 'yes'
  3569                              <1> 	;cmc
  3570                              <1>         ;jnc	loc_file_rw_restore_retn
  3571 00007B6E 3C4E                <1> 	cmp	al, 'N' ; 'no'
  3572 00007B70 0F8480FAFFFF        <1>         je	loc_file_rw_restore_retn  
  3573                              <1> 
  3574                              <1> loc_delete_file:
  3575 00007B76 8A3D[122A0100]      <1> 	mov	bh, [FindFile_Drv]
  3576                              <1> 	;mov	bl, [DelFile_LNEL]
  3577 00007B7C 8A1D[612A0100]      <1> 	mov	bl, [FindFile_LongNameEntryLength]
  3578                              <1> 	;mov	cx, [DirBuff_EntryCounter]
  3579 00007B82 668B0D[8C2A0100]    <1> 	mov	cx, [FindFile_DirEntryNumber]
  3580                              <1> 	; (*) EDI = Directory buffer entry offset/address 
  3581 00007B89 E8F81F0000          <1> 	call	remove_file ; (FILE.ASM, 'proc_delete_file')
  3582 00007B8E 0F8358FAFFFF        <1> 	jnc	loc_print_deleted_message
  3583                              <1> 
  3584 00007B94 3C05                <1> 	cmp	al, 05h
  3585 00007B96 0F8464FAFFFF        <1> 	je	loc_permission_denied
  3586 00007B9C F9                  <1> 	stc
  3587 00007B9D E954FAFFFF          <1> 	jmp	loc_file_rw_cmd_failed
  3588                              <1> 
  3589                              <1> loc_delfile_y_n_escape:
  3590 00007BA2 B04E                <1> 	mov	al, 'N' ; 'no'
  3591 00007BA4 EBB4                <1> 	jmp	short loc_do_not_delete_file
  3592                              <1> 
  3593                              <1> set_file_attributes:
  3594                              <1> 	; 06/03/2016
  3595                              <1> 	; 04/03/2016 (TRDOS 386 =  TRDOS v2.0)
  3596                              <1> 	; 10/07/2010 (TRDOS v1, CMD_INTR.ASM, 'cmp_cmd_attrib')
  3597                              <1> 	; 23/05/2010 
  3598                              <1> 	; 17/12/2000 (P2000.ASM)
  3599                              <1> 
  3600                              <1> 	; esi = file or directory name
  3601 00007BA6 6631C0              <1> 	xor	ax, ax
  3602 00007BA9 66A3[0AE30000]      <1> 	mov	[Attr_Chars], ax
  3603 00007BAF A2[282B0100]        <1> 	mov	[Attributes], al
  3604                              <1> 
  3605                              <1> get_attrib_fchar:
  3606                              <1> 	; esi = file name
  3607 00007BB4 8A06                <1> 	mov	al, [esi]
  3608 00007BB6 3C20                <1> 	cmp	al, 20h
  3609 00007BB8 7623                <1> 	jna	short loc_attr_file_nofilename_retn
  3610                              <1> 
  3611                              <1> loc_scan_attrib_params:
  3612 00007BBA 3C2D                <1> 	cmp	al, '-'
  3613 00007BBC 0F871C010000        <1> 	ja	loc_attr_file_parse_path_name
  3614 00007BC2 7408                <1> 	je	short loc_attr_space
  3615                              <1> 
  3616 00007BC4 3C2B                <1> 	cmp	al, '+'
  3617 00007BC6 0F8500F1FFFF        <1> 	jne	loc_cmd_failed
  3618                              <1> 
  3619                              <1> loc_attr_space:
  3620 00007BCC 8A6601              <1> 	mov	ah, [esi+1]
  3621 00007BCF 80FC20              <1>  	cmp	ah, 20h
  3622 00007BD2 770A                <1> 	ja	short pass_attr_space
  3623 00007BD4 0F82F2F0FFFF        <1> 	jb	loc_cmd_failed
  3624 00007BDA 46                  <1> 	inc	esi
  3625 00007BDB EBEF                <1> 	jmp	short loc_attr_space
  3626                              <1> 
  3627                              <1> loc_attr_file_nofilename_retn:
  3628 00007BDD C3                  <1> 	retn
  3629                              <1> 
  3630                              <1> pass_attr_space:
  3631 00007BDE 80E4DF              <1> 	and	ah, 0DFh
  3632 00007BE1 80FC53              <1> 	cmp	ah, 'S'
  3633 00007BE4 0F87E2F0FFFF        <1> 	ja	loc_cmd_failed
  3634 00007BEA 7204                <1> 	jb	short pass_attr_system
  3635 00007BEC B404                <1> 	mov	ah, 04h   ; System
  3636 00007BEE EB21                <1> 	jmp	short pass_attr_archive
  3637                              <1> 
  3638                              <1> pass_attr_system:
  3639 00007BF0 80FC48              <1> 	cmp	ah, 'H'
  3640 00007BF3 7706                <1> 	ja	short pass_attr_hidden
  3641 00007BF5 7213                <1> 	jb	short pass_attr_read_only
  3642 00007BF7 B402                <1> 	mov	ah, 02h    ; Hidden
  3643 00007BF9 EB16                <1> 	jmp	short pass_attr_archive
  3644                              <1> 
  3645                              <1> pass_attr_hidden:
  3646 00007BFB 80FC52              <1> 	cmp	ah, 'R'
  3647 00007BFE 0F87C8F0FFFF        <1> 	ja	loc_cmd_failed
  3648 00007C04 7204                <1> 	jb	short pass_attr_read_only ; Read only
  3649 00007C06 B401                <1> 	mov	ah, 01h
  3650 00007C08 EB07                <1> 	jmp	short pass_attr_archive
  3651                              <1> 
  3652                              <1> pass_attr_read_only:
  3653 00007C0A 80FC41              <1> 	cmp	ah, 'A'
  3654 00007C0D 753B                <1> 	jne	short loc_chk_attr_enter
  3655 00007C0F B420                <1> 	mov	ah, 20h    ; Archive
  3656                              <1> 
  3657                              <1> pass_attr_archive:
  3658 00007C11 3C2D                <1> 	cmp	al, '-'
  3659 00007C13 7508                <1> 	jne	short pass_reducing_attributes
  3660 00007C15 0825[0AE30000]      <1> 	or	[Attr_Chars], ah
  3661 00007C1B EB06                <1> 	jmp	short loc_change_attributes_inc
  3662                              <1> 
  3663                              <1> pass_reducing_attributes:
  3664 00007C1D 0825[0BE30000]      <1> 	or	[Attr_Chars+1], ah
  3665                              <1> 
  3666                              <1> loc_change_attributes_inc:
  3667 00007C23 46                  <1> 	inc	esi
  3668 00007C24 8A6601              <1> 	mov	ah, [esi+1]
  3669 00007C27 80FC20              <1> 	cmp	ah, 20h
  3670 00007C2A 7227                <1> 	jb	short pass_change_attr
  3671 00007C2C 74F5                <1> 	je	short loc_change_attributes_inc
  3672 00007C2E 80FC2D              <1> 	cmp	ah, '-'
  3673 00007C31 770D                <1> 	ja	short loc_chk_next_attr_char1
  3674 00007C33 7405                <1> 	je	short loc_chk_next_attr_char0
  3675 00007C35 80FC2B              <1> 	cmp	ah, '+'
  3676 00007C38 7506                <1> 	jne	short loc_chk_next_attr_char1
  3677                              <1> 
  3678                              <1> loc_chk_next_attr_char0:
  3679 00007C3A 46                  <1> 	inc	esi
  3680 00007C3B 668B06              <1> 	mov	ax, [esi]
  3681 00007C3E EB9E                <1> 	jmp	short pass_attr_space
  3682                              <1> 
  3683                              <1> loc_chk_next_attr_char1:
  3684 00007C40 803E2D              <1> 	cmp	byte [esi], '-'
  3685 00007C43 7799                <1> 	ja	short pass_attr_space
  3686 00007C45 E988000000          <1>         jmp     loc_attr_file_check_fname_fchar
  3687                              <1> 
  3688                              <1> loc_chk_attr_enter:
  3689 00007C4A 80FC0D              <1> 	cmp	ah, 0Dh
  3690 00007C4D 0F8579F0FFFF        <1> 	jne	loc_cmd_failed
  3691                              <1> 
  3692                              <1> pass_change_attr:
  3693 00007C53 A0[0AE30000]        <1> 	mov	al, [Attr_Chars]
  3694 00007C58 F6D0                <1> 	not	al
  3695 00007C5A 2005[282B0100]      <1> 	and	[Attributes], al
  3696 00007C60 A0[0BE30000]        <1> 	mov	al, [Attr_Chars+1]
  3697 00007C65 0805[282B0100]      <1> 	or	[Attributes], al
  3698                              <1> 
  3699                              <1> loc_show_attributes:
  3700 00007C6B BE[8BEE0000]        <1> 	mov	esi, nextline
  3701 00007C70 E8BDD8FFFF          <1> 	call	print_msg
  3702                              <1> 
  3703                              <1> loc_show_attributes_no_nextline:
  3704 00007C75 C705[0AE30000]4E4F- <1> 	mov	dword [Attr_Chars], 'NORM'
  3704 00007C7D 524D                <1>
  3705 00007C7F 66C705[0EE30000]41- <1> 	mov	word [Attr_Chars+4], 'AL'
  3705 00007C87 4C                  <1>
  3706 00007C88 BE[0AE30000]        <1> 	mov	esi, Attr_Chars
  3707 00007C8D A0[282B0100]        <1> 	mov	al, [Attributes]
  3708 00007C92 A804                <1> 	test	al, 04h
  3709 00007C94 7406                <1> 	jz	short pass_put_attr_s
  3710 00007C96 66C7065300          <1> 	mov	word [esi], 0053h     ; S
  3711 00007C9B 46                  <1> 	inc	esi
  3712                              <1> 
  3713                              <1> pass_put_attr_s:
  3714 00007C9C A802                <1> 	test	al, 02h
  3715 00007C9E 7406                <1> 	jz	short pass_put_attr_h
  3716 00007CA0 66C7064800          <1> 	mov	word [esi], 0048h     ; H
  3717 00007CA5 46                  <1> 	inc	esi
  3718                              <1> 
  3719                              <1> pass_put_attr_h:
  3720 00007CA6 A801                <1> 	test	al, 01h
  3721 00007CA8 7406                <1> 	jz	short pass_put_attr_r
  3722 00007CAA 66C7065200          <1> 	mov	word [esi], 0052h     ; R
  3723 00007CAF 46                  <1> 	inc	esi
  3724                              <1> 
  3725                              <1> pass_put_attr_r:
  3726 00007CB0 3C20                <1> 	cmp	al, 20h
  3727 00007CB2 7205                <1> 	jb	short pass_put_attr_a
  3728 00007CB4 66C7064100          <1> 	mov	word [esi], 0041h     ; A
  3729                              <1> 
  3730                              <1> pass_put_attr_a:
  3731 00007CB9 BE[FDE20000]        <1> 	mov	esi, Str_Attributes
  3732 00007CBE E86FD8FFFF          <1> 	call	print_msg
  3733 00007CC3 BE[8BEE0000]        <1> 	mov	esi, nextline
  3734 00007CC8 E865D8FFFF          <1> 	call	print_msg
  3735 00007CCD E924F9FFFF          <1> 	jmp	loc_file_rw_restore_retn 
  3736                              <1> 
  3737                              <1> loc_attr_file_check_fname_fchar:
  3738 00007CD2 46                  <1> 	inc	esi
  3739 00007CD3 803E20              <1> 	cmp	byte [esi], 20h
  3740 00007CD6 74FA                <1> 	je	short loc_attr_file_check_fname_fchar
  3741 00007CD8 0F8275FFFFFF        <1>         jb      pass_change_attr
  3742                              <1> 		   
  3743                              <1> loc_attr_file_parse_path_name:
  3744 00007CDE BF[122A0100]        <1> 	mov	edi, FindFile_Drv
  3745 00007CE3 E8F0160000          <1> 	call	parse_path_name
  3746 00007CE8 0F82DEEFFFFF        <1> 	jc	loc_cmd_failed
  3747                              <1> 
  3748                              <1> loc_attr_file_check_filename_exists:
  3749 00007CEE BE[542A0100]        <1> 	mov	esi, FindFile_Name
  3750 00007CF3 803E20              <1> 	cmp	byte [esi], 20h
  3751 00007CF6 0F86D0EFFFFF        <1> 	jna	loc_cmd_failed
  3752 00007CFC 8935[D02A0100]      <1> 	mov	[DelFile_FNPointer], esi 
  3753                              <1> 
  3754                              <1> loc_attr_file_drv:
  3755 00007D02 8A35[6E200100]      <1> 	mov	dh, [Current_Drv]
  3756 00007D08 8835[CE280100]      <1> 	mov	[RUN_CDRV], dh
  3757                              <1> 
  3758 00007D0E 8A15[122A0100]      <1> 	mov	dl, [FindFile_Drv]
  3759 00007D14 38F2                <1> 	cmp	dl, dh
  3760 00007D16 740B                <1> 	je	short loc_attr_file_change_directory
  3761                              <1> 
  3762 00007D18 E815E1FFFF          <1> 	call	change_current_drive
  3763 00007D1D 0F82D3F8FFFF        <1> 	jc	loc_file_rw_cmd_failed
  3764                              <1> 
  3765                              <1> loc_attr_file_change_directory:
  3766 00007D23 803D[132A0100]20    <1>         cmp     byte [FindFile_Directory], 20h
  3767 00007D2A 7618                <1> 	jna	short loc_attr_file_find
  3768                              <1> 
  3769 00007D2C FE05[E4DD0000]      <1> 	inc	byte [Restore_CDIR]
  3770                              <1> 	
  3771 00007D32 BE[132A0100]        <1> 	mov	esi, FindFile_Directory
  3772 00007D37 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
  3773 00007D39 E886100000          <1> 	call	change_current_directory
  3774 00007D3E 0F82B2F8FFFF        <1> 	jc	loc_file_rw_cmd_failed
  3775                              <1> 
  3776                              <1> ;loc_attr_file_change_prompt_dir_string:
  3777                              <1> 	;call	change_prompt_dir_string
  3778                              <1> 
  3779                              <1> loc_attr_file_find:
  3780                              <1> 	;mov	esi, FindFile_Name
  3781 00007D44 8B35[D02A0100]      <1> 	mov	esi, [DelFile_FNPointer]
  3782 00007D4A 66B80008            <1> 	mov	ax, 0800h ; Except volume labels
  3783 00007D4E E87BF4FFFF          <1> 	call	find_first_file
  3784 00007D53 0F829DF8FFFF        <1> 	jc	loc_file_rw_cmd_failed
  3785                              <1> 
  3786                              <1> loc_attr_file_ambgfn_check:
  3787 00007D59 6609D2              <1> 	or	dx, dx ; Ambiguous filename chars used sign (DX>0)
  3788                              <1> 	;	(Note: It was BX in TRDOS v1)
  3789                              <1> 	;jz	short loc_attr_file_found
  3790 00007D5C 0F85AAFDFFFF        <1>         jnz     loc_file_not_found ; 06/03/2016 
  3791                              <1> 
  3792                              <1> 	;mov	eax, 2 ; File not found sign
  3793                              <1> 	;stc
  3794                              <1> 	;jmp	loc_file_rw_cmd_failed   
  3795                              <1> 
  3796                              <1> loc_attr_file_found:
  3797                              <1> 	; EDI = Directory buffer entry offset/address
  3798                              <1> 	; BL = File (or Directory) Attributes 
  3799                              <1> 	;	(Note: It was 'CL' in TRDOS v1)
  3800                              <1> 	; mov	bl, [EDI+0Bh]
  3801                              <1> 	
  3802 00007D62 66833D[0AE30000]00  <1> 	cmp	word [Attr_Chars], 0
  3803 00007D6A 770B                <1> 	ja	short loc_attr_file_change_attributes
  3804 00007D6C 881D[282B0100]      <1> 	mov	[Attributes], bl
  3805 00007D72 E9F4FEFFFF          <1> 	jmp	loc_show_attributes
  3806                              <1> 
  3807                              <1> loc_attr_file_change_attributes:
  3808 00007D77 A0[0AE30000]        <1> 	mov	al, [Attr_Chars]
  3809 00007D7C F6D0                <1> 	not	al
  3810 00007D7E 20C3                <1> 	and	bl, al
  3811 00007D80 A0[0BE30000]        <1> 	mov	al, [Attr_Chars+1]
  3812 00007D85 08C3                <1> 	or	bl, al
  3813                              <1> 
  3814 00007D87 66817F0CA101        <1> 	cmp	word [edi+DirEntry_NTRes], 01A1h ; Singlix FS
  3815 00007D8D 741D                <1> 	je	short loc_attr_file_fs_check
  3816                              <1> 
  3817 00007D8F 881D[282B0100]      <1> 	mov	[Attributes], bl
  3818 00007D95 885F0B              <1> 	mov	[edi+0Bh], bl    ; Attributes (New!)
  3819                              <1> 
  3820                              <1> 	; 04/03/2016
  3821                              <1> 	; TRDOS v1 has a bug here! it does not set
  3822                              <1> 	; 'DirBuff_ValidData' to 2; as result of this bug,
  3823                              <1> 	; 'save_directory_buffer' would not save the new attributes ! 
  3824                              <1> 	
  3825 00007D98 C605[98280100]02    <1> 	mov	byte [DirBuff_ValidData], 2
  3826                              <1> 
  3827 00007D9F E8981A0000          <1> 	call 	save_directory_buffer
  3828 00007DA4 0F824CF8FFFF        <1> 	jc	loc_file_rw_cmd_failed
  3829                              <1> 
  3830 00007DAA EB33                <1> 	jmp	short loc_print_attr_changed_message
  3831                              <1> 
  3832                              <1> loc_attr_file_fs_check:
  3833 00007DAC 29C0                <1> 	sub	eax, eax
  3834 00007DAE 8A25[96280100]      <1>         mov     ah, [DirBuff_DRV]
  3835 00007DB4 BE00010900          <1> 	mov	esi, Logical_DOSDisks
  3836 00007DB9 01C6                <1>         add     esi, eax
  3837 00007DBB 807E04A1            <1>         cmp     byte [esi+LD_FSType], 0A1h
  3838 00007DBF 7309                <1> 	jnc	short loc_attr_file_change_fs_file_attributes
  3839 00007DC1 66B80D00            <1> 	mov	ax, 0Dh ; Invalid Data
  3840 00007DC5 E92CF8FFFF          <1> 	jmp	loc_file_rw_cmd_failed
  3841                              <1> 
  3842                              <1> loc_attr_file_change_fs_file_attributes:
  3843                              <1> 	; BL = New MS-DOS File Attributes
  3844 00007DCA 88D8                <1> 	mov	al, bl ; File/Directory Attributes
  3845 00007DCC 30E4                <1> 	xor	ah, ah ; Attributes in MS-DOS format sign	  
  3846 00007DCE E89C050000          <1> 	call	change_fs_file_attributes
  3847 00007DD3 0F821DF8FFFF        <1> 	jc	loc_file_rw_cmd_failed
  3848                              <1> 
  3849 00007DD9 881D[282B0100]      <1> 	mov	[Attributes], bl 
  3850                              <1> 
  3851                              <1> loc_print_attr_changed_message:
  3852 00007DDF BE[F8E20000]        <1> 	mov	esi, Msg_New
  3853 00007DE4 E849D7FFFF          <1> 	call	print_msg
  3854 00007DE9 E987FEFFFF          <1> 	jmp	loc_show_attributes_no_nextline
  3855                              <1> 
  3856                              <1> rename_file:
  3857                              <1> 	; 08/03/2016
  3858                              <1> 	; 06/03/2016 (TRDOS 386 =  TRDOS v2.0)
  3859                              <1> 	; 20/11/2010 (TRDOS v1, CMD_INTR.ASM, 'cmp_cmd_rename')
  3860                              <1> 	; 16/11/2010 
  3861                              <1> 
  3862                              <1> get_rename_source_fchar:
  3863                              <1> 	; esi = file name
  3864 00007DEE 803E20              <1> 	cmp	byte [esi], 20h
  3865 00007DF1 7614                <1>         jna	short loc_rename_nofilename_retn
  3866                              <1> 
  3867 00007DF3 8935[4C2B0100]      <1> 	mov	[SourceFilePath], esi
  3868                              <1> 
  3869                              <1> rename_scan_source_file:
  3870 00007DF9 46                  <1> 	inc	esi
  3871 00007DFA 803E20              <1> 	cmp	byte [esi], 20h
  3872 00007DFD 7409                <1> 	je	short rename_scan_destination_file_1
  3873                              <1> 	;jb	short loc_rename_nofilename_retn
  3874 00007DFF 0F82C7EEFFFF        <1> 	jb	loc_cmd_failed
  3875 00007E05 EBF2                <1> 	jmp	short rename_scan_source_file
  3876                              <1> 
  3877                              <1> loc_rename_nofilename_retn: ; 08/03/2016
  3878 00007E07 C3                  <1> 	retn
  3879                              <1> 
  3880                              <1> rename_scan_destination_file_1:
  3881 00007E08 C60600              <1> 	mov	byte [esi], 0
  3882                              <1> 
  3883                              <1> rename_scan_destination_file_2:
  3884 00007E0B 46                  <1> 	inc	esi  
  3885 00007E0C 803E20              <1> 	cmp	byte [esi], 20h
  3886 00007E0F 74FA                <1> 	je	short rename_scan_destination_file_2
  3887                              <1> 	;jb	short loc_rename_nofilename_retn
  3888 00007E11 0F82B5EEFFFF        <1> 	jb	loc_cmd_failed
  3889                              <1> 
  3890 00007E17 8935[502B0100]      <1> 	mov	[DestinationFilePath], esi
  3891                              <1> 
  3892                              <1> rename_scan_destination_file_3:
  3893 00007E1D 46                  <1> 	inc	esi  
  3894 00007E1E 803E20              <1> 	cmp	byte [esi], 20h
  3895 00007E21 77FA                <1> 	ja	short rename_scan_destination_file_3
  3896                              <1> 
  3897 00007E23 C60600              <1> 	mov	byte [esi], 0
  3898                              <1> 
  3899                              <1> loc_rename_save_current_drive:
  3900 00007E26 8A35[6E200100]      <1> 	mov	dh, [Current_Drv]
  3901 00007E2C 8835[CE280100]      <1> 	mov	byte [RUN_CDRV], dh
  3902                              <1> 
  3903                              <1> loc_rename_sf_parse_path_name:
  3904 00007E32 8B35[4C2B0100]      <1> 	mov	esi, [SourceFilePath] 
  3905 00007E38 BF[122A0100]        <1> 	mov	edi, FindFile_Drv
  3906 00007E3D E896150000          <1> 	call	parse_path_name
  3907 00007E42 0F8284EEFFFF        <1> 	jc	loc_cmd_failed
  3908                              <1> 
  3909                              <1> loc_rename_sf_check_filename_exists:
  3910 00007E48 BE[542A0100]        <1> 	mov	esi, FindFile_Name
  3911 00007E4D 803E20              <1> 	cmp	byte [esi], 20h
  3912 00007E50 0F8676EEFFFF        <1> 	jna	loc_cmd_failed
  3913                              <1> 
  3914                              <1> 	;mov	[DelFile_FNPointer], esi 
  3915                              <1> 
  3916                              <1> loc_rename_sf_drv:
  3917                              <1> 	;mov	dh, [Current_Drv]
  3918                              <1> 	;mov	[RUN_CDRV], dh
  3919                              <1> 
  3920 00007E56 8A15[122A0100]      <1> 	mov	dl, [FindFile_Drv]
  3921 00007E5C 38F2                <1> 	cmp	dl, dh ; dh = [Current_Drv]
  3922 00007E5E 740B                <1> 	je	short rename_sf_change_directory
  3923                              <1> 
  3924 00007E60 E8CDDFFFFF          <1> 	call	change_current_drive
  3925 00007E65 0F828BF7FFFF        <1> 	jc	loc_file_rw_cmd_failed
  3926                              <1> 
  3927                              <1> rename_sf_change_directory:
  3928 00007E6B 803D[132A0100]20    <1> 	cmp	byte [FindFile_Directory], 20h
  3929 00007E72 7618                <1> 	jna	short rename_sf_find
  3930                              <1> 
  3931 00007E74 FE05[E4DD0000]      <1> 	inc	byte [Restore_CDIR]
  3932 00007E7A BE[132A0100]        <1> 	mov	esi, FindFile_Directory
  3933 00007E7F 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
  3934 00007E81 E83E0F0000          <1> 	call	change_current_directory
  3935 00007E86 0F826AF7FFFF        <1>  	jc	loc_file_rw_cmd_failed
  3936                              <1> 
  3937                              <1> ;rename_sf_change_prompt_dir_string:
  3938                              <1> 	;call	change_prompt_dir_string
  3939                              <1> 
  3940                              <1> rename_sf_find:
  3941                              <1> 	;mov	esi, [DelFile_FNPointer]
  3942 00007E8C BE[542A0100]        <1> 	mov	esi, FindFile_Name
  3943                              <1> 
  3944 00007E91 66B80008            <1> 	mov	ax, 0800h ; Except volume labels
  3945 00007E95 E834F3FFFF          <1> 	call	find_first_file
  3946 00007E9A 0F8256F7FFFF        <1> 	jc	loc_file_rw_cmd_failed
  3947                              <1> 
  3948                              <1> loc_rename_sf_ambgfn_check:
  3949 00007EA0 6621D2              <1> 	and	dx, dx ; Ambiguous filename chars used sign (DX>0)
  3950                              <1> 	;	(Note: It was BX in TRDOS v1)
  3951                              <1> 	;jz	short loc_rename_sf_found
  3952 00007EA3 0F8563FCFFFF        <1> 	jnz	loc_file_not_found
  3953                              <1> 
  3954                              <1> 	;mov	eax, 2 ; File not found sign
  3955                              <1> 	;stc
  3956                              <1> 	;jmp	loc_file_rw_cmd_failed   
  3957                              <1> 
  3958                              <1> loc_rename_sf_found:
  3959                              <1> 	; EDI = Directory buffer entry offset/address
  3960                              <1> 	; BL = File (or Directory) Attributes 
  3961                              <1> 	;	(Note: It was 'CL' in TRDOS v1)
  3962                              <1> 	; mov	bl, [EDI+0Bh]
  3963                              <1> 
  3964 00007EA9 F6C307              <1> 	test	bl, 07h ; Attributes, S-H-R
  3965 00007EAC 0F854EF7FFFF        <1> 	jnz	loc_permission_denied
  3966                              <1> 	
  3967 00007EB2 BE[122A0100]        <1>         mov     esi, FindFile_Drv
  3968 00007EB7 BF[542B0100]        <1>         mov     edi, SourceFile_Drv
  3969 00007EBC B920000000          <1> 	mov	ecx, 32
  3970 00007EC1 F3A5                <1> 	rep	movsd
  3971                              <1> 
  3972                              <1> loc_rename_df_parse_path_name:
  3973 00007EC3 8B35[502B0100]      <1> 	mov	esi, [DestinationFilePath]
  3974 00007EC9 BF[122A0100]        <1> 	mov	edi, FindFile_Drv
  3975 00007ECE E805150000          <1> 	call	parse_path_name
  3976 00007ED3 7219                <1> 	jc	short loc_rename_df_cmd_failed
  3977                              <1> 
  3978                              <1> 	;mov	dh, [RUN_CDRV]
  3979 00007ED5 8A35[6E200100]      <1> 	mov	dh, [Current_Drv]
  3980                              <1> 
  3981                              <1> 	; 'rename' command is valid only for same dos drive and same dir!
  3982                              <1> 	; ('move' command must be used if source file and destination file
  3983                              <1> 	; directories are not same!) 
  3984 00007EDB 8A15[122A0100]      <1> 	mov	dl, [FindFile_Drv]
  3985 00007EE1 38F2                <1> 	cmp	dl, dh ; are source and destination drives different ?!
  3986 00007EE3 7509                <1> 	jne	short loc_rename_df_cmd_failed ; yes! 
  3987                              <1> 
  3988                              <1> rename_df_check_dirname_exists:
  3989 00007EE5 803D[132A0100]00    <1> 	cmp	byte [FindFile_Directory], 0
  3990 00007EEC 760B                <1> 	jna	short rename_df_check_filename_exists
  3991                              <1> 
  3992                              <1> 	; different source file and destination file directories !
  3993                              <1> loc_rename_df_cmd_failed:
  3994                              <1> loc_rename_df_found:
  3995 00007EEE B801000000          <1> 	mov	eax, 1 ; TRDOS 'Bad command or file name' error
  3996 00007EF3 F9                  <1> 	stc
  3997 00007EF4 E9FDF6FFFF          <1> 	jmp	loc_file_rw_cmd_failed
  3998                              <1> 	  
  3999                              <1> rename_df_check_filename_exists:
  4000 00007EF9 BE[542A0100]        <1> 	mov	esi, FindFile_Name
  4001 00007EFE E883F6FFFF          <1> 	call	check_filename
  4002 00007F03 0F829FF7FFFF        <1> 	jc	loc_mkdir_invalid_dir_name_chars
  4003                              <1> 
  4004                              <1> 	;mov	[DelFile_FNPointer], esi 
  4005                              <1> 	;cmp	byte [esi], 20h
  4006                              <1> 	;ja	short loc_rename_df_find
  4007                              <1> 
  4008                              <1> 	;mov	dh, [Current_Drv] ; dh has not been changed
  4009                              <1> 
  4010                              <1> rename_df_drv_check_writable:
  4011 00007F09 0FB6F6              <1> 	movzx	esi, dh
  4012                              <1> 	;movzx	esi, byte [Current_Drv]
  4013 00007F0C 81C600010900        <1> 	add	esi, Logical_DOSDisks
  4014                              <1> 
  4015 00007F12 88F2                <1> 	mov	dl, dh ; dl = [Current_Drv]
  4016 00007F14 8A7601              <1> 	mov	dh, [esi+LD_DiskType]
  4017                              <1> 
  4018 00007F17 80FE01              <1> 	cmp	dh, 1 ; 0 = Invalid
  4019 00007F1A 7310                <1> 	jnb	short rename_df_compare_sf_df_name
  4020                              <1> 
  4021 00007F1C B813000000          <1> 	mov	eax, 13h ; MSDOS err => Disk write-protected
  4022 00007F21 8B1D[502B0100]      <1> 	mov	ebx, [DestinationFilePath] 
  4023 00007F27 E9CAF6FFFF          <1> 	jmp	loc_file_rw_cmd_failed
  4024                              <1> 
  4025                              <1> rename_df_compare_sf_df_name:
  4026 00007F2C BE[542A0100]        <1> 	mov	esi, FindFile_Name
  4027 00007F31 BF[962B0100]        <1> 	mov	edi, SourceFile_Name
  4028 00007F36 B90C000000          <1> 	mov	ecx, 12
  4029                              <1> rename_df_compare_sf_df_name_next: 
  4030 00007F3B AC                  <1> 	lodsb
  4031 00007F3C AE                  <1> 	scasb
  4032 00007F3D 7506                <1> 	jne	short loc_rename_df_find
  4033 00007F3F 08C0                <1> 	or	al, al
  4034 00007F41 74AB                <1> 	jz	short loc_rename_df_cmd_failed
  4035 00007F43 E2F6                <1> 	loop	rename_df_compare_sf_df_name_next 
  4036                              <1> 
  4037                              <1> loc_rename_df_find:
  4038                              <1> 	;mov	esi, [DelFile_FNPointer]
  4039 00007F45 BE[542A0100]        <1> 	mov	esi, FindFile_Name
  4040                              <1> 
  4041 00007F4A 6631C0              <1> 	xor	ax, ax ; Any
  4042 00007F4D E87CF2FFFF          <1> 	call	find_first_file
  4043 00007F52 739A                <1> 	jnc	short loc_rename_df_found
  4044                              <1> 
  4045                              <1> loc_rename_df_check_error_code:
  4046                              <1> 	;cmp	eax, 2
  4047 00007F54 3C02                <1> 	cmp	al, 2 ; Not found error
  4048 00007F56 7406                <1> 	je	short rename_df_move_find_struct_to_dest
  4049 00007F58 F9                  <1> 	stc
  4050 00007F59 E998F6FFFF          <1> 	jmp loc_file_rw_cmd_failed
  4051                              <1> 
  4052                              <1> ;loc_rename_df_found:
  4053                              <1> ;	mov	eax, 1 ;Bad command or file name error
  4054                              <1> ;	stc
  4055                              <1> ;	jmp	loc_file_rw_cmd_failed
  4056                              <1> 
  4057                              <1> rename_df_move_find_struct_to_dest:
  4058 00007F5E BE[122A0100]        <1>         mov     esi, FindFile_Drv
  4059 00007F63 BF[D42B0100]        <1>         mov     edi, DestinationFile_Drv
  4060 00007F68 B920000000          <1> 	mov	ecx, 32
  4061 00007F6D F3A5                <1> 	rep	movsd
  4062                              <1> 
  4063                              <1> loc_rename_df_process_q_sf:
  4064                              <1> 	;mov	ecx, 12
  4065 00007F6F B10C                <1> 	mov	cl, 12
  4066 00007F71 BE[962B0100]        <1>  	mov	esi, SourceFile_Name
  4067 00007F76 BF[39E30000]        <1> 	mov	edi, Rename_OldName
  4068                              <1> rename_df_process_q_nml_1_sf:
  4069 00007F7B AC                  <1> 	lodsb
  4070 00007F7C 3C20                <1>         cmp	al, 20h
  4071 00007F7E 7603                <1>         jna	short rename_df_process_q_nml_2_sf
  4072 00007F80 AA                  <1> 	stosb
  4073 00007F81 E2F8                <1> 	loop	rename_df_process_q_nml_1_sf
  4074                              <1> 
  4075                              <1> rename_df_process_q_nml_2_sf:
  4076 00007F83 C60700              <1> 	mov	byte [edi], 0
  4077                              <1> 
  4078                              <1> loc_rename_df_process_q_df:
  4079                              <1> 	;mov	ecx, 12
  4080 00007F86 B10C                <1> 	mov	cl, 12
  4081 00007F88 BE[162C0100]        <1> 	mov	esi, DestinationFile_Name
  4082 00007F8D BF[4AE30000]        <1> 	mov	edi, Rename_NewName
  4083                              <1> rename_df_process_q_nml_1_df:
  4084 00007F92 AC                  <1> 	lodsb
  4085 00007F93 3C20                <1> 	cmp	al, 20h
  4086 00007F95 7603                <1> 	jna	short loc_rename_df_process_q_nml_2_df
  4087 00007F97 AA                  <1> 	stosb
  4088 00007F98 E2F8                <1> 	loop	rename_df_process_q_nml_1_df
  4089                              <1> 
  4090                              <1> loc_rename_df_process_q_nml_2_df:
  4091 00007F9A C60700              <1> 	mov	byte [edi], 0
  4092                              <1> 
  4093                              <1> loc_rename_confirmation_question:
  4094 00007F9D BE[11E30000]        <1> 	mov	esi, Msg_DoYouWantRename
  4095 00007FA2 E88BD5FFFF          <1> 	call	print_msg
  4096                              <1> 
  4097 00007FA7 A0[B12B0100]        <1> 	mov	al, [SourceFile_DirEntry+11] ; Attributes
  4098 00007FAC 2410                <1> 	and	al, 10h
  4099 00007FAE 750C                <1> 	jnz	short rename_confirmation_question_dir
  4100                              <1> 
  4101                              <1> rename_confirmation_question_file:
  4102 00007FB0 BE[28E30000]        <1> 	mov	esi, Rename_File
  4103 00007FB5 E878D5FFFF          <1> 	call	print_msg 
  4104 00007FBA EB0A                <1> 	jmp	short rename_confirmation_question_as 
  4105                              <1> 
  4106                              <1> rename_confirmation_question_dir:
  4107 00007FBC BE[2EE30000]        <1> 	mov	esi, Rename_Directory
  4108 00007FC1 E86CD5FFFF          <1> 	call	print_msg
  4109                              <1> 
  4110                              <1> rename_confirmation_question_as:
  4111 00007FC6 BE[39E30000]        <1> 	mov	esi, Rename_OldName
  4112 00007FCB E862D5FFFF          <1> 	call	print_msg
  4113 00007FD0 BE[46E30000]        <1> 	mov	esi, Msg_File_rename_as
  4114 00007FD5 E858D5FFFF          <1> 	call	print_msg
  4115 00007FDA BE[6DE20000]        <1> 	mov	esi, Msg_YesNo
  4116 00007FDF E84ED5FFFF          <1> 	call	print_msg
  4117                              <1> 
  4118                              <1> loc_rename_ask_again:
  4119 00007FE4 30E4                <1> 	xor	ah, ah
  4120 00007FE6 E8E18AFFFF          <1> 	call	int16h
  4121 00007FEB 3C1B                <1> 	cmp	al, 1Bh
  4122 00007FED 740F                <1> 	je	short loc_do_not_rename_file
  4123 00007FEF 24DF                <1> 	and	al, 0DFh
  4124 00007FF1 A2[77E20000]        <1> 	mov	[Y_N_nextline], al
  4125 00007FF6 3C59                <1> 	cmp	al, 'Y'
  4126 00007FF8 7404                <1> 	je	short loc_yes_rename_file
  4127 00007FFA 3C4E                <1> 	cmp	al, 'N'
  4128 00007FFC 75E6                <1> 	jne	short loc_rename_ask_again
  4129                              <1> 
  4130                              <1> loc_do_not_rename_file:
  4131                              <1> loc_yes_rename_file:
  4132 00007FFE A2[77E20000]        <1> 	mov	[Y_N_nextline], al
  4133 00008003 6650                <1> 	push	ax
  4134 00008005 BE[77E20000]        <1> 	mov	esi, Y_N_nextline
  4135 0000800A E823D5FFFF          <1> 	call	print_msg
  4136 0000800F 6658                <1> 	pop	ax
  4137                              <1> 	;cmp	al, 'Y' ; 'yes'
  4138                              <1> 	;cmc
  4139                              <1>         ;jnc	loc_file_rw_restore_retn
  4140 00008011 3C4E                <1> 	cmp	al, 'N' ; 'no'
  4141 00008013 0F84DDF5FFFF        <1>         je	loc_file_rw_restore_retn  
  4142                              <1> 
  4143 00008019 BE[4AE30000]        <1> 	mov	esi, Rename_NewName
  4144 0000801E 668B0D[CE2B0100]    <1> 	mov	cx, [SourceFile_DirEntryNumber] 
  4145 00008025 66A1[BA2B0100]      <1> 	mov	ax, [SourceFile_DirEntry+20] ; First Cluster, HW 
  4146 0000802B 66C1E010            <1> 	shl	ax, 16
  4147 0000802F 66A1[C02B0100]      <1> 	mov	ax, [SourceFile_DirEntry+26] ; First Cluster, LW 
  4148                              <1> 
  4149 00008035 0FB61D[A32B0100]    <1>   	movzx	ebx, byte [SourceFile_LongNameEntryLength]  
  4150 0000803C E8E11B0000          <1>    	call	rename_directory_entry
  4151 00008041 E9DEF6FFFF          <1> 	jmp	loc_rename_file_ok	
  4152                              <1> ;loc_rename_file_ok:
  4153                              <1> ;	jc	loc_run_cmd_failed
  4154                              <1> ;	mov	esi, Msg_OK
  4155                              <1> ;	call	proc_printmsg
  4156                              <1> ;	jmp	loc_file_rw_restore_retn
  4157                              <1> 
  4158                              <1> move_file:
  4159                              <1> 	; 11/03/2016
  4160                              <1> 	; 09/03/2016
  4161                              <1> 	; 08/03/2016 (TRDOS 386 =  TRDOS v2.0)
  4162                              <1> 	; 21/05/2011 (TRDOS v1, CMD_INTR.ASM, 'cmp_cmd_move')
  4163                              <1> 	; 23/04/2011
  4164                              <1> 
  4165                              <1> get_move_source_fchar:
  4166                              <1> 	; esi = file name
  4167 00008046 803E20              <1> 	cmp	byte [esi], 20h
  4168 00008049 7614                <1>         jna	short loc_move_nofilename_retn
  4169                              <1> 
  4170 0000804B 8935[4C2B0100]      <1> 	mov	[SourceFilePath], esi
  4171                              <1> 
  4172                              <1> move_scan_source_file:
  4173 00008051 46                  <1> 	inc	esi
  4174 00008052 803E20              <1> 	cmp	byte [esi], 20h
  4175 00008055 7409                <1>         je      short move_scan_destination_1
  4176                              <1> 	;jb	short loc_move_nofilename_retn
  4177 00008057 0F826FECFFFF        <1> 	jb	loc_cmd_failed
  4178 0000805D EBF2                <1> 	jmp	short move_scan_source_file
  4179                              <1> 
  4180                              <1> loc_move_nofilename_retn:
  4181 0000805F C3                  <1> 	retn
  4182                              <1> 
  4183                              <1> move_scan_destination_1:
  4184 00008060 C60600              <1> 	mov	byte [esi], 0
  4185                              <1> 
  4186                              <1> move_scan_destination_2:
  4187 00008063 46                  <1> 	inc	esi  
  4188 00008064 803E20              <1> 	cmp	byte [esi], 20h
  4189 00008067 74FA                <1> 	je	short move_scan_destination_2
  4190                              <1> 	;jb	short loc_move_nofilename_retn
  4191 00008069 0F825DECFFFF        <1> 	jb	loc_cmd_failed
  4192                              <1> 
  4193 0000806F 8935[502B0100]      <1> 	mov	[DestinationFilePath], esi
  4194                              <1> 
  4195                              <1> move_scan_destination_3:
  4196 00008075 46                  <1> 	inc	esi  
  4197 00008076 803E20              <1> 	cmp	byte [esi], 20h
  4198 00008079 77FA                <1> 	ja	short move_scan_destination_3
  4199 0000807B C60600              <1> 	mov	byte [esi], 0
  4200                              <1> 
  4201                              <1> loc_move_scan_destination_OK:
  4202 0000807E 8B35[4C2B0100]      <1> 	mov	esi, [SourceFilePath]
  4203 00008084 8B3D[502B0100]      <1> 	mov	edi, [DestinationFilePath]
  4204                              <1> 
  4205 0000808A B001                <1> 	mov	al, 1  ; move procedure Phase 1
  4206 0000808C E80E1C0000          <1> 	call	move_source_file_to_destination_file
  4207 00008091 7328                <1> 	jnc	short move_source_file_to_destination_question
  4208                              <1> 
  4209                              <1> loc_move_cmd_failed_1:
  4210 00008093 08C0                <1> 	or	al, al
  4211 00008095 0F8431ECFFFF        <1> 	jz	loc_cmd_failed 
  4212 0000809B 3C11                <1> 	cmp	al, 11h
  4213 0000809D 740D                <1> 	je	short loc_msg_not_same_device   
  4214 0000809F 3C05                <1> 	cmp	al, 05h
  4215 000080A1 0F8550ECFFFF        <1> 	jne	loc_run_cmd_failed
  4216                              <1> 
  4217 000080A7 E954F5FFFF          <1> 	jmp	loc_permission_denied
  4218                              <1> 
  4219                              <1> 	;mov	esi, Msg_Permission_denied
  4220                              <1> 	;call	print_msg
  4221                              <1> 	;jmp	loc_file_rw_restore_retn
  4222                              <1> 
  4223                              <1> loc_msg_not_same_device:
  4224 000080AC BE[57E30000]        <1> 	mov	esi, msg_not_same_drv 
  4225 000080B1 E87CD4FFFF          <1> 	call	print_msg
  4226 000080B6 E93BF5FFFF          <1> 	jmp	loc_file_rw_restore_retn
  4227                              <1> 
  4228                              <1> move_source_file_to_destination_question:
  4229 000080BB A0[542B0100]        <1>         mov     al, [SourceFile_Drv]
  4230 000080C0 0441                <1> 	add	al, 'A'
  4231 000080C2 A2[B9E30000]        <1> 	mov	[msg_source_file_drv], al
  4232 000080C7 A0[D42B0100]        <1>         mov     al, [DestinationFile_Drv]
  4233 000080CC 0441                <1> 	add	al, 'A'
  4234 000080CE A2[D8E30000]        <1> 	mov	[msg_destination_file_drv], al
  4235                              <1> 
  4236 000080D3 57                  <1> 	push	edi ; *
  4237                              <1> 
  4238 000080D4 BE[9DE30000]        <1> 	mov	esi, msg_source_file
  4239 000080D9 E854D4FFFF          <1> 	call	print_msg
  4240 000080DE BE[552B0100]        <1> 	mov	esi, SourceFile_Directory
  4241 000080E3 803E20              <1> 	cmp	byte [esi], 20h
  4242 000080E6 7605                <1> 	jna	short msftdfq_sfn
  4243 000080E8 E845D4FFFF          <1> 	call	print_msg
  4244                              <1> msftdfq_sfn:
  4245 000080ED BE[962B0100]        <1> 	mov	esi, SourceFile_Name
  4246 000080F2 E83BD4FFFF          <1> 	call	print_msg
  4247 000080F7 BE[BCE30000]        <1> 	mov	esi, msg_destination_file
  4248 000080FC E831D4FFFF          <1> 	call	print_msg
  4249 00008101 BE[D52B0100]        <1> 	mov	esi, DestinationFile_Directory
  4250 00008106 803E20              <1> 	cmp	byte [esi], 20h
  4251 00008109 7605                <1> 	jna	short msftdfq_dfn
  4252 0000810B E822D4FFFF          <1> 	call	print_msg
  4253                              <1> msftdfq_dfn:
  4254 00008110 BE[162C0100]        <1> 	mov	esi, DestinationFile_Name
  4255 00008115 E818D4FFFF          <1> 	call	print_msg
  4256 0000811A BE[DBE30000]        <1> 	mov	esi, msg_copy_nextline
  4257 0000811F E80ED4FFFF          <1> 	call	print_msg
  4258 00008124 BE[DBE30000]        <1> 	mov	esi, msg_copy_nextline
  4259 00008129 E804D4FFFF          <1> 	call	print_msg
  4260                              <1> 
  4261                              <1> loc_move_ask_for_new_file_yes_no:
  4262 0000812E BE[69E30000]        <1> 	mov	esi, Msg_DoYouWantMoveFile
  4263 00008133 E8FAD3FFFF          <1> 	call	print_msg
  4264 00008138 BE[6DE20000]        <1> 	mov	esi, Msg_YesNo
  4265 0000813D E8F0D3FFFF          <1> 	call	print_msg
  4266                              <1> loc_move_ask_for_new_file_again:
  4267 00008142 30E4                <1> 	xor	ah, ah
  4268 00008144 E88389FFFF          <1> 	call	int16h
  4269 00008149 3C1B                <1> 	cmp	al, 1Bh
  4270                              <1> 	;je	short loc_do_not_move_file
  4271 0000814B 744F                <1> 	je	short loc_move_y_n_escape
  4272 0000814D 24DF                <1> 	and	al, 0DFh
  4273 0000814F A2[77E20000]        <1>         mov     [Y_N_nextline], al
  4274 00008154 3C59                <1> 	cmp	al, 'Y'
  4275 00008156 7404                <1> 	je	short loc_yes_move_file
  4276 00008158 3C4E                <1> 	cmp	al, 'N'
  4277 0000815A 75E6                <1> 	jne	short loc_move_ask_for_new_file_again
  4278                              <1> 
  4279                              <1> loc_do_not_move_file:
  4280                              <1> loc_yes_move_file:
  4281 0000815C A2[77E20000]        <1> 	mov	[Y_N_nextline], al
  4282 00008161 6650                <1> 	push	ax
  4283 00008163 BE[77E20000]        <1> 	mov	esi, Y_N_nextline
  4284 00008168 E8C5D3FFFF          <1> 	call	print_msg
  4285 0000816D 6658                <1> 	pop	ax
  4286 0000816F 5F                  <1> 	pop	edi ; *
  4287                              <1> 	;cmp	al, 'Y' ; 'yes'
  4288                              <1> 	;cmc
  4289                              <1>         ;jnc	loc_file_rw_restore_retn
  4290 00008170 3C4E                <1> 	cmp	al, 'N' ; 'no'
  4291 00008172 0F847EF4FFFF        <1>         je	loc_file_rw_restore_retn
  4292                              <1> 
  4293                              <1> loc_move_yes_move_file:
  4294 00008178 B002                <1> 	mov	al, 2 ; move procedure Phase 2
  4295 0000817A E8201B0000          <1> 	call	move_source_file_to_destination_file
  4296                              <1> 	;jc	short loc_move_cmd_failed_2
  4297 0000817F 0F83A5F5FFFF        <1>         jnc     move_source_file_to_destination_OK
  4298                              <1> 
  4299                              <1> ;move_source_file_to_destination_OK:
  4300                              <1> ;	mov	esi, Msg_OK
  4301                              <1> ;	call	print_msg
  4302                              <1> ;	jmp	loc_file_rw_restore_retn
  4303                              <1> 
  4304                              <1> loc_move_cmd_failed_2:
  4305 00008185 3C27                <1> 	cmp	al, 27h
  4306 00008187 0F856AEBFFFF        <1> 	jne	loc_run_cmd_failed
  4307                              <1> 
  4308 0000818D BE[82E30000]        <1> 	mov	esi, msg_insufficient_disk_space
  4309 00008192 E89BD3FFFF          <1> 	call	print_msg
  4310                              <1> 
  4311 00008197 E95AF4FFFF          <1> 	jmp	loc_file_rw_restore_retn
  4312                              <1> 
  4313                              <1> loc_move_y_n_escape:
  4314 0000819C B04E                <1> 	mov	al, 'N' ; 'no'
  4315 0000819E EBBC                <1> 	jmp	short loc_do_not_move_file
  4316                              <1> 
  4317                              <1> copy_file:
  4318                              <1> 	; 24/03/2016
  4319                              <1> 	; 21/03/2016
  4320                              <1> 	; 15/03/2016 (TRDOS 386 =  TRDOS v2.0)
  4321                              <1> 	; 21/05/2011 (TRDOS v1, CMD_INTR.ASM, 'cmp_cmd_copy')
  4322                              <1> 	; 01/08/2010
  4323                              <1> 
  4324                              <1> get_copy_source_fchar:
  4325                              <1> 	; esi = file name
  4326 000081A0 803E20              <1> 	cmp	byte [esi], 20h
  4327 000081A3 7614                <1>         jna     short loc_copy_nofilename_retn
  4328                              <1> 
  4329 000081A5 8935[4C2B0100]      <1> 	mov	[SourceFilePath], esi
  4330                              <1> 
  4331                              <1> copy_scan_source_file:
  4332 000081AB 46                  <1> 	inc	esi  
  4333 000081AC 803E20              <1> 	cmp	byte [esi], 20h
  4334 000081AF 7409                <1> 	je	short copy_scan_destination_1
  4335                              <1> 	;jb	short loc_copy_nofilename_retn
  4336 000081B1 0F8215EBFFFF        <1> 	jb	loc_cmd_failed
  4337 000081B7 EBF2                <1> 	jmp	short copy_scan_source_file
  4338                              <1> 
  4339                              <1> loc_copy_nofilename_retn:
  4340 000081B9 C3                  <1> 	retn
  4341                              <1> 
  4342                              <1> copy_scan_destination_1:
  4343 000081BA C60600              <1> 	mov	byte [esi], 0
  4344                              <1> 
  4345                              <1> copy_scan_destination_2:
  4346 000081BD 46                  <1> 	inc	esi  
  4347 000081BE 803E20              <1> 	cmp	byte [esi], 20h
  4348 000081C1 74FA                <1> 	je	short copy_scan_destination_2
  4349                              <1> 	;jb	short loc_copy_nofilename_retn
  4350 000081C3 0F8203EBFFFF        <1> 	jb	loc_cmd_failed
  4351                              <1> 
  4352 000081C9 8935[502B0100]      <1> 	mov	[DestinationFilePath], esi
  4353                              <1> 
  4354                              <1> copy_scan_destination_3:
  4355 000081CF 46                  <1> 	inc	esi  
  4356 000081D0 803E20              <1> 	cmp	byte [esi], 20h
  4357 000081D3 77FA                <1> 	ja	short copy_scan_destination_3
  4358 000081D5 C60600              <1> 	mov	byte [esi], 0
  4359                              <1> 
  4360                              <1> loc_copy_save_current_drive:
  4361 000081D8 8A35[6E200100]      <1> 	mov	dh, [Current_Drv]
  4362 000081DE 8835[CE280100]      <1> 	mov	[RUN_CDRV], dh
  4363                              <1> 
  4364                              <1> copy_source_file_to_destination_phase_1:
  4365 000081E4 8B35[4C2B0100]      <1> 	mov	esi, [SourceFilePath]
  4366 000081EA 8B3D[502B0100]      <1> 	mov	edi, [DestinationFilePath]
  4367                              <1> 
  4368 000081F0 B001                <1> 	mov	al, 1  ; copy procedure Phase 1
  4369 000081F2 E8331D0000          <1> 	call	copy_source_file_to_destination_file
  4370 000081F7 732B                <1> 	jnc	short copy_source_file_to_destination_question
  4371                              <1> 
  4372                              <1> loc_copy_cmd_failed_1:
  4373                              <1> 	; 18/03/2016 (restore current drive and directory)
  4374 000081F9 08C0                <1> 	or	al, al
  4375 000081FB 7507                <1> 	jnz	short loc_copy_cmd_failed_2
  4376                              <1> 
  4377 000081FD FEC0                <1>         inc     al ; mov al, 1 ; Bad command or file name !
  4378 000081FF E9F3EAFFFF          <1> 	jmp	loc_run_cmd_failed
  4379                              <1> 
  4380                              <1> loc_copy_cmd_failed_2:
  4381 00008204 3C27                <1> 	cmp	al, 27h ; Insufficient disk space 
  4382 00008206 740D                <1> 	je	short loc_file_write_insuff_disk_space_msg
  4383                              <1>  
  4384 00008208 3C05                <1> 	cmp	al, 05h
  4385 0000820A 0F85E7EAFFFF        <1> 	jne	loc_run_cmd_failed
  4386                              <1> 	
  4387 00008210 E9EBF3FFFF          <1> 	jmp	loc_permission_denied
  4388                              <1> 
  4389                              <1> loc_file_write_insuff_disk_space_msg:
  4390 00008215 BE[82E30000]        <1> 	mov	esi, msg_insufficient_disk_space
  4391 0000821A E813D3FFFF          <1> 	call	print_msg
  4392 0000821F E9D2F3FFFF          <1>         jmp     loc_file_rw_restore_retn 
  4393                              <1> 
  4394                              <1> copy_source_file_to_destination_question:
  4395 00008224 57                  <1> 	push	edi ; *
  4396                              <1> 
  4397                              <1> 	; dh = source file attributes
  4398                              <1> 	; dl > 0 -> destination file found
  4399 00008225 20D2                <1> 	and	dl, dl            
  4400 00008227 7449                <1> 	jz	short copy_source_file_to_destination_pass_owrq
  4401                              <1> 
  4402                              <1> loc_copy_ask_for_owr_yes_no:
  4403 00008229 BE[DEE30000]        <1> 	mov	esi, Msg_DoYouWantOverWriteFile
  4404 0000822E E8FFD2FFFF          <1> 	call	print_msg
  4405 00008233 BE[162C0100]        <1> 	mov	esi, DestinationFile_Name
  4406 00008238 E8F5D2FFFF          <1> 	call	print_msg
  4407 0000823D BE[6DE20000]        <1> 	mov	esi, Msg_YesNo
  4408 00008242 E8EBD2FFFF          <1> 	call	print_msg
  4409                              <1> 
  4410                              <1> loc_copy_ask_for_owr_again:
  4411 00008247 30E4                <1> 	xor	ah, ah
  4412 00008249 E87E88FFFF          <1> 	call	int16h
  4413 0000824E 3C1B                <1> 	cmp	al, 1Bh
  4414                              <1>         ;je     loc_do_not_copy_file
  4415 00008250 7419                <1>         je      short loc_copy_y_n_escape
  4416 00008252 24DF                <1> 	and	al, 0DFh
  4417 00008254 A2[77E20000]        <1>         mov     [Y_N_nextline], al
  4418 00008259 3C59                <1> 	cmp	al, 'Y'
  4419 0000825B 0F84B1000000        <1>         je      loc_yes_copy_file
  4420 00008261 3C4E                <1> 	cmp	al, 'N'
  4421 00008263 0F84A9000000        <1>         je      loc_do_not_copy_file
  4422 00008269 EBDC                <1> 	jmp	short loc_copy_ask_for_owr_again
  4423                              <1> 
  4424                              <1> loc_copy_y_n_escape:
  4425 0000826B B04E                <1> 	mov	al, 'N' ; 'no'
  4426 0000826D E9A0000000          <1>         jmp     loc_do_not_copy_file
  4427                              <1> 
  4428                              <1> copy_source_file_to_destination_pass_owrq:
  4429 00008272 A0[542B0100]        <1> 	mov     al, [SourceFile_Drv]
  4430 00008277 0441                <1> 	add	al, 'A'
  4431 00008279 A2[B9E30000]        <1> 	mov	[msg_source_file_drv], al
  4432 0000827E A0[D42B0100]        <1>         mov     al, [DestinationFile_Drv]
  4433 00008283 0441                <1> 	add	al, 'A'
  4434 00008285 A2[D8E30000]        <1> 	mov	[msg_destination_file_drv], al
  4435                              <1> 
  4436 0000828A BE[9DE30000]        <1> 	mov	esi, msg_source_file
  4437 0000828F E89ED2FFFF          <1> 	call	print_msg
  4438 00008294 BE[552B0100]        <1> 	mov	esi, SourceFile_Directory
  4439 00008299 803E20              <1> 	cmp	byte [esi], 20h
  4440 0000829C 7605                <1> 	jna	short csftdfq_sfn
  4441 0000829E E88FD2FFFF          <1> 	call	print_msg
  4442                              <1> csftdfq_sfn:
  4443 000082A3 BE[962B0100]        <1> 	mov	esi, SourceFile_Name
  4444 000082A8 E885D2FFFF          <1> 	call	print_msg
  4445 000082AD BE[BCE30000]        <1> 	mov	esi, msg_destination_file
  4446 000082B2 E87BD2FFFF          <1> 	call	print_msg
  4447 000082B7 BE[D52B0100]        <1> 	mov	esi, DestinationFile_Directory
  4448 000082BC 803E20              <1> 	cmp	byte [esi], 20h
  4449 000082BF 7605                <1> 	jna	short csftdfq_dfn
  4450 000082C1 E86CD2FFFF          <1> 	call	print_msg
  4451                              <1> csftdfq_dfn:
  4452 000082C6 BE[162C0100]        <1> 	mov	esi, DestinationFile_Name
  4453 000082CB E862D2FFFF          <1> 	call	print_msg
  4454 000082D0 BE[DBE30000]        <1> 	mov	esi, msg_copy_nextline
  4455 000082D5 E858D2FFFF          <1> 	call	print_msg
  4456 000082DA BE[DBE30000]        <1> 	mov	esi, msg_copy_nextline
  4457 000082DF E84ED2FFFF          <1> 	call	print_msg
  4458                              <1> 
  4459                              <1> loc_copy_ask_for_new_file_yes_no:
  4460 000082E4 BE[FDE30000]        <1> 	mov	esi, Msg_DoYouWantCopyFile
  4461 000082E9 E844D2FFFF          <1> 	call	print_msg
  4462 000082EE BE[6DE20000]        <1> 	mov	esi, Msg_YesNo
  4463 000082F3 E83AD2FFFF          <1> 	call	print_msg
  4464                              <1> 
  4465                              <1> loc_copy_ask_for_new_file_again:
  4466 000082F8 30E4                <1> 	xor	ah, ah
  4467 000082FA E8CD87FFFF          <1> 	call	int16h
  4468 000082FF 3C1B                <1> 	cmp	al, 1Bh
  4469 00008301 740F                <1> 	je	short loc_do_not_copy_file
  4470 00008303 24DF                <1> 	and	al, 0DFh
  4471 00008305 A2[77E20000]        <1>         mov     [Y_N_nextline], al
  4472 0000830A 3C59                <1> 	cmp	al, 'Y'
  4473 0000830C 7404                <1> 	je	short loc_yes_copy_file
  4474 0000830E 3C4E                <1> 	cmp	al, 'N'
  4475 00008310 75E6                <1> 	jne	short loc_copy_ask_for_new_file_again
  4476                              <1> 
  4477                              <1> loc_do_not_copy_file:
  4478                              <1> loc_yes_copy_file:
  4479 00008312 A2[77E20000]        <1> 	mov	[Y_N_nextline], al
  4480 00008317 6650                <1> 	push	ax
  4481 00008319 BE[77E20000]        <1> 	mov	esi, Y_N_nextline
  4482 0000831E E80FD2FFFF          <1> 	call	print_msg
  4483 00008323 6658                <1> 	pop	ax
  4484 00008325 5F                  <1> 	pop	edi ; *
  4485                              <1> 	;cmp	al, 'Y' ; 'yes'
  4486                              <1> 	;cmc
  4487                              <1>         ;jnc	loc_file_rw_restore_retn
  4488 00008326 3C4E                <1> 	cmp	al, 'N' ; 'no'
  4489 00008328 0F84C8F2FFFF        <1>         je	loc_file_rw_restore_retn
  4490                              <1> 
  4491                              <1> copy_source_file_to_destination_pass_q:
  4492 0000832E B002                <1> 	mov	al, 2  ; copy procedure Phase 2
  4493 00008330 E8F51B0000          <1> 	call	copy_source_file_to_destination_file
  4494                              <1> 	;jc	short loc_file_write_check_disk_space_err
  4495                              <1> 
  4496                              <1> 	; 24/03/2016
  4497 00008335 6651                <1> 	push	cx
  4498 00008337 BE[DBE30000]        <1> 	mov	esi, msg_copy_nextline
  4499 0000833C E8F1D1FFFF          <1> 	call	print_msg
  4500                              <1> 	;pop	cx
  4501 00008341 6658                <1> 	pop	ax
  4502                              <1> 
  4503                              <1> 	;or	cl, cl
  4504 00008343 08C0                <1> 	or	al, al
  4505 00008345 7419                <1> 	jz	short copy_source_file_to_destination_OK
  4506                              <1> 	
  4507                              <1> 	; 18/03/2016
  4508                              <1> 	;cmp	cl, 1Dh ; write error
  4509 00008347 3C1D                <1> 	cmp	al, 1Dh
  4510 00008349 7506                <1> 	jne	short copy_source_file_to_destination_not_OK
  4511                              <1> 	;
  4512                              <1> 	;mov	al, cl ; error number (write fault!)
  4513 0000834B F9                  <1> 	stc
  4514 0000834C E9A5F2FFFF          <1> 	jmp	loc_file_rw_cmd_failed
  4515                              <1> 
  4516                              <1> copy_source_file_to_destination_not_OK:
  4517 00008351 BE[16E40000]        <1> 	mov	esi, Msg_read_file_error_before_EOF
  4518 00008356 E8D7D1FFFF          <1> 	call	print_msg
  4519 0000835B E996F2FFFF          <1> 	jmp	loc_file_rw_restore_retn	      
  4520                              <1>  
  4521                              <1> copy_source_file_to_destination_OK:
  4522 00008360 BE[7BE20000]        <1> 	mov	esi, Msg_OK
  4523 00008365 E8C8D1FFFF          <1> 	call	print_msg
  4524                              <1> 
  4525 0000836A E987F2FFFF          <1> 	jmp	loc_file_rw_restore_retn
  4526                              <1> 
  4527                              <1> ;loc_file_write_check_disk_space_err:
  4528                              <1> 	;cmp	al, 27h ; Insufficient disk space 
  4529                              <1> 	;je	loc_file_write_insuff_disk_space_msg
  4530                              <1>         ;jb	loc_file_rw_cmd_failed
  4531                              <1> 
  4532                              <1> 	;call	print_misc_error_msg ; 15/03/2016
  4533                              <1>         ;jmp	loc_file_rw_restore_retn 
  4534                              <1> 
  4535                              <1> change_fs_file_attributes:
  4536                              <1> 	; 04/03/2016 ; Temporary
  4537                              <1> 	; AL = File or directory attributes
  4538                              <1> 	; AH = 0 -> Attributes are in MS-DOS format
  4539                              <1> 	; AH > 0 -> Attributes are in SINGLIX format
  4540                              <1> 	;push	ebx
  4541                              <1> 	; ... do somethings here ...
  4542                              <1> 	;pop	ebx
  4543                              <1> 	; BL = File or directory attributes
  4544 0000836F C3                  <1> 	retn
  4545                              <1> 
  4546                              <1> set_get_env:
  4547                              <1> 	; 11/04/2016 (TRDOS 386 =  TRDOS v2.0)
  4548                              <1> 	; 02/09/2011 (TRDOS v1, CMD_INTR.ASM, 'cmp_cmd_set')
  4549                              <1> 	; 2005 - 28/08/2011 
  4550                              <1> get_setenv_fchar:
  4551                              <1> 	; esi = environment variable/string
  4552 00008370 8A06                <1> 	mov	al, [esi]
  4553 00008372 3C20                <1> 	cmp	al, 20h
  4554 00008374 771E                <1> 	ja	short loc_find_env
  4555                              <1> 
  4556 00008376 BE00300900          <1> 	mov	esi, Env_Page
  4557                              <1> loc_print_setline:
  4558 0000837B 803E00              <1> 	cmp	byte [esi], 0
  4559 0000837E 7613                <1> 	jna	short loc_setenv_retn
  4560 00008380 E8ADD1FFFF          <1> 	call	print_msg
  4561 00008385 56                  <1> 	push	esi
  4562 00008386 BE[8BEE0000]        <1> 	mov	esi, nextline
  4563 0000838B E8A2D1FFFF          <1> 	call	print_msg 
  4564 00008390 5E                  <1> 	pop	esi
  4565 00008391 EBE8                <1> 	jmp	short loc_print_setline   
  4566                              <1> 
  4567                              <1> loc_setenv_retn: 
  4568 00008393 C3                  <1> 	retn
  4569                              <1> 
  4570                              <1> loc_find_env:
  4571 00008394 3C3D                <1> 	cmp	al, '='
  4572 00008396 0F8430E9FFFF        <1> 	je	loc_cmd_failed
  4573                              <1> 
  4574 0000839C 56                  <1> 	push	esi
  4575                              <1> loc_repeat_env_equal_check:
  4576 0000839D 46                  <1> 	inc	esi
  4577 0000839E 803E3D              <1> 	cmp	byte [esi], '='
  4578 000083A1 7431                <1> 	je	short pass_env_equal_check
  4579 000083A3 803E20              <1> 	cmp	byte [esi], 20h
  4580 000083A6 73F5                <1> 	jnb	short loc_repeat_env_equal_check
  4581 000083A8 C60600              <1> 	mov	byte [esi], 0 
  4582 000083AB 5E                  <1> 	pop	esi
  4583 000083AC BF[6E210100]        <1> 	mov	edi, TextBuffer ; out buffer
  4584 000083B1 B9FF000000          <1> 	mov	ecx, 255 ; maximum size (limit)
  4585 000083B6 30C0                <1> 	xor	al, al ; 0 -> use [ESI]
  4586 000083B8 E89E000000          <1> 	call	get_environment_string
  4587 000083BD 72D4                <1> 	jc	short loc_setenv_retn
  4588                              <1> 
  4589 000083BF BE[6E210100]        <1> 	mov	esi, TextBuffer
  4590 000083C4 E869D1FFFF          <1> 	call	print_msg
  4591 000083C9 BE[8BEE0000]        <1> 	mov	esi, nextline
  4592 000083CE E85FD1FFFF          <1> 	call	print_msg
  4593                              <1> 
  4594 000083D3 C3                  <1> 	retn 
  4595                              <1>               
  4596                              <1> pass_env_equal_check:
  4597 000083D4 46                  <1> 	inc	esi
  4598 000083D5 803E20              <1> 	cmp	byte [esi], 20h
  4599 000083D8 73FA                <1> 	jnb	short pass_env_equal_check
  4600 000083DA C60600              <1> 	mov	byte [esi], 0	
  4601                              <1> 
  4602                              <1> loc_call_set_env_string:
  4603 000083DD 5E                  <1> 	pop	esi
  4604 000083DE E83B010000          <1> 	call	set_environment_string
  4605 000083E3 73AE                <1> 	jnc	short loc_setenv_retn
  4606                              <1> 
  4607                              <1> loc_set_cmd_failed:
  4608 000083E5 3C08                <1> 	cmp	al, 08h
  4609 000083E7 0F85DFE8FFFF        <1> 	jne	loc_cmd_failed
  4610                              <1> 
  4611 000083ED BE[56E40000]        <1> 	mov	esi, Msg_No_Set_Space
  4612 000083F2 E83BD1FFFF          <1> 	call	print_msg
  4613                              <1> 
  4614 000083F7 C3                  <1> 	retn
  4615                              <1> 
  4616                              <1> set_get_path:
  4617                              <1> 	; 11/04/2016 (TRDOS 386 =  TRDOS v2.0)
  4618                              <1> 	; 03/09/2011 (TRDOS v1, CMD_INTR.ASM, 'cmp_cmd_path')
  4619                              <1> 	; 2005
  4620                              <1> get_path_fchar:
  4621                              <1>  	; esi = path
  4622 000083F8 803E20              <1> 	cmp	byte [esi], 20h
  4623 000083FB 7737                <1> 	ja	short loc_set_path
  4624                              <1> 
  4625 000083FD BE00300900          <1> 	mov	esi, Env_Page
  4626                              <1> loc_print_path:
  4627 00008402 803E00              <1> 	cmp	byte [esi], 0
  4628 00008405 762C                <1> 	jna	short loc_path_retn
  4629                              <1> 
  4630 00008407 BE[B0DE0000]        <1> 	mov	esi, Cmd_Path ; 'PATH' address
  4631 0000840C BF[6E210100]        <1> 	mov	edi, TextBuffer ; oout buffer
  4632 00008411 30C0                <1> 	xor	al, al  ; use [ESI]
  4633 00008413 B9FF000000          <1> 	mov	ecx, 255 ; maximum size (limit)
  4634 00008418 E83E000000          <1> 	call	get_environment_string
  4635 0000841D 7214                <1> 	jc	short loc_path_retn
  4636                              <1> 
  4637 0000841F BE[6E210100]        <1> 	mov	esi, TextBuffer
  4638 00008424 E809D1FFFF          <1> 	call	print_msg
  4639 00008429 BE[8BEE0000]        <1> 	mov	esi, nextline
  4640 0000842E E8FFD0FFFF          <1> 	call	print_msg   
  4641                              <1> 
  4642                              <1> loc_path_retn: 
  4643 00008433 C3                  <1> 	retn
  4644                              <1> 
  4645                              <1> loc_set_path:
  4646 00008434 56                  <1> 	push	esi 
  4647                              <1> loc_set_path_find_end:
  4648 00008435 46                  <1> 	inc	esi
  4649 00008436 803E20              <1> 	cmp	byte [esi], 20h
  4650 00008439 73FA                <1> 	jnb	short loc_set_path_find_end
  4651 0000843B C60600              <1> 	mov	byte [esi], 0 
  4652                              <1> loc_set_path_header: 
  4653 0000843E 5E                  <1> 	pop	esi	  
  4654 0000843F 4E                  <1> 	dec	esi
  4655 00008440 C6063D              <1> 	mov	byte [esi], '='
  4656 00008443 4E                  <1> 	dec	esi
  4657 00008444 C60648              <1> 	mov	byte [esi], 'H'
  4658 00008447 4E                  <1> 	dec	esi
  4659 00008448 C60654              <1> 	mov	byte [esi], 'T'
  4660 0000844B 4E                  <1> 	dec	esi
  4661 0000844C C60641              <1> 	mov	byte [esi], 'A'
  4662 0000844F 4E                  <1> 	dec	esi
  4663 00008450 C60650              <1> 	mov	byte [esi], 'P'   
  4664                              <1> 
  4665                              <1> loc_path_call_set_env_string:
  4666 00008453 E8C6000000          <1> 	call	set_environment_string
  4667 00008458 728B                <1>         jc	short loc_set_cmd_failed
  4668                              <1> 
  4669 0000845A C3                  <1> 	retn              
  4670                              <1> 
  4671                              <1> get_environment_string:
  4672                              <1> 	; 12/04/2016
  4673                              <1> 	; 11/04/2016
  4674                              <1> 	; 05/04/2016 (TRDOS 386 =  TRDOS v2.0)
  4675                              <1> 	; 02/09/2011 (TRDOS v1, MAINPROG.ASM)
  4676                              <1> 	; 28/08/2011
  4677                              <1> 	; INPUT->
  4678                              <1> 	;	EDI = Output buffer
  4679                              <1> 	;	CX = Buffer length (<= ENV_PAGE_SIZE)
  4680                              <1> 	;
  4681                              <1> 	;	AL > 0 = AL = String sequence number
  4682                              <1> 	;	AL = 0 -> ESI = ASCIIZ Set word 
  4683                              <1> 	;		(environment variable)
  4684                              <1> 	; OUTPUT ->
  4685                              <1> 	;	ESI is not changed
  4686                              <1> 	;	EDI is not changed
  4687                              <1> 	;	EAX = String length (with zero tail)
  4688                              <1> 	;	EDX = Environment variables page address
  4689                              <1> 	;	CF = 1 -> Not found (EAX not valid)
  4690                              <1> 	;
  4691                              <1> 	; (Modified registers: EAX, EDX) 
  4692                              <1> 
  4693 0000845B BA00300900          <1> 	mov	edx, Env_Page
  4694 00008460 803A00              <1> 	cmp	byte [edx], 0
  4695 00008463 7474                <1> 	jz	short get_env_string_with_word_stc_retn
  4696                              <1> 
  4697 00008465 66890D[D82C0100]    <1> 	mov	[env_var_length], cx
  4698                              <1> 
  4699 0000846C 51                  <1> 	push	ecx ; *
  4700 0000846D 56                  <1> 	push	esi ; **
  4701                              <1> 
  4702 0000846E 08C0                <1> 	or	al, al
  4703 00008470 7449                <1> 	jz	short get_env_string_with_word
  4704                              <1> 
  4705                              <1> get_env_string_with_seq_number:
  4706 00008472 B101                <1> 	mov	cl, 1
  4707 00008474 88C5                <1> 	mov	ch, al
  4708 00008476 31C0                <1> 	xor	eax, eax
  4709 00008478 89D6                <1> 	mov	esi, edx ; Env_Page
  4710                              <1> 
  4711                              <1> get_env_string_seq_number_check:
  4712 0000847A 38CD                <1> 	cmp	ch, cl
  4713 0000847C 7726                <1> 	ja	short get_env_string_seq_number_next
  4714                              <1> 
  4715                              <1> get_env_string_move_to_buff:
  4716 0000847E 57                  <1> 	push	edi ; ***
  4717                              <1> 
  4718 0000847F 29D2                <1> 	sub	edx, edx
  4719                              <1> 
  4720                              <1> get_env_string_seq_number_repeat1:
  4721 00008481 42                  <1> 	inc	edx
  4722 00008482 AC                  <1> 	lodsb
  4723 00008483 AA                  <1> 	stosb
  4724                              <1> 
  4725 00008484 66FF0D[D82C0100]    <1> 	dec	word [env_var_length]
  4726 0000848B 7508                <1> 	jnz	short get_env_string_seq_number_repeat3
  4727                              <1> 
  4728                              <1> get_env_string_seq_number_repeat2:
  4729 0000848D 20C0                <1> 	and	al, al
  4730 0000848F 7408                <1> 	jz	short get_env_string_seq_number_ok
  4731 00008491 42                  <1> 	inc	edx
  4732 00008492 AC                  <1> 	lodsb
  4733 00008493 EBF8                <1> 	jmp	short get_env_string_seq_number_repeat2
  4734                              <1> 
  4735                              <1> get_env_string_seq_number_repeat3:
  4736 00008495 08C0                <1> 	or	al, al
  4737 00008497 75E8                <1> 	jnz	short get_env_string_seq_number_repeat1
  4738                              <1> 
  4739                              <1> get_env_string_seq_number_ok:
  4740 00008499 5F                  <1> 	pop	edi ; ***
  4741 0000849A 89D0                <1> 	mov	eax, edx ; Length of the environment string
  4742                              <1> 			 ; (ASCIIZ, includes ZERO tail)
  4743 0000849C BA00300900          <1> 	mov	edx, Env_Page
  4744                              <1> 
  4745                              <1> get_env_string_stc_retn:
  4746 000084A1 5E                  <1> 	pop	esi ; **
  4747 000084A2 59                  <1> 	pop	ecx ; *
  4748 000084A3 C3                  <1> 	retn   
  4749                              <1> 	
  4750                              <1> get_env_string_seq_number_next:
  4751 000084A4 AC                  <1> 	lodsb
  4752 000084A5 08C0                <1> 	or	al, al
  4753 000084A7 75FB                <1> 	jnz	short get_env_string_seq_number_next
  4754                              <1> 
  4755 000084A9 81FE00320900        <1> 	cmp	esi, Env_Page + Env_Page_Size ; +512 (+4096)
  4756 000084AF F5                  <1> 	cmc
  4757 000084B0 72EF                <1> 	jc	short get_env_string_stc_retn
  4758                              <1> 
  4759 000084B2 AC                  <1> 	lodsb
  4760 000084B3 3C01                <1> 	cmp	al, 1
  4761 000084B5 72EA                <1> 	jb	short get_env_string_stc_retn
  4762 000084B7 FEC1                <1> 	inc	cl
  4763 000084B9 EBBF                <1> 	jmp	short get_env_string_seq_number_check
  4764                              <1> 
  4765                              <1> get_env_string_with_word:
  4766 000084BB 31C9                <1> 	xor	ecx, ecx
  4767                              <1> 
  4768                              <1> get_env_string_calc_word_length:
  4769 000084BD AC                  <1> 	lodsb 
  4770 000084BE 3C20                <1> 	cmp	al, 20h
  4771 000084C0 7211                <1> 	jb	short get_env_string_calc_word_length_ok
  4772                              <1> 	;inc	cx
  4773 000084C2 FEC1                <1> 	inc	cl
  4774                              <1> 
  4775 000084C4 3C61                <1> 	cmp	al, 'a'
  4776 000084C6 72F5                <1> 	jb	short get_env_string_calc_word_length
  4777 000084C8 3C7A                <1> 	cmp	al, 'z'
  4778 000084CA 77F1                <1> 	ja	short get_env_string_calc_word_length
  4779 000084CC 24DF                <1> 	and	al, 0DFh
  4780 000084CE 8846FF              <1> 	mov	[esi-1], al
  4781 000084D1 EBEA                <1> 	jmp	short get_env_string_calc_word_length
  4782                              <1> 	
  4783                              <1> get_env_string_calc_word_length_ok:
  4784 000084D3 08C9                <1> 	or	cl, cl
  4785 000084D5 7506                <1> 	jnz	short get_env_string_calc_word_length_save
  4786                              <1>      
  4787 000084D7 5E                  <1> 	pop	esi ; **
  4788                              <1> 
  4789                              <1> get_env_string_stc_retn1:
  4790 000084D8 59                  <1> 	pop	ecx ; *
  4791                              <1>         
  4792                              <1> get_env_string_with_word_stc_retn:
  4793 000084D9 31C0                <1> 	xor	eax, eax  
  4794 000084DB F9                  <1> 	stc
  4795 000084DC C3                  <1> 	retn
  4796                              <1>   
  4797                              <1> get_env_string_calc_word_length_save:
  4798 000084DD 871C24              <1> 	xchg	ebx, [esp] ; **
  4799 000084E0 89DE                <1> 	mov	esi, ebx 
  4800                              <1> 		; Start of the env string (to be searched)
  4801                              <1> 
  4802 000084E2 57                  <1> 	push	edi ; ***
  4803 000084E3 89D7                <1> 	mov	edi, edx ; Env_Page
  4804                              <1> 
  4805                              <1> get_env_string_compare:
  4806 000084E5 57                  <1> 	push	edi ; ****
  4807 000084E6 51                  <1> 	push	ecx ; ***** ; Variable name length
  4808                              <1> 
  4809                              <1> get_env_string_compare_rep:
  4810 000084E7 AC                  <1> 	lodsb
  4811 000084E8 AE                  <1> 	scasb
  4812 000084E9 7511                <1> 	jne	short get_env_string_compare_next1
  4813 000084EB E2FA                <1> 	loop	get_env_string_compare_rep
  4814                              <1> 	
  4815 000084ED 803F3D              <1> 	cmp	byte [edi], '='
  4816 000084F0 750A                <1> 	jne	short get_env_string_compare_next1
  4817                              <1>  
  4818 000084F2 59                  <1> 	pop	ecx ; *****
  4819 000084F3 5F                  <1> 	pop	edi ; ****
  4820 000084F4 89FE                <1> 	mov	esi, edi
  4821 000084F6 5F                  <1> 	pop	edi ; ***
  4822 000084F7 871C24              <1> 	xchg	ebx, [esp] ; **
  4823 000084FA EB82                <1> 	jmp	short get_env_string_move_to_buff
  4824                              <1> 
  4825                              <1> get_env_string_compare_next1:
  4826 000084FC 89FE                <1> 	mov	esi, edi
  4827 000084FE 59                  <1> 	pop	ecx ; *****
  4828 000084FF 5F                  <1> 	pop	edi ; ****
  4829                              <1> get_env_string_compare_next2:
  4830 00008500 81FEFF310900        <1> 	cmp	esi, Env_Page + Env_Page_Size - 1 ; +511 (+4095)
  4831 00008506 7310                <1> 	jnb	short get_env_string_compare_not_ok
  4832 00008508 20C0                <1> 	and	al, al
  4833 0000850A AC                  <1> 	lodsb
  4834 0000850B 75F3                <1> 	jnz	short get_env_string_compare_next2
  4835 0000850D 08C0                <1> 	or	al, al
  4836 0000850F 7407                <1> 	jz	short get_env_string_compare_not_ok
  4837 00008511 4E                  <1> 	dec	esi ; 12/04/2016
  4838 00008512 89F7                <1> 	mov	edi, esi
  4839 00008514 89DE                <1> 	mov	esi, ebx
  4840 00008516 EBCD                <1> 	jmp	short get_env_string_compare
  4841                              <1> 
  4842                              <1> get_env_string_compare_not_ok:
  4843 00008518 5F                  <1> 	pop	edi ; ***
  4844 00008519 89DE                <1> 	mov	esi, ebx
  4845 0000851B 5B                  <1> 	pop	ebx ; **
  4846 0000851C EBBA                <1> 	jmp	short get_env_string_stc_retn1
  4847                              <1> 
  4848                              <1> set_environment_string:
  4849                              <1> 	; 13/04/2016
  4850                              <1> 	; 12/04/2016
  4851                              <1> 	; 11/04/2016
  4852                              <1> 	; 06/04/2016
  4853                              <1> 	; 05/04/2016 (TRDOS 386 = TRDOS v2.0)
  4854                              <1> 	; 02/09/2011 (TRDOS v1, MAINPROG.ASM)
  4855                              <1> 	; 29/08/2011
  4856                              <1> 	; 29/08/2011
  4857                              <1> 	; INPUT->
  4858                              <1> 	;	ESI = ASCIIZ environment string
  4859                              <1> 	; OUTPUT ->
  4860                              <1> 	;	ESI is not changed
  4861                              <1> 	;	CF = 1 -> Could not set, 
  4862                              <1> 	;	     insufficient environment space
  4863                              <1> 	;
  4864                              <1> 	; (EAX, EDX will be changed) 
  4865                              <1> 	;
  4866                              <1> 	;    (EAX = Start address of the env string if > 0)	
  4867                              <1> 	;    (EDX = Environment string length)	
  4868                              <1> 
  4869 0000851E 56                  <1> 	push 	esi ; *
  4870                              <1> 
  4871 0000851F 31C0                <1> 	xor	eax, eax
  4872                              <1> 
  4873                              <1> set_env_chk_validation1:
  4874 00008521 FEC4                <1> 	inc	ah ; variable (string) length
  4875 00008523 AC                  <1> 	lodsb
  4876 00008524 3C3D                <1> 	cmp	al, '='
  4877 00008526 7415                <1> 	je	short set_env_chk_validation2
  4878 00008528 3C20                <1> 	cmp	al, 20h
  4879 0000852A 720F                <1> 	jb	short set_env_string_stc
  4880                              <1> 
  4881                              <1> 	; 06/04/2016
  4882 0000852C 3C61                <1> 	cmp	al, 'a'
  4883 0000852E 72F1                <1> 	jb	short set_env_chk_validation1
  4884 00008530 3C7A                <1> 	cmp	al, 'z'
  4885 00008532 77ED                <1> 	ja	short set_env_chk_validation1
  4886 00008534 2C20                <1> 	sub	al, 'a'-'A'
  4887 00008536 8846FF              <1> 	mov	[esi-1], al
  4888 00008539 EBE6                <1> 	jmp	short set_env_chk_validation1
  4889                              <1> 
  4890                              <1> set_env_string_stc:
  4891 0000853B 5E                  <1> 	pop	esi ; *
  4892                              <1> 	;stc
  4893 0000853C C3                  <1> 	retn 
  4894                              <1> 	   
  4895                              <1> set_env_chk_validation2:
  4896 0000853D 51                  <1> 	push	ecx ; **
  4897 0000853E 53                  <1> 	push	ebx ; *** 
  4898 0000853F 57                  <1> 	push	edi ; ****
  4899                              <1> 
  4900                              <1> 	; 12/04/2016
  4901 00008540 8B5C240C            <1> 	mov	ebx, [esp+12]
  4902                              <1> 
  4903                              <1> set_env_chk_validation2w:
  4904 00008544 89F7                <1> 	mov	edi, esi
  4905 00008546 4F                  <1> 	dec	edi
  4906                              <1> 
  4907 00008547 807FFF20            <1> 	cmp	byte [edi-1], 20h
  4908 0000854B 771A                <1> 	ja	short set_env_chk_validation2z
  4909                              <1> 	
  4910 0000854D 56                  <1> 	push	esi
  4911 0000854E 89FE                <1> 	mov	esi, edi
  4912 00008550 4E                  <1> 	dec	esi
  4913                              <1> 
  4914                              <1> set_env_chk_validation2x:
  4915 00008551 4E                  <1> 	dec	esi
  4916                              <1> 
  4917 00008552 39DE                <1> 	cmp	esi, ebx
  4918 00008554 7207                <1> 	jb	short set_env_chk_validation2y
  4919                              <1> 
  4920 00008556 4F                  <1> 	dec	edi
  4921                              <1> 
  4922 00008557 8A06                <1> 	mov	al, [esi]
  4923 00008559 8807                <1> 	mov	[edi], al
  4924                              <1> 
  4925 0000855B EBF4                <1> 	jmp	short set_env_chk_validation2x
  4926                              <1> 
  4927                              <1> set_env_chk_validation2y:
  4928 0000855D 5E                  <1> 	pop	esi
  4929                              <1> 
  4930                              <1> 	;mov	byte [ebx], 20h
  4931                              <1> 	
  4932 0000855E 43                  <1> 	inc 	ebx
  4933 0000855F 895C240C            <1> 	mov	[esp+12], ebx
  4934                              <1> 
  4935 00008563 FECC                <1> 	dec 	ah ; 13/04/2016
  4936                              <1> 
  4937 00008565 EBDD                <1> 	jmp	short set_env_chk_validation2w
  4938                              <1> 	
  4939                              <1> set_env_chk_validation2z:	
  4940 00008567 BA00300900          <1> 	mov	edx, Env_Page
  4941 0000856C 89D7                <1> 	mov	edi, edx
  4942                              <1> 
  4943                              <1> set_env_chk_validation3:
  4944 0000856E AC                  <1> 	lodsb
  4945 0000856F 3C20                <1> 	cmp	al, 20h
  4946 00008571 74FB                <1> 	je	short set_env_chk_validation3
  4947                              <1> 
  4948 00008573 9C                  <1> 	pushf
  4949                              <1> 
  4950                              <1> 	; 12/04/2016
  4951                              <1> set_env_chk_validation3n:
  4952 00008574 3C61                <1> 	cmp	al, 'a'
  4953 00008576 720C                <1> 	jb	short set_env_chk_validation3c
  4954 00008578 3C7A                <1> 	cmp	al, 'z'
  4955 0000857A 7705                <1> 	ja	short set_env_chk_validation3x
  4956 0000857C 2C20                <1> 	sub	al, 'a'-'A'
  4957 0000857E 8846FF              <1> 	mov	[esi-1], al
  4958                              <1> 
  4959                              <1> set_env_chk_validation3x:
  4960 00008581 AC                  <1> 	lodsb
  4961 00008582 EBF0                <1> 	jmp	short set_env_chk_validation3n
  4962                              <1> 
  4963                              <1> set_env_chk_validation3c:
  4964 00008584 3C20                <1> 	cmp	al, 20h
  4965 00008586 73F9                <1> 	jnb	short set_env_chk_validation3x
  4966                              <1> 		
  4967 00008588 803F00              <1> 	cmp	byte [edi], 0
  4968 0000858B 7731                <1> 	ja	short set_env_chk_validation4
  4969                              <1> 
  4970 0000858D 9D                  <1> 	popf
  4971 0000858E 7228                <1> 	jb	short set_env_string_nothing
  4972                              <1> 
  4973 00008590 B900020000          <1> 	mov	ecx, Env_Page_Size ; 512 (4096)
  4974                              <1> 
  4975 00008595 89DE                <1> 	mov	esi, ebx ; 12/04/2016
  4976                              <1> 
  4977                              <1> set_env_string_copy_to_envb:
  4978 00008597 AC                  <1> 	lodsb
  4979 00008598 3C20                <1> 	cmp	al, 20h
  4980 0000859A 720A                <1> 	jb	short set_env_string_copy_to_envb_z
  4981 0000859C AA                  <1> 	stosb
  4982 0000859D E2F8                <1> 	loop	set_env_string_copy_to_envb
  4983                              <1> 
  4984                              <1> 	; 11/04/2016
  4985 0000859F 89D7                <1> 	mov	edi, edx ; Env_Page
  4986 000085A1 B900020000          <1> 	mov	ecx, Env_Page_Size 
  4987                              <1> 
  4988                              <1> set_env_string_copy_to_envb_z:
  4989 000085A6 52                  <1> 	push	edx  ; Start address of the variable
  4990 000085A7 BA00020000          <1> 	mov	edx, Env_Page_Size
  4991 000085AC 29CA                <1> 	sub	edx, ecx ; variable (string) length
  4992                              <1> 
  4993 000085AE 28C0                <1> 	sub	al, al ; 0
  4994 000085B0 F3AA                <1>  	rep	stosb ; clear remain bytes of the env page
  4995                              <1> 
  4996 000085B2 58                  <1> 	pop	eax  ; Start address of the variable
  4997                              <1> 
  4998                              <1> set_env_string_allocate_envb_retn:  ; stc or clc return
  4999 000085B3 5F                  <1> 	pop	edi ; ****
  5000 000085B4 5B                  <1> 	pop	ebx ; ***
  5001 000085B5 59                  <1> 	pop	ecx ; **
  5002 000085B6 5E                  <1> 	pop	esi ; *	
  5003 000085B7 C3                  <1> 	retn
  5004                              <1> 
  5005                              <1> set_env_string_nothing:
  5006 000085B8 31C0                <1> 	xor	eax, eax
  5007 000085BA 31D2                <1> 	xor	edx, edx ; 11/04/2016
  5008 000085BC EBF5                <1> 	jmp	short set_env_string_allocate_envb_retn
  5009                              <1> 
  5010                              <1> set_env_chk_validation4:
  5011                              <1> 	; 11/04/2016
  5012 000085BE 9D                  <1> 	popf
  5013                              <1> 
  5014 000085BF 89D6                <1> 	mov	esi, edx  ; Env_Page
  5015                              <1> 
  5016                              <1> set_env_chk_validation5:	
  5017 000085C1 89DF                <1> 	mov	edi, ebx  ; ASCIIZ environment string address	
  5018 000085C3 0FB6CC              <1> 	movzx	ecx, ah ; Variable (string) length (with '=')
  5019                              <1> 
  5020                              <1> set_env_chk_validation5_loop:
  5021 000085C6 AC                  <1> 	lodsb
  5022 000085C7 AE                  <1> 	scasb
  5023 000085C8 750A                <1> 	jne	short set_env_chk_validation6
  5024 000085CA E2FA                <1> 	loop	set_env_chk_validation5_loop
  5025                              <1> 
  5026 000085CC 3C3D                <1> 	cmp	al, '='
  5027 000085CE 0F8483000000        <1>         je      set_env_change_variable
  5028                              <1> 
  5029                              <1> set_env_chk_validation6:
  5030 000085D4 08C0                <1> 	or	al, al ; 0
  5031 000085D6 7403                <1> 	jz	short set_env_chk_validation7
  5032                              <1> 
  5033 000085D8 AC                  <1> 	lodsb
  5034 000085D9 EBF9                <1> 	jmp	short set_env_chk_validation6
  5035                              <1> 
  5036                              <1> set_env_chk_validation7:
  5037 000085DB 88E1                <1> 	mov	cl, ah
  5038 000085DD 01F1                <1> 	add	ecx, esi
  5039 000085DF 81F9FF310900        <1> 	cmp	ecx, Env_Page + Env_Page_Size - 1 
  5040                              <1> 		; 511 (4095) 
  5041                              <1> 		; strlen + '=' + 0
  5042 000085E5 72DA                <1> 	jb	short set_env_chk_validation5
  5043                              <1> 
  5044                              <1> set_env_chk_validation8: ; variable not found
  5045 000085E7 0FB6F4              <1> 	movzx	esi, ah  ; variable name length (with '=') 
  5046 000085EA 01DE                <1> 	add	esi, ebx ; position just after of the '='
  5047                              <1> 
  5048                              <1> set_env_chk_validation8_loop:
  5049 000085EC AC                  <1> 	lodsb
  5050 000085ED 3C20                <1> 	cmp	al, 20h
  5051 000085EF 74FB                <1> 	je	short set_env_chk_validation8_loop	
  5052 000085F1 72C5                <1> 	jb	short set_env_string_nothing
  5053                              <1> 
  5054                              <1> set_env_chk_validation9:
  5055 000085F3 AC                  <1> 	lodsb
  5056 000085F4 3C20                <1> 	cmp	al, 20h
  5057 000085F6 73FB                <1> 	jnb	short set_env_chk_validation9
  5058                              <1> 
  5059                              <1> 	; End of ASCIIZ environment string
  5060                              <1> 
  5061                              <1> set_env_add_variable:
  5062 000085F8 29DE                <1> 	sub	esi, ebx ; variable+definition length
  5063                              <1> 	
  5064 000085FA 56                  <1> 	push	esi ; *****
  5065                              <1> 
  5066 000085FB 89D6                <1> 	mov	esi, edx ; Environment page address
  5067                              <1> 
  5068 000085FD B900020000          <1> 	mov	ecx, Env_Page_Size ; 512 (4096)	
  5069                              <1> 
  5070                              <1> set_env_add_variable_loop:
  5071 00008602 AC                  <1> 	lodsb
  5072 00008603 20C0                <1> 	and	al, al		
  5073 00008605 7406                <1> 	jz	short set_env_add_variable_chk1 ; 0
  5074 00008607 E2F9                <1> 	loop	set_env_add_variable_loop
  5075                              <1> 
  5076                              <1> 	; 11/04/2016
  5077 00008609 884EFF              <1> 	mov	[esi-1], cl ; 0
  5078 0000860C 41                  <1> 	inc	ecx
  5079                              <1> 	
  5080                              <1> set_env_add_variable_chk1: 
  5081 0000860D 49                  <1> 	dec	ecx
  5082 0000860E 7408                <1> 	jz	short set_env_add_variable_nspc
  5083 00008610 AC                  <1> 	lodsb
  5084 00008611 08C0                <1> 	or 	al, al
  5085 00008613 740C                <1> 	jz	short set_env_add_variable_chk2 ; 00
  5086 00008615 49                  <1> 	dec	ecx
  5087 00008616 75EA                <1> 	jnz	short set_env_add_variable_loop
  5088                              <1> 
  5089                              <1> set_env_add_variable_nspc: ; no space on environment page
  5090 00008618 58                  <1> 	pop	eax ; *****
  5091 00008619 B808000000          <1> 	mov	eax, 08h ; No space for new environment string
  5092 0000861E F9                  <1> 	stc
  5093 0000861F EB92                <1>         jmp     short set_env_string_allocate_envb_retn
  5094                              <1> 
  5095                              <1> set_env_add_variable_chk2:
  5096 00008621 8B0C24              <1> 	mov	ecx, [esp] ; *****
  5097 00008624 4E                  <1> 	dec	esi ; beginning address of the new variable
  5098 00008625 89F0                <1> 	mov	eax, esi
  5099 00008627 01C8                <1> 	add	eax, ecx ; string length (with CR)
  5100 00008629 81C200020000        <1> 	add	edx, Env_Page_Size ; 512 (4096)
  5101 0000862F 39D0                <1> 	cmp	eax, edx 
  5102 00008631 77E5                <1> 	ja	short set_env_add_variable_nspc
  5103 00008633 49                  <1> 	dec	ecx ; except CR at the end
  5104 00008634 89CA                <1> 	mov	edx, ecx ; 12/04/2016
  5105 00008636 89F7                <1> 	mov	edi, esi
  5106 00008638 893C24              <1> 	mov	[esp], edi ; ***** ; Start address of new variable
  5107 0000863B 89DE                <1> 	mov	esi, ebx ; ASCIIZ environment string address
  5108 0000863D F3A4                <1> 	rep	movsb
  5109 0000863F 28C0                <1> 	sub	al, al
  5110 00008641 AA                  <1> 	stosb
  5111 00008642 58                  <1> 	pop	eax ; ***** ; Beginning address of new variable			
  5112 00008643 81FF00320900        <1>         cmp     edi, Env_Page + Env_Page_Size ; 12/04/2016
  5113 00008649 0F8364FFFFFF        <1>         jnb     set_env_string_allocate_envb_retn ; OK !
  5114 0000864F 880F                <1> 	mov	[edi], cl ; 0
  5115 00008651 F8                  <1> 	clc	; 13/04/2016
  5116 00008652 E95CFFFFFF          <1>         jmp     set_env_string_allocate_envb_retn ; OK !
  5117                              <1> 
  5118                              <1> set_env_change_variable:
  5119                              <1> 	; 06/04/2016
  5120                              <1> 	; esi = Variable's address in environment page (after '=')
  5121                              <1> 	; edi = ASCIIZ environment string address (after '=')
  5122                              <1> 
  5123                              <1> 	; ah = variable length from start to the '='
  5124 00008657 8825[D82C0100]      <1> 	mov	[env_var_length], ah
  5125                              <1> 
  5126 0000865D 28C9                <1> 	sub	cl, cl ; ecx = 0
  5127                              <1> 
  5128 0000865F 57                  <1> 	push	edi ; *****
  5129                              <1> 
  5130 00008660 89F7                <1> 	mov	edi, esi ; 11/04/2016
  5131                              <1> 
  5132                              <1> set_env_change_variable_calc1:
  5133 00008662 AC                  <1> 	lodsb
  5134 00008663 08C0                <1> 	or	al, al
  5135 00008665 7403                <1> 	jz	short set_env_change_variable_calc2
  5136                              <1> 
  5137 00008667 41                  <1> 	inc	ecx ; length of environment string (after the '=')
  5138                              <1> 
  5139 00008668 EBF8                <1> 	jmp	short set_env_change_variable_calc1	
  5140                              <1> 
  5141                              <1> set_env_change_variable_calc2:
  5142 0000866A 8B3424              <1> 	mov	esi, [esp] ; ASCIIZ environment string address
  5143                              <1> 	
  5144 0000866D 29D2                <1> 	sub	edx, edx
  5145                              <1> 
  5146                              <1> set_env_change_variable_calc3:
  5147 0000866F AC                  <1> 	lodsb
  5148 00008670 3C20                <1> 	cmp	al, 20h
  5149 00008672 7203                <1> 	jb	short set_env_change_variable_calc4
  5150                              <1> 
  5151 00008674 42                  <1> 	inc	edx ; length of ASCIIZ string (after the '=')
  5152                              <1> 	
  5153 00008675 EBF8                <1> 	jmp	short set_env_change_variable_calc3
  5154                              <1> 	
  5155                              <1> set_env_change_variable_calc4:
  5156 00008677 C646FF00            <1> 	mov	byte [esi-1], 0  ; put ZERO instead of CR
  5157                              <1> 	
  5158 0000867B 5E                  <1> 	pop	esi ; ***** ; ASCIIZ string address (after '=')
  5159                              <1> 
  5160                              <1> 	; EDI = Old variable's address (after '=')
  5161                              <1> 	
  5162                              <1> 	; compare the new string with the old string
  5163 0000867C 39CA                <1> 	cmp	edx, ecx
  5164 0000867E 7717                <1> 	ja	short set_env_change_variable_calc5 ; longer
  5165 00008680 0F828F000000        <1>         jb      set_env_change_variable_calc9 ; shorter
  5166                              <1> 	
  5167                              <1> 	;same length (simple copy)
  5168 00008686 0FB6C4              <1> 	movzx	eax, ah
  5169 00008689 01C2                <1> 	add	edx, eax
  5170 0000868B F7D8                <1> 	neg	eax
  5171 0000868D 01F8                <1> 	add	eax, edi
  5172                              <1> 	; EAX = Start address of the variable
  5173                              <1> 	; EDX = Variable length (without ZERO at the end of variable)
  5174                              <1> 
  5175 0000868F F3A4                <1> 	rep	movsb
  5176 00008691 F8                  <1> 	clc	; 13/04/2016
  5177 00008692 E91CFFFFFF          <1>         jmp     set_env_string_allocate_envb_retn ; OK !
  5178                              <1> 
  5179                              <1> set_env_change_variable_calc5:
  5180                              <1> 	; 11/04/2016
  5181 00008697 52                  <1> 	push	edx ; *****
  5182 00008698 29CA                <1> 	sub	edx, ecx ; difference ; (the new string is longer)
  5183 0000869A 89F3                <1> 	mov 	ebx, esi
  5184 0000869C 89FE                <1> 	mov	esi, edi
  5185                              <1> 
  5186                              <1> set_env_change_variable_calc6:
  5187 0000869E AC                  <1> 	lodsb 
  5188 0000869F 20C0                <1> 	and	al, al
  5189 000086A1 75FB                <1> 	jnz	short set_env_change_variable_calc6
  5190                              <1> 
  5191 000086A3 81FE00320900        <1> 	cmp	esi, Env_Page + Env_Page_Size ; 512 (4096)
  5192 000086A9 0F8369FFFFFF        <1>         jnb     set_env_add_variable_nspc
  5193                              <1> 
  5194 000086AF 89F9                <1> 	mov	ecx, edi  ; current (old) variable's address
  5195 000086B1 89F7                <1> 	mov	edi, esi  ; next variable's address 
  5196                              <1> 
  5197 000086B3 AC                  <1> 	lodsb
  5198 000086B4 08C0                <1> 	or	al, al
  5199 000086B6 7416                <1> 	jz	short set_env_change_variable_calc8 ; 00
  5200                              <1> 
  5201                              <1> set_env_change_variable_calc7:
  5202 000086B8 AC                  <1> 	lodsb
  5203 000086B9 20C0                <1> 	and	al, al
  5204 000086BB 75FB                <1> 	jnz	short set_env_change_variable_calc7
  5205                              <1> 
  5206 000086BD 81FE00320900        <1> 	cmp	esi, Env_Page + Env_Page_Size ; 512 (4096)
  5207 000086C3 0F834FFFFFFF        <1>         jnb     set_env_add_variable_nspc
  5208                              <1> 
  5209 000086C9 AC                  <1> 	lodsb
  5210 000086CA 08C0                <1> 	or	al, al
  5211 000086CC 75EA                <1> 	jnz	short set_env_change_variable_calc7
  5212                              <1> 
  5213                              <1> set_env_change_variable_calc8:
  5214 000086CE 4E                  <1> 	dec	esi ; address of the second (last) 0 of the 00
  5215                              <1> 
  5216 000086CF 01F2                <1> 	add	edx, esi ; final position of the last 0
  5217                              <1> 
  5218 000086D1 81FA00320900        <1> 	cmp	edx, Env_Page + Env_Page_Size ; 512 (4096)
  5219 000086D7 0F833BFFFFFF        <1>         jnb     set_env_add_variable_nspc
  5220                              <1> 
  5221 000086DD 89C8                <1> 	mov	eax, ecx ; old variable's address (after '=')
  5222                              <1> 
  5223 000086DF 89F1                <1> 	mov	ecx, esi 
  5224 000086E1 29F9                <1> 	sub	ecx, edi ; count of bytes to move forward
  5225                              <1> 
  5226                              <1> 	; 13/04/2016
  5227 000086E3 C60200              <1> 	mov	byte [edx], 0
  5228 000086E6 89D7                <1> 	mov	edi, edx
  5229 000086E8 29F2                <1> 	sub	edx, esi ; difference (additional byte count)
  5230 000086EA 4F                  <1> 	dec	edi ; the last zero address (first byte of the 00)
  5231 000086EB 89FE                <1> 	mov	esi, edi
  5232 000086ED 29D6                <1> 	sub	esi, edx ; - displacement
  5233                              <1> 	
  5234 000086EF FA                  <1> 	cli	; disable interrupts
  5235 000086F0 FD                  <1> 	std	; backward
  5236                              <1> 
  5237 000086F1 F3A4                <1> 	rep	movsb ; move ECX bytes from DS:ESI to ES:EDI
  5238                              <1> 
  5239 000086F3 FC                  <1> 	cld	; forward (default)
  5240 000086F4 FB                  <1> 	sti	; enable interrupts
  5241                              <1> 	
  5242 000086F5 89C7                <1> 	mov	edi, eax
  5243 000086F7 59                  <1> 	pop	ecx ; ***** ; byte count (after '=')
  5244 000086F8 89CA                <1> 	mov	edx, ecx
  5245 000086FA 89DE                <1> 	mov	esi, ebx ; ASCIIZ string address (after '=')
  5246 000086FC 89FB                <1> 	mov	ebx, edi
  5247                              <1> 
  5248 000086FE F3A4                <1> 	rep	movsb
  5249                              <1> 
  5250 00008700 880F                <1> 	mov	[edi], cl ; 0 ; end of variable
  5251                              <1> 
  5252 00008702 0FB605[D82C0100]    <1> 	movzx	eax, byte [env_var_length]
  5253 00008709 01C2                <1> 	add	edx, eax ; variable length (total)
  5254 0000870B F7D8                <1> 	neg	eax
  5255 0000870D 01D8                <1> 	add	eax, ebx ; start address of the variable
  5256 0000870F F8                  <1> 	clc	; 13/04/2016
  5257 00008710 E99EFEFFFF          <1>         jmp     set_env_string_allocate_envb_retn ; OK !
  5258                              <1> 
  5259                              <1> set_env_change_variable_calc9:
  5260                              <1> 	; 11/04/2016
  5261 00008715 21D2                <1> 	and	edx, edx ; is empty ?
  5262 00008717 753B                <1> 	jnz	short set_env_change_variable_calc15
  5263                              <1> 	
  5264 00008719 0FB6DC              <1> 	movzx	ebx, ah
  5265 0000871C F7DB                <1> 	neg	ebx
  5266 0000871E 01FB                <1> 	add	ebx, edi
  5267                              <1> 
  5268                              <1> 	; EBX = Start address of the variable (in env page)
  5269                              <1> 	; EDX = Variable length = 0
  5270                              <1> 	
  5271 00008720 89FE                <1> 	mov	esi, edi
  5272                              <1> 
  5273                              <1> set_env_change_variable_calc10:
  5274 00008722 AC                  <1> 	lodsb
  5275 00008723 08C0                <1> 	or	al, al
  5276 00008725 75FB                <1> 	jnz	short set_env_change_variable_calc10
  5277                              <1> 
  5278 00008727 B9FF310900          <1> 	mov	ecx, Env_Page + Env_Page_Size - 1
  5279                              <1> 
  5280 0000872C 39CE                <1> 	cmp	esi, ecx ; +511 (+4095)
  5281 0000872E 7604                <1> 	jna	short set_env_change_variable_calc11
  5282                              <1> 
  5283 00008730 89CE                <1> 	mov	esi, ecx
  5284 00008732 8806                <1> 	mov	[esi], al ; 0
  5285                              <1> 
  5286                              <1> set_env_change_variable_calc11:
  5287 00008734 89DF                <1> 	mov	edi, ebx ; old variable's start address
  5288                              <1> 
  5289                              <1> set_env_change_variable_calc12:
  5290 00008736 AC                  <1> 	lodsb
  5291 00008737 AA                  <1> 	stosb
  5292 00008738 20C0                <1> 	and	al, al
  5293 0000873A 75FA                <1> 	jnz	short set_env_change_variable_calc12
  5294 0000873C 39CE                <1> 	cmp	esi, ecx
  5295 0000873E 7706                <1> 	ja	short set_env_change_variable_calc13
  5296 00008740 AC                  <1> 	lodsb
  5297 00008741 AA                  <1> 	stosb
  5298 00008742 20C0                <1> 	and	al, al
  5299 00008744 75F0                <1> 	jnz	short set_env_change_variable_calc12	
  5300                              <1> 
  5301                              <1> set_env_change_variable_calc13:
  5302 00008746 29F9                <1> 	sub	ecx, edi
  5303 00008748 7203                <1> 	jb	short set_env_change_variable_calc14
  5304 0000874A 41                  <1> 	inc	ecx ; 1-512 (1-4096)
  5305 0000874B F3AA                <1> 	rep	stosb ; al = 0	
  5306                              <1> 
  5307                              <1> set_env_change_variable_calc14:
  5308 0000874D 29C0                <1> 	sub	eax, eax ; Start address of the variable
  5309                              <1> 	; EAX = 0 -> Variable is removed
  5310                              <1> 	; EDX = Variable length = 0	
  5311                              <1> 
  5312 0000874F E95FFEFFFF          <1>         jmp     set_env_string_allocate_envb_retn ; OK !
  5313                              <1> 	    
  5314                              <1> set_env_change_variable_calc15:	
  5315 00008754 52                  <1> 	push	edx ; *****
  5316 00008755 F7DA                <1> 	neg	edx
  5317 00008757 01CA                <1> 	add	edx, ecx ; difference (the old string is longer)
  5318 00008759 89F3                <1> 	mov 	ebx, esi
  5319 0000875B 89FE                <1> 	mov	esi, edi
  5320                              <1> 
  5321                              <1> set_env_change_variable_calc16:
  5322 0000875D AC                  <1> 	lodsb 
  5323 0000875E 20C0                <1> 	and	al, al
  5324 00008760 75FB                <1> 	jnz	short set_env_change_variable_calc16
  5325                              <1> 
  5326 00008762 B900320900          <1> 	mov	ecx, Env_Page + Env_Page_Size
  5327                              <1> 
  5328 00008767 39CE                <1> 	cmp	esi, ecx ; +512 (+4096)
  5329 00008769 7605                <1> 	jna	short set_env_change_variable_calc17
  5330                              <1> 
  5331 0000876B 89CE                <1> 	mov	esi, ecx
  5332 0000876D 8846FF              <1> 	mov	[esi-1], al ; 0
  5333                              <1> 
  5334                              <1> set_env_change_variable_calc17:
  5335 00008770 89F9                <1> 	mov	ecx, edi  ; current (old) variable's address
  5336 00008772 89F7                <1> 	mov	edi, esi  ; next variable's address 
  5337                              <1> 
  5338 00008774 AC                  <1> 	lodsb
  5339 00008775 08C0                <1> 	or	al, al
  5340 00008777 741D                <1> 	jz	short set_env_change_variable_calc20
  5341                              <1> 
  5342                              <1> set_env_change_variable_calc18:
  5343 00008779 AC                  <1> 	lodsb
  5344 0000877A 20C0                <1> 	and	al, al
  5345 0000877C 75FB                <1> 	jnz	short set_env_change_variable_calc18
  5346                              <1> 
  5347 0000877E 81FE00320900        <1> 	cmp	esi, Env_Page + Env_Page_Size
  5348 00008784 720B                <1> 	jb	short set_env_change_variable_calc19
  5349 00008786 740E                <1> 	je	short set_env_change_variable_calc20
  5350                              <1> 
  5351 00008788 BEFF310900          <1> 	mov	esi, Env_Page + Env_Page_Size - 1
  5352 0000878D 8806                <1> 	mov	[esi], al ; 0
  5353 0000878F EB06                <1> 	jmp	short set_env_change_variable_calc21
  5354                              <1> 
  5355                              <1> set_env_change_variable_calc19:
  5356 00008791 AC                  <1> 	lodsb
  5357 00008792 08C0                <1> 	or	al, al
  5358 00008794 75E3                <1> 	jnz	short set_env_change_variable_calc18
  5359                              <1> 
  5360                              <1> set_env_change_variable_calc20:
  5361 00008796 4E                  <1> 	dec	esi ; address of the second (last) 0 of the 00
  5362                              <1> 
  5363                              <1> set_env_change_variable_calc21:
  5364                              <1> 	; edx = difference (byte count)
  5365                              <1> 	
  5366 00008797 89C8                <1> 	mov	eax, ecx ; old variable's address (after '=')
  5367                              <1> 
  5368 00008799 89F1                <1> 	mov	ecx, esi 
  5369 0000879B 29F9                <1> 	sub	ecx, edi ; count of bytes to move backward
  5370                              <1> 
  5371 0000879D 89FE                <1> 	mov	esi, edi ; next variable's address
  5372 0000879F 29D7                <1> 	sub	edi, edx ; (displacement)
  5373                              <1> 	
  5374 000087A1 F3A4                <1> 	rep	movsb
  5375                              <1> 
  5376 000087A3 880F                <1> 	mov	[edi], cl ; 0 ; 00 ; end of environment variables
  5377                              <1> 
  5378 000087A5 89C7                <1> 	mov	edi, eax
  5379 000087A7 5A                  <1> 	pop	edx ; ***** ; byte count (after '=')
  5380 000087A8 89D1                <1> 	mov	ecx, edx
  5381 000087AA 89DE                <1> 	mov	esi, ebx ; ASCIIZ string address (after '=')
  5382 000087AC 89FB                <1> 	mov	ebx, edi
  5383                              <1> 	
  5384 000087AE F3A4                <1> 	rep	movsb
  5385                              <1> 
  5386 000087B0 880F                <1> 	mov	[edi], cl ; 0 ; end of variable
  5387                              <1> 
  5388 000087B2 0FB605[D82C0100]    <1> 	movzx	eax, byte [env_var_length]
  5389 000087B9 01C2                <1> 	add	edx, eax ; variable length (total)
  5390 000087BB F7D8                <1> 	neg	eax
  5391 000087BD 01D8                <1> 	add	eax, ebx ; start address of the variable
  5392 000087BF F8                  <1> 	clc	; 13/04/2016
  5393 000087C0 E9EEFDFFFF          <1>         jmp     set_env_string_allocate_envb_retn ; OK !
  5394                              <1> 
  5395                              <1> mainprog_startup_configuration:
  5396                              <1> 	; 06/05/2016
  5397                              <1> 	; 14/04/2016 (TRDOS 386 = TRDOS v2.0)
  5398                              <1> 	; 17/09/2011 (TRDOS v1, MAINPROG.ASM)
  5399                              <1> 	;
  5400                              <1> loc_load_mainprog_cfg_file:
  5401 000087C5 BE[2ADE0000]        <1> 	mov	esi, MainProgCfgFile
  5402 000087CA 66B80018            <1> 	mov	ax, 1800h ; Except volume label and dirs
  5403 000087CE E8FBE9FFFF          <1> 	call	find_first_file
  5404 000087D3 7256                <1> 	jc	short loc_load_mainprog_cfg_exit
  5405                              <1> 
  5406                              <1> 	;or	eax, eax
  5407                              <1> 	;jz	short loc_load_mainprog_cfg_exit
  5408                              <1> 
  5409                              <1> loc_start_mainprog_configuration:
  5410                              <1> 	; ESI = FindFile_DirEntry Location
  5411                              <1> 	; EAX = File Size
  5412                              <1> 
  5413 000087D5 A3[5C200100]        <1> 	mov	[MainProgCfg_FileSize], eax
  5414                              <1> 
  5415 000087DA 668B5614            <1> 	mov	dx, [esi+DirEntry_FstClusHI]
  5416 000087DE C1E210              <1> 	shl	edx, 16
  5417 000087E1 668B561A            <1> 	mov	dx, [esi+DirEntry_FstClusLO]
  5418 000087E5 8915[8C2C0100]      <1> 	mov	[csftdf_sf_cluster], edx
  5419                              <1> 
  5420 000087EB 89C1                <1> 	mov	ecx, eax
  5421 000087ED 29C0                <1> 	sub	eax, eax
  5422                              <1> 
  5423                              <1> 	; TRDOS 386 (TRDOS v2.0)
  5424                              <1> 	; Allocate contiguous memory block for loading the file
  5425                              <1> 	
  5426                              <1> 	; eax = 0 (Allocate memory from the beginning)
  5427                              <1> 	; ecx = File (Allocation) size in bytes
  5428                              <1> 	
  5429 000087EF E83FC6FFFF          <1> 	call	allocate_memory_block
  5430 000087F4 7235                <1> 	jc	short loc_load_mainprog_cfg_exit
  5431                              <1> 
  5432 000087F6 A3[842C0100]        <1> 	mov	[csftdf_sf_mem_addr], eax ; loading address
  5433 000087FB 890D[882C0100]      <1> 	mov	[csftdf_sf_mem_bsize], ecx ; block size
  5434                              <1> 
  5435 00008801 31DB                <1> 	xor	ebx, ebx
  5436                              <1> 	;mov	[csftdf_sf_rbytes], ebx ; 0, reset
  5437                              <1> 
  5438 00008803 8A3D[6E200100]      <1> 	mov	bh, [Current_Drv] ; [FindFile_Drv]
  5439 00008809 BE00010900          <1> 	mov	esi, Logical_DOSDisks
  5440 0000880E 01DE                <1> 	add	esi, ebx
  5441                              <1> 
  5442 00008810 8B1D[842C0100]      <1> 	mov	ebx, [csftdf_sf_mem_addr] ; memory block address
  5443                              <1> 
  5444 00008816 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
  5445 0000881A 7710                <1>         ja	short loc_mcfg_load_fat_file
  5446                              <1> 
  5447 0000881C C705[942C0100]0000- <1> 	mov	dword [csftdf_r_size], 65536
  5447 00008824 0100                <1>
  5448 00008826 E992010000          <1>         jmp     loc_mcfg_load_fs_file
  5449                              <1> 
  5450                              <1> loc_load_mainprog_cfg_exit:
  5451 0000882B C3                  <1> 	retn 
  5452                              <1> 
  5453                              <1> loc_mcfg_load_fat_file:
  5454 0000882C 0FB74611            <1> 	movzx	eax, word [esi+LD_BPB+BytesPerSec]
  5455 00008830 0FB64E13            <1> 	movzx	ecx, byte [esi+LD_BPB+SecPerClust]
  5456 00008834 F7E1                <1> 	mul	ecx
  5457 00008836 A3[942C0100]        <1> 	mov	[csftdf_r_size], eax
  5458                              <1> 
  5459                              <1> loc_mcfg_load_fat_file_next:
  5460 0000883B E813010000          <1> 	call	mcfg_read_fat_file_sectors
  5461 00008840 0F82F7000000        <1>         jc      mcfg_deallocate_mem
  5462                              <1> 
  5463 00008846 09D2                <1> 	or	edx, edx ; edx > 0 -> EOF
  5464 00008848 74F1                <1> 	jz	short loc_mcfg_load_fat_file_next
  5465                              <1> 
  5466                              <1> loc_mcfg_load_fat_file_ok:
  5467                              <1> 	; 06/05/2016
  5468 0000884A C705[1C2D0100]-     <1> 	mov	dword [mainprog_return_addr], loc_mcfg_ci_return_addr 
  5468 00008850 [FE880000]          <1>
  5469                              <1> 	;
  5470 00008854 8B35[842C0100]      <1> 	mov	esi, [csftdf_sf_mem_addr]
  5471 0000885A 8935[60200100]      <1> 	mov	[MainProgCfg_LineOffset], esi
  5472                              <1> 	
  5473 00008860 A1[5C200100]        <1> 	mov	eax, [MainProgCfg_FileSize]
  5474 00008865 89C2                <1> 	mov	edx, eax
  5475 00008867 01F2                <1> 	add	edx, esi
  5476                              <1> 
  5477                              <1> loc_mcfg_process_next_line_check:
  5478 00008869 89C1                <1> 	mov	ecx, eax
  5479                              <1> 
  5480 0000886B 803E2A              <1> 	cmp	byte [esi], "*" ; Remark sign
  5481 0000886E 7503                <1> 	jne	short loc_mcfg_process_next_line
  5482 00008870 46                  <1> 	inc	esi
  5483 00008871 EB17                <1> 	jmp	short loc_move_mainprog_cfg_nl1
  5484                              <1> 
  5485                              <1> loc_mcfg_process_next_line:
  5486 00008873 83F94F              <1> 	cmp	ecx, 79
  5487 00008876 7605                <1> 	jna	short loc_start_mainprog_cfg_process
  5488                              <1> 	
  5489 00008878 B94F000000          <1> 	mov	ecx, 79 
  5490                              <1> 
  5491                              <1> loc_start_mainprog_cfg_process:
  5492 0000887D BF[1E210100]        <1> 	mov	edi, CommandBuffer
  5493                              <1> 
  5494                              <1> loc_move_mainprog_cfg_line:
  5495 00008882 AC                  <1> 	lodsb
  5496 00008883 3C20                <1> 	cmp	al, 20h
  5497 00008885 720C                <1> 	jb	short loc_move_mainprog_cfg_nl2
  5498 00008887 AA                  <1> 	stosb
  5499 00008888 E2F8                <1> 	loop	loc_move_mainprog_cfg_line
  5500                              <1> 
  5501                              <1> loc_move_mainprog_cfg_nl1:
  5502 0000888A 39D6                <1> 	cmp	esi, edx ; + configuration file size
  5503 0000888C 7312                <1> 	jnb	short loc_end_of_mainprog_cfg_line
  5504 0000888E AC                  <1> 	lodsb
  5505 0000888F 3C20                <1> 	cmp	al, 20h
  5506 00008891 73F7                <1> 	jnb	short loc_move_mainprog_cfg_nl1
  5507                              <1> 
  5508                              <1> loc_move_mainprog_cfg_nl2:
  5509 00008893 39D6                <1> 	cmp	esi, edx
  5510 00008895 7309                <1> 	jnb	short loc_end_of_mainprog_cfg_line
  5511 00008897 8A06                <1> 	mov	al, [esi]
  5512 00008899 3C20                <1> 	cmp	al, 20h
  5513 0000889B 7703                <1>  	ja	short loc_end_of_mainprog_cfg_line
  5514 0000889D 46                  <1> 	inc	esi
  5515 0000889E EBF3                <1> 	jmp	short loc_move_mainprog_cfg_nl2	               
  5516                              <1> 
  5517                              <1> loc_end_of_mainprog_cfg_line:
  5518 000088A0 C60700              <1> 	mov	byte [edi], 0
  5519                              <1> 
  5520 000088A3 8935[60200100]      <1> 	mov	[MainProgCfg_LineOffset], esi
  5521                              <1> 	
  5522                              <1> loc_move_mainprog_cfg_command:
  5523 000088A9 BE[1E210100]        <1> 	mov	esi, CommandBuffer
  5524 000088AE 89F7                <1> 	mov	edi, esi
  5525 000088B0 31DB                <1> 	xor	ebx, ebx
  5526                              <1> 	;xor	ecx, ecx
  5527 000088B2 30C9                <1> 	xor	cl, cl
  5528                              <1> 
  5529                              <1> loc_move_mcfg_first_cmd_char:
  5530 000088B4 8A041E              <1> 	mov	al, [esi+ebx]
  5531 000088B7 FEC3                <1> 	inc	bl 
  5532 000088B9 3C20                <1> 	cmp	al, 20h
  5533 000088BB 7712                <1> 	ja	short loc_move_mcfg_cmd_capitalizing
  5534 000088BD 7237                <1> 	jb	short loc_move_mcfg_cmd_arguments_ok
  5535 000088BF 80FB4F              <1> 	cmp	bl, 79
  5536 000088C2 72F0                <1> 	jb	short loc_move_mcfg_first_cmd_char
  5537 000088C4 EB30                <1> 	jmp	short loc_move_mcfg_cmd_arguments_ok
  5538                              <1> 
  5539                              <1> loc_move_mcfg_next_cmd_char:
  5540 000088C6 8A041E              <1> 	mov	al, [esi+ebx]
  5541 000088C9 FEC3                <1> 	inc	bl
  5542 000088CB 3C20                <1> 	cmp	al, 20h
  5543 000088CD 7614                <1> 	jna	short loc_move_mcfg_cmd_ok
  5544                              <1> 
  5545                              <1> loc_move_mcfg_cmd_capitalizing:
  5546 000088CF 3C61                <1> 	cmp	al, 61h ; 'a'
  5547 000088D1 7206                <1> 	jb	short loc_move_mcfg_cmd_caps_ok
  5548 000088D3 3C7A                <1> 	cmp	al, 7Ah ; 'z'
  5549 000088D5 7702                <1> 	ja	short loc_move_mcfg_cmd_caps_ok
  5550 000088D7 24DF                <1> 	and	al, 0DFh ; sub	al, 'a'-'A'
  5551                              <1> 
  5552                              <1> loc_move_mcfg_cmd_caps_ok:
  5553 000088D9 AA                  <1> 	stosb 
  5554 000088DA FEC1                <1> 	inc	cl
  5555 000088DC 80FB4F              <1> 	cmp	bl, 79
  5556 000088DF 72E5                <1> 	jb	short loc_move_mcfg_next_cmd_char
  5557 000088E1 EB13                <1> 	jmp	short loc_move_mcfg_cmd_arguments_ok
  5558                              <1> 
  5559                              <1> loc_move_mcfg_cmd_ok:
  5560 000088E3 30C0                <1> 	xor	al, al ; 0
  5561                              <1> 
  5562                              <1> loc_move_mcfg_cmd_arguments:
  5563 000088E5 8807                <1> 	mov	[edi], al
  5564 000088E7 47                  <1> 	inc	edi
  5565 000088E8 80FB4F              <1> 	cmp	bl, 79
  5566 000088EB 7309                <1> 	jnb	short loc_move_mcfg_cmd_arguments_ok
  5567 000088ED 8A041E              <1> 	mov	al, [esi+ebx]
  5568 000088F0 FEC3                <1> 	inc	bl
  5569 000088F2 3C20                <1> 	cmp	al, 20h
  5570 000088F4 73EF                <1> 	jnb	short loc_move_mcfg_cmd_arguments
  5571                              <1> 	
  5572                              <1> loc_move_mcfg_cmd_arguments_ok:
  5573 000088F6 C60700              <1> 	mov	byte [edi], 0
  5574                              <1>        
  5575                              <1> loc_mcfg_process_cmd_interpreter:
  5576 000088F9 E8F8DFFFFF          <1> 	call    command_interpreter
  5577                              <1> 
  5578                              <1> loc_mcfg_ci_return_addr: 
  5579 000088FE A1[5C200100]        <1> 	mov	eax, [MainProgCfg_FileSize]
  5580 00008903 89C2                <1> 	mov	edx, eax
  5581 00008905 8B35[60200100]      <1> 	mov	esi, [MainProgCfg_LineOffset]
  5582 0000890B 01F2                <1> 	add	edx, esi
  5583 0000890D 0305[842C0100]      <1> 	add	eax, [csftdf_sf_mem_addr]
  5584 00008913 29F0                <1> 	sub	eax, esi
  5585 00008915 0F874EFFFFFF        <1>         ja      loc_mcfg_process_next_line_check
  5586                              <1> 
  5587 0000891B E81D000000          <1> 	call	mcfg_deallocate_mem
  5588                              <1>  
  5589 00008920 B94F000000          <1>  	mov	ecx, 79 ; 80 ?
  5590 00008925 BF[1E210100]        <1> 	mov	edi, CommandBuffer
  5591 0000892A 30C0                <1> 	xor	al, al
  5592 0000892C F3AA                <1> 	rep	stosb
  5593                              <1> 
  5594                              <1> 	; 06/05/2016
  5595 0000892E BE[8BEE0000]        <1> 	mov	esi, nextline
  5596 00008933 E8FACBFFFF          <1> 	call	print_msg
  5597 00008938 E931D6FFFF          <1> 	jmp	dos_prompt
  5598                              <1> 
  5599                              <1> mcfg_deallocate_mem:
  5600 0000893D A1[842C0100]        <1> 	mov	eax, [csftdf_sf_mem_addr] ; start address
  5601 00008942 8B0D[882C0100]      <1> 	mov	ecx, [csftdf_sf_mem_bsize] ; block size	
  5602                              <1> 	;call	deallocate_memory_block
  5603                              <1> 	;retn
  5604 00008948 E9E7C6FFFF          <1> 	jmp	deallocate_memory_block
  5605                              <1> 
  5606                              <1> mcfg_read_file_sectors:
  5607                              <1> 	; 14/04/2016
  5608 0000894D 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
  5609 00008951 7669                <1>         jna	short mcfg_read_fs_file_sectors
  5610                              <1> 
  5611                              <1> mcfg_read_fat_file_sectors:
  5612                              <1> 	; return:
  5613                              <1> 	;   CF = 0 & EDX > 0 -> END OF FILE
  5614                              <1> 	;   CF = 0 & EDX = 0 -> not EOF
  5615                              <1> 	;   CF = 1 -> read error (error code in AL)	
  5616                              <1> 
  5617                              <1> mcfg_read_fat_file_secs_0:
  5618 00008953 8B15[5C200100]      <1> 	mov	edx, [MainProgCfg_FileSize]
  5619 00008959 2B15[9C2C0100]      <1> 	sub	edx, [csftdf_sf_rbytes]
  5620 0000895F 3B15[942C0100]      <1> 	cmp	edx, [csftdf_r_size]	
  5621 00008965 7306                <1> 	jnb	short mcfg_read_fat_file_secs_1
  5622 00008967 8915[942C0100]      <1> 	mov	[csftdf_r_size], edx
  5623                              <1> 		
  5624                              <1> mcfg_read_fat_file_secs_1:
  5625 0000896D A1[942C0100]        <1> 	mov	eax, [csftdf_r_size]
  5626 00008972 29D2                <1> 	sub	edx, edx
  5627 00008974 0FB74E11            <1> 	movzx	ecx, word [esi+LD_BPB+BytesPerSec]
  5628 00008978 01C8                <1> 	add	eax, ecx
  5629 0000897A 48                  <1> 	dec	eax
  5630 0000897B F7F1                <1> 	div	ecx
  5631 0000897D 89C1                <1> 	mov	ecx, eax ; sector count
  5632 0000897F A1[8C2C0100]        <1> 	mov	eax, [csftdf_sf_cluster]
  5633                              <1> 
  5634                              <1> 	; EBX = memory block address (current)
  5635                              <1> 	
  5636 00008984 E874230000          <1> 	call	read_fat_file_sectors
  5637 00008989 7230                <1> 	jc	short mcfg_read_fat_file_secs_3
  5638                              <1> 
  5639                              <1> 	; EBX = next memory address
  5640                              <1> 
  5641 0000898B A1[9C2C0100]        <1> 	mov	eax, [csftdf_sf_rbytes]
  5642 00008990 0305[942C0100]      <1> 	add	eax, [csftdf_r_size]
  5643 00008996 8B15[5C200100]      <1> 	mov	edx, [MainProgCfg_FileSize]
  5644 0000899C 39D0                <1> 	cmp	eax, edx
  5645 0000899E 731B                <1> 	jnb	short mcfg_read_fat_file_secs_3 ; edx > 0
  5646 000089A0 A3[9C2C0100]        <1> 	mov	[csftdf_sf_rbytes], eax
  5647                              <1> 
  5648 000089A5 53                  <1> 	push	ebx ; *
  5649                              <1> 	; get next cluster (csftdf_r_size! bytes)
  5650 000089A6 A1[8C2C0100]        <1> 	mov	eax, [csftdf_sf_cluster]
  5651 000089AB E81F210000          <1> 	call	get_next_cluster
  5652 000089B0 5B                  <1> 	pop	ebx ; *
  5653 000089B1 7301                <1> 	jnc	short mcfg_read_fat_file_secs_2
  5654                              <1> 
  5655                              <1> 	;mov	eax, 15h ; Read error !
  5656 000089B3 C3                  <1> 	retn
  5657                              <1> 
  5658                              <1> mcfg_read_fat_file_secs_2:
  5659 000089B4 29D2                <1> 	sub	edx, edx ; 0
  5660 000089B6 A3[8C2C0100]        <1> 	mov	[csftdf_sf_cluster], eax ; next cluster
  5661                              <1> 
  5662                              <1> mcfg_read_fat_file_secs_3:
  5663 000089BB C3                  <1> 	retn
  5664                              <1> 
  5665                              <1> mcfg_read_fs_file_sectors:
  5666 000089BC C3                  <1> 	retn
  5667                              <1> 
  5668                              <1> loc_mcfg_load_fs_file:
  5669 000089BD C3                  <1> 	retn
  5670                              <1> 
  5671                              <1> load_and_execute_file:
  5672                              <1> 	; 11/05/2016
  5673                              <1> 	; 07/05/2016
  5674                              <1> 	; 06/05/2016
  5675                              <1> 	; 24/04/2016
  5676                              <1> 	; 23/04/2016
  5677                              <1> 	; 22/04/2016 (TRDOS 386 = TRDOS v2.0)
  5678                              <1> 	; 05/11/2011 
  5679                              <1> 	; (TRDOS v1, CMDINTR.ASM, 'cmp_cmd_run', 'cmp_cmd_external')
  5680                              <1> 	; ('loc_run_check_filename')
  5681                              <1> 	; 29/08/2011
  5682                              <1> 	; 10/09/2011
  5683                              <1> 	; INPUT->
  5684                              <1> 	;	ESI = Path Name address (CommandBuffer address)
  5685                              <1> 	; OUTPUT ->
  5686                              <1> 	;	none (error message will be shown if an error will occur)
  5687                              <1> 	;
  5688                              <1> 	; (EAX, EBX, ECX, EDX, ESI, EDI, EBP will be changed) 
  5689                              <1> 	;
  5690                              <1> loc_run_check_filename:
  5691 000089BE 803E20              <1> 	cmp	byte [esi], 20h
  5692 000089C1 0F8205E3FFFF        <1> 	jb	loc_cmd_failed
  5693 000089C7 7703                <1> 	ja	short loc_run_check_filename_ok
  5694 000089C9 46                  <1> 	inc	esi
  5695 000089CA EBF2                <1> 	jmp	short loc_run_check_filename
  5696                              <1> 
  5697                              <1> loc_run_check_filename_ok:
  5698 000089CC C605[CF200100]00    <1> 	mov	byte [CmdArgStart], 0 ; reset
  5699 000089D3 56                  <1> 	push	esi ; *
  5700                              <1> loc_run_get_first_arg_pos:
  5701 000089D4 46                  <1> 	inc	esi
  5702 000089D5 8A06                <1> 	mov	al, [esi]
  5703 000089D7 3C20                <1> 	cmp	al, 20h
  5704 000089D9 77F9                <1> 	ja	short loc_run_get_first_arg_pos
  5705 000089DB C60600              <1> 	mov	byte [esi], 0
  5706                              <1> loc_run_get_external_arg_pos:
  5707                              <1> 	; 11/05/2016
  5708 000089DE 46                  <1> 	inc	esi
  5709 000089DF 8A06                <1> 	mov	al, [esi]
  5710 000089E1 3C20                <1> 	cmp	al, 20h
  5711 000089E3 760C                <1> 	jna	short loc_run_parse_path_name
  5712 000089E5 89F0                <1> 	mov	eax, esi
  5713 000089E7 2D[1E210100]        <1> 	sub	eax, CommandBuffer
  5714 000089EC A2[CF200100]        <1> 	mov	byte [CmdArgStart], al
  5715                              <1> loc_run_parse_path_name:
  5716 000089F1 5E                  <1> 	pop	esi ; *
  5717 000089F2 BF[122A0100]        <1> 	mov	edi, FindFile_Drv
  5718 000089F7 E8DC090000          <1> 	call	parse_path_name
  5719 000089FC 0F82CAE2FFFF        <1> 	jc	loc_cmd_failed
  5720                              <1> 
  5721                              <1> loc_run_check_filename_exists:
  5722 00008A02 BE[542A0100]        <1> 	mov	esi, FindFile_Name
  5723 00008A07 803E20              <1> 	cmp	byte [esi], 20h
  5724 00008A0A 0F86BCE2FFFF        <1> 	jna	loc_cmd_failed
  5725                              <1> 
  5726                              <1> loc_run_check_exe_filename_ext:
  5727 00008A10 E897020000          <1> 	call	check_prg_filename_ext
  5728 00008A15 0F82B1E2FFFF        <1> 	jc	loc_cmd_failed
  5729                              <1> 	
  5730                              <1> loc_run_check_exe_filename_ext_ok:
  5731 00008A1B 66A3[1A2D0100]      <1> 	mov	word [EXE_ID], ax
  5732                              <1> 
  5733                              <1> loc_run_drv:
  5734 00008A21 C605[192D0100]00    <1> 	mov	byte [Run_Manual_Path], 0
  5735 00008A28 A1[68200100]        <1> 	mov	eax, [Current_Dir_FCluster]
  5736 00008A2D A3[142D0100]        <1>         mov     [Run_CDirFC], eax
  5737                              <1> 	;
  5738 00008A32 8A35[6E200100]      <1> 	mov	dh, [Current_Drv]
  5739 00008A38 8835[CE280100]      <1> 	mov	[RUN_CDRV], dh
  5740                              <1> 
  5741 00008A3E 8A15[122A0100]      <1> 	mov	dl, [FindFile_Drv]
  5742 00008A44 38F2                <1> 	cmp	dl, dh
  5743 00008A46 7412                <1> 	je	short loc_run_change_directory
  5744                              <1>                
  5745 00008A48 8005[192D0100]02    <1> 	add	byte [Run_Manual_Path], 2
  5746                              <1> 
  5747 00008A4F E8DED3FFFF          <1> 	call	change_current_drive
  5748 00008A54 0F829DE2FFFF        <1> 	jc	loc_run_cmd_failed
  5749                              <1> 
  5750                              <1> loc_run_change_directory:
  5751 00008A5A 803D[132A0100]20    <1> 	cmp	byte [FindFile_Directory], 20h
  5752 00008A61 7623                <1> 	jna	short loc_run_find_executable_file
  5753                              <1> 
  5754 00008A63 FE05[192D0100]      <1> 	inc	byte [Run_Manual_Path]
  5755                              <1>      
  5756 00008A69 FE05[E4DD0000]      <1> 	inc	byte [Restore_CDIR]
  5757                              <1> 
  5758 00008A6F BE[132A0100]        <1> 	mov	esi, FindFile_Directory
  5759 00008A74 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
  5760 00008A76 E849030000          <1> 	call	change_current_directory
  5761 00008A7B 0F8276E2FFFF        <1> 	jc	loc_run_cmd_failed
  5762                              <1> 
  5763                              <1> loc_run_change_prompt_dir_string:
  5764 00008A81 E85E020000          <1> 	call	change_prompt_dir_string
  5765                              <1> 
  5766                              <1> loc_run_find_executable_file:
  5767 00008A86 66C705[182D0100]00- <1> 	mov	word [Run_Auto_Path], 0
  5767 00008A8E 00                  <1>
  5768                              <1> 
  5769                              <1> loc_run_find_executable_file_next:
  5770 00008A8F BE[542A0100]        <1> 	mov	esi, FindFile_Name
  5771                              <1> loc_run_find_program_file_next:
  5772 00008A94 66B80018            <1> 	mov	ax, 1800h ; Except volume label and dirs
  5773 00008A98 E831E7FFFF          <1> 	call	find_first_file
  5774                              <1> 	; ESI = Directory Entry (FindFile_DirEntry) Location
  5775                              <1> 	; EDI = Directory Buffer Directory Entry Location
  5776                              <1> 	; EAX = File size
  5777 00008A9D 0F835C010000        <1> 	jnc	loc_load_and_run_file
  5778                              <1> 	 
  5779 00008AA3 3C02                <1> 	cmp	al, 2 ; file not found
  5780 00008AA5 0F854CE2FFFF        <1> 	jne	loc_run_cmd_failed
  5781                              <1> 
  5782 00008AAB 66A1[1A2D0100]      <1> 	mov	ax, word [EXE_ID]
  5783 00008AB1 80FC2E              <1> 	cmp	ah, '.' ; File name has extension sign
  5784 00008AB4 7424                <1> 	je	short loc_run_check_auto_path
  5785                              <1> 
  5786 00008AB6 08C0                <1> 	or	al, al
  5787 00008AB8 7520                <1> 	jnz	short loc_run_check_auto_path
  5788                              <1> 
  5789 00008ABA 80FC08              <1> 	cmp	ah, 8 ; count of file name chars
  5790 00008ABD 771B                <1> 	ja	short loc_run_check_auto_path
  5791                              <1> 
  5792                              <1> loc_run_change_file_ext_to_prg:
  5793 00008ABF 0FB6DC              <1> 	movzx	ebx, ah ; count of file name chars
  5794 00008AC2 BE[542A0100]        <1> 	mov	esi, FindFile_Name
  5795 00008AC7 01F3                <1> 	add	ebx, esi	
  5796                              <1> 	; 07/05/2016
  5797 00008AC9 C7032E505247        <1> 	mov	dword [ebx],  '.PRG'
  5798 00008ACF 66C705[1A2D0100]50- <1> 	mov	word [EXE_ID], 'P.'
  5798 00008AD7 2E                  <1>
  5799 00008AD8 EBBA                <1> 	jmp	short loc_run_find_program_file_next	
  5800                              <1> 
  5801                              <1> loc_run_check_auto_path:
  5802                              <1> 	; NOTE: /// 07/05/2016 ///
  5803                              <1> 	; If the path is given, value of byte [Run_Manual_Path]
  5804                              <1> 	; will not be ZERO. If so, file searching by using
  5805                              <1> 	; Automatic Path (via 'PATH' environment variable)
  5806                              <1> 	; will not be applicable, because the program file 
  5807                              <1> 	; is already/absolutely not found.
  5808                              <1> 
  5809 00008ADA A0[192D0100]        <1> 	mov	al, [Run_Manual_Path]
  5810 00008ADF 08C0                <1> 	or	al, al
  5811 00008AE1 0F85E5E1FFFF        <1> 	jnz	loc_cmd_failed
  5812                              <1> 
  5813                              <1> loc_run_check_auto_path_again:
  5814 00008AE7 66833D[182D0100]FF  <1> 	cmp	word [Run_Auto_Path], 0FFFFh		 
  5815                              <1> 		; 0FFFFh = Not a valid run path (in ENV block) 
  5816 00008AEF 0F83D7E1FFFF        <1> 	jnb	loc_cmd_failed
  5817                              <1> 	; xor	al, al 
  5818 00008AF5 BE[B0DE0000]        <1> 	mov	esi, Cmd_Path ; 'PATH'
  5819 00008AFA BF[6E210100]        <1> 	mov	edi, TextBuffer
  5820 00008AFF E857F9FFFF          <1> 	call	get_environment_string
  5821 00008B04 730E                <1> 	jnc	short loc_run_chk_filename_ext_again
  5822 00008B06 66C705[182D0100]FF- <1> 	mov	word [Run_Auto_Path], 0FFFFh ; invalid
  5822 00008B0E FF                  <1>
  5823 00008B0F E9B8E1FFFF          <1> 	jmp	loc_cmd_failed
  5824                              <1> 
  5825                              <1> loc_run_chk_filename_ext_again:
  5826 00008B14 89C1                <1> 	mov	ecx, eax ; string length (with zero tail)
  5827 00008B16 49                  <1> 	dec	ecx ; without zero tail
  5828 00008B17 66A1[1A2D0100]      <1> 	mov	ax, [EXE_ID]
  5829 00008B1D 80FC2E              <1> 	cmp	ah, '.'
  5830 00008B20 740E                <1> 	je	short loc_run_chk_auto_path_pos
  5831                              <1> 	 
  5832                              <1> loc_run_change_file_ext_to_noext_again:
  5833 00008B22 0FB6DC              <1> 	movzx	ebx, ah
  5834 00008B25 BE[542A0100]        <1> 	mov	esi, FindFile_Name
  5835 00008B2A 01F3                <1> 	add 	ebx, esi
  5836 00008B2C 29C0                <1> 	sub	eax, eax
  5837 00008B2E 8903                <1> 	mov	[ebx], eax ; 0 ; erase extension (.PRG)
  5838                              <1> 
  5839                              <1> loc_run_chk_auto_path_pos:
  5840                              <1> 	;movzx	eax,  word [Run_Auto_Path]
  5841 00008B30 66A1[182D0100]      <1> 	mov	ax, [Run_Auto_Path]
  5842 00008B36 39C8                <1> 	cmp	eax, ecx ; ecx = string length (except zero tail)
  5843 00008B38 0F838EE1FFFF        <1> 	jnb	loc_cmd_failed
  5844                              <1> 	;or	eax, eax
  5845 00008B3E 6609C0              <1> 	or	ax, ax
  5846 00008B41 7502                <1> 	jnz	short loc_run_auto_path_pos_move
  5847 00008B43 B005                <1> 	mov	al, 5
  5848                              <1> 
  5849                              <1> loc_run_auto_path_pos_move:
  5850 00008B45 89FE                <1> 	mov	esi, edi ; offset TextBuffer
  5851 00008B47 01C6                <1> 	add	esi, eax
  5852                              <1> 
  5853                              <1> loc_run_auto_path_pos_space_loop:
  5854 00008B49 AC                  <1> 	lodsb
  5855 00008B4A 3C20                <1> 	cmp	al, 20h 
  5856 00008B4C 74FB                <1> 	je	short loc_run_auto_path_pos_space_loop
  5857 00008B4E 0F8278E1FFFF        <1> 	jb	loc_cmd_failed 
  5858 00008B54 AA                  <1> 	stosb
  5859                              <1> loc_run_auto_path_pos_move_next: 
  5860 00008B55 AC                  <1> 	lodsb
  5861 00008B56 3C3B                <1> 	cmp	al, ';'
  5862 00008B58 7414                <1> 	je	short loc_run_auto_path_pos_move_last_byte
  5863 00008B5A 3C20                <1> 	cmp	al, 20h
  5864 00008B5C 74F7                <1> 	je	short loc_run_auto_path_pos_move_next
  5865 00008B5E 7203                <1> 	jb	short loc_byte_ptr_end_of_path
  5866 00008B60 AA                  <1> 	stosb
  5867 00008B61 EBF2                <1> 	jmp	short loc_run_auto_path_pos_move_next 
  5868                              <1> 
  5869                              <1> loc_byte_ptr_end_of_path: 
  5870 00008B63 66C705[182D0100]FF- <1> 	mov	word [Run_Auto_Path], 0FFFFh ; end of path
  5870 00008B6B FF                  <1>
  5871 00008B6C EB0D                <1> 	jmp	short loc_run_auto_path_move_ok 
  5872                              <1> 
  5873                              <1> loc_run_auto_path_pos_move_last_byte:
  5874 00008B6E 89F0                <1> 	mov	eax, esi
  5875 00008B70 2D[6E210100]        <1> 	sub	eax, TextBuffer 
  5876 00008B75 66A3[182D0100]      <1> 	mov	[Run_Auto_Path], ax ; next path position
  5877                              <1> 
  5878                              <1> loc_run_auto_path_move_ok:
  5879 00008B7B 4F                  <1> 	dec	edi
  5880 00008B7C B02F                <1> 	mov	al, '/'
  5881 00008B7E 3807                <1> 	cmp	[edi], al
  5882 00008B80 7403                <1> 	je	short loc_run_auto_path_move_file_name
  5883 00008B82 47                  <1> 	inc	edi
  5884 00008B83 8807                <1> 	mov	[edi], al
  5885                              <1> 
  5886                              <1> loc_run_auto_path_move_file_name:
  5887 00008B85 47                  <1> 	inc	edi   
  5888 00008B86 BE[542A0100]        <1> 	mov	esi, FindFile_Name
  5889                              <1> 
  5890                              <1> loc_run_auto_path_move_fn_loop:
  5891 00008B8B AC                  <1> 	lodsb
  5892 00008B8C AA                  <1> 	stosb
  5893 00008B8D 08C0                <1> 	or	al, al
  5894 00008B8F 75FA                <1> 	jnz	short loc_run_auto_path_move_fn_loop
  5895                              <1> 
  5896 00008B91 BE[6E210100]        <1> 	mov	esi, TextBuffer
  5897 00008B96 BF[122A0100]        <1> 	mov	edi, FindFile_Drv
  5898 00008B9B E838080000          <1> 	call	parse_path_name
  5899 00008BA0 0F8226E1FFFF        <1> 	jc	loc_cmd_failed
  5900                              <1> 
  5901 00008BA6 8A35[6E200100]      <1> 	mov	dh, [Current_Drv]
  5902 00008BAC 8A15[122A0100]      <1> 	mov	dl, [FindFile_Drv]
  5903 00008BB2 38F2                <1> 	cmp	dl, dh
  5904 00008BB4 740B                <1> 	je	short loc_run_change_directory_again
  5905                              <1>                
  5906 00008BB6 E877D2FFFF          <1> 	call	change_current_drive
  5907 00008BBB 0F8236E1FFFF        <1> 	jc	loc_run_cmd_failed
  5908                              <1> 
  5909                              <1> loc_run_change_directory_again:
  5910 00008BC1 803D[132A0100]20    <1> 	cmp	byte [FindFile_Directory], 20h
  5911 00008BC8 761D                <1> 	jna	short loc_load_executable_cdir_chk_again
  5912                              <1> 
  5913 00008BCA FE05[E4DD0000]      <1> 	inc	byte [Restore_CDIR]
  5914 00008BD0 BE[132A0100]        <1> 	mov	esi, FindFile_Directory
  5915 00008BD5 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
  5916 00008BD7 E8E8010000          <1> 	call	change_current_directory
  5917 00008BDC 0F8215E1FFFF        <1> 	jc	loc_run_cmd_failed
  5918                              <1> 
  5919                              <1> loc_run_chg_prompt_dir_str_again:
  5920 00008BE2 E8FD000000          <1> 	call	change_prompt_dir_string
  5921                              <1> 
  5922                              <1> loc_load_executable_cdir_chk_again:
  5923 00008BE7 A1[68200100]        <1> 	mov	eax, [Current_Dir_FCluster]
  5924 00008BEC 3B05[142D0100]      <1> 	cmp	eax, [Run_CDirFC]
  5925 00008BF2 0F8597FEFFFF        <1> 	jne	loc_run_find_executable_file_next
  5926 00008BF8 30C0                <1> 	xor	al, al ; 0
  5927 00008BFA E9E8FEFFFF          <1> 	jmp	loc_run_check_auto_path_again
  5928                              <1> 
  5929                              <1> loc_load_and_run_file:
  5930                              <1> 	; 23/04/2016
  5931 00008BFF BE[542A0100]        <1> 	mov	esi, FindFile_Name
  5932 00008C04 BF[6E210100]        <1> 	mov	edi, TextBuffer
  5933                              <1> 
  5934                              <1>  	; 24/04/2016
  5935 00008C09 31D2                <1> 	xor	edx, edx
  5936 00008C0B 668915[06310100]    <1> 	mov	word [argc], dx ; 0
  5937 00008C12 8915[B0300100]      <1> 	mov	dword [u.nread], edx ; 0
  5938                              <1> 
  5939                              <1> loc_load_and_run_file_1:
  5940 00008C18 AC                  <1> 	lodsb	
  5941 00008C19 AA                  <1> 	stosb
  5942 00008C1A FF05[B0300100]      <1> 	inc	dword [u.nread]
  5943 00008C20 20C0                <1> 	and	al, al
  5944 00008C22 75F4                <1> 	jnz 	short loc_load_and_run_file_1
  5945                              <1> 	
  5946 00008C24 A0[CF200100]        <1> 	mov	al, [CmdArgStart]
  5947 00008C29 20C0                <1> 	and	al, al
  5948 00008C2B 7445                <1> 	jz	short loc_load_and_run_file_7
  5949                              <1> 
  5950 00008C2D 0FB6F0              <1> 	movzx	esi, al ; 11/05/2016
  5951 00008C30 B950000000          <1> 	mov	ecx, 80
  5952 00008C35 29F1                <1> 	sub	ecx, esi
  5953 00008C37 81C6[1E210100]      <1> 	add	esi, CommandBuffer
  5954                              <1> 
  5955 00008C3D 66FF05[06310100]    <1> 	inc	word [argc] ; 11/05/2016
  5956                              <1> 
  5957                              <1> loc_load_and_run_file_2:
  5958 00008C44 AC                  <1> 	lodsb
  5959 00008C45 3C20                <1> 	cmp	al, 20h
  5960 00008C47 7717                <1> 	ja	short loc_load_and_run_file_5	
  5961 00008C49 721E                <1> 	jb	short loc_load_and_run_file_6
  5962                              <1> 
  5963                              <1> loc_load_and_run_file_3:
  5964 00008C4B 803E20              <1> 	cmp	byte [esi], 20h
  5965 00008C4E 7707                <1> 	ja	short loc_load_and_run_file_4
  5966 00008C50 7217                <1> 	jb	short loc_load_and_run_file_6
  5967 00008C52 46                  <1> 	inc	esi
  5968 00008C53 E2F6                <1> 	loop	loc_load_and_run_file_3
  5969 00008C55 EB12                <1> 	jmp	short loc_load_and_run_file_6
  5970                              <1> 
  5971                              <1> loc_load_and_run_file_4:
  5972 00008C57 28C0                <1> 	sub	al, al ; 0
  5973 00008C59 66FF05[06310100]    <1> 	inc	word [argc]
  5974                              <1> loc_load_and_run_file_5:
  5975 00008C60 AA                  <1> 	stosb
  5976 00008C61 FF05[B0300100]      <1> 	inc	dword [u.nread]
  5977 00008C67 E2DB                <1> 	loop	loc_load_and_run_file_2
  5978                              <1> 			
  5979                              <1> loc_load_and_run_file_6:
  5980 00008C69 30C0                <1> 	xor	al, al ; 0
  5981 00008C6B AA                  <1> 	stosb
  5982 00008C6C FF05[B0300100]      <1> 	inc	dword [u.nread]
  5983                              <1> loc_load_and_run_file_7:
  5984 00008C72 8807                <1> 	mov 	[edi], al ; 0
  5985 00008C74 66FF05[06310100]    <1> 	inc	word [argc] ; 24/04/2016
  5986 00008C7B FF05[B0300100]      <1> 	inc	dword [u.nread] ; 24/04/2016
  5987 00008C81 BE[6E210100]        <1> 	mov	esi, TextBuffer
  5988 00008C86 8B15[802A0100]      <1> 	mov	edx, [FindFile_DirEntry+DirEntry_FileSize]
  5989 00008C8C 66A1[782A0100]      <1> 	mov	ax, [FindFile_DirEntry+DirEntry_FstClusHI]
  5990 00008C92 66C1E010            <1> 	shl	ax, 16
  5991 00008C96 66A1[7E2A0100]      <1> 	mov	ax, [FindFile_DirEntry+DirEntry_FstClusLO]
  5992                              <1> 	; EAX = First Cluster number
  5993                              <1> 	; EDX = File Size
  5994                              <1> 	; ESI = Argument list address
  5995                              <1> 	; [argc] = argument count
  5996                              <1> 	; [u.nread] = argument list length
  5997 00008C9C E8C4440000          <1> 	call	load_and_run_file ; trdosk6.s
  5998 00008CA1 0F8250E0FFFF        <1>         jc      loc_run_cmd_failed
  5999                              <1> loc_load_and_run_file_8: ; 06/05/2016
  6000 00008CA7 E94AE9FFFF          <1> 	jmp	loc_file_rw_restore_retn
  6001                              <1> 
  6002                              <1> check_prg_filename_ext:
  6003                              <1> 	; 23/04/2016 (TRDOS 386 = TRDOS v2.0)
  6004                              <1> 	; 10/09/2011 
  6005                              <1> 	; (TRDOS v1, CMDINTR.ASM, 'proc_check_exe_filename_ext')
  6006                              <1> 	; 14/11/2009
  6007                              <1> 	; INPUT -> 
  6008                              <1> 	;	ESI = Dot File Name
  6009                              <1> 	; OUTPUT ->
  6010                              <1> 	;     cf = 0 -> EXE_ID in AL
  6011                              <1> 	;	ESI = Last char + 1 position
  6012                              <1> 	;     cf = 1 -> Invalid executable file name
  6013                              <1> 	;	or no file name extension if AH<=8
  6014                              <1> 	;	AL = Last file name char     
  6015                              <1> 	;     cf = 0 -> AL='P' (PRG), AL=0 (no extension)
  6016                              <1> 	;
  6017                              <1> 	; (Modified registers: EAX, ESI)
  6018                              <1>   
  6019 00008CAC 30E4                <1> 	xor	ah, ah
  6020                              <1> loc_run_check_filename_ext:	
  6021 00008CAE AC                  <1> 	lodsb
  6022 00008CAF 3C21                <1> 	cmp	al, 21h
  6023 00008CB1 7229                <1> 	jb	short loc_check_exe_fn_retn 
  6024 00008CB3 FEC4                <1> 	inc	ah
  6025 00008CB5 3C2E                <1> 	cmp	al, '.'
  6026 00008CB7 75F5                <1> 	jne	short loc_run_check_filename_ext	
  6027                              <1> 		 
  6028                              <1> loc_run_check_filename_ext_dot:
  6029 00008CB9 80FC02              <1> 	cmp	ah, 2 ; .??? is not valid
  6030 00008CBC 88C4                <1> 	mov	ah, al ; '.' 
  6031 00008CBE 7219                <1> 	jb	short loc_check_prg_fn_retn
  6032                              <1> 
  6033                              <1> loc_run_check_filename_ext_dot_ok:
  6034 00008CC0 AC                  <1> 	lodsb
  6035 00008CC1 24DF                <1> 	and	al, 0DFh 
  6036                              <1> 
  6037                              <1> loc_run_check_filename_ext_prg:
  6038 00008CC3 3C50                <1> 	cmp	al, 'P'
  6039 00008CC5 7212                <1> 	jb	short loc_check_prg_fn_retn
  6040 00008CC7 7711                <1> 	ja	short loc_check_prg_fn_stc
  6041 00008CC9 AC                  <1> 	lodsb
  6042 00008CCA 24DF                <1> 	and	al, 0DFh 
  6043 00008CCC 3C52                <1> 	cmp	al, 'R'
  6044 00008CCE 750A                <1> 	jne	short loc_check_prg_fn_stc
  6045 00008CD0 AC                  <1> 	lodsb
  6046 00008CD1 24DF                <1> 	and	al, 0DFh
  6047 00008CD3 3C47                <1> 	cmp	al, 'G'
  6048 00008CD5 7503                <1> 	jne	short loc_check_prg_fn_stc
  6049                              <1> 
  6050 00008CD7 B050                <1> 	mov	al, 'P'
  6051                              <1> loc_check_prg_fn_retn:
  6052 00008CD9 C3                  <1> 	retn
  6053                              <1> 
  6054                              <1> loc_check_prg_fn_stc:
  6055 00008CDA F9                  <1> 	stc
  6056 00008CDB C3                  <1> 	retn
  6057                              <1>  
  6058                              <1> loc_check_exe_fn_retn:
  6059 00008CDC 28C0                <1> 	sub	al, al ; 0
  6060 00008CDE C3                  <1> 	retn
  6061                              <1>               
  6062                              <1> find_and_list_files:
  6063 00008CDF C3                  <1> 	retn
  6064                              <1> set_exec_arguments:
  6065 00008CE0 C3                  <1> 	retn
  6066                              <1> delete_fs_directory:
  6067 00008CE1 31C0                <1> 	xor eax, eax
  6068 00008CE3 C3                  <1> 	retn
  1921                                  %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: 13/05/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> ; 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> 	; 24/01/2016 (TRDOS 386 = TRDOS v2.0)
    20                              <1> 	; 27/03/2011
    21                              <1> 	; 09/10/2009
    22                              <1> 	; INPUT/OUTPUT => none
    23                              <1> 	; this procedure changes current directory string/text  
    24                              <1> 	; 2005
    25                              <1> 
    26 00008CE4 BF[72200100]        <1> 	mov	edi, Current_Directory
    27 00008CE9 8A25[6C200100]      <1> 	mov	ah, [Current_Dir_Level]
    28 00008CEF BE[CF280100]        <1> 	mov	esi, PATH_Array
    29 00008CF4 E807000000          <1> 	call	set_current_directory_string
    30 00008CF9 880D[CD200100]      <1> 	mov	[Current_Dir_StrLen], cl
    31                              <1> 
    32 00008CFF C3                  <1> 	retn
    33                              <1> 
    34                              <1> set_current_directory_string:
    35                              <1> 	; 24/01/2016 (TRDOS 386 = TRDOS v2.0)
    36                              <1> 	; 27/03/2011
    37                              <1> 	; 09/10/2009
    38                              <1> 	; INPUT:
    39                              <1> 	;    ESI = Path Array Address 
    40                              <1> 	;    EDI = Current Directory String Buffer
    41                              <1> 	;    AH = Current Directory Level
    42                              <1> 	; OUTPUT => EAX, EBX, ESI will be changed
    43                              <1> 	;    EDI will be same with input
    44                              <1> 	;    ECX = Current Directory String Length 
    45                              <1> 
    46 00008D00 57                  <1> 	push    edi
    47 00008D01 80FC00              <1> 	cmp     ah, 0
    48 00008D04 7652                <1> 	jna	short pass_write_path
    49 00008D06 83C610              <1> 	add	esi, 16
    50 00008D09 89F3                <1> 	mov	ebx, esi
    51                              <1> loc_write_path:
    52 00008D0B B908000000          <1> 	mov	ecx, 8
    53                              <1> path_write_dirname1:
    54 00008D10 AC                  <1> 	lodsb
    55 00008D11 3C20                <1> 	cmp	al, 20h
    56 00008D13 7612                <1> 	jna	short pass_write_dirname1
    57 00008D15 AA                  <1> 	stosb
    58 00008D16 81FF[CC200100]      <1> 	cmp	edi, End_Of_Current_Dir_Str
    59 00008D1C 733A                <1> 	jnb	short pass_write_path
    60 00008D1E E2F0                <1> 	loop	path_write_dirname1
    61 00008D20 803E20              <1> 	cmp	byte [esi], 20h
    62 00008D23 7624                <1> 	jna	short pass_write_dirname2
    63 00008D25 EB0A                <1> 	jmp     short loc_put_dot_cont_ext
    64                              <1> pass_write_dirname1:
    65 00008D27 89DE                <1> 	mov	esi, ebx
    66 00008D29 83C608              <1> 	add	esi, 8
    67 00008D2C 803E20              <1> 	cmp	byte [esi], 20h
    68 00008D2F 7618                <1> 	jna	short pass_write_dirname2
    69                              <1> loc_put_dot_cont_ext:
    70 00008D31 C6072E              <1> 	mov	byte [edi], "."
    71                              <1> 	;mov	ecx, 3
    72 00008D34 B103                <1> 	mov	cl, 3
    73                              <1> loc_check_dir_name_ext:
    74 00008D36 AC                  <1> 	lodsb
    75 00008D37 47                  <1> 	inc	edi
    76 00008D38 3C20                <1> 	cmp	al, 20h
    77 00008D3A 760D                <1> 	jna	short pass_write_dirname2
    78 00008D3C 8807                <1> 	mov	[edi], al
    79 00008D3E 81FF[CC200100]      <1> 	cmp	edi, End_Of_Current_Dir_Str
    80 00008D44 7312                <1> 	jnb	short pass_write_path
    81 00008D46 E2EE                <1> 	loop    loc_check_dir_name_ext
    82 00008D48 47                  <1> 	inc	edi
    83                              <1> pass_write_dirname2:
    84 00008D49 FECC                <1> 	dec	ah
    85 00008D4B 740B                <1> 	jz      short pass_write_path
    86 00008D4D 83C310              <1> 	add	ebx, 16
    87 00008D50 89DE                <1> 	mov	esi, ebx
    88 00008D52 C6072F              <1> 	mov	byte [edi],"/"
    89 00008D55 47                  <1> 	inc	edi
    90 00008D56 EBB3                <1> 	jmp	short loc_write_path
    91                              <1> pass_write_path:
    92 00008D58 C60700              <1> 	mov	byte [edi], 0
    93 00008D5B 47                  <1> 	inc	edi
    94 00008D5C 89F9                <1> 	mov	ecx, edi
    95 00008D5E 5F                  <1> 	pop	edi
    96 00008D5F 29F9                <1> 	sub	ecx, edi
    97                              <1> 	; ECX = Current Directory String Length
    98 00008D61 C3                  <1> 	retn
    99                              <1> 
   100                              <1> get_current_directory:
   101                              <1> 	; 14/02/2016
   102                              <1> 	; 24/01/2016 (TRDOS 386 = TRDOS v2.0)
   103                              <1> 	; 27/03/2011
   104                              <1> 	;
   105                              <1> 	; INPUT-> ESI = Current Directory Buffer
   106                              <1> 	;         DL = TRDOS Logical Dos Drive Number + 1
   107                              <1> 	;              (0= Default/Current Drive)
   108                              <1> 	;           
   109                              <1> 	;   Note: Required dir buffer length may be <= 92 bytes
   110                              <1> 	;         for TRDOS (7*12 name chars + 7 slash + 0)
   111                              <1> 	; OUTPUT ->  ESI = Current Directory Buffer
   112                              <1> 	;            EAX, EBX, ECX, EDX, EDI will be changed
   113                              <1> 	;            CX/CL = Current Directory String Length
   114                              <1> 	;	     DL = Drive Number (0 based)
   115                              <1> 	;            (If input is 0, output is current drv number) 
   116                              <1> 	;            DH = same with input 
   117                              <1> 	;   cf = 0 -> AL = 0
   118                              <1> 	;   cf = 1 -> error code in AL 
   119                              <1>               
   120                              <1> loc_get_current_drive_0:
   121 00008D62 80FA00              <1> 	cmp	dl, 0
   122 00008D65 7708                <1> 	ja	short loc_get_current_drive_1
   123 00008D67 8A15[6E200100]      <1> 	mov	dl, [Current_Drv]
   124 00008D6D EB17                <1> 	jmp	short loc_get_current_drive_2
   125                              <1> loc_get_current_drive_1:
   126 00008D6F FECA                <1> 	dec 	dl
   127 00008D71 3A15[E3DD0000]      <1> 	cmp	dl, [Last_DOS_DiskNo]
   128 00008D77 760D                <1> 	jna	short loc_get_current_drive_2
   129 00008D79 B80F000000          <1> 	mov	eax, 0Fh ; Invalid drive
   130 00008D7E F5                  <1> 	cmc 	; stc
   131 00008D7F C3                  <1> 	retn
   132                              <1> 
   133                              <1> loc_get_current_drive_not_ready_retn:
   134 00008D80 5E                  <1> 	pop	esi
   135                              <1> 	;mov	eax, 15h
   136 00008D81 66B81500            <1> 	mov	ax, 15h ; Drive not ready
   137 00008D85 C3                  <1> 	retn  
   138                              <1>  
   139                              <1> loc_get_current_drive_2:
   140 00008D86 31C0                <1> 	xor	eax, eax
   141 00008D88 88D4                <1> 	mov	ah, dl
   142 00008D8A 56                  <1> 	push	esi
   143 00008D8B BE00010900          <1> 	mov	esi, Logical_DOSDisks
   144 00008D90 01C6                <1> 	add	esi, eax
   145 00008D92 8A06                <1> 	mov	al, [esi+LD_Name] 
   146 00008D94 3C41                <1> 	cmp	al, 'A'
   147 00008D96 72E8                <1> 	jb	short loc_get_current_drive_not_ready_retn
   148                              <1> 
   149 00008D98 8A667F              <1> 	mov	ah, [esi+LD_CDirLevel]
   150 00008D9B 08E4                <1> 	or	ah, ah
   151 00008D9D 7506                <1> 	jnz	short loc_get_current_drive_3
   152                              <1> 
   153                              <1> 	;xor	ah, ah ; mov ah, 0
   154 00008D9F 8826                <1> 	mov	[esi], ah
   155 00008DA1 31C9                <1> 	xor	ecx, ecx
   156 00008DA3 EB1C                <1> 	jmp	short loc_get_current_drive_4
   157                              <1> 
   158                              <1> loc_get_current_drive_3:
   159 00008DA5 BF[CF280100]        <1>         mov     edi, PATH_Array
   160 00008DAA 57                  <1> 	push	edi
   161 00008DAB 81C680000000        <1> 	add	esi, LD_CurrentDirectory
   162 00008DB1 B920000000          <1> 	mov	ecx, 32
   163 00008DB6 F3A5                <1> 	rep	movsd
   164 00008DB8 5E                  <1> 	pop	esi ; Path Array Address
   165 00008DB9 5F                  <1> 	pop	edi ; pushed esi (current dir buffer offset) 
   166                              <1> 	;
   167 00008DBA E841FFFFFF          <1> 	call	set_current_directory_string
   168 00008DBF 89FE                <1> 	mov	esi, edi
   169                              <1> 
   170                              <1> loc_get_current_drive_4:
   171 00008DC1 30C0                <1> 	xor	al, al
   172 00008DC3 C3                  <1> 	retn
   173                              <1> 
   174                              <1> change_current_directory:
   175                              <1> 	; 19/02/2016
   176                              <1> 	; 11/02/2016
   177                              <1> 	; 10/02/2016
   178                              <1> 	; 08/02/2016
   179                              <1> 	; 06/02/2016 (TRDOS 386 = TRDOS v2.0)
   180                              <1> 	; 18/09/2011 (DIR.ASM, 09/10/2011)	
   181                              <1> 	; 04/10/2009
   182                              <1> 	; 2005
   183                              <1> 	; INPUT -> 
   184                              <1> 	;	ESI = Directory string
   185                              <1> 	;	ah = CD command (CDh = save current dir string)
   186                              <1> 	; OUTPUT -> 
   187                              <1> 	; 	EDI = DOS Drive Description Table
   188                              <1> 	; 	cf = 1 -> error
   189                              <1> 	;	   EAX = Error code
   190                              <1> 	;	cf = 0 -> succesful
   191                              <1> 	;	   ESI = PATH_Array
   192                              <1> 	;	   EAX = Current Directory First Cluster
   193                              <1> 	;
   194                              <1> 	; (EAX, EBX, ECX, EDX, ESI, EDI will be changed)
   195                              <1> 	
   196 00008DC4 8825[5D290100]      <1> 	mov	[CD_COMMAND], ah
   197 00008DCA 803E2F              <1> 	cmp	byte [esi], '/'
   198 00008DCD 7505                <1> 	jne	short loc_ccd_cdir_level
   199 00008DCF 46                  <1> 	inc	esi
   200 00008DD0 30C0                <1> 	xor	al, al
   201 00008DD2 EB05                <1> 	jmp	short loc_ccd_parse_path_name
   202                              <1> loc_ccd_cdir_level:
   203 00008DD4 A0[6C200100]        <1> 	mov	al, [Current_Dir_Level]
   204                              <1> loc_ccd_parse_path_name:
   205 00008DD9 88C4                <1> 	mov	ah, al
   206 00008DDB BF[CF280100]        <1> 	mov	edi, PATH_Array
   207                              <1> 
   208                              <1> ; Reset directory levels > cdir level
   209                              <1> 	; is this required !?
   210                              <1> 	;
   211                              <1> 	; Relations:
   212                              <1> 	; MAINPROG.ASM (pass_ccdrv_reset_cdir_FAT_fcluster)
   213                              <1> 	; proc_parse_dir_name,
   214                              <1> 	; proc_change_current_directory (this procedure)
   215                              <1> 	; proc_change_prompt_dir_string 
   216                              <1>  
   217 00008DE0 0FB6C8              <1> 	movzx	ecx, al
   218 00008DE3 FEC1                <1> 	inc	cl
   219 00008DE5 C0E104              <1> 	shl	cl, 4
   220 00008DE8 01CF                <1> 	add	edi, ecx
   221 00008DEA B107                <1> 	mov	cl, 7
   222 00008DEC 28C1                <1> 	sub	cl, al
   223 00008DEE C0E102              <1> 	shl	cl, 2
   224 00008DF1 89C3                <1> 	mov	ebx, eax
   225 00008DF3 31C0                <1> 	xor	eax, eax ; 0
   226 00008DF5 F3AB                <1> 	rep	stosd
   227 00008DF7 89D8                <1> 	mov	eax, ebx
   228                              <1> 
   229 00008DF9 BF[CF280100]        <1> 	mov	edi, PATH_Array
   230                              <1> 
   231 00008DFE 803E20              <1> 	cmp	byte [esi], 20h
   232 00008E01 F5                  <1> 	cmc
   233 00008E02 7305                <1> 	jnc	short pass_ccd_parse_dir_name
   234                              <1> 
   235                              <1> 		; ESI = Path name
   236                              <1> 		; AL = CCD_Level
   237 00008E04 E872010000          <1>         call    parse_dir_name
   238                              <1> 		; AL = CCD_Level 
   239                              <1> 		; AH = Last_Dir_Level
   240                              <1> 		; (EDI = PATH_Array)
   241                              <1> 
   242                              <1> pass_ccd_parse_dir_name:
   243 00008E09 9C                  <1> 	pushf
   244                              <1> 
   245                              <1> 	;mov	[CCD_Level], al
   246                              <1>         ;mov	[Last_Dir_Level], ah
   247 00008E0A 66A3[53290100]      <1> 	mov	[CCD_Level], ax
   248                              <1> 
   249 00008E10 31DB                <1> 	xor	ebx, ebx
   250 00008E12 8A3D[6E200100]      <1> 	mov	bh, [Current_Drv]
   251 00008E18 BE00010900          <1> 	mov	esi, Logical_DOSDisks
   252 00008E1D 01DE                <1> 	add	esi, ebx
   253                              <1> 
   254 00008E1F 9D                  <1> 	popf 
   255 00008E20 720A                <1> 	jc	short loc_ccd_bad_path_name_retn
   256                              <1> 
   257 00008E22 8935[4F290100]      <1> 	mov	[CCD_DriveDT], esi
   258                              <1> 
   259 00008E28 3C07                <1> 	cmp	al, 7
   260 00008E2A 7209                <1> 	jb	short loc_ccd_load_child_dir
   261                              <1> 
   262                              <1> loc_ccd_bad_path_name_retn:
   263 00008E2C 87F7                <1> 	xchg	esi, edi
   264                              <1> 	; DOS Error Code 
   265 00008E2E B818000000          <1> 	mov	eax, 18h ; Bad request structure length 
   266 00008E33 F9                  <1> 	stc
   267                              <1> loc_ccd_retn_p:
   268 00008E34 C3                  <1> 	retn
   269                              <1> 
   270                              <1> loc_ccd_load_child_dir:
   271                              <1> 	; AL = CCD_Level
   272 00008E35 08C0                <1> 	or	al, al
   273 00008E37 7468                <1> 	jz	short loc_ccd_load_root_dir
   274                              <1> 
   275 00008E39 6689C1              <1> 	mov	cx, ax
   276 00008E3C C0E004              <1> 	shl	al, 4
   277 00008E3F 0FB6F0              <1> 	movzx	esi, al
   278 00008E42 01FE                <1>      	add	esi, edi  ; offset PATH_Array
   279                              <1> 
   280 00008E44 8B460C              <1> 	mov	eax, [esi+12]
   281 00008E47 38E9                <1> 	cmp	cl, ch
   282 00008E49 0F84FA000000        <1>         je      loc_ccd_load_sub_directory
   283 00008E4F A3[68200100]        <1> 	mov	[Current_Dir_FCluster], eax
   284                              <1> 
   285                              <1> loc_ccd_load_child_dir_next:
   286 00008E54 83C610              <1> 	add	esi, 16 ; DOS DirEntry Format FileName Address
   287                              <1> 
   288                              <1>  	; Directory attribute : 10h
   289 00008E57 B010                <1> 	mov	al, 00010000b ; 10h (Attrib AND mask)
   290                              <1> 	;mov	ah, 11001000b ; C8h
   291                              <1> 	; Volume name attribute: 8h
   292 00008E59 B408                <1> 	mov	ah, 00001000b ; 08h (Attrib NAND, AND --> zero mask)
   293                              <1> 
   294 00008E5B 6631C9              <1> 	xor	cx, cx  
   295 00008E5E E8B5010000          <1> 	call	locate_current_dir_file
   296 00008E63 7353                <1> 	jnc	short loc_ccd_set_dir_cluster_ptr
   297                              <1> 
   298                              <1> 	 ; 19/02/2016
   299                              <1> 	;mov	edi, [CCD_DriveDT]
   300 00008E65 8A25[53290100]      <1> 	mov	ah, [CCD_Level]
   301 00008E6B 803D[5D290100]CD    <1> 	cmp	byte [CD_COMMAND], 0CDh ;'CD' command or another
   302 00008E72 7509                <1> 	jne	short loc_ccd_load_child_dir_err
   303                              <1> 	; It is better to save recent successful part 
   304                              <1> 	; of the (requested) path as current directory.
   305                              <1> 	; (Otherwise the path would be reset to back
   306                              <1> 	; on the next 'CD' command.)
   307 00008E74 88E1                <1> 	mov	cl, ah
   308 00008E76 50                  <1> 	push	eax
   309 00008E77 E8E3000000          <1> 	call	loc_ccd_save_current_dir
   310 00008E7C 58                  <1> 	pop	eax
   311                              <1> loc_ccd_load_child_dir_err:            
   312 00008E7D 3C03                <1> 	cmp	al, 3	; AL = 2 => File not found error
   313 00008E7F 7202                <1> 	jb	short loc_ccd_path_not_found_retn
   314 00008E81 F9                  <1> 	stc
   315 00008E82 C3                  <1> 	retn
   316                              <1> 
   317                              <1> loc_ccd_path_not_found_retn:
   318 00008E83 B003                <1> 	mov	al, 3	; Path not found
   319 00008E85 C3                  <1> 	retn
   320                              <1> 
   321                              <1> loc_ccd_load_FAT_root_dir:
   322 00008E86 803D[6D200100]02    <1> 	cmp	byte [Current_FATType], 2
   323 00008E8D 776B                <1> 	ja	short loc_ccd_load_FAT32_root_dir
   324                              <1> 
   325                              <1> 	;mov	esi, [CCD_DriveDT]
   326                              <1> 	;push	esi
   327 00008E8F E8961D0000          <1> 	call	load_FAT_root_directory
   328                              <1> 	;pop	edi ; Dos Drv Description Table
   329                              <1> 
   330 00008E94 89F7                <1> 	mov	edi, esi
   331 00008E96 BE[CF280100]        <1> 	mov	esi, PATH_Array
   332 00008E9B 7297                <1> 	jc	short loc_ccd_retn_p
   333                              <1> 
   334 00008E9D 31C0                <1> 	xor	eax, eax
   335 00008E9F EB78                <1>         jmp	short loc_ccd_set_cdfc
   336                              <1> 
   337                              <1> loc_ccd_load_root_dir:
   338 00008EA1 803D[6D200100]01    <1> 	cmp	byte [Current_FATType], 1
   339 00008EA8 73DC                <1> 	jnb	short loc_ccd_load_FAT_root_dir
   340                              <1> 
   341                              <1> loc_ccd_load_FS_root_dir:
   342 00008EAA E8421E0000          <1> 	call	load_FS_root_directory
   343 00008EAF EB5C                <1> 	jmp	short pass_ccd_load_FAT_sub_directory
   344                              <1> 
   345                              <1> loc_ccd_load_FS_sub_directory_next:
   346 00008EB1 E83C1E0000          <1> 	call	load_FS_sub_directory
   347 00008EB6 EB1F                <1> 	jmp	short pass_ccd_set_dir_cluster_ptr  
   348                              <1> 
   349                              <1> loc_ccd_set_dir_cluster_ptr:
   350                              <1> 	; EDI = Directory Entry
   351 00008EB8 668B4714            <1> 	mov	ax, [edi+20] ; First Cluster High Word
   352 00008EBC C1E010              <1> 	shl	eax, 16
   353 00008EBF 668B471A            <1> 	mov	ax, [edi+26] ; First Cluster Low Word
   354                              <1> 
   355 00008EC3 8B35[4F290100]      <1> 	mov	esi, [CCD_DriveDT]
   356 00008EC9 803D[6D200100]01    <1> 	cmp	byte [Current_FATType], 1
   357 00008ED0 72DF                <1> 	jb	short loc_ccd_load_FS_sub_directory_next
   358                              <1> 	;push	esi
   359 00008ED2 E8DE1D0000          <1> 	call	load_FAT_sub_directory
   360                              <1> 	;pop	edi ; Dos Drv Description Table
   361                              <1> 
   362                              <1> pass_ccd_set_dir_cluster_ptr:
   363                              <1> 	;mov	edi, esi
   364 00008ED7 BE[CF280100]        <1> 	mov	esi, PATH_Array
   365 00008EDC 7264                <1> 	jc	short loc_ccd_retn_c
   366                              <1> 
   367 00008EDE A1[9D280100]        <1> 	mov	eax, [DirBuff_Cluster]
   368                              <1> 
   369 00008EE3 FE05[53290100]      <1> 	inc	byte [CCD_Level]
   370 00008EE9 0FB61D[53290100]    <1> 	movzx	ebx, byte [CCD_Level]
   371 00008EF0 C0E304              <1> 	shl	bl, 4 ; * 16 (<= 128)   
   372 00008EF3 01DE                <1> 	add	esi, ebx ; 19/02/2016
   373 00008EF5 89460C              <1> 	mov	[esi+12], eax
   374 00008EF8 EB1F                <1> 	jmp	short loc_ccd_set_cdfc
   375                              <1> 
   376                              <1> loc_ccd_load_FAT32_root_dir:
   377 00008EFA BE[CF280100]        <1> 	mov	esi, PATH_Array
   378 00008EFF 8B460C              <1> 	mov	eax, [esi+12]
   379 00008F02 8B35[4F290100]      <1> 	mov	esi, [CCD_DriveDT]
   380                              <1>  
   381                              <1> loc_ccd_load_FAT_sub_directory:
   382                              <1> 	;push	esi
   383 00008F08 E8A81D0000          <1> 	call	load_FAT_sub_directory
   384                              <1> 	;pop	edi ; Dos Drv Description Table
   385                              <1> 
   386                              <1> pass_ccd_load_FAT_sub_directory:
   387                              <1> 	;mov	edi, esi
   388 00008F0D BE[CF280100]        <1> 	mov	esi, PATH_Array
   389 00008F12 722E                <1> 	jc	short loc_ccd_retn_c
   390                              <1> 
   391 00008F14 A1[9D280100]        <1> 	mov	eax, [DirBuff_Cluster]
   392                              <1> 
   393                              <1> loc_ccd_set_cdfc:
   394 00008F19 8A0D[53290100]      <1> 	mov	cl, [CCD_Level]
   395 00008F1F 880D[6C200100]      <1> 	mov	[Current_Dir_Level], cl
   396 00008F25 A3[68200100]        <1> 	mov	[Current_Dir_FCluster], eax
   397                              <1> 
   398 00008F2A 8A2D[54290100]      <1> 	mov	ch, [Last_Dir_Level]
   399 00008F30 38E9                <1> 	cmp	cl, ch 
   400 00008F32 0F821CFFFFFF        <1> 	jb	loc_ccd_load_child_dir_next
   401                              <1> 	
   402 00008F38 803D[5D290100]CD    <1> 	cmp	byte [CD_COMMAND], 0CDh ;'CD' command or another
   403 00008F3F 741E                <1> 	je	short loc_ccd_save_current_dir
   404                              <1> 
   405                              <1>         ; jne -> don't save, restore (the previous cdir) later !
   406                              <1>         ; (saving the cdir would prevent previous cdir restoration!)
   407                              <1> 
   408 00008F41 F8                  <1> 	clc
   409                              <1> 
   410                              <1> loc_ccd_retn_c:
   411 00008F42 8B3D[4F290100]      <1> 	mov	edi, [CCD_DriveDT]
   412 00008F48 C3                  <1> 	retn
   413                              <1> 
   414                              <1> loc_ccd_load_sub_directory:
   415 00008F49 8B35[4F290100]      <1> 	mov	esi, [CCD_DriveDT]
   416 00008F4F 803D[6D200100]01    <1> 	cmp	byte [Current_FATType], 1
   417 00008F56 73B0                <1> 	jnb	short loc_ccd_load_FAT_sub_directory 
   418 00008F58 E8951D0000          <1> 	call	load_FS_sub_directory
   419 00008F5D EBAE                <1> 	jmp	short pass_ccd_load_FAT_sub_directory 
   420                              <1> 
   421                              <1> loc_ccd_save_current_dir:
   422 00008F5F BE[CF280100]        <1> 	mov	esi, PATH_Array ; 19/02/2016
   423 00008F64 8B3D[4F290100]      <1> 	mov	edi, [CCD_DriveDT]
   424 00008F6A 57                  <1> 	push	edi
   425 00008F6B 83C77F              <1>         add     edi, LD_CDirLevel
   426 00008F6E 880F                <1> 	mov	[edi], cl
   427 00008F70 47                  <1> 	inc	edi ; LD_CurrentDirectory 
   428 00008F71 56                  <1> 	push	esi
   429                              <1> 	;mov	ecx, 32  ; always < 65536 (in this procedure)
   430 00008F72 66B92000            <1> 	mov	cx, 32
   431 00008F76 F3A5                <1> 	rep	movsd
   432                              <1> 	; Current directory has been saved to 
   433                              <1> 	; the DOS drive description table, cdir area !
   434 00008F78 5E                  <1> 	pop	esi  ; PATH_Array
   435 00008F79 5F                  <1> 	pop	edi  ; Dos Drv Description Table
   436                              <1> 
   437 00008F7A C3                  <1> 	retn
   438                              <1> 
   439                              <1> parse_dir_name:
   440                              <1> 	; 11/02/2016
   441                              <1> 	; 10/02/2016
   442                              <1> 	; 07/02/2016 (TRDOS 386 = TRDOS v2.0)
   443                              <1> 	; 18/09/2011
   444                              <1> 	; 17/10/2009
   445                              <1> 	; INPUT ->
   446                              <1> 	;	ESI = ASCIIZ Directory String Address
   447                              <1> 	;	AL = Current Directory Level
   448                              <1> 	;	EDI = Destination Adress
   449                              <1> 	;	     (8 levels, each one 12+4 byte)
   450                              <1> 	; OUTPUT ->
   451                              <1> 	;	EDI = Dir Entry Formatted Array
   452                              <1> 	;	     with zero cluster pointer at the last level
   453                              <1> 	;	AH = Last Dir Level
   454                              <1> 	;	AL = Current Dir Level
   455                              <1> 	;
   456                              <1> 	; (esi, ebx, ecx will be changed) 
   457                              <1> 
   458                              <1> 	;mov	[PATH_Array_Ptr], edi
   459 00008F7B 88C4                <1> 	mov	ah, al
   460 00008F7D 66A3[F4290100]      <1> 	mov	[PATH_CDLevel], ax
   461                              <1> repeat_ppdn_check_slash:
   462 00008F83 AC                  <1> 	lodsb
   463 00008F84 3C2F                <1> 	cmp	al, '/'
   464 00008F86 74FB                <1> 	je	short repeat_ppdn_check_slash
   465 00008F88 3C21                <1> 	cmp	al, 21h
   466 00008F8A 7219                <1> 	jb	short loc_ppdn_retn
   467 00008F8C 57                  <1> 	push	edi
   468                              <1> loc_ppdn_get_dir_name:
   469 00008F8D B90C000000          <1> 	mov	ecx, 12
   470 00008F92 BF[F6290100]        <1> 	mov	edi, Dir_File_Name
   471                              <1> repeat_ppdn_get_dir_name:
   472 00008F97 AA                  <1> 	stosb
   473 00008F98 AC                  <1> 	lodsb
   474 00008F99 3C2F                <1> 	cmp	al, '/'
   475 00008F9B 740A                <1> 	je	short loc_check_level_dot_conv_dir_name
   476 00008F9D 3C20                <1> 	cmp	al, 20h
   477 00008F9F 7605                <1> 	jna	short loc_ppdn_end_of_path_scan
   478 00008FA1 E2F4                <1> 	loop	repeat_ppdn_get_dir_name
   479 00008FA3 5F                  <1> 	pop	edi
   480 00008FA4 F9                  <1> 	stc
   481                              <1> loc_ppdn_retn:
   482 00008FA5 C3                  <1> 	retn
   483                              <1> 
   484                              <1> loc_ppdn_end_of_path_scan:
   485 00008FA6 4E                  <1> 	dec	esi
   486                              <1> loc_check_level_dot_conv_dir_name:
   487 00008FA7 31C0                <1> 	xor	eax, eax
   488 00008FA9 AA                  <1> 	stosb
   489 00008FAA 89F3                <1> 	mov	ebx, esi
   490 00008FAC BE[F6290100]        <1> 	mov	esi, Dir_File_Name
   491 00008FB1 AC                  <1> 	lodsb
   492                              <1> repeat_ppdn_name_check_dot:
   493 00008FB2 3C2E                <1> 	cmp	al, '.'
   494 00008FB4 7509                <1> 	jne	short loc_ppdn_convert_sub_dir_name
   495                              <1> repeat_ppdn_name_dot_dot:
   496 00008FB6 AC                  <1> 	lodsb
   497 00008FB7 3C2E                <1> 	cmp	al, '.'
   498 00008FB9 743E                <1> 	je	short loc_ppdn_dot_dot
   499 00008FBB 3C21                <1> 	cmp	al, 21h
   500 00008FBD 7226                <1> 	jb	short pass_ppdn_convert_sub_dir_name
   501                              <1> loc_ppdn_convert_sub_dir_name:
   502 00008FBF 8A25[F5290100]      <1> 	mov	ah, [PATH_Level]
   503 00008FC5 80FC07              <1> 	cmp	ah, 7
   504 00008FC8 731B                <1> 	jnb	short pass_ppdn_convert_sub_dir_name
   505 00008FCA FEC4                <1> 	inc	ah  
   506 00008FCC 8825[F5290100]      <1> 	mov	[PATH_Level], ah
   507 00008FD2 BE[F6290100]        <1> 	mov	esi, Dir_File_Name
   508                              <1> 	;mov	edi, [PATH_Array_Ptr]
   509 00008FD7 B010                <1> 	mov	al, 16
   510 00008FD9 F6E4                <1> 	mul	ah
   511 00008FDB 8B3C24              <1> 	mov	edi, [esp]
   512                              <1> 	;push	edi 
   513 00008FDE 01C7                <1> 	add	edi, eax
   514 00008FE0 E828030000          <1> 	call	convert_file_name
   515                              <1> 	;pop	edi
   516                              <1> pass_ppdn_convert_sub_dir_name:
   517 00008FE5 89DE                <1> 	mov	esi, ebx
   518                              <1> repeat_ppdn_check_last_slash:
   519 00008FE7 AC                  <1> 	lodsb
   520 00008FE8 3C2F                <1> 	cmp	al, '/'
   521 00008FEA 74FB                <1> 	je	short repeat_ppdn_check_last_slash
   522 00008FEC 3C21                <1> 	cmp	al, 21h
   523 00008FEE 739D                <1> 	jnb	short loc_ppdn_get_dir_name
   524                              <1> end_of_parse_dir_name:
   525 00008FF0 5F                  <1> 	pop	edi
   526 00008FF1 F5                  <1> 	cmc  
   527                              <1> 	;mov	al, [PATH_CDLevel]
   528                              <1> 	;mov	ah, [PATH_Level]
   529 00008FF2 66A1[F4290100]      <1> 	mov	ax, [PATH_CDLevel]
   530 00008FF8 C3                  <1> 	retn
   531                              <1> 
   532                              <1> loc_ppdn_dot_dot:
   533 00008FF9 AC                  <1> 	lodsb
   534 00008FFA 3C21                <1> 	cmp	al, 21h
   535 00008FFC 73F2                <1> 	jnb	short end_of_parse_dir_name 
   536                              <1> loc_ppdn_dot_dot_prev_level:
   537 00008FFE 66A1[F4290100]      <1> 	mov	ax, [PATH_CDLevel]
   538 00009004 80EC01              <1> 	sub	ah, 1
   539 00009007 80D400              <1> 	adc	ah, 0
   540 0000900A 38E0                <1> 	cmp	al, ah
   541 0000900C 7602                <1> 	jna	short pass_ppdn_set_al_to_ah
   542 0000900E 88E0                <1> 	mov	al, ah
   543                              <1> pass_ppdn_set_al_to_ah:
   544 00009010 66A3[F4290100]      <1> 	mov	[PATH_CDLevel], ax
   545 00009016 EBCD                <1> 	jmp	short pass_ppdn_convert_sub_dir_name
   546                              <1> 
   547                              <1> locate_current_dir_file:
   548                              <1> 	; 14/02/2016
   549                              <1> 	; 13/02/2016
   550                              <1> 	; 10/02/2016
   551                              <1> 	; 06/02/2016 (TRDOS 386 = TRDOS v2.0)
   552                              <1> 	; 14/08/2010
   553                              <1> 	; 19/09/2009
   554                              <1>         ; 2005
   555                              <1> 	; INPUT ->
   556                              <1> 	;	ESI = DOS DirEntry Format FileName Address
   557                              <1> 	;	AL = Attributes Mask 
   558                              <1> 	;	(<AL AND EntryAttrib> must be equal to AL)
   559                              <1> 	;	AH = Negative Attributes Mask (If AH>0)
   560                              <1> 	;	(<AH AND EntryAttrib> must be ZERO)
   561                              <1> 	;	CH > 0 Find First Free Dir Entry or Deleted Entry
   562                              <1> 	;	CL = 0 -> Return the First Free Dir Entry
   563                              <1> 	;	CL = E5h -> Return the 1st deleted entry
   564                              <1> 	;	CL = FFh -> Return the 1st deleted or free entry
   565                              <1> 	;	CL > 0 and CL <> E5h and CL <> FFh -> Return the first 
   566                              <1> 	;	     proper entry (which fits with Atributes Masks)
   567                              <1> 	;	CX = 0 Find Valid File/Directory/VolumeName
   568                              <1> 	;	? = Any One Char
   569                              <1> 	;	* = Every Chars
   570                              <1> 	; OUTPUT ->
   571                              <1> 	;	EDI = Directory Entry Address (in Directory Buffer)
   572                              <1> 	;	ESI = DOS DirEntry Format FileName Address
   573                              <1> 	;	CF = 0 -> No Error, Proper Entry,
   574                              <1> 	;	DL = Attributes
   575                              <1> 	;	DH = Previous Entry Attr (LongName Check)
   576                              <1> 	;	AL > 0 -> Ambiguous filename wildcard "?" used
   577                              <1> 	;	AH > 0 -> Ambiguous filename wildcard "*" used
   578                              <1> 	;	AX = 0 -> Filename full fits with directory entry
   579                              <1> 	;	CH = The 1st Name Char of Current Dir Entry
   580                              <1> 	;	CF = 1 -> Proper entry not found, Error Code in EAX/AL
   581                              <1> 	;	CL = 0 and CH = 0 -> Free Entry (End Of Dir)
   582                              <1> 	;	CL = 0 and CH = E5h -> Deleted Entry fits with filters
   583                              <1> 	;	CL > 0 -> Entry not found, CH invalid
   584                              <1> 	;	CF = 0 -> 
   585                              <1> 	;	EBX = Current Directory Entry Index/Number (BX)
   586                              <1> 
   587                              <1> 	;mov	word [DirBuff_EntryCounter], 0 ; Zero Based
   588                              <1> 
   589 00009018 8935[57290100]      <1> 	mov	[CDLF_FNAddress], esi
   590 0000901E 66A3[55290100]      <1> 	mov	[CDLF_AttributesMask], ax
   591 00009024 66890D[5B290100]    <1> 	mov	[CDLF_DEType], cx
   592                              <1> 
   593 0000902B 31DB                <1> 	xor	ebx, ebx
   594 0000902D 881D[6C290100]      <1> 	mov	[PreviousAttr], bl ; 0  ; 13/02/2016
   595                              <1> 
   596 00009033 8A3D[6E200100]      <1> 	mov	bh, [Current_Drv]
   597 00009039 381D[98280100]      <1> 	cmp	byte [DirBuff_ValidData], bl ; 0
   598 0000903F 761D                <1> 	jna	short loc_lcdf_reload_current_dir2
   599 00009041 8A1D[96280100]      <1>         mov     bl, [DirBuff_DRV]
   600 00009047 80EB41              <1> 	sub	bl, 'A'
   601 0000904A 38DF                <1> 	cmp	bh, bl
   602 0000904C 750E                <1> 	jne	short loc_lcdf_reload_current_dir1
   603 0000904E 8B15[9D280100]      <1> 	mov	edx, [DirBuff_Cluster]
   604 00009054 3B15[68200100]      <1> 	cmp	edx, [Current_Dir_FCluster]
   605 0000905A 7412                <1> 	je	short loc_cdir_locatefile_search
   606                              <1> 
   607                              <1> loc_lcdf_reload_current_dir1:
   608 0000905C 30DB                <1> 	xor	bl, bl
   609                              <1> loc_lcdf_reload_current_dir2:
   610 0000905E 89DE                <1> 	mov	esi, ebx
   611 00009060 81C600010900        <1>         add     esi, Logical_DOSDisks
   612 00009066 E872000000          <1> 	call	reload_current_directory 
   613 0000906B 735B                <1> 	jnc	short loc_locatefile_search_again 
   614 0000906D C3                  <1> 	retn  
   615                              <1> 
   616                              <1> loc_cdir_locatefile_search:
   617 0000906E 31DB                <1> 	xor	ebx, ebx
   618 00009070 E8A5000000          <1> 	call	find_directory_entry
   619 00009075 7349                <1> 	jnc	short loc_cdir_locate_file_retn
   620                              <1> 
   621                              <1> loc_locatefile_check_stc_reason:
   622 00009077 08ED                <1> 	or	ch, ch
   623 00009079 7444                <1> 	jz	short loc_cdir_locate_file_stc_retn
   624                              <1> 
   625                              <1> loc_locatefile_check_next_entryblock:
   626 0000907B 8A3D[6E200100]      <1> 	mov	bh, [Current_Drv]
   627 00009081 28DB                <1> 	sub	bl, bl
   628 00009083 0FB7F3              <1> 	movzx	esi, bx
   629 00009086 81C600010900        <1>         add     esi, Logical_DOSDisks
   630                              <1> 
   631 0000908C 803D[6C200100]00    <1> 	cmp	byte [Current_Dir_Level], 0
   632 00009093 760A                <1> 	jna	short loc_locatefile_check_FAT_type
   633                              <1>             
   634 00009095 803D[6D200100]01    <1> 	cmp	byte [Current_FATType], 1
   635 0000909C 730A                <1> 	jnb	short loc_locatefile_load_subdir_cluster
   636 0000909E C3                  <1> 	retn  
   637                              <1> 
   638                              <1> loc_locatefile_check_FAT_type:
   639 0000909F 803D[6D200100]03    <1> 	cmp	byte [Current_FATType], 3
   640 000090A6 7218                <1> 	jb	short loc_cdir_locate_file_retn
   641                              <1> 
   642                              <1> loc_locatefile_load_subdir_cluster:
   643 000090A8 A1[9D280100]        <1> 	mov	eax, [DirBuff_Cluster]
   644 000090AD E81D1A0000          <1> 	call	get_next_cluster
   645 000090B2 730D                <1> 	jnc	short loc_locatefile_next_cluster
   646 000090B4 09C0                <1> 	or	eax, eax
   647 000090B6 7507                <1> 	jnz	short loc_locatefile_drive_not_ready_read_err
   648 000090B8 F9                  <1> 	stc
   649                              <1> loc_locatefile_file_notfound:
   650 000090B9 B802000000          <1> 	mov	eax, 2 ; File/Directory/VolName not found
   651 000090BE C3                  <1> 	retn
   652                              <1> 
   653                              <1> loc_locatefile_drive_not_ready_read_err:
   654                              <1> 	;mov	eax, 15h ;Drive not ready or read error
   655                              <1> loc_cdir_locate_file_stc_retn:
   656 000090BF F5                  <1> 	cmc ;stc
   657                              <1> loc_cdir_locate_file_retn:
   658 000090C0 C3                  <1> 	retn
   659                              <1> 
   660                              <1> loc_locatefile_next_cluster:
   661 000090C1 E8EF1B0000          <1> 	call	load_FAT_sub_directory
   662                              <1> 	;jc	short loc_locatefile_drive_not_ready_read_err
   663 000090C6 72F8                <1> 	jc	short loc_cdir_locate_file_retn 
   664                              <1> 
   665                              <1> loc_locatefile_search_again:
   666 000090C8 8B35[57290100]      <1> 	mov	esi, [CDLF_FNAddress] 
   667 000090CE 66A1[55290100]      <1> 	mov	ax, [CDLF_AttributesMask]
   668 000090D4 668B0D[5B290100]    <1> 	mov	cx, [CDLF_DEType] 
   669 000090DB EB91                <1> 	jmp	short loc_cdir_locatefile_search
   670                              <1> 
   671                              <1> reload_current_directory:
   672                              <1> 	; 06/02/2016 (TRDOS 386 = TRDOS v2.0)
   673                              <1> 	; 13/06/2010
   674                              <1> 	; 22/09/2009
   675                              <1>         ;
   676                              <1> 	; INPUT ->
   677                              <1> 	;	ESI = Dos drive description table address
   678                              <1> 	
   679                              <1> 	;mov	al, [esi+LD_FATType]
   680 000090DD A0[6D200100]        <1> 	mov	al, [Current_FATType]
   681 000090E2 3C02                <1> 	cmp	al, 2
   682 000090E4 7729                <1> 	ja	short loc_reload_FAT_sub_directory
   683 000090E6 8A25[6C200100]      <1> 	mov	ah, [Current_Dir_Level]
   684 000090EC 08C0                <1> 	or	al, al
   685 000090EE 740A                <1> 	jz	short loc_reload_FS_directory
   686 000090F0 08E4                <1> 	or	ah, ah
   687 000090F2 751B                <1> 	jnz	short loc_reload_FAT_sub_directory
   688                              <1> loc_reload_FAT_12_16_root_directory:
   689 000090F4 E8311B0000          <1> 	call	load_FAT_root_directory
   690 000090F9 C3                  <1> 	retn
   691                              <1> loc_reload_FS_directory:
   692 000090FA 20E4                <1> 	and	ah, ah
   693 000090FC 7506                <1> 	jnz	short loc_reload_FS_sub_directory 
   694                              <1> loc_reload_FS_root_directory: 
   695 000090FE E8EE1B0000          <1> 	call	load_FS_root_directory
   696 00009103 C3                  <1> 	retn
   697                              <1> loc_reload_FS_sub_directory:
   698 00009104 A1[68200100]        <1> 	mov	eax, [Current_Dir_FCluster]
   699 00009109 E8E41B0000          <1> 	call	load_FS_sub_directory
   700 0000910E C3                  <1> 	retn 
   701                              <1> loc_reload_FAT_sub_directory:
   702 0000910F A1[68200100]        <1> 	mov	eax, [Current_Dir_FCluster]
   703 00009114 E89C1B0000          <1> 	call	load_FAT_sub_directory
   704 00009119 C3                  <1> 	retn
   705                              <1> 
   706                              <1> find_directory_entry:
   707                              <1> 	; 14/02/2016
   708                              <1> 	; 13/02/2016
   709                              <1> 	; 10/02/2016
   710                              <1> 	; 06/02/2016 (TRDOS 386 = TRDOS v2.0)
   711                              <1> 	; 14/08/2010 (DIR.ASM, "proc_find_direntry")
   712                              <1> 	; 19/09/2009
   713                              <1> 	; 2005
   714                              <1> 	; INPUT ->
   715                              <1> 	;	ESI = Sub Dir or File Name Address
   716                              <1> 	;	AL = Attributes Mask 
   717                              <1> 	;	(<AL AND EntryAttrib> must be equal to AL)
   718                              <1> 	;	AH = Negative Attributes Mask (If AH>0)
   719                              <1> 	;	(<AH AND EntryAttrib> must be ZERO)
   720                              <1> 	;	CH > 0 Find First Free Dir Entry or Deleted Entry
   721                              <1> 	;	CL = 0 -> Return the First Free Dir Entry
   722                              <1> 	;	CL = E5h -> Return the 1st deleted entry
   723                              <1> 	;	CL = FFh -> Return the 1st deleted or free entry
   724                              <1> 	;	CL > 0 and CL <> E5h and CL <> FFh -> Return the first 
   725                              <1> 	;            proper entry (which fits with Atributes Masks)
   726                              <1> 	;	CX = 0 -> Find Valid File/Directory/VolumeName
   727                              <1> 	;	? = Any One Char
   728                              <1> 	;	* = Every Chars
   729                              <1> 	;	EBX = Current Dir Entry (BX)
   730                              <1> 	;
   731                              <1> 	; OUTPUT -> 
   732                              <1> 	;	EDI = Directory Entry Address (in DirectoryBuffer)
   733                              <1> 	;	ESI = Sub Dir or File Name Address
   734                              <1> 	;	CF = 0 -> No Error, Proper Entry,
   735                              <1> 	;	DL = Attributes
   736                              <1> 	;	DH = Previous Entry Attr (LongName Check)
   737                              <1> 	;	AL > 0 -> Ambiguous filename wildcard "?" used
   738                              <1> 	;	AH > 0 -> Ambiguous filename wildcard "*" used
   739                              <1> 	;	AX = 0 -> Filename full fits with directory entry
   740                              <1> 	;	EBX = CurrentDirEntry (BX)
   741                              <1> 	;	CH = The 1st Name Char of Current Dir Entry
   742                              <1> 	;	CF = 1 -> Proper entry not found, Error Code in AX/AL
   743                              <1> 	;	CL = 0 and CH = 0 -> Free Entry (End Of Dir)
   744                              <1> 	;	CL = 0 and CH = E5h -> Deleted Entry fits with filters
   745                              <1> 	;	CL > 0 -> Entry not found, CH invalid
   746                              <1> 	;
   747                              <1> 	; (EAX, EBX, ECX, EDX, EDI, EBP will be changed)	 
   748                              <1> 
   749 0000911A 663B1D[9B280100]    <1> 	cmp	bx, [DirBuff_LastEntry]
   750 00009121 0F8739010000        <1>         ja      loc_ffde_stc_retn_255
   751                              <1> 
   752                              <1> 	;mov    [DirBuff_CurrentEntry], bx  
   753                              <1> 
   754 00009127 BF00000800          <1>   	mov	edi, Directory_Buffer
   755 0000912C 66A3[68290100]      <1> 	mov	[FDE_AttrMask], ax
   756                              <1> 
   757 00009132 29C0                <1> 	sub	eax, eax
   758                              <1>             
   759                              <1> 	;;mov	[PreviousAttr], al ; 0 ;; 13/02/2016
   760 00009134 66A3[6A290100]      <1> 	mov	[AmbiguousFileName], ax ; 0
   761                              <1> 
   762 0000913A 6689D8              <1> 	mov	ax, bx
   763 0000913D 66C1E005            <1> 	shl	ax, 5 ; ; * 32 ; Directory entry size
   764 00009141 01C7                <1> 	add     edi, eax
   765                              <1> 
   766 00009143 08ED                <1> 	or	ch, ch
   767 00009145 0F852C010000        <1>         jnz     loc_find_free_deleted_entry_0
   768                              <1> 
   769 0000914B 08C9                <1> 	or      cl, cl
   770 0000914D 0F850D010000        <1>         jnz     loc_ffde_stc_retn_255
   771                              <1>  
   772                              <1> check_find_dir_entry:
   773 00009153 66A1[68290100]      <1> 	mov	ax, [FDE_AttrMask]
   774 00009159 8A2F                <1> 	mov	ch, [edi]
   775 0000915B 80FD00              <1> 	cmp     ch, 0 ; Is it never used entry?
   776 0000915E 0F86FF000000        <1> 	jna	loc_find_direntry_stc_retn 
   777 00009164 56                  <1> 	push	esi
   778 00009165 8A570B              <1> 	mov	dl, [edi+0Bh] ; File attributes
   779 00009168 80FDE5              <1> 	cmp	ch, 0E5h ; Is it a deleted file?
   780 0000916B 746D                <1> 	je	short loc_find_dir_next_entry_prevdeleted
   781                              <1> 
   782 0000916D 80FA0F              <1> 	cmp     dl, 0Fh ; longname sub component check
   783 00009170 7505                <1> 	jne     short loc_check_attributes_mask
   784 00009172 E8ED010000          <1> 	call	save_longname_sub_component
   785                              <1> 
   786                              <1> loc_check_attributes_mask:
   787 00009177 88C6                <1> 	mov	dh, al
   788 00009179 20D6                <1> 	and	dh, dl    
   789 0000917B 38F0                <1> 	cmp	al, dh
   790 0000917D 0F85BA000000        <1>         jne     loc_find_dir_next_entry
   791 00009183 20D4                <1> 	and	ah, dl
   792 00009185 0F85B2000000        <1>         jnz     loc_find_dir_next_entry
   793 0000918B 80FA0F              <1> 	cmp	dl, 0Fh
   794 0000918E 751A                <1> 	jne	short pass_direntry_attr_check
   795                              <1> 
   796 00009190 3C0F                <1> 	cmp	al, 0Fh ; AL = 0Fh -> find long name
   797 00009192 0F85A5000000        <1>         jne     loc_find_dir_next_entry
   798                              <1> 
   799 00009198 5E                  <1> 	pop	esi
   800 00009199 6631C0              <1> 	xor	ax, ax
   801 0000919C 8A35[6C290100]      <1> 	mov	dh, [PreviousAttr]
   802 000091A2 66891D[99280100]    <1> 	mov	[DirBuff_CurrentEntry], bx
   803 000091A9 C3                  <1> 	retn
   804                              <1> 
   805                              <1> pass_direntry_attr_check:
   806 000091AA 89FD                <1> 	mov	ebp, edi ; 14/02/2016
   807 000091AC B908000000          <1> 	mov	ecx, 8
   808                              <1> loc_lodsb_find_dir:
   809 000091B1 AC                  <1> 	lodsb
   810 000091B2 3C2A                <1> 	cmp	al, '*'
   811 000091B4 7508                <1> 	jne	short pass_fde_ambiguous1_check
   812 000091B6 FE05[6B290100]      <1>         inc     byte [AmbiguousFileName+1]
   813 000091BC EB28                <1> 	jmp	short loc_check_direntry_extension
   814                              <1> 
   815                              <1> pass_fde_ambiguous1_check:
   816 000091BE 3C3F                <1> 	cmp	al, '?'
   817 000091C0 750D                <1> 	jne	short pass_fde_ambiguous2_check
   818 000091C2 FE05[6A290100]      <1> 	inc	byte [AmbiguousFileName]
   819 000091C8 803F20              <1> 	cmp	byte [edi], 20h
   820 000091CB 764E                <1> 	jna	short loc_find_dir_next_entry_ebp
   821 000091CD EB14                <1> 	jmp	short loc_scasb_find_dir_inc_di
   822                              <1> 
   823                              <1> pass_fde_ambiguous2_check:
   824 000091CF 3C20                <1> 	cmp	al, 20h
   825 000091D1 750C                <1> 	jne	short loc_scasb_find_dir
   826 000091D3 803F20              <1> 	cmp	byte [edi], 20h
   827 000091D6 7543                <1> 	jne	short loc_find_dir_next_entry_ebp
   828 000091D8 EB0C                <1> 	jmp	short loc_check_direntry_extension
   829                              <1> 
   830                              <1> loc_find_dir_next_entry_prevdeleted:
   831 000091DA 80CA80              <1> 	or	dl, 80h  ; Bit 7 -> deleted entry sign
   832 000091DD EB5E                <1> 	jmp	short loc_find_dir_next_entry
   833                              <1> 
   834                              <1> loc_scasb_find_dir:
   835 000091DF 3A07                <1> 	cmp	al, [edi]
   836 000091E1 7538                <1> 	jne	short loc_find_dir_next_entry_ebp
   837                              <1> loc_scasb_find_dir_inc_di:
   838 000091E3 47                  <1> 	inc	edi
   839 000091E4 E2CB                <1> 	loop	loc_lodsb_find_dir
   840                              <1> 
   841                              <1> loc_check_direntry_extension:
   842 000091E6 BE08000000          <1> 	mov	esi, 8
   843 000091EB 89F7                <1> 	mov	edi, esi ; 8
   844 000091ED 033424              <1> 	add	esi, [esp] ; Sub Dir or File Name Address
   845 000091F0 01EF                <1> 	add	edi, ebp
   846 000091F2 B103                <1> 	mov	cl, 3
   847                              <1> loc_lodsb_find_dir_ext:
   848 000091F4 AC                  <1> 	lodsb
   849 000091F5 3C2A                <1> 	cmp	al, '*'
   850 000091F7 7508                <1> 	jne	short pass_fde_ambiguous3_check
   851 000091F9 FE05[6B290100]      <1> 	inc	byte [AmbiguousFileName+1]
   852 000091FF EB1E                <1> 	jmp	short loc_find_dir_proper_direntry
   853                              <1> 
   854                              <1> pass_fde_ambiguous3_check:
   855 00009201 3C3F                <1> 	cmp	al, '?'
   856 00009203 750D                <1> 	jne	short pass_fde_ambiguous4_check
   857 00009205 FE05[6A290100]      <1> 	inc	byte [AmbiguousFileName]
   858 0000920B 803F20              <1> 	cmp	byte [edi], 20h
   859 0000920E 760B                <1> 	jna	short loc_find_dir_next_entry_ebp
   860 00009210 EB49                <1> 	jmp	short loc_scasb_find_dir_ext_inc_di
   861                              <1> 
   862                              <1> pass_fde_ambiguous4_check:
   863 00009212 3C20                <1> 	cmp	al, 20h
   864 00009214 7541                <1> 	jne	short loc_scasb_find_dir_ext
   865 00009216 803F20              <1> 	cmp	byte [edi], 20h
   866 00009219 7404                <1> 	je	short loc_find_dir_proper_direntry
   867                              <1> 
   868                              <1> loc_find_dir_next_entry_ebp:
   869 0000921B 89EF                <1> 	mov	edi, ebp ; 14/02/2016
   870 0000921D EB1E                <1> 	jmp	short loc_find_dir_next_entry
   871                              <1> 
   872                              <1> loc_find_dir_proper_direntry:
   873 0000921F 30C9                <1> 	xor	cl, cl
   874                              <1> loc_find_dir_proper_direntry_1:
   875 00009221 5E                  <1> 	pop	esi
   876 00009222 89EF                <1>         mov     edi, ebp
   877 00009224 8A2F                <1> 	mov	ch, [edi]
   878 00009226 8A570B              <1> 	mov     dl, [edi+0Bh] ; Dir entry attributes
   879 00009229 66A1[6A290100]      <1> 	mov	ax, [AmbiguousFileName]
   880                              <1> loc_find_dir_proper_direntry_2:
   881 0000922F 8A35[6C290100]      <1> 	mov     dh, [PreviousAttr]
   882 00009235 66891D[99280100]    <1> 	mov	[DirBuff_CurrentEntry], bx
   883 0000923C C3                  <1> 	retn
   884                              <1> 
   885                              <1> loc_find_dir_next_entry:
   886 0000923D 8815[6C290100]      <1> 	mov	byte [PreviousAttr], dl ; LongName check
   887                              <1> loc_find_dir_next_entry_1:
   888 00009243 5E                  <1> 	pop	esi
   889 00009244 83C720              <1> 	add	edi, 32
   890                              <1> 	;inc	word [DirBuff_EntryCounter]
   891 00009247 6643                <1> 	inc	bx
   892 00009249 663B1D[9B280100]    <1> 	cmp	bx, [DirBuff_LastEntry]
   893 00009250 770E                <1> 	ja	short loc_ffde_stc_retn_255
   894 00009252 E9FCFEFFFF          <1>         jmp     check_find_dir_entry 
   895                              <1> 
   896                              <1> loc_scasb_find_dir_ext:
   897 00009257 3A07                <1> 	cmp	al, [edi]
   898 00009259 75C0                <1> 	jne	short loc_find_dir_next_entry_ebp
   899                              <1> loc_scasb_find_dir_ext_inc_di:
   900 0000925B 47                  <1> 	inc	edi
   901 0000925C E296                <1> 	loop    loc_lodsb_find_dir_ext
   902 0000925E EBC1                <1> 	jmp	short loc_find_dir_proper_direntry_1
   903                              <1> 
   904                              <1> loc_ffde_stc_retn_255:
   905                              <1> 	;mov	cx, 0FFFFh
   906 00009260 31C9                <1> 	xor	ecx, ecx
   907 00009262 49                  <1> 	dec	ecx ; 0FFFFFFFFh
   908                              <1> 	;xor	eax, eax
   909                              <1> loc_find_direntry_stc_retn:
   910                              <1> loc_check_ffde_retn_1:
   911                              <1> 	;mov	ax, 2
   912 00009263 B802000000          <1> 	mov	eax, 2 ; File Not Found
   913 00009268 8A35[6C290100]      <1> 	mov	dh, [PreviousAttr]
   914 0000926E 66891D[99280100]    <1> 	mov	[DirBuff_CurrentEntry], bx
   915 00009275 F9                  <1> 	stc
   916 00009276 C3                  <1> 	retn
   917                              <1> 
   918                              <1> loc_find_free_deleted_entry_0:
   919 00009277 66A1[68290100]      <1> 	mov	ax, [FDE_AttrMask]
   920 0000927D 8A2F                <1> 	mov	ch, [edi]
   921 0000927F 8A570B              <1> 	mov	dl, [edi+0Bh] ; File attributes
   922 00009282 08C9                <1> 	or	cl, cl 
   923 00009284 7407                <1> 	jz	short loc_check_ffde_0_repeat
   924                              <1> 	;cmp	cl, 0E5h
   925                              <1> 	;je	short pass_loc_check_ffde_0_err
   926 00009286 80F9FF              <1> 	cmp	cl, 0FFh
   927 00009289 7432                <1> 	je	short loc_find_free_deleted_entry_1
   928 0000928B EB4D                <1> 	jmp	short pass_loc_check_ffde_0_err
   929                              <1> 
   930                              <1> loc_check_ffde_0_repeat:
   931 0000928D 08ED                <1> 	or	ch, ch
   932 0000928F 7511                <1> 	jnz	short loc_check_ffde_0_next
   933                              <1> 
   934                              <1> loc_check_ffde_retn_2:
   935 00009291 6629C0              <1> 	sub	ax, ax
   936 00009294 8A35[6C290100]      <1> 	mov	dh, [PreviousAttr]
   937 0000929A 66891D[99280100]    <1> 	mov	[DirBuff_CurrentEntry], bx
   938 000092A1 C3                  <1> 	retn
   939                              <1>  
   940                              <1> loc_check_ffde_0_next:
   941 000092A2 6643                <1> 	inc	bx
   942 000092A4 83C720              <1> 	add	edi, 32
   943                              <1> 	;inc	word [DirBuff_EntryCounter]
   944                              <1> 	 
   945 000092A7 663B1D[9B280100]    <1>         cmp	bx, [DirBuff_LastEntry]
   946 000092AE 77B0                <1> 	ja	short loc_ffde_stc_retn_255
   947 000092B0 8815[6C290100]      <1> 	mov	[PreviousAttr], dl
   948 000092B6 8A2F                <1> 	mov	ch, [edi]
   949 000092B8 8A570B              <1> 	mov	dl, [edi+0Bh] ; file attributes
   950 000092BB EBD0                <1> 	jmp	short loc_check_ffde_0_repeat
   951                              <1> 
   952                              <1> loc_find_free_deleted_entry_1:
   953 000092BD 28D2                <1> 	sub	dl, dl      
   954                              <1> loc_find_free_deleted_entry_2:
   955 000092BF 20ED                <1> 	and	ch, ch  
   956 000092C1 74CE                <1> 	jz	short loc_check_ffde_retn_2
   957 000092C3 80FDE5              <1> 	cmp	ch, 0E5h
   958 000092C6 74C9                <1> 	je	short loc_check_ffde_retn_2
   959 000092C8 6643                <1> 	inc	bx
   960 000092CA 83C720              <1> 	add	edi, 32
   961 000092CD 663B1D[9B280100]    <1> 	cmp	bx, [DirBuff_LastEntry]
   962 000092D4 778A                <1> 	ja	short loc_ffde_stc_retn_255
   963 000092D6 8A2F                <1> 	mov	ch, [edi]
   964 000092D8 EBE5                <1> 	jmp	short loc_find_free_deleted_entry_2
   965                              <1> 
   966                              <1> pass_loc_check_ffde_0_err:
   967 000092DA 38CD                <1> 	cmp	ch, cl
   968 000092DC 741F                <1> 	je	short loc_check_ffde_attrib 
   969                              <1> 
   970 000092DE 6643                <1> 	inc	bx
   971 000092E0 83C720              <1> 	add	edi, 32
   972 000092E3 663B1D[9B280100]    <1> 	cmp	bx, [DirBuff_LastEntry]
   973 000092EA 0F8770FFFFFF        <1>         ja      loc_ffde_stc_retn_255
   974 000092F0 8815[6C290100]      <1> 	mov	[PreviousAttr], dl
   975 000092F6 8A2F                <1> 	mov	ch, [edi]
   976 000092F8 8A570B              <1> 	mov	dl, [edi+0Bh]
   977 000092FB EBDD                <1> 	jmp	short pass_loc_check_ffde_0_err
   978                              <1> 
   979                              <1> loc_check_ffde_attrib:
   980 000092FD 88C6                <1> 	mov	dh, al
   981 000092FF 20D6                <1> 	and	dh, dl    
   982 00009301 38F0                <1> 	cmp	al, dh
   983 00009303 759D                <1> 	jne	short loc_check_ffde_0_next
   984 00009305 20D4                <1> 	and	ah, dl
   985 00009307 7599                <1> 	jnz	short loc_check_ffde_0_next
   986 00009309 30C9                <1> 	xor	cl, cl 
   987 0000930B EB84                <1>         jmp     loc_check_ffde_retn_2
   988                              <1> 
   989                              <1> convert_file_name:
   990                              <1> 	; 06/03/2016
   991                              <1> 	; 11/02/2016
   992                              <1> 	; 07/02/2016 (TRDOS 386 = TRDOS v2.0)
   993                              <1> 	; 06/10/2009
   994                              <1> 	; 2005
   995                              <1> 	;
   996                              <1> 	; INPUT  ->
   997                              <1> 	;	ESI = Dot File Name Location
   998                              <1> 	;	EDI = Dir Entry Format File Name Location
   999                              <1> 	; OUTPUT ->
  1000                              <1> 	;	EDI = Dir Entry Format File Name Location
  1001                              <1> 	;	ESI = Dot File Name Location (capitalized)
  1002                              <1> 	;
  1003                              <1> 	; (ECX, AL will be changed) 
  1004                              <1>      
  1005 0000930D 56                  <1> 	push	esi  
  1006 0000930E 57                  <1> 	push	edi
  1007                              <1> 
  1008 0000930F B90B000000          <1> 	mov	ecx, 11
  1009 00009314 B020                <1> 	mov	al, 20h
  1010 00009316 F3AA                <1> 	rep	stosb
  1011                              <1> 
  1012 00009318 8B3C24              <1> 	mov	edi, [esp]
  1013                              <1> 
  1014 0000931B B10C                <1> 	mov	cl, 12 ; file name length (max.)
  1015                              <1> 	; 06/03/2016
  1016                              <1> 	; Directory entry name limit (11 bytes) check for
  1017                              <1> 	; 'rename_directory_entry' procedure.
  1018                              <1> 	; (EDI points to Directory Entry)
  1019                              <1> 	; (If the file name would not contain a dot
  1020                              <1> 	; and file name length would be 12, this would cause to
  1021                              <1> 	; overwrite the attributes byte of the directory entry.)
  1022                              <1> 	;
  1023 0000931D B50B                <1> 	mov	ch, 11 ; directory entry's name length
  1024                              <1> loc_check_first_dot:
  1025 0000931F 8A06                <1> 	mov	al, [esi]
  1026 00009321 3C2E                <1> 	cmp	al, 2Eh
  1027 00009323 750C                <1> 	jne	short pass_check_first_dot
  1028 00009325 8807                <1> 	mov	[edi], al
  1029 00009327 47                  <1> 	inc	edi
  1030 00009328 46                  <1> 	inc	esi
  1031 00009329 FEC9                <1> 	dec	cl
  1032 0000932B 75F2                <1> 	jnz	short loc_check_first_dot
  1033                              <1> 	;;(ecx <= 12)
  1034                              <1> 	;;loop	loc_check_first_dot 
  1035 0000932D EB30                <1> 	jmp	short stop_convert_file
  1036                              <1> 
  1037                              <1> loc_get_fchar:
  1038 0000932F 8A06                <1> 	mov	al, [esi]
  1039                              <1> pass_check_first_dot:
  1040 00009331 3C61                <1> 	cmp	al, 61h ; 'a'
  1041 00009333 7208                <1> 	jb	short pass_name_capitalize
  1042 00009335 3C7A                <1> 	cmp	al, 7Ah ; 'z'
  1043 00009337 7704                <1> 	ja	short pass_name_capitalize
  1044 00009339 24DF                <1> 	and	al, 0DFh
  1045 0000933B 8806                <1> 	mov	[esi], al
  1046                              <1> pass_name_capitalize:
  1047 0000933D 3C21                <1> 	cmp	al, 21h
  1048 0000933F 721E                <1> 	jb	short stop_convert_file
  1049 00009341 3C2E                <1> 	cmp	al, 2Eh ; '.'
  1050 00009343 750C                <1> 	jne	short pass_dot_space
  1051                              <1> add_dot_space: 
  1052 00009345 80F904              <1> 	cmp	cl, 4
  1053 00009348 760E                <1> 	jna	short inc_and_loop
  1054 0000934A 47                  <1> 	inc	edi
  1055 0000934B FECD                <1> 	dec	ch ; 06/03/2016
  1056 0000934D FEC9                <1> 	dec	cl
  1057 0000934F EBF4                <1> 	jmp	short add_dot_space
  1058                              <1> 	
  1059                              <1> 	;mov	al, 4
  1060                              <1> 	;cmp	cl, al
  1061                              <1> 	;jna	short inc_and_loop
  1062                              <1> 	;sub	cl, al
  1063                              <1> 	;add	edi, ecx
  1064                              <1> 	;mov	cl, al
  1065                              <1> 	;jmp	short inc_and_loop	
  1066                              <1> 
  1067                              <1> pass_dot_space:
  1068 00009351 8807                <1> 	mov	[edi], al
  1069                              <1> loc_after_double_dot:
  1070                              <1> 	; 06/03/2016
  1071 00009353 FECD                <1> 	dec	ch ; count down for 11 bytes dir entry limit
  1072 00009355 740A                <1> 	jz	short stop_convert_file_x
  1073 00009357 47                  <1> 	inc	edi
  1074                              <1> inc_and_loop:
  1075 00009358 FEC9                <1> 	dec	cl ; count down for 12 bytes filename limit 
  1076 0000935A 7403                <1> 	jz	short stop_convert_file	
  1077 0000935C 46                  <1> 	inc	esi
  1078                              <1> 	;;(ecx <= 12)
  1079                              <1> 	;;loop	loc_get_fchar
  1080 0000935D EBD0                <1> 	jmp	short loc_get_fchar
  1081                              <1> 
  1082                              <1> stop_convert_file:
  1083                              <1> 	; 06/03/2016
  1084 0000935F 30ED                <1> 	xor	ch, ch
  1085                              <1> 	; ECX < 256 ; 'find_first_file' -> xor cl, cl
  1086                              <1> stop_convert_file_x:
  1087 00009361 5F                  <1> 	pop	edi
  1088 00009362 5E                  <1> 	pop	esi
  1089 00009363 C3                  <1> 	retn
  1090                              <1>  
  1091                              <1> save_longname_sub_component:
  1092                              <1> 	; 13/02/2016
  1093                              <1> 	; 06/02/2016 (TRDOS 386 = TRDOS v2.0)
  1094                              <1> 	; 28/02/2010
  1095                              <1> 	; 17/10/2009
  1096                              <1> 	; INPUT ->
  1097                              <1> 	;	EDI = Directory Entry    
  1098                              <1> 	;     	// This procedure is called
  1099                              <1> 	;	// from 'find_directory_entry' procedure.
  1100                              <1> 	;	// If the last entry returns with
  1101                              <1> 	;	// a non-zero LongnameFound value and
  1102                              <1> 	;	// if LFN_CheckSum value is equal to
  1103                              <1> 	;	// the next shortname checksum,
  1104                              <1> 	;	// long name is valid.
  1105                              <1> 	;	// If a longname is longer than 65 bytes,
  1106                              <1> 	;	// it is invalid for trdos. (>45h)
  1107                              <1>  
  1108 00009364 57                  <1> 	push	edi
  1109 00009365 56                  <1> 	push	esi
  1110                              <1> 	;push	ebx
  1111                              <1> 	;push	ecx
  1112                              <1> 	;push	edx
  1113 00009366 50                  <1> 	push	eax
  1114                              <1>            
  1115 00009367 29C9                <1> 	sub	ecx, ecx
  1116                              <1> 	;sub	eax, eax
  1117 00009369 B11A                <1> 	mov	cl, 26
  1118                              <1> 
  1119 0000936B 0FB607              <1> 	movzx	eax, byte [edi] ; LDIR_Order
  1120 0000936E 3C41                <1> 	cmp	al, 41h  ; 40h (last long entry sign) + 1
  1121 00009370 722B                <1> 	jb	short pass_pslnsc_last_long_entry
  1122                              <1> 
  1123 00009372 88C4                <1> 	mov	ah, al
  1124 00009374 80EC40              <1> 	sub	ah, 40h
  1125 00009377 8825[6E290100]      <1> 	mov	[LFN_EntryLength], ah
  1126                              <1> 	
  1127 0000937D 3C45                <1> 	cmp	al, 45h  ; 40h (last long entry sign) + 5
  1128                              <1>  		; Max 130 byte length is usable in TRDOS
  1129                              <1> ; 26*5 = 130
  1130 0000937F 7753                <1> 	ja	short loc_pslnsc_retn
  1131                              <1> 
  1132 00009381 2407                <1> 	and	al, 07h ; 0Fh
  1133 00009383 A2[6D290100]        <1> 	mov	[LongNameFound], al
  1134                              <1> 
  1135 00009388 FEC8                <1> 	dec	al
  1136                              <1> 	;mov	cl, 26
  1137 0000938A F6E1                <1> 	mul	cl
  1138                              <1> 
  1139 0000938C 89C6                <1> 	mov	esi, eax
  1140 0000938E 01CE                <1> 	add	esi, ecx
  1141                              <1> 		; to make is an ASCIZZ string
  1142                              <1> 		; with ax+26 bytes length
  1143 00009390 81C6[70290100]      <1> 	add	esi, LongFileName
  1144 00009396 66C7060000          <1> 	mov	word [esi], 0   
  1145 0000939B EB16                <1> 	jmp	short loc_pslsc_move_ldir_name2 
  1146                              <1> 
  1147                              <1> pass_pslnsc_last_long_entry:
  1148 0000939D 3C04                <1> 	cmp	al, 04h
  1149 0000939F 7733                <1> 	ja	short loc_pslnsc_retn
  1150 000093A1 FE0D[6D290100]      <1> 	dec	byte [LongNameFound]
  1151 000093A7 3A05[6D290100]      <1> 	cmp	al, [LongNameFound]
  1152 000093AD 7525                <1> 	jne	short loc_pslnsc_retn
  1153                              <1> 
  1154                              <1> loc_pslsc_move_ldir_name1:
  1155 000093AF FEC8                <1> 	dec	al
  1156                              <1> 	;mov	cl, 26
  1157 000093B1 F6E1                <1> 	mul	cl
  1158                              <1> 
  1159                              <1> loc_pslsc_move_ldir_name2:
  1160 000093B3 8A4F0D              <1> 	mov	cl, [edi+0Dh] ; long name checksum
  1161 000093B6 880D[6F290100]      <1> 	mov	[LFN_CheckSum], cl 
  1162 000093BC 89FE                <1> 	mov	esi, edi ; LDIR_Order
  1163 000093BE BF[70290100]        <1> 	mov	edi, LongFileName
  1164 000093C3 01C7                <1> 	add	edi, eax
  1165 000093C5 46                  <1> 	inc	esi
  1166 000093C6 B105                <1> 	mov	cl, 5 ; chars 1 to 5
  1167 000093C8 F366A5              <1> 	rep	movsw
  1168 000093CB 83C603              <1> 	add	esi, 3
  1169 000093CE A5                  <1> 	movsd	; char 6 & 7 
  1170 000093CF A5                  <1> 	movsd	; char 8 & 9
  1171 000093D0 A5                  <1> 	movsd	; char 10 & 11
  1172 000093D1 46                  <1> 	inc	esi
  1173 000093D2 46                  <1> 	inc	esi 
  1174 000093D3 A5                  <1> 	movsd   ; char 12 & 13 
  1175                              <1> 
  1176                              <1> loc_pslnsc_retn:
  1177 000093D4 58                  <1>  	pop	eax
  1178                              <1> 	;pop	edx
  1179                              <1> 	;pop	ecx
  1180                              <1> 	;pop	ebx
  1181 000093D5 5E                  <1> 	pop	esi  
  1182 000093D6 5F                  <1> 	pop	edi
  1183                              <1>  
  1184 000093D7 C3                  <1>     	retn
  1185                              <1> 
  1186                              <1> parse_path_name:
  1187                              <1> 	; 10/02/2016
  1188                              <1> 	; 08/02/2016 (TRDOS 386 = TRDOS v2.0)
  1189                              <1> 	; 10/009/2011 ('proc_parse_pathname')
  1190                              <1> 	; 27/11/2009
  1191                              <1> 	; 05/12/2004
  1192                              <1> 	;
  1193                              <1> 	; INPUT ->
  1194                              <1> 	;	ESI = Beginning of ASCIIZ pathname string
  1195                              <1> 	;       EDI = Destination Address
  1196                              <1> 	;	      (which is TR-DOS FindFile data buffer)
  1197                              <1> 	; OUTPUT ->
  1198                              <1> 	;	CF = 1 -> Error
  1199                              <1> 	;	     EAX = Error Code (AL)
  1200                              <1> 	;
  1201                              <1> 	; (Modified registers: eax, ecx, esi, edi) 
  1202                              <1> 	
  1203                              <1> 	; Clear the pathname bytes in TR-DOS Findfile data buffer 
  1204 000093D8 57                  <1> 	push	edi
  1205 000093D9 B914000000          <1> 	mov	ecx, 20  ; 80 bytes
  1206 000093DE 31C0                <1> 	xor	eax, eax
  1207 000093E0 F3AB                <1> 	rep	stosd 
  1208 000093E2 5F                  <1> 	pop	edi
  1209                              <1> 
  1210 000093E3 668B06              <1> 	mov	ax, [esi]
  1211 000093E6 80FC3A              <1> 	cmp	ah, ':'
  1212 000093E9 741C                <1> 	je	short loc_ppn_change_drive
  1213 000093EB A0[6E200100]        <1> 	mov	al, [Current_Drv]
  1214 000093F0 EB33                <1> 	jmp	short pass_ppn_change_drive
  1215                              <1> 
  1216                              <1> pass_ppn_cdir:
  1217 000093F2 8B35[922A0100]      <1> 	mov	esi, [First_Path_Pos]
  1218 000093F8 AC                  <1> 	lodsb
  1219                              <1> loc_ppn_get_filename:
  1220 000093F9 83C741              <1> 	add	edi, 65 ; FindFile_Name location
  1221                              <1> 	; TRDOS Filename length must not be more than 12 bytes
  1222                              <1> 	;mov	ecx, 12
  1223 000093FC B10C                <1> 	mov	cl, 12
  1224                              <1> loc_ppn_get_fnchar_next:
  1225 000093FE AA                  <1> 	stosb
  1226 000093FF AC                  <1> 	lodsb
  1227 00009400 3C21                <1> 	cmp	al, 21h
  1228 00009402 7274                <1> 	jb	short loc_ppn_clc_return 
  1229 00009404 E2F8                <1>         loop    loc_ppn_get_fnchar_next
  1230                              <1> loc_ppn_return:
  1231 00009406 C3                  <1> 	retn
  1232                              <1> 
  1233                              <1> loc_ppn_change_drive:
  1234 00009407 24DF                <1> 	and	al, 0DFh
  1235 00009409 2C41                <1> 	sub	al, 'A'; A:
  1236 0000940B 726F                <1> 	jc	short loc_ppn_invalid_drive
  1237 0000940D 3805[E3DD0000]      <1> 	cmp	[Last_DOS_DiskNo], al
  1238 00009413 7267                <1> 	jb	short loc_ppn_invalid_drive
  1239                              <1> 
  1240 00009415 46                  <1> 	inc	esi
  1241 00009416 46                  <1> 	inc	esi
  1242 00009417 8A26                <1> 	mov	ah, [esi]
  1243 00009419 80FC21              <1> 	cmp	ah, 21h
  1244 0000941C 7307                <1> 	jnb	short pass_ppn_change_drive
  1245                              <1> 
  1246                              <1> loc_ppn_cmd_failed:
  1247                              <1> 	; File or directory name is not existing
  1248 0000941E 8807                <1> 	mov	[edi], al ; Drv 
  1249 00009420 66B80100            <1> 	mov	ax, 1 ; eax = 1
  1250                              <1> 	; TR-DOS Error Code 1h = Bad Command Argument
  1251                              <1> 	; MS-DOS Error Code 1h : Invalid Function Number
  1252                              <1> 	;stc
  1253                              <1> 	; (MainProg ErrMsg: "Bad command or file name!")
  1254 00009424 C3                  <1> 	retn
  1255                              <1> 
  1256                              <1> pass_ppn_change_drive:
  1257 00009425 8935[922A0100]      <1> 	mov	[First_Path_Pos], esi
  1258 0000942B C705[962A0100]0000- <1> 	mov	dword [Last_Slash_Pos], 0
  1258 00009433 0000                <1>
  1259 00009435 AA                  <1> 	stosb
  1260 00009436 8A06                <1> 	mov	al, [esi]
  1261                              <1> loc_scan_ppn_dslash:
  1262 00009438 3C2F                <1> 	cmp	al, '/'
  1263 0000943A 7506                <1>   	jne	short loc_scan_next_slash_pos
  1264 0000943C 8935[962A0100]      <1> 	mov	[Last_Slash_Pos], esi
  1265                              <1> loc_scan_next_slash_pos:
  1266 00009442 46                  <1> 	inc	esi
  1267 00009443 8A06                <1> 	mov	al, [esi]
  1268 00009445 3C20                <1> 	cmp	al, 20h
  1269 00009447 77EF                <1> 	ja	short loc_scan_ppn_dslash
  1270 00009449 833D[962A0100]00    <1> 	cmp	dword [Last_Slash_Pos], 0
  1271 00009450 76A0                <1> 	jna	short pass_ppn_cdir
  1272                              <1> 	
  1273 00009452 8B0D[962A0100]      <1> 	mov	ecx, [Last_Slash_Pos]
  1274 00009458 8B35[922A0100]      <1> 	mov	esi, [First_Path_Pos]
  1275 0000945E 29F1                <1> 	sub	ecx, esi
  1276 00009460 41                  <1> 	inc	ecx
  1277                              <1> 	;cmp	ecx, 64
  1278 00009461 80F940              <1> 	cmp	cl, 64
  1279 00009464 7715                <1> 	ja	short loc_ppn_invalid_drive_stc
  1280                              <1> 
  1281 00009466 89F8                <1> 	mov	eax, edi ; Dest Dir String Location (65 byte)
  1282 00009468 F3A4                <1> 	rep	movsb
  1283                              <1> 	;mov	[edi], cl ; 0, End of Dir String
  1284 0000946A 8B35[962A0100]      <1> 	mov	esi, [Last_Slash_Pos]
  1285 00009470 46                  <1> 	inc	esi
  1286 00009471 89C7                <1> 	mov	edi, eax
  1287 00009473 AC                  <1> 	lodsb
  1288 00009474 3C21                <1> 	cmp	al, 21h
  1289 00009476 7381                <1> 	jnb	short loc_ppn_get_filename
  1290                              <1> loc_ppn_clc_return:
  1291                              <1> 	;clc
  1292 00009478 31C0                <1> 	xor	eax, eax
  1293 0000947A C3                  <1> 	retn
  1294                              <1> 
  1295                              <1> loc_ppn_invalid_drive_stc:
  1296 0000947B F5                  <1> 	cmc	 ; stc
  1297                              <1> loc_ppn_invalid_drive:
  1298                              <1> 	; cf = 1
  1299                              <1> 	; The Drive Letter/Char < "A" or > "Z"
  1300 0000947C 66B80F00            <1> 	mov	ax, 0Fh
  1301                              <1> 	; MS-DOS Error Code 0Fh = Disk Drive Invalid 
  1302                              <1> 	; (MainProg ErrMsg: "Drive not ready or read error!")
  1303 00009480 C3                  <1> 	retn
  1304                              <1> 
  1305                              <1> find_longname:
  1306                              <1> 	; 13/02/2016 (TRDOS 386 = TRDOS v2.0)
  1307                              <1> 	; 24/01/2010 (DIR.ASM, 'proc_find_longname')
  1308                              <1> 	; 17/10/2009
  1309                              <1> 	
  1310                              <1> 	; INPUT -> 
  1311                              <1> 	;	ESI = DOS short file name address
  1312                              <1> 	; 	for example: "filename.ext"
  1313                              <1> 	;
  1314                              <1> 	; OUTPUT ->
  1315                              <1> 	; 	ESI = ASCIIZ longname address (cf = 0)
  1316                              <1> 	;	cf = 1 -> error number returns in EAX (AL)
  1317                              <1> 	;	AL = 0 & CF=1 -> longname not found
  1318                              <1> 	;	     the file/directory has no longname
  1319                              <1> 	; 	cf = 0 -> AL = FAT Type 
  1320                              <1>  
  1321                              <1> 	; 17/10/2009
  1322                              <1> 	; ASCIIZ string will be returned
  1323                              <1> 	; as LongFileName
  1324                              <1> 	; clearing/reset is not needed
  1325                              <1> 	;mov	ecx, 33
  1326                              <1> 	;mov	edi, LongFileName
  1327                              <1> 	;sub	ax, ax ; 0
  1328                              <1> 	;rep	stosw
  1329                              <1> 
  1330                              <1> 	;mov	byte [LongNameFound], 0
  1331                              <1> 
  1332                              <1> 	; ESI = ASCIIZ file/directory name address
  1333                              <1> 	;   AL = Attributes AND mask 
  1334                              <1> 	;	(Result of AND must be equal to AL)
  1335                              <1> 	;   AH = Negative attributes mask 
  1336                              <1> 	;	(Result of AND must be ZERO)
  1337 00009481 66B80008            <1> 	mov	ax, 0800h 
  1338                              <1> 		; it must not be volume name or longname
  1339 00009485 E844DDFFFF          <1> 	call	find_first_file
  1340 0000948A 7216                <1> 	jc	short loc_fln_retn
  1341                              <1>  
  1342                              <1> loc_fln_check_FAT_Type:
  1343 0000948C 803D[6D200100]01    <1> 	cmp	byte [Current_FATType], 1
  1344 00009493 7306                <1> 	jnb	short loc_fln_check_longname_yes_sign
  1345                              <1> 
  1346 00009495 E839000000          <1> 	call	get_fs_longname
  1347 0000949A C3                  <1> 	retn
  1348                              <1> 
  1349                              <1> loc_fln_check_longname_yes_sign:
  1350 0000949B 08FF                <1> 	or	bh, bh
  1351 0000949D 7504                <1> 	jnz	short loc_fln_check_longnamefound_number
  1352                              <1> loc_fln_longname_not_found_retn:
  1353 0000949F 31C0                <1> 	xor	eax, eax 
  1354                              <1> 	; cf = 1 & al = 0 -> longname not found
  1355 000094A1 F9                  <1> 	stc
  1356                              <1> loc_fln_retn:
  1357 000094A2 C3                  <1> 	retn
  1358                              <1> 
  1359                              <1> loc_fln_check_longnamefound_number:
  1360                              <1> 	; 'LongNameFound' is set by
  1361                              <1>         ; by 'save_longname_sub_component'
  1362                              <1> 	; which is called from
  1363                              <1> 	; 'find_directory_entry' 
  1364                              <1> 	; which is called from 
  1365                              <1> 	; 'find_first_file'
  1366                              <1> 	; It must 1 if the longname is valid
  1367 000094A3 803D[6D290100]01    <1>         cmp     byte [LongNameFound], 1
  1368 000094AA 75F3                <1> 	jne	short loc_fln_longname_not_found_retn
  1369                              <1>              
  1370                              <1> loc_fln_calculate_checksum: 
  1371 000094AC E813000000          <1> 	call	calculate_checksum
  1372                              <1> 	; AL = shortname checksum
  1373                              <1> 
  1374                              <1> loc_fln_longname_validation:
  1375                              <1> 	; 'LFN_CheckSum' has been set already
  1376                              <1> 	; by 'save_longname_sub_component'
  1377                              <1> 	; which is called from
  1378                              <1> 	; 'find_directory_entry' 
  1379                              <1> 	; which is called from 
  1380                              <1> 	; 'find_first_file'
  1381 000094B1 3805[6F290100]      <1> 	cmp	[LFN_CheckSum], al
  1382 000094B7 75E6                <1> 	jne	short loc_fln_longname_not_found_retn
  1383                              <1> 
  1384 000094B9 BE[70290100]        <1> 	mov	esi, LongFileName
  1385 000094BE A0[6D200100]        <1> 	mov	al, [Current_FATType]
  1386 000094C3 C3                  <1> 	retn
  1387                              <1> 
  1388                              <1> calculate_checksum:
  1389                              <1> 	; 13/02/2016 (TRDOS 386 = TRDOS v2.0)
  1390                              <1> 	; 17/10/2009 (DIR.ASM, 'proc_calculate_checksum')
  1391                              <1>         ;    
  1392                              <1> 	; INPUT ->
  1393                              <1> 	;	ESI = 11 byte DOS File Name location
  1394                              <1> 	;	(in DOS Directory Entry Format)
  1395                              <1> 	; OUTPUT ->
  1396                              <1> 	;	 AL = 8 bit checksum (CRC) value
  1397                              <1> 	;
  1398                              <1> 	; (Modified registers: EAX, ECX, ESI)
  1399                              <1> 
  1400                              <1> 	; Erdogan Tan [ 17-10-2009 ]
  1401                              <1> 	;  'ror al, 1' instruction
  1402                              <1> 
  1403                              <1> 	; Erdogan Tan [ 20-06-2004 ]
  1404                              <1> 	; This 8086 assembly code is an original code
  1405                              <1> 	; which is adapted from C code in
  1406                              <1> 	; Microsoft FAT32 File System Specification
  1407                              <1> 	; Version 1.03, December 6, 2000
  1408                              <1> 	; Page 28
  1409                              <1> 
  1410 000094C4 30C0                <1> 	xor	al, al
  1411 000094C6 B90B000000          <1> 	mov	ecx, 11
  1412                              <1> loc_next_sum:
  1413                              <1> 	;xor	ah, ah
  1414                              <1> 	;test	al, 1
  1415                              <1> 	;jz	short pass_ah_80h
  1416                              <1> 	;mov	ah, 80h
  1417                              <1> ;pass_ah_80h:
  1418                              <1> 	;shr	al, 1
  1419 000094CB D0C8                <1> 	ror	al, 1 ; 17/10/2009  
  1420 000094CD 0206                <1> 	add	al, [esi]
  1421 000094CF 46                  <1> 	inc	esi
  1422                              <1> 	;add	al, ah
  1423 000094D0 E2F9                <1> 	loop	loc_next_sum
  1424 000094D2 C3                  <1> 	retn
  1425                              <1> 
  1426                              <1> get_fs_longname:
  1427                              <1> 	; temporary (13/02/2016)
  1428 000094D3 31C0                <1> 	xor eax, eax
  1429 000094D5 F9                  <1> 	stc
  1430 000094D6 C3                  <1> 	retn
  1431                              <1> 
  1432                              <1> make_sub_directory:
  1433                              <1> 	; 03/03/2016
  1434                              <1> 	; 02/03/2016
  1435                              <1> 	; 27/02/2026
  1436                              <1> 	; 26/02/2016
  1437                              <1> 	; 21/02/2016 (TRDOS 386 = TRDOS v2.0)
  1438                              <1> 	; 01/08/2011 (DIR.ASM, 'proc_make_directory')
  1439                              <1> 	; 10/07/2010
  1440                              <1> 	; INPUT ->
  1441                              <1> 	; 	ESI = ASCIIZ Directory Name
  1442                              <1> 	;	CL = Directory Attributes
  1443                              <1> 	; OUTPUT ->
  1444                              <1> 	;	EAX = New sub dir's first cluster
  1445                              <1> 	;	ESI = Logical Dos Drv Descr. Table Addr.
  1446                              <1> 	;	CF = 1 -> error code in AL (EAX)
  1447                              <1> 
  1448                              <1> 	;test	cl, 10h  ; directory
  1449                              <1> 	;jz	short loc_make_directory_access_denied
  1450                              <1> 	;test	cl, 08h ; volume name
  1451                              <1> 	;jnz	short loc_make_directory_access_denied
  1452                              <1> 
  1453 000094D7 80E107              <1> 	and	cl, 07h
  1454 000094DA 880D[EC2A0100]      <1> 	mov	byte [mkdir_attrib], cl
  1455                              <1> 
  1456 000094E0 56                  <1> 	push	esi
  1457 000094E1 31DB                <1> 	xor	ebx, ebx
  1458 000094E3 8A3D[6E200100]      <1> 	mov	bh, [Current_Drv]
  1459 000094E9 BE00010900          <1> 	mov	esi, Logical_DOSDisks
  1460 000094EE 01DE                <1> 	add	esi, ebx
  1461 000094F0 5B                  <1> 	pop	ebx
  1462                              <1> 
  1463                              <1> 	; 10/07/2010 -> 1st writable disk check for trdos
  1464                              <1> 	; LD_DiskType = 0 for write protection (read only) 
  1465 000094F1 807E0101            <1> 	cmp	byte [esi+LD_DiskType], 1 ; 0 = Invalid
  1466 000094F5 730B                <1> 	jnb	short loc_mkdir_check_file_sytem
  1467 000094F7 B813000000          <1> 	mov	eax, 13h ; MSDOS err => Disk write-protected 
  1468 000094FC BA00000000          <1> 	mov	edx, 0
  1469                              <1> 	; err retn: EDX = 0, EBX = Dir name offset
  1470                              <1> 	;ESI = Logical DOS drive description table address
  1471 00009501 C3                  <1> 	retn
  1472                              <1> 
  1473                              <1> ;loc_make_directory_access_denied:
  1474                              <1> 	;mov	ax, 05h ; access denied (invalid attributes input)
  1475                              <1> 	;stc
  1476                              <1> 	;retn
  1477                              <1> 
  1478                              <1> loc_mkdir_check_file_sytem:
  1479 00009502 807E0301            <1> 	cmp	byte [esi+LD_FATType], 1
  1480 00009506 730B                <1> 	jnb	short loc_mkdir_check_free_sectors
  1481                              <1> 
  1482                              <1> loc_make_fs_directory:
  1483 00009508 A1[68200100]        <1> 	mov	eax, [Current_Dir_FCluster]
  1484                              <1> 	; EAX = Parent directory DDT Address
  1485                              <1> 	; ESI = Logical DOS Drive DT Address
  1486                              <1> 	; EBX = Directory name offset (as ASCIIZ name)
  1487 0000950D E8B8150000          <1> 	call	make_fs_directory
  1488 00009512 C3                  <1> 	retn
  1489                              <1> 
  1490                              <1> loc_mkdir_check_free_sectors:
  1491 00009513 0FB64613            <1>         movzx   eax, byte [esi+LD_BPB+SecPerClust]
  1492 00009517 8B4E74              <1> 	mov	ecx, [esi+LD_FreeSectors]
  1493 0000951A 39C1                <1> 	cmp	ecx, eax
  1494 0000951C 7255                <1> 	jb	short loc_mkdir_insufficient_disk_space
  1495                              <1> 
  1496                              <1> loc_make_fat_directory:
  1497 0000951E 891D[DC2A0100]      <1> 	mov	[mkdir_DirName_Offset], ebx
  1498 00009524 890D[E82A0100]      <1> 	mov	[mkdir_FreeSectors], ecx
  1499                              <1> 
  1500                              <1> 	;mov	al, [esi+LD_BPB+SecPerClust]
  1501 0000952A A2[EE2A0100]        <1> 	mov	byte [mkdir_SecPerClust], al
  1502                              <1> 
  1503                              <1> loc_mkdir_gffc_1:
  1504 0000952F E8F2170000          <1> 	call	get_first_free_cluster
  1505 00009534 722A                <1> 	jc	short loc_mkdir_gffc_retn
  1506                              <1> 
  1507                              <1> ;loc_mkdir_gffc_1_cont: 
  1508                              <1> 	;cmp	eax, 2
  1509                              <1> 	;jb	short loc_mkdir_gffc_insufficient_disk_space
  1510                              <1> 
  1511                              <1> ;loc_mkdir_gffc_1_save_fcluster:  
  1512 00009536 A3[E02A0100]        <1> 	mov	[mkdir_FFCluster], eax
  1513                              <1> 
  1514                              <1> loc_mkdir_locate_ffe:
  1515                              <1> 	; Current directory fcluster <> Directory buffer cluster
  1516                              <1> 	; Current directory will be reloaded by
  1517                              <1> 	; 'locate_current_dir_file' procedure
  1518                              <1> 	;
  1519                              <1> 	; ESI = Logical DOS Drive Description Table Address 
  1520                              <1> 	;push	esi ; 27/02/2016
  1521 0000953B 31C0                <1> 	xor	eax, eax
  1522 0000953D 89C1                <1>         mov	ecx, eax
  1523 0000953F 6649                <1> 	dec	cx ; FFFFh  
  1524                              <1> 	; CX = FFFFh -> find first deleted or free entry
  1525                              <1> 	; ESI would be ASCIIZ filename address if the call
  1526                              <1> 	; would not be for first free or deleted dir entry
  1527 00009541 E8D2FAFFFF          <1> 	call	locate_current_dir_file
  1528 00009546 734C                <1> 	jnc	short loc_mkdir_set_ff_dir_entry_1
  1529                              <1> 	;pop	esi 
  1530                              <1> 	; ESI = Logical DOS Drive Description Table Address 
  1531 00009548 83F802              <1> 	cmp	eax, 2  ; cmp al, 2 ; File/Dir not found !
  1532 0000954B 752B                <1> 	jne	short loc_mkdir_stc_return
  1533                              <1> 
  1534                              <1> loc_mkdir_add_new_cluster:
  1535 0000954D 3805[6D200100]      <1> 	cmp	byte [Current_FATType], al ; 2
  1536                              <1> 	;cmp	byte ptr [esi+LD_FATType], 2
  1537 00009553 770C                <1> 	ja	short loc_mkdir_add_new_cluster_check_fsc
  1538 00009555 803D[6C200100]01    <1> 	cmp	byte [Current_Dir_Level], 1
  1539                              <1> 	;cmp	byte [esi+LD_CDirLevel], 1
  1540 0000955C 7303                <1> 	jnb	short loc_mkdir_add_new_cluster_check_fsc
  1541                              <1> 
  1542 0000955E B00C                <1> 	mov	al, 12 ; No more files 
  1543                              <1> loc_mkdir_gffc_retn:
  1544 00009560 C3                  <1> 	retn
  1545                              <1> 
  1546                              <1> loc_mkdir_add_new_cluster_check_fsc:
  1547 00009561 8B0D[E82A0100]      <1> 	mov	ecx, [mkdir_FreeSectors]
  1548                              <1> 	;movzx	eax, byte [mkdir_SecPerClust]
  1549 00009567 A0[EE2A0100]        <1> 	mov	al, [mkdir_SecPerClust]
  1550 0000956C 66D1E0              <1> 	shl	ax, 1 ; AX = 2 * AX
  1551 0000956F 39C1                <1> 	cmp	ecx, eax
  1552 00009571 7350                <1> 	jnb	short loc_mkdir_add_new_subdir_cluster
  1553                              <1> 
  1554                              <1> loc_mkdir_insufficient_disk_space:
  1555                              <1> 	;mov	edx, ecx
  1556                              <1> ;loc_mkdir_gffc_insufficient_disk_space:
  1557 00009573 66B82700            <1> 	mov	ax, 27h ; MSDOS err => insufficient disk space
  1558                              <1> 	; err retn: EDX = Free sectors, EBX = Dir name offset
  1559                              <1>         ; ESI -> Dos drive description table address
  1560                              <1> 	;; ecx = edx
  1561                              <1> 	;
  1562 00009577 C3                  <1> 	retn
  1563                              <1> 
  1564                              <1> loc_mkdir_stc_return:
  1565 00009578 F9                  <1> 	stc
  1566 00009579 C3                  <1> 	retn 
  1567                              <1> 
  1568                              <1> loc_mkdir_gffc_2:
  1569 0000957A E8A7170000          <1> 	call	get_first_free_cluster
  1570 0000957F 72DF                <1> 	jc	short loc_mkdir_gffc_retn
  1571                              <1> 
  1572                              <1> ;loc_mkdir_gffc_1_cont: 
  1573                              <1> 	;cmp	eax, 2
  1574                              <1> 	;jb	short loc_mkdir_gffc_insufficient_disk_space
  1575                              <1> 
  1576                              <1> ;loc_mkdir_gffc_2_save_fcluster:  
  1577 00009581 A3[E02A0100]        <1> 	mov	[mkdir_FFCluster], eax
  1578                              <1> 
  1579 00009586 A1[E42A0100]        <1> 	mov	eax, [mkdir_LastDirCluster]
  1580                              <1> 
  1581 0000958B E825170000          <1> 	call	load_FAT_sub_directory 
  1582 00009590 72CE                <1> 	jc	short loc_mkdir_gffc_retn
  1583                              <1> 
  1584 00009592 31FF                <1> 	xor	edi, edi
  1585                              <1> loc_mkdir_set_ff_dir_entry_1:
  1586                              <1> 	; 27/02/2016
  1587 00009594 56                  <1> 	push	esi ; Logical DOS Drv Desc. Tbl. address
  1588                              <1> 	; EDI = Directory Entry Address
  1589 00009595 8B35[DC2A0100]      <1> 	mov	esi, [mkdir_DirName_Offset]
  1590 0000959B A1[E02A0100]        <1> 	mov	eax, [mkdir_FFCluster]
  1591                              <1> 
  1592 000095A0 66B91000            <1> 	mov	cx, 10h	; CL = Directory attribute
  1593                              <1> 			; CH = 0 -> File size is 0
  1594 000095A4 0A0D[EC2A0100]      <1> 	or	cl, [mkdir_attrib] ; S, H, R  
  1595 000095AA E8B0010000          <1> 	call	make_directory_entry
  1596                              <1> 
  1597 000095AF 5E                  <1> 	pop	esi
  1598                              <1> 
  1599 000095B0 C605[98280100]02    <1> 	mov	byte [DirBuff_ValidData], 2
  1600 000095B7 E880020000          <1> 	call	save_directory_buffer
  1601 000095BC 0F83DA000000        <1>         jnc     loc_mkdir_set_ff_dir_entry_2
  1602                              <1> 
  1603                              <1> loc_mkdir_return:
  1604 000095C2 C3                  <1> 	retn
  1605                              <1> 
  1606                              <1> loc_mkdir_add_new_subdir_cluster:
  1607 000095C3 8B15[9D280100]      <1> 	mov	edx, [DirBuff_Cluster]
  1608 000095C9 8915[E42A0100]      <1> 	mov	[mkdir_LastDirCluster], edx       
  1609                              <1> 
  1610 000095CF A1[E02A0100]        <1> 	mov	eax, [mkdir_FFCluster]
  1611 000095D4 E8DC160000          <1> 	call	load_FAT_sub_directory 
  1612 000095D9 72E7                <1> 	jc	short loc_mkdir_return
  1613                              <1> 	; eax = 0
  1614                              <1> 	; ecx =  directory buffer sector count (<= 128)
  1615                              <1> 
  1616                              <1> pass_mkdir_add_new_subdir_cluster:
  1617 000095DB 29FF                <1> 	sub	edi, edi ; 0
  1618                              <1> 	;mov	al, 128 ; double word
  1619                              <1> 	;mul	ecx ; ecx =  directory buffer sector count
  1620                              <1> 	;mov	ecx, eax
  1621                              <1> 	;shl	cx, 7 ; 128 * sector count	
  1622 000095DD 668B4611            <1> 	mov	ax, [esi+LD_BPB+BytesPerSec] ; 512
  1623 000095E1 66C1E802            <1> 	shr	ax, 2 ; 'byte count / 4' for 'stosd'
  1624 000095E5 66F7E1              <1> 	mul	cx ; max = 128*(512/4) -> 16384 (stosd)
  1625 000095E8 6689C1              <1> 	mov	cx, ax
  1626 000095EB 6629C0              <1> 	sub	ax, ax ; 0
  1627 000095EE F3AB                <1> 	rep	stosd ; clear directory buffer
  1628                              <1> 
  1629 000095F0 C605[98280100]02    <1> 	mov	byte [DirBuff_ValidData], 2
  1630 000095F7 E840020000          <1> 	call	save_directory_buffer 
  1631 000095FC 72C4                <1> 	jc	short loc_mkdir_return
  1632                              <1> 
  1633                              <1> loc_mkdir_save_added_cluster:
  1634 000095FE A1[E42A0100]        <1> 	mov	eax, [mkdir_LastDirCluster]
  1635 00009603 8B0D[E02A0100]      <1> 	mov	ecx, [mkdir_FFCluster]
  1636                              <1> 	; 01/03/2016
  1637 00009609 31D2                <1> 	xor	edx, edx
  1638 0000960B 8915[8E280100]      <1> 	mov	[FAT_ClusterCounter], edx ; 0 ; reset
  1639 00009611 E8E3170000          <1> 	call	update_cluster
  1640 00009616 7304                <1> 	jnc	short loc_mkdir_save_fat_buffer_0
  1641 00009618 09C0                <1> 	or	eax, eax ; EAX = 0 -> cluster value is 0 or eocc
  1642 0000961A 7518                <1> 	jnz	short loc_mkdir_save_fat_buffer_stc_retn
  1643                              <1> 
  1644                              <1> loc_mkdir_save_fat_buffer_0:
  1645 0000961C A1[E02A0100]        <1> 	mov	eax, [mkdir_FFCluster]
  1646 00009621 A3[E42A0100]        <1> 	mov	[mkdir_LastDirCluster], eax
  1647                              <1> 
  1648 00009626 31C9                <1> 	xor	ecx, ecx
  1649 00009628 49                  <1> 	dec	ecx ; FFFFFFFFh
  1650                              <1> 	; ESI = Logical DOS Drive Description Table address 
  1651 00009629 E8CB170000          <1> 	call	update_cluster
  1652 0000962E 731A                <1> 	jnc	short loc_mkdir_save_fat_buffer_1
  1653 00009630 09C0                <1> 	or	eax, eax
  1654 00009632 7416                <1> 	jz	short loc_mkdir_save_fat_buffer_1
  1655                              <1> 
  1656                              <1> loc_mkdir_save_fat_buffer_stc_retn:
  1657                              <1> 	; 01/03/2016
  1658 00009634 803D[8E280100]01    <1> 	cmp	byte [FAT_ClusterCounter], 1
  1659 0000963B 720C                <1> 	jb	short loc_mkdir_save_fat_buffer_retn
  1660                              <1> 
  1661 0000963D 66BB00FF            <1> 	mov	bx, 0FF00h ; recalculate free space (BL = 0)
  1662                              <1> 			   ; (BH = FFh -> Use ESI as Drv Param. Tbl.)
  1663 00009641 50                  <1> 	push	eax
  1664 00009642 E8041B0000          <1> 	call	calculate_fat_freespace
  1665 00009647 58                  <1> 	pop	eax
  1666 00009648 F9                  <1> 	stc
  1667                              <1> loc_mkdir_save_fat_buffer_retn:
  1668 00009649 C3                  <1> 	retn
  1669                              <1> 
  1670                              <1> loc_mkdir_save_fat_buffer_1:
  1671                              <1> 	; byte [FAT_BuffValidData] = 2 
  1672 0000964A E8671A0000          <1> 	call	save_fat_buffer
  1673 0000964F 72E3                <1> 	jc	short loc_mkdir_save_fat_buffer_stc_retn
  1674                              <1> 
  1675                              <1> 	; 01/03/2016
  1676 00009651 803D[8E280100]01    <1> 	cmp	byte [FAT_ClusterCounter], 1
  1677 00009658 721B                <1> 	jb	short loc_mkdir_save_fat_buffer_2
  1678                              <1> 
  1679                              <1> 	; ESI = Logical DOS Drive Description Table address 
  1680 0000965A A1[8E280100]        <1> 	mov	eax, [FAT_ClusterCounter]
  1681 0000965F 66BB01FF            <1> 	mov	bx, 0FF01h ; add free clusters 
  1682 00009663 E8E31A0000          <1> 	call	calculate_fat_freespace
  1683                              <1> 
  1684                              <1> 	;inc	eax ; 0FFFFFFFFh -> 0 ; recalculation is needed!
  1685                              <1> 	;jnz	short loc_mkdir_save_fat_buffer_2
  1686                              <1> 
  1687                              <1> 	; ecx > 0 -> Recalculation is needed
  1688 00009668 09C9                <1> 	or	ecx, ecx 
  1689 0000966A 7409                <1> 	jz	short loc_mkdir_save_fat_buffer_2
  1690                              <1> 
  1691 0000966C 66BB00FF            <1> 	mov	bx, 0FF00h ; ; recalculate free space
  1692 00009670 E8D61A0000          <1> 	call	calculate_fat_freespace
  1693                              <1> 
  1694                              <1> loc_mkdir_save_fat_buffer_2:
  1695 00009675 C605[EF2A0100]01    <1> 	mov	byte [mkdir_add_new_cluster], 1
  1696 0000967C E9C4000000          <1> 	jmp	loc_mkdir_upd_parent_dir_lmdt
  1697                              <1> 
  1698                              <1> loc_mkdir_update_sub_dir_cluster:
  1699 00009681 A1[E02A0100]        <1> 	mov	eax, [mkdir_FFCluster]
  1700 00009686 29C9                <1> 	sub	ecx, ecx ; 0
  1701                              <1> 	; 01/03/2016
  1702 00009688 890D[8E280100]      <1> 	mov	[FAT_ClusterCounter], ecx ; 0 ; Reset
  1703 0000968E 49                  <1> 	dec	ecx ; 0FFFFFFFFh
  1704                              <1> 
  1705                              <1> 	; ESI = Logical DOS Drive Descisption Table address  
  1706 0000968F E865170000          <1> 	call	update_cluster
  1707 00009694 7379                <1> 	jnc	short loc_mkdir_save_fat_buffer_3
  1708 00009696 09C0                <1> 	or	eax, eax ; EAX = 0 -> cluster value is 0 or eocc
  1709 00009698 7475                <1> 	jz	short loc_mkdir_save_fat_buffer_3
  1710                              <1> 	; 01/03/2016
  1711 0000969A EB98                <1> 	jmp	short loc_mkdir_save_fat_buffer_stc_retn
  1712                              <1> 
  1713                              <1> loc_mkdir_set_ff_dir_entry_2:
  1714                              <1> 	; ESI = Logical DOS Drive Description Table address  
  1715 0000969C A1[E02A0100]        <1> 	mov	eax, [mkdir_FFCluster]
  1716                              <1> 	; Load disk sectors as a directory cluster
  1717 000096A1 E80F160000          <1> 	call	load_FAT_sub_directory 
  1718 000096A6 7266                <1> 	jc	short retn_make_fat_directory
  1719                              <1> 	
  1720                              <1> 	; eax = 0
  1721                              <1> 	; ecx =  directory buffer sector count (<= 128)
  1722                              <1> 
  1723 000096A8 BF40000800          <1> 	mov	edi, Directory_Buffer + 64 ; 26/02/2016
  1724                              <1> 
  1725                              <1> 	; 02/03/2016
  1726 000096AD 668B4611            <1> 	mov	ax, [esi+LD_BPB+BytesPerSec] ; 512
  1727 000096B1 66C1E802            <1> 	shr	ax, 2 ; 'byte count / 4' for 'stosd'
  1728 000096B5 F7E1                <1> 	mul 	ecx
  1729 000096B7 89C1                <1> 	mov	ecx, eax
  1730 000096B9 6629C0              <1> 	sub	ax, ax
  1731 000096BC F3AB                <1> 	rep	stosd
  1732                              <1> 
  1733                              <1> 	;;mov	al, 128 ; double word
  1734                              <1> 	;;mul	ecx ; ecx =  directory buffer sector count
  1735                              <1> 	;;mov	ecx, eax
  1736                              <1> 	;shl	cx, 7 ; 128 * sector count	
  1737                              <1> 	;;sub	eax, eax
  1738                              <1> 	;;sub	al, al ; 0
  1739                              <1> 	;rep	stosd ; clear directory buffer
  1740                              <1> 
  1741 000096BE BF00000800          <1> 	mov	edi, Directory_Buffer ; 26/02/2016
  1742                              <1> 	
  1743 000096C3 56                  <1> 	push	esi
  1744                              <1> 
  1745 000096C4 BE[F02A0100]        <1> 	mov	esi, mkdir_Name
  1746 000096C9 66C7062E00          <1> 	mov	word [esi], 2Eh ; db '.', '0'
  1747                              <1> 
  1748 000096CE A1[E02A0100]        <1> 	mov	eax, [mkdir_FFCluster]
  1749 000096D3 66B91000            <1> 	mov	cx, 10h ; CL = Directory attribute
  1750                              <1> 			; CH = 0 -> File size is 0
  1751 000096D7 E883000000          <1> 	call	make_directory_entry
  1752                              <1> 
  1753 000096DC BF20000800          <1> 	mov	edi, Directory_Buffer + 32 ; 26/02/2016
  1754                              <1> 
  1755                              <1> 	; 03/03/2016
  1756                              <1> 	; Following modification has been done according to 
  1757                              <1> 	; 'Microsoft Extensible Firmware Initiative
  1758                              <1> 	; FAT32 File System Specification' document,
  1759                              <1> 	; 'FAT: General Overview of On-Disk FormatPage 25'.
  1760                              <1> 	; "Finally, you set DIR_FstClusLO and DIR_FstClusHI
  1761                              <1> 	; for the dotdot entry (the second entry) to the
  1762                              <1> 	; first cluster number of the directory in which you 
  1763                              <1> 	; just created the directory (value is 0 if this directory
  1764                              <1> 	; is the root directory even for FAT32 volumes)."
  1765                              <1> 	; (Correctness of this modification has been verified
  1766                              <1> 	;  by using Windows 98 'scandisk.exe'.)
  1767                              <1> 
  1768 000096E1 29C0                <1> 	sub	eax, eax
  1769 000096E3 3805[6C200100]      <1> 	cmp	byte [Current_Dir_Level], al ; 0
  1770 000096E9 7605                <1> 	jna	short loc_mkdir_set_ff_dir_entry_3
  1771 000096EB A1[68200100]        <1> 	mov	eax, [Current_Dir_FCluster] ; parent dir
  1772                              <1> loc_mkdir_set_ff_dir_entry_3:
  1773 000096F0 66C746012E00        <1> 	mov	word [esi+1], 2Eh ; db '.', '0'
  1774                              <1> 
  1775                              <1> 	;mov	cx, 10h
  1776 000096F6 E864000000          <1> 	call	make_directory_entry
  1777                              <1> 
  1778 000096FB 5E                  <1> 	pop	esi
  1779                              <1> 
  1780 000096FC C605[98280100]02    <1> 	mov	byte [DirBuff_ValidData], 2
  1781 00009703 E834010000          <1> 	call	save_directory_buffer
  1782 00009708 0F8373FFFFFF        <1>         jnc     loc_mkdir_update_sub_dir_cluster
  1783                              <1>  
  1784                              <1> retn_make_fat_directory:
  1785 0000970E C3                  <1> 	retn
  1786                              <1> 
  1787                              <1> loc_mkdir_save_fat_buffer_3:
  1788                              <1> 	; 01/03/2016
  1789                              <1> 	; byte [FAT_BuffValidData] = 2 
  1790 0000970F E8A2190000          <1> 	call	save_fat_buffer
  1791 00009714 0F821AFFFFFF        <1>         jc      loc_mkdir_save_fat_buffer_stc_retn
  1792                              <1> 
  1793 0000971A 803D[8E280100]01    <1> 	cmp	byte [FAT_ClusterCounter], 1
  1794 00009721 721B                <1> 	jb	short loc_mkdir_save_fat_buffer_4
  1795                              <1> 
  1796                              <1> 	; ESI = Logical DOS Drive Description Table address 
  1797 00009723 A1[8E280100]        <1> 	mov	eax, [FAT_ClusterCounter]
  1798 00009728 66BB01FF            <1> 	mov	bx, 0FF01h ; add free clusters 
  1799 0000972C E81A1A0000          <1> 	call	calculate_fat_freespace
  1800                              <1> 
  1801                              <1> 	;inc	eax ; 0FFFFFFFFh -> 0 ; recalculation is needed!
  1802                              <1>         ;jnz    short loc_mkdir_save_fat_buffer_4
  1803                              <1> 
  1804                              <1> 	; ecx > 0 -> Recalculation is needed
  1805 00009731 09C9                <1> 	or	ecx, ecx 
  1806 00009733 7409                <1>         jz      short loc_mkdir_save_fat_buffer_4
  1807                              <1> 
  1808 00009735 66BB00FF            <1> 	mov	bx, 0FF00h ; recalculate free space
  1809 00009739 E80D1A0000          <1> 	call	calculate_fat_freespace
  1810                              <1> 
  1811                              <1> loc_mkdir_save_fat_buffer_4:	
  1812 0000973E C605[EF2A0100]00    <1> 	mov	byte [mkdir_add_new_cluster], 0
  1813                              <1> 
  1814                              <1> loc_mkdir_upd_parent_dir_lmdt:
  1815 00009745 E88D010000          <1> 	call	update_parent_dir_lmdt
  1816                              <1> 
  1817                              <1> 	; 01/03/2016
  1818 0000974A 803D[EF2A0100]00    <1> 	cmp	byte [mkdir_add_new_cluster], 0
  1819 00009751 0F8723FEFFFF        <1>         ja      loc_mkdir_gffc_2
  1820                              <1> 
  1821                              <1> loc_mkdir_retn_new_dir_cluster:
  1822 00009757 A1[E02A0100]        <1> 	mov	eax, [mkdir_FFCluster]
  1823 0000975C 31D2                <1> 	xor	edx, edx
  1824                              <1> loc_mkdir_retn:
  1825 0000975E C3                  <1> 	retn
  1826                              <1> 
  1827                              <1> make_directory_entry:
  1828                              <1> 	; 02/03/2016
  1829                              <1> 	; 21/02/2016 (TRDOS 386 = TRDOS v2.0)
  1830                              <1> 	; 09/08/2010 (DIR.ASM, 'proc_make_directory_entry')
  1831                              <1> 	; 17/07/2010
  1832                              <1> 	; INPUT ->
  1833                              <1> 	; 	EDI = Directory Entry Address
  1834                              <1> 	;	ESI = Dot File Name Location
  1835                              <1> 	;	EAX = First Cluster
  1836                              <1> 	;	File Size = 0 (Must be set later)
  1837                              <1> 	;	CL = Attributes
  1838                              <1> 	;	CH = 0 (File size = 0) 
  1839                              <1> 	;	(If CH>0, File size is in dword [EBX]) (*)
  1840                              <1> 	; OUTPUT -> 
  1841                              <1> 	;	EDI = Directory Entry Address
  1842                              <1> 	;	ESI = Dot File Name Location (Capitalized)
  1843                              <1> 	;	If CH input = 0, File Size = 0
  1844                              <1> 	;	Otherwise file size is as dword [EBX] (*)
  1845                              <1> 	;	DX = Date, AX = Time in DOS Dir Entry format
  1846                              <1> 	;	EBX = same
  1847                              <1> 	;	ECX = same
  1848                              <1> 
  1849 0000975F 51                  <1> 	push	ecx
  1850                              <1> 
  1851 00009760 884F0B              <1> 	mov	[edi+11], cl ; Attributes
  1852 00009763 6689471A            <1> 	mov	[edi+26], ax ; FClusterLw, 26
  1853 00009767 C1E810              <1> 	shr	eax, 16
  1854 0000976A 66894714            <1> 	mov	[edi+20], ax ; FClusterHw, 20
  1855 0000976E 6631C0              <1> 	xor	ax, ax 
  1856 00009771 6689470C            <1> 	mov	[edi+12], ax ; NTReserved, 12
  1857                              <1> 			     ; CrtTimeTenth, 13
  1858 00009775 08ED                <1> 	or	ch, ch
  1859 00009777 7402                <1> 	jz	short loc_make_direntry_set_filesize
  1860                              <1> 
  1861 00009779 8B03                <1> 	mov	eax, [ebx]
  1862                              <1>         
  1863                              <1> loc_make_direntry_set_filesize:
  1864 0000977B 89471C              <1> 	mov	[edi+28], eax ; FileSize, 28
  1865                              <1> 	
  1866 0000977E E88AFBFFFF          <1> 	call	convert_file_name
  1867                              <1> 	;EDI = Dir Entry Format File Name Location
  1868                              <1> 	;ESI = Dot File Name Location (capitalized)
  1869                              <1> 
  1870 00009783 E816000000          <1> 	call	convert_current_date_time
  1871                              <1> 	; OUTPUT -> DX = Date in dos dir entry format
  1872                              <1>         ; 	    AX = Time in dos dir entry format
  1873 00009788 6689470E            <1> 	mov	[edi+14], ax ; CrtTime, 14
  1874 0000978C 66895710            <1> 	mov	[edi+16], dx ; CrtDate, 16
  1875 00009790 66895712            <1> 	mov	[edi+18], dx ; LastAccDate, 18
  1876 00009794 66894716            <1> 	mov	[edi+22], ax ; WrtTime, 14
  1877 00009798 66895718            <1> 	mov	[edi+24], dx ; WrtDate, 16
  1878 0000979C 59                  <1> 	pop	ecx
  1879                              <1> 
  1880 0000979D C3                  <1> 	retn
  1881                              <1> 
  1882                              <1> convert_current_date_time:
  1883                              <1> 	; 21/02/2016 (TRDOS 386 = TRDOS v2.0)
  1884                              <1> 	; 13/06/2010 (DIR.ASM, 'proc_convert_current_date_time')
  1885                              <1> 	; converts date&time to dos dir entry format
  1886                              <1> 	; INPUT -> none
  1887                              <1> 	; OUTPUT -> DX = Date in dos dir entry format
  1888                              <1> 	;           AX = Time in dos dir entry format
  1889                              <1>  
  1890 0000979E B404                <1> 	mov	ah, 04h ; Return Current Date
  1891 000097A0 E8CFB9FFFF          <1> 	call	int1Ah 
  1892                              <1> 
  1893 000097A5 88E8                <1> 	mov	al, ch ; <- century BCD
  1894 000097A7 240F                <1> 	and	al, 0Fh
  1895 000097A9 88EC                <1> 	mov	ah, ch
  1896 000097AB C0EC04              <1> 	shr	ah, 4
  1897 000097AE D50A                <1> 	aad
  1898 000097B0 88C5                <1> 	mov	ch, al ; -> century 
  1899                              <1> 
  1900 000097B2 88C8                <1> 	mov	al, cl ; <- year BCD
  1901 000097B4 240F                <1> 	and	al, 0Fh
  1902 000097B6 88CC                <1> 	mov	ah, cl
  1903 000097B8 C0EC04              <1> 	shr	ah, 4
  1904 000097BB D50A                <1> 	aad
  1905 000097BD 88C1                <1> 	mov	cl, al ; -> year
  1906                              <1> 
  1907 000097BF 88E8                <1> 	mov	al, ch
  1908 000097C1 B464                <1> 	mov	ah, 100
  1909 000097C3 F6E4                <1> 	mul	ah
  1910 000097C5 30ED                <1> 	xor	ch, ch
  1911 000097C7 6601C8              <1> 	add	ax, cx
  1912 000097CA 662DBC07            <1> 	sub	ax, 1980 ; ms-dos epoch
  1913 000097CE 6689C1              <1> 	mov	cx, ax
  1914                              <1> 
  1915 000097D1 88F0                <1> 	mov	al, dh ; <- month in bcd
  1916 000097D3 240F                <1> 	and	al, 0Fh
  1917 000097D5 88F4                <1> 	mov	ah, dh
  1918 000097D7 C0EC04              <1> 	shr	ah, 4
  1919 000097DA D50A                <1> 	aad
  1920 000097DC 88C6                <1> 	mov	dh, al ; -> month
  1921                              <1> 
  1922 000097DE 88D0                <1> 	mov	al, dl ; <- day BCD
  1923 000097E0 240F                <1> 	and	al, 0Fh
  1924 000097E2 88D4                <1> 	mov	ah, dl
  1925 000097E4 C0EC04              <1> 	shr	ah, 4
  1926 000097E7 D50A                <1> 	aad
  1927 000097E9 88C2                <1> 	mov	dl, al ; -> day
  1928                              <1> 
  1929 000097EB 88C8                <1> 	mov	al, cl ; count of years from 1980
  1930 000097ED 66C1E004            <1> 	shl	ax, 4
  1931 000097F1 08F0                <1> 	or	al, dh ; month of year, 1 to 12
  1932 000097F3 66C1E005            <1> 	shl	ax, 5
  1933 000097F7 08D0                <1> 	or	al, dl ; day of year, 1 to 31
  1934                              <1> 	
  1935 000097F9 6650                <1> 	push	ax ; push date
  1936                              <1> 
  1937 000097FB B402                <1> 	mov	ah, 02h ; Return Current Time
  1938 000097FD E872B9FFFF          <1> 	call	int1Ah
  1939                              <1> 
  1940 00009802 88E8                <1> 	mov	al, ch ; <- hours BCD
  1941 00009804 240F                <1> 	and	al, 0Fh
  1942 00009806 88EC                <1> 	mov	ah, ch
  1943 00009808 C0EC04              <1> 	shr	ah, 4
  1944 0000980B D50A                <1> 	aad
  1945 0000980D 88C5                <1> 	mov	ch, al ; -> hours
  1946                              <1> 
  1947 0000980F 88C8                <1> 	mov	al, cl ; <- minutes BCD
  1948 00009811 240F                <1> 	and	al, 0Fh
  1949 00009813 88CC                <1> 	mov	ah, cl
  1950 00009815 C0EC04              <1> 	shr	ah, 4
  1951 00009818 D50A                <1> 	aad
  1952 0000981A 88C1                <1> 	mov	cl, al ; -> minutes
  1953                              <1> 
  1954 0000981C 88F0                <1> 	mov	al, dh ; <- seconds BCD
  1955 0000981E 240F                <1> 	and	al, 0Fh
  1956 00009820 88F4                <1> 	mov	ah, dh
  1957 00009822 C0EC04              <1> 	shr	ah, 4
  1958 00009825 D50A                <1> 	aad
  1959 00009827 88C6                <1> 	mov	dh, al ; -> seconds
  1960                              <1> 
  1961 00009829 88E8                <1> 	mov	al, ch ; hours
  1962 0000982B 66C1E006            <1> 	shl	ax, 6
  1963 0000982F 08C8                <1> 	or	al, cl ; minutes
  1964 00009831 66C1E005            <1> 	shl	ax, 5
  1965 00009835 D0EE                <1> 	shr	dh, 1 ; 2 seconds
  1966                              <1> 	; There is a bug in TRDOS v1 here !
  1967                              <1> 	; it was 'or al, dl' ! 
  1968 00009837 08F0                <1> 	or	al, dh ; seconds
  1969                              <1> 
  1970 00009839 665A                <1> 	pop	dx ; pop date
  1971                              <1> 	
  1972 0000983B C3                  <1> 	retn
  1973                              <1> 
  1974                              <1> save_directory_buffer:
  1975                              <1> 	; 23/03/2016
  1976                              <1> 	; 26/02/2016
  1977                              <1> 	; 22/02/2016 (TRDOS 386 = TRDOS v2.0)
  1978                              <1> 	; 01/08/2011
  1979                              <1> 	; 14/03/2010
  1980                              <1> 	; INPUT ->
  1981                              <1> 	; 	 none
  1982                              <1> 	; OUTPUT ->
  1983                              <1> 	;  cf = 0 -> write OK...
  1984                              <1> 	;  cf = 1 -> error code in AL (EAX)
  1985                              <1> 	;  cf = 1 & AL = 0Dh => CH & CL = FS & FAT type
  1986                              <1> 	;  EBX = Directory Buffer Address
  1987                              <1> 	;
  1988                              <1> 	;  (EAX, ECX, EDX will be modified)
  1989                              <1>  
  1990 0000983C BB00000800          <1> 	mov	ebx, Directory_Buffer
  1991 00009841 803D[98280100]02    <1> 	cmp	byte [DirBuff_ValidData], 2
  1992 00009848 7403                <1> 	je	short loc_save_dir_buffer
  1993 0000984A 31C0                <1> 	xor	eax, eax
  1994 0000984C C3                  <1> 	retn            
  1995                              <1> 
  1996                              <1> loc_save_dir_buffer:
  1997 0000984D 56                  <1> 	push	esi
  1998 0000984E 31DB                <1> 	xor	ebx, ebx 
  1999 00009850 8A3D[96280100]      <1>         mov     bh, [DirBuff_DRV]
  2000 00009856 80EF41              <1> 	sub	bh, 'A'
  2001 00009859 BE00010900          <1>         mov     esi, Logical_DOSDisks
  2002 0000985E 01DE                <1> 	add	esi, ebx
  2003 00009860 668B4E03            <1>         mov     cx, [esi+LD_FATType]
  2004                              <1> 	; CH = FS Type (A1h for FS)
  2005                              <1> 	; CL = FAT Type (0 for FS)
  2006 00009864 08C9                <1> 	or	cl, cl
  2007 00009866 7433                <1> 	jz	short loc_save_dir_buff_stc_retn
  2008                              <1> 
  2009                              <1> loc_save_dir_buffer_check_cluster_no:    
  2010 00009868 A1[9D280100]        <1> 	mov	eax, [DirBuff_Cluster]
  2011 0000986D 28FF                <1> 	sub	bh, bh ; ebx = 0
  2012 0000986F 09C0                <1> 	or	eax, eax
  2013 00009871 7540                <1> 	jnz	short loc_save_sub_dir_buffer
  2014 00009873 8A25[97280100]      <1> 	mov	ah, [DirBuff_FATType]
  2015 00009879 FEC3                <1> 	inc	bl ;  bl = 1
  2016 0000987B 38DC                <1> 	cmp	ah, bl
  2017 0000987D 721D                <1> 	jb	short loc_save_dir_buff_inv_data_retn
  2018 0000987F FEC3                <1> 	inc	bl ; bl = 2
  2019 00009881 38E3                <1> 	cmp	bl, ah
  2020 00009883 7217                <1> 	jb	short loc_save_dir_buff_inv_data_retn
  2021                              <1> 
  2022                              <1> loc_save_root_dir_buffer:
  2023 00009885 668B5E17            <1> 	mov	bx, [esi+LD_BPB+RootDirEnts]
  2024 00009889 6683C30F            <1> 	add	bx, 15
  2025 0000988D 66C1EB04            <1> 	shr	bx, 4 ; 16 dir entries per sector
  2026 00009891 6609DB              <1> 	or	bx, bx
  2027 00009894 7405                <1> 	jz	short loc_save_dir_buff_stc_retn
  2028                              <1> 	;mov	ecx, ebx 
  2029 00009896 8B4664              <1> 	mov	eax, [esi+LD_ROOTBegin] ; 26/02/2016
  2030 00009899 EB23                <1> 	jmp	short loc_write_directory_to_disk
  2031                              <1> 
  2032                              <1> loc_save_dir_buff_stc_retn:
  2033 0000989B F9                  <1> 	stc
  2034                              <1> loc_save_dir_buff_inv_data_retn:
  2035 0000989C B00D                <1> 	mov	al, 0Dh ; Invalid data !
  2036 0000989E C605[98280100]00    <1> 	mov	byte [DirBuff_ValidData], 0
  2037 000098A5 EB05                <1> 	jmp	short loc_save_dir_buff_retn 
  2038                              <1> 
  2039                              <1> loc_write_directory_to_disk_err:
  2040                              <1> 	; 23/03/2016
  2041 000098A7 B81D000000          <1> 	mov	eax, 1Dh ; Drive not ready or write error 
  2042                              <1> 
  2043                              <1> loc_save_dir_buff_retn:
  2044 000098AC BB00000800          <1> 	mov	ebx, Directory_Buffer
  2045 000098B1 5E                  <1> 	pop	esi
  2046 000098B2 C3                  <1> 	retn
  2047                              <1>  
  2048                              <1> loc_save_sub_dir_buffer:
  2049                              <1> 	; ebx  = 0
  2050 000098B3 83E802              <1> 	sub	eax, 2
  2051 000098B6 8A5E13              <1> 	mov	bl, [esi+LD_BPB+SecPerClust]
  2052 000098B9 F7E3                <1> 	mul	ebx
  2053 000098BB 034668              <1>         add     eax, [esi+LD_DATABegin]
  2054                              <1>  	;mov	ecx, ebx
  2055                              <1> 
  2056                              <1> loc_write_directory_to_disk:
  2057 000098BE 89D9                <1>  	mov	ecx, ebx
  2058 000098C0 BB00000800          <1> 	mov	ebx, Directory_Buffer
  2059 000098C5 E81F410000          <1> 	call	disk_write
  2060 000098CA 72DB                <1> 	jc	short loc_write_directory_to_disk_err
  2061                              <1> 
  2062                              <1> loc_save_dir_buff_validate_retn:
  2063 000098CC C605[98280100]01    <1> 	mov	byte [DirBuff_ValidData], 1
  2064 000098D3 31C0                <1> 	xor	eax, eax
  2065                              <1> 	; 26/02/2016
  2066 000098D5 EBD5                <1> 	jmp	short loc_save_dir_buff_retn
  2067                              <1> 
  2068                              <1> update_parent_dir_lmdt:
  2069                              <1> 	; 22/02/2016 (TRDOS 386 = TRDOS v2.0)
  2070                              <1> 	; 01/08/2011
  2071                              <1> 	; 16/10/2010 
  2072                              <1> 	; 
  2073                              <1> 	; INPUT -> 
  2074                              <1> 	;	none
  2075                              <1>  	; OUTPUT ->
  2076                              <1> 	;	(last modification date & time of the parent dir
  2077                              <1> 	;	will be changed/updated)
  2078                              <1> 	;
  2079                              <1> 	; (EAX, EBX, ECX, EDX, EDI will be changed)
  2080                              <1> 
  2081 000098D7 29C0                <1> 	sub	eax, eax
  2082 000098D9 8A25[6C200100]      <1> 	mov	ah, [Current_Dir_Level]
  2083 000098DF A0[6D200100]        <1> 	mov	al, [Current_FATType]
  2084 000098E4 3C01                <1> 	cmp	al, 1
  2085 000098E6 723A                <1> 	jb	short loc_UPDLMDT_proc_retn
  2086                              <1>     
  2087                              <1> loc_update_parent_dir_lm_date_time:
  2088 000098E8 08E4                <1> 	or	ah, ah
  2089 000098EA 7436                <1> 	jz	short loc_UPDLMDT_proc_retn
  2090                              <1> 
  2091 000098EC 56                  <1> 	push	esi ; *
  2092 000098ED 8825[102B0100]      <1> 	mov	[UPDLMDT_CDirLevel], ah
  2093 000098F3 8B15[68200100]      <1> 	mov	edx, [Current_Dir_FCluster]
  2094 000098F9 8915[112B0100]      <1> 	mov	[UPDLMDT_CDirFCluster], edx
  2095                              <1> 
  2096 000098FF FECC                <1> 	dec	ah
  2097 00009901 B90C000000          <1> 	mov	ecx, 12
  2098 00009906 BE[CF280100]        <1>         mov     esi, PATH_Array
  2099                              <1> 
  2100 0000990B 8825[6C200100]      <1> 	mov	[Current_Dir_Level], ah
  2101 00009911 08E4                <1> 	or	ah, ah
  2102 00009913 750E                <1> 	jnz	short loc_update_parent_dir_lmdt_load_sub_dir_1
  2103 00009915 803D[6D200100]02    <1> 	cmp	byte [Current_FATType], 2
  2104 0000991C 770B                <1> 	ja	short loc_update_parent_dir_lmdt_load_sub_dir_2
  2105 0000991E 28C0                <1> 	sub	al, al ; eax = 0
  2106 00009920 EB0A                <1> 	jmp	short loc_update_parent_dir_lmdt_load_sub_dir_3
  2107                              <1> 
  2108                              <1> loc_UPDLMDT_proc_retn:
  2109 00009922 C3                  <1> 	retn
  2110                              <1>          
  2111                              <1> loc_update_parent_dir_lmdt_load_sub_dir_1:
  2112 00009923 B010                <1> 	mov	al, 16
  2113 00009925 F6E4                <1> 	mul	ah 
  2114 00009927 01C6                <1> 	add	esi, eax
  2115                              <1> 
  2116                              <1> loc_update_parent_dir_lmdt_load_sub_dir_2:  
  2117 00009929 8B460C              <1> 	mov	eax, [esi+12] ; Parent Dir First Cluster
  2118                              <1> 
  2119                              <1> loc_update_parent_dir_lmdt_load_sub_dir_3:
  2120 0000992C A3[68200100]        <1> 	mov	[Current_Dir_FCluster], eax
  2121                              <1> 
  2122 00009931 83C610              <1> 	add	esi, 16
  2123 00009934 66BF[F629]          <1> 	mov	di, Dir_File_Name  
  2124 00009938 F3A4                <1> 	rep	movsb
  2125                              <1> 	
  2126 0000993A BE00010900          <1> 	mov	esi, Logical_DOSDisks
  2127 0000993F 29DB                <1> 	sub	ebx, ebx
  2128 00009941 8A3D[6E200100]      <1> 	mov	bh, [Current_Drv]
  2129 00009947 01DE                <1> 	add	esi, ebx
  2130 00009949 E88FF7FFFF          <1> 	call	reload_current_directory
  2131 0000994E 7232                <1> 	jc	short loc_update_parent_dir_lmdt_restore_cdirlevel
  2132                              <1> 
  2133                              <1> loc_update_parent_dir_lmdt_locate_dir: 
  2134 00009950 BE[F6290100]        <1> 	mov	esi, Dir_File_Name        
  2135 00009955 6631C9              <1> 	xor	cx, cx
  2136 00009958 66B81008            <1> 	mov	ax, 0810h ; Only directories
  2137 0000995C E8B7F6FFFF          <1>         call    locate_current_dir_file
  2138                              <1> 	; EDI = DirBuff Directory Entry Address
  2139 00009961 721F                <1> 	jc short loc_update_parent_dir_lmdt_restore_cdirlevel
  2140                              <1> 
  2141 00009963 E836FEFFFF          <1> 	call	convert_current_date_time
  2142 00009968 66895712            <1> 	mov	[edi+18], dx ; Last Access Date
  2143 0000996C 66895718            <1> 	mov	[edi+24], dx ; Last Write Date
  2144 00009970 66894716            <1> 	mov	[edi+22], ax ; Last Write Time
  2145                              <1> 
  2146 00009974 C605[98280100]02    <1> 	mov	byte [DirBuff_ValidData], 2
  2147 0000997B E8BCFEFFFF          <1> 	call	save_directory_buffer
  2148 00009980 7200                <1> 	jc	short loc_update_parent_dir_lmdt_restore_cdirlevel
  2149                              <1> 	;xor	al, al 
  2150                              <1> loc_update_parent_dir_lmdt_restore_cdirlevel:
  2151                              <1>  	;current directory level restoration
  2152 00009982 8A25[102B0100]      <1> 	mov	ah, [UPDLMDT_CDirLevel]
  2153 00009988 8825[6C200100]      <1> 	mov	[Current_Dir_Level], ah
  2154 0000998E 8B15[112B0100]      <1>         mov     edx, [UPDLMDT_CDirFCluster]
  2155 00009994 8915[68200100]      <1> 	mov	[Current_Dir_FCluster], edx
  2156                              <1> 
  2157 0000999A 5E                  <1> 	pop	esi ; *
  2158 0000999B C3                  <1> 	retn
  2159                              <1> 
  2160                              <1> delete_longname:
  2161                              <1> 	; 27/02/2016 (TRDOS 386 = TRDOS v2.0)
  2162                              <1> 	; 01/08/2011 (DIR.ASM, 'proc_delete_longname')
  2163                              <1> 	; 14/03/2010
  2164                              <1> 	; INPUT ->
  2165                              <1> 	; 	EAX = Directory Entry (Index) Number (< 65536)
  2166                              <1> 	; OUTPUT ->
  2167                              <1> 	;	cf = 0 -> OK  (EAX = 0)
  2168                              <1> 	; 	cf = 1 -> error code in EAX (AL)
  2169                              <1> 	;
  2170                              <1> 	; (Modified registers: EAX, EDX, ECX, EBX, EDI) 
  2171                              <1> 
  2172 0000999C 66A3[3C2B0100]      <1> 	mov	[DLN_EntryNumber], ax
  2173 000099A2 C605[3E2B0100]40    <1>         mov     byte [DLN_40h], 40h
  2174                              <1> 
  2175 000099A9 E858000000          <1> 	call	locate_current_dir_entry
  2176 000099AE 7308                <1> 	jnc	short loc_dln_check_attributes
  2177 000099B0 C3                  <1> 	retn
  2178                              <1> 
  2179                              <1> loc_dln_longname_not_found:
  2180 000099B1 B802000000          <1> 	mov	eax, 2
  2181 000099B6 F9                  <1> 	stc
  2182 000099B7 C3                  <1> 	retn
  2183                              <1> 
  2184                              <1> loc_dln_check_attributes:
  2185 000099B8 B00F                <1> 	mov	al, 0Fh  ; long name
  2186 000099BA 8A670B              <1> 	mov	ah, [edi+0Bh] ; dir entry attributes
  2187 000099BD 38C4                <1> 	cmp	ah, al
  2188 000099BF 75F0                <1> 	jne	short loc_dln_longname_not_found
  2189 000099C1 8A27                <1> 	mov	ah, [edi]
  2190 000099C3 2A25[3E2B0100]      <1> 	sub	ah, [DLN_40h]
  2191 000099C9 76E6                <1> 	jna	short loc_dln_longname_not_found         
  2192 000099CB 80FC14              <1> 	cmp	ah, 14h ; 84-64=20 -> 20*13=260 bytes
  2193 000099CE 77E1                <1> 	ja	short loc_dln_longname_not_found
  2194                              <1>              
  2195 000099D0 C607E5              <1> 	mov	byte [edi], 0E5h  ; deleted sign
  2196 000099D3 C605[98280100]02    <1> 	mov	byte [DirBuff_ValidData], 2 ; changed/write sign
  2197 000099DA C605[3E2B0100]00    <1> 	mov	byte [DLN_40h], 0 ; 40h -> 0
  2198                              <1> 	  
  2199                              <1> loc_dln_delete_next_ln_entry:
  2200 000099E1 80FC01              <1> 	cmp	ah, 1
  2201 000099E4 7616                <1> 	jna	short loc_dln_longname_retn
  2202                              <1> loc_dln_delete_next_ln_entry_0:
  2203 000099E6 66FF05[3C2B0100]    <1> 	inc	word [DLN_EntryNumber]
  2204 000099ED 0FB705[3C2B0100]    <1> 	movzx	eax, word [DLN_EntryNumber] 
  2205 000099F4 E80D000000          <1> 	call	locate_current_dir_entry
  2206 000099F9 73BD                <1> 	jnc	short loc_dln_check_attributes
  2207                              <1> 
  2208                              <1> loc_dln_longname_stc_retn:
  2209 000099FB C3                  <1> 	retn 
  2210                              <1> 	   
  2211                              <1> loc_dln_longname_retn:
  2212                              <1> 	;cmp	byte [DirBuff_ValidData], 2
  2213                              <1> 	;jne	short loc_dln_longname_retn_xor_eax
  2214 000099FC E83BFEFFFF          <1> 	call	save_directory_buffer
  2215 00009A01 72F8                <1> 	jc	short loc_dln_longname_stc_retn
  2216                              <1> 
  2217                              <1> loc_dln_longname_retn_xor_eax:
  2218 00009A03 31C0                <1> 	xor	eax, eax
  2219 00009A05 C3                  <1> 	retn
  2220                              <1> 
  2221                              <1> locate_current_dir_entry:
  2222                              <1> 	; 23/03/2016
  2223                              <1> 	; 27/02/2016 (TRDOS 386 = TRDOS v2.0)
  2224                              <1> 	; 01/08/2011 (DIR.ASM, 'proc_locate_current_dir_entry')
  2225                              <1> 	; 07/03/2010
  2226                              <1> 	; INPUT ->
  2227                              <1> 	;	EAX = Directory Entry (Index) Number (< 65536) 
  2228                              <1> 	; OUTPUT ->
  2229                              <1> 	;	EDI = Directory Entry Address
  2230                              <1> 	; 	EAX = Cluster Number of Directory Buffer
  2231                              <1> 	;	EBX = Directory Buffer Entry Offset
  2232                              <1> 	;	ECX = DirBuff Valid Data identifier (CL)
  2233                              <1> 	;   	If CF = 0 and CL = 2 then
  2234                              <1> 	;	   directory buffer modified and
  2235                              <1> 	;	   must be written to disk.
  2236                              <1> 	; 	If CF = 0  and CL = 1 then
  2237                              <1> 	;	   dir buffer has been written to disk, already.
  2238                              <1> 	;	CF = 1 -> Error code in EAX (AL)
  2239                              <1> 	;
  2240                              <1> 	; (Modified registers: EAX, EDX, ECX, EBX, EDI) 
  2241                              <1> 
  2242                              <1> loc_locate_current_dir_entry:
  2243 00009A06 56                  <1> 	push	esi
  2244 00009A07 89C1                <1> 	mov	ecx, eax
  2245 00009A09 BA20000000          <1> 	mov	edx, 32
  2246 00009A0E F7E2                <1> 	mul	edx 
  2247 00009A10 A3[482B0100]        <1> 	mov	[LCDE_ByteOffset], eax
  2248 00009A15 31DB                <1> 	xor	ebx, ebx
  2249 00009A17 8A3D[6E200100]      <1> 	mov	bh, [Current_Drv]
  2250 00009A1D A0[96280100]        <1>         mov     al, [DirBuff_DRV]
  2251 00009A22 2C41                <1> 	sub	al, 'A'
  2252 00009A24 BE00010900          <1>         mov     esi, Logical_DOSDisks
  2253 00009A29 01DE                <1> 	add	esi, ebx
  2254 00009A2B 38C7                <1> 	cmp	bh, al
  2255 00009A2D 0F8592000000        <1>         jne     loc_lcde_reload_current_directory
  2256                              <1> loc_lcde_cdl_check:
  2257 00009A33 803D[6C200100]00    <1> 	cmp	byte [Current_Dir_Level], 0
  2258 00009A3A 772A                <1> 	ja	short loc_lcde_calc_dirbuff_cluster_offset
  2259                              <1> 	; 27/02/2016
  2260                              <1> 	; TRDOS v1 has bug here for FAT32 fs !
  2261                              <1> 	; (Root Directory Entries for FAT32 = 0)
  2262 00009A3C 807E0303            <1> 	cmp	byte [esi+LD_FATType], 3  ; FAT32
  2263 00009A40 7324                <1> 	jnb	short loc_lcde_calc_dirbuff_cluster_offset
  2264                              <1> 
  2265                              <1> loc_lcde_cdl_check_FAT12_16:
  2266 00009A42 668B4617            <1> 	mov	ax, [esi+LD_BPB+RootDirEnts]
  2267 00009A46 6648                <1> 	dec	ax
  2268                              <1> 	;xor	dx, dx  
  2269 00009A48 6639C8              <1> 	cmp	ax, cx ; cx = Directory Entry (Index) Number
  2270 00009A4B 720E                <1> 	jb	short loc_lcde_stc_12h_retn
  2271 00009A4D 66890D[402B0100]    <1> 	mov	[LCDE_EntryIndex], cx
  2272 00009A54 31C0                <1> 	xor	eax, eax
  2273 00009A56 E993000000          <1>         jmp     loc_lcde_check_dir_buffer_cluster
  2274                              <1> 
  2275                              <1> loc_lcde_stc_12h_retn:
  2276 00009A5B 5E                  <1> 	pop	esi
  2277 00009A5C 89CB                <1> 	mov	ebx, ecx
  2278 00009A5E 89D1                <1> 	mov	ecx, edx
  2279 00009A60 B812000000          <1> 	mov	eax, 12h ; No more files
  2280 00009A65 C3                  <1> 	retn 
  2281                              <1> 
  2282                              <1> loc_lcde_calc_dirbuff_cluster_offset:
  2283 00009A66 8A5E13              <1> 	mov	bl, [esi+LD_BPB+SecPerClust]
  2284 00009A69 30FF                <1> 	xor	bh, bh
  2285 00009A6B 668B4611            <1> 	mov	ax, [esi+LD_BPB+BytesPerSec]
  2286 00009A6F 66F7E3              <1> 	mul	bx
  2287 00009A72 6609D2              <1>  	or	dx, dx ; If bytes per cluster > 32KB it is invalid
  2288 00009A75 755D                <1> 	jnz	short loc_lcde_invalid_format
  2289                              <1> 	;mov	ecx, eax
  2290 00009A77 6689C1              <1> 	mov	cx, ax ; BYTES PER CLUSTER
  2291 00009A7A A1[482B0100]        <1> 	mov	eax, [LCDE_ByteOffset]
  2292                              <1> 	;sub	edx, edx
  2293 00009A7F F7F1                <1> 	div	ecx
  2294 00009A81 3DFFFF0000          <1> 	cmp	eax, 65535
  2295 00009A86 774C                <1> 	ja	short loc_lcde_invalid_format
  2296                              <1> 
  2297                              <1> 	; cluster sequence number of directory (< 65536)
  2298 00009A88 66A3[422B0100]      <1> 	mov	[LCDE_ClusterSN], ax 
  2299                              <1> 
  2300 00009A8E 6689D0              <1> 	mov	ax, dx ; byte offset in cluster (directory buffer)
  2301 00009A91 66BB2000            <1> 	mov	bx, 32 ; ; 1 dir entry = 32 bytes
  2302 00009A95 6629D2              <1>         sub     dx, dx  ; 0
  2303 00009A98 66F7F3              <1> 	div	bx 
  2304 00009A9B 66A3[402B0100]      <1> 	mov	[LCDE_EntryIndex], ax ; dir entry index/sequence number
  2305                              <1> 				      ; (in directory buffer/cluster)	  
  2306                              <1> loc_lcde_get_current_sub_dir_fcluster:
  2307 00009AA1 A1[68200100]        <1> 	mov	eax, [Current_Dir_FCluster]
  2308                              <1> 
  2309                              <1> loc_lcde_get_next_cluster:
  2310 00009AA6 66833D[422B0100]00  <1> 	cmp	word [LCDE_ClusterSN], 0
  2311 00009AAE 763E                <1> 	jna	short loc_lcde_check_dir_buffer_cluster
  2312 00009AB0 A3[442B0100]        <1> 	mov	[LCDE_Cluster], eax
  2313 00009AB5 E815100000          <1> 	call	get_next_cluster
  2314 00009ABA 7220                <1> 	jc	short loc_lcde_check_gnc_error
  2315 00009ABC 66FF0D[422B0100]    <1>   	dec	word [LCDE_ClusterSN]
  2316 00009AC3 EBE1                <1> 	jmp	short loc_lcde_get_next_cluster
  2317                              <1> 
  2318                              <1> loc_lcde_reload_current_directory:
  2319 00009AC5 51                  <1> 	push	ecx
  2320 00009AC6 E812F6FFFF          <1> 	call	reload_current_directory
  2321 00009ACB 59                  <1> 	pop	ecx
  2322 00009ACC 0F8361FFFFFF        <1>         jnc     loc_lcde_cdl_check
  2323 00009AD2 5E                  <1> 	pop	esi
  2324 00009AD3 C3                  <1> 	retn
  2325                              <1> 
  2326                              <1> loc_lcde_invalid_format:
  2327 00009AD4 B80B000000          <1> 	mov	eax, 0Bh ; MSDOS Error code: Invalid Format
  2328                              <1> 	;mov	eax, 0Dh ; MSDOS Error code: Invalid Data
  2329                              <1> loc_lcde_drive_not_ready_read_err:
  2330 00009AD9 F9                  <1> 	stc
  2331 00009ADA 5E                  <1> 	pop	esi 
  2332 00009ADB C3                  <1> 	retn  
  2333                              <1> 
  2334                              <1> loc_lcde_check_gnc_error:
  2335 00009ADC 09C0                <1> 	or	eax, eax
  2336 00009ADE 75F9                <1> 	jnz	short loc_lcde_drive_not_ready_read_err
  2337 00009AE0 66FF0D[422B0100]    <1> 	dec	word [LCDE_ClusterSN]
  2338 00009AE7 75EB                <1> 	jnz	short loc_lcde_invalid_format 
  2339 00009AE9 A1[442B0100]        <1> 	mov	eax, [LCDE_Cluster]
  2340                              <1> 
  2341                              <1> loc_lcde_check_dir_buffer_cluster:
  2342 00009AEE 3B05[9D280100]      <1> 	cmp	eax, [DirBuff_Cluster]
  2343 00009AF4 755C                <1> 	jne	short loc_lcde_load_dir_cluster
  2344 00009AF6 803D[98280100]00    <1> 	cmp	byte [DirBuff_ValidData], 0
  2345 00009AFD 7727                <1> 	ja	short lcde_check_dir_buffer_cluster_next
  2346 00009AFF 803D[6C200100]00    <1> 	cmp	byte [Current_Dir_Level], 0    
  2347 00009B06 775F                <1> 	ja	short loc_lcde_load_dir_cluster_0
  2348                              <1> 	; 27/02/2016
  2349                              <1> 	; TRDOS v1 has bug here for FAT32 fs !
  2350 00009B08 807E0303            <1> 	cmp	byte [esi+LD_FATType], 3  ; FAT32
  2351 00009B0C 7359                <1> 	jnb	short loc_lcde_load_dir_cluster_0
  2352                              <1> 	;
  2353 00009B0E 0FB74E17            <1> 	movzx	ecx, word [esi+LD_BPB+RootDirEnts]
  2354 00009B12 6683C10F            <1> 	add	cx, 15 ; round up (16 entries per sector)
  2355 00009B16 66C1E904            <1> 	shr	cx, 4 ; 1 sector contains 16 dir entries	
  2356                              <1> 
  2357 00009B1A 8B4664              <1>         mov     eax, [esi+LD_ROOTBegin]
  2358 00009B1D EB54                <1> 	jmp	short loc_lcde_load_dir_cluster_1 
  2359                              <1> 
  2360                              <1> loc_lcde_validate_dirBuff:
  2361 00009B1F C605[98280100]01    <1> 	mov	byte [DirBuff_ValidData], 1
  2362                              <1> 
  2363                              <1> lcde_check_dir_buffer_cluster_next:
  2364 00009B26 0FB71D[402B0100]    <1> 	movzx	ebx, word [LCDE_EntryIndex]
  2365 00009B2D 663B1D[9B280100]    <1> 	cmp	bx, [DirBuff_LastEntry]
  2366 00009B34 779E                <1> 	ja	short loc_lcde_invalid_format 
  2367 00009B36 B820000000          <1> 	mov	eax, 32
  2368 00009B3B F7E3                <1> 	mul	ebx
  2369                              <1> 	;or	edx, edx
  2370                              <1> 	;jnz	short loc_lcde_invalid_format
  2371                              <1> 
  2372 00009B3D BF00000800          <1> 	mov	edi, Directory_Buffer  
  2373 00009B42 01C7                <1> 	add	edi, eax ; add entry offset to buffer address
  2374                              <1> 
  2375                              <1> loc_lcde_dir_buffer_last_check:
  2376 00009B44 A1[9D280100]        <1> 	mov	eax, [DirBuff_Cluster]
  2377 00009B49 0FB60D[98280100]    <1> 	movzx	ecx, byte [DirBuff_ValidData]
  2378                              <1> 
  2379                              <1> loc_lcde_retn:
  2380 00009B50 5E                  <1> 	pop	esi
  2381 00009B51 C3                  <1> 	retn
  2382                              <1> 
  2383                              <1> loc_lcde_load_dir_cluster:
  2384                              <1> 	;cmp	byte [DirBuff_ValidData], 2
  2385                              <1> 	;jne	short loc_lcde_load_dir_cluster_n2
  2386 00009B52 50                  <1> 	push	eax
  2387 00009B53 E8E4FCFFFF          <1> 	call	save_directory_buffer
  2388 00009B58 58                  <1> 	pop	eax
  2389 00009B59 72F5                <1> 	jc	short loc_lcde_retn
  2390                              <1> 
  2391                              <1> loc_lcde_load_dir_cluster_n2:
  2392 00009B5B C605[98280100]00    <1> 	mov	byte [DirBuff_ValidData], 0
  2393 00009B62 A3[9D280100]        <1> 	mov	[DirBuff_Cluster], eax
  2394                              <1> 
  2395                              <1> loc_lcde_load_dir_cluster_0:
  2396 00009B67 83E802              <1> 	sub	eax, 2
  2397 00009B6A 0FB64E13            <1> 	movzx	ecx, byte [esi+LD_BPB+SecPerClust]
  2398 00009B6E F7E1                <1> 	mul	ecx
  2399 00009B70 034668              <1>         add     eax, [esi+LD_DATABegin]
  2400                              <1> 
  2401                              <1> loc_lcde_load_dir_cluster_1:
  2402 00009B73 BB00000800          <1> 	mov	ebx, Directory_Buffer
  2403                              <1> 	; ecx = sector count
  2404 00009B78 E87B3E0000          <1> 	call	disk_read
  2405 00009B7D 73A0                <1> 	jnc	short loc_lcde_validate_dirBuff
  2406                              <1> 
  2407                              <1> 	; 23/03/2016
  2408 00009B7F B815000000          <1> 	mov	eax, 15h ; Drive not ready or read error !
  2409 00009B84 EBCA                <1> 	jmp	short loc_lcde_retn
  2410                              <1> 
  2411                              <1> 
  2412                              <1> remove_file:
  2413                              <1> 	; 28/02/2016 (TRDOS 386 = TRDOS v2.0)
  2414                              <1> 	; 10/04/2011 (FILE.ASM, 'proc_delete_file')
  2415                              <1> 	; 09/08/2010
  2416                              <1> 	; INPUT ->
  2417                              <1> 	;	EDI = Directory Buffer Entry Address
  2418                              <1> 	;	 CX = Directory Buffer Entry Counter/Index
  2419                              <1> 	;	 BL = Longname Entry Length
  2420                              <1> 	;	 BH = Logical DOS Drive Number 
  2421                              <1> 
  2422 00009B86 29C0                <1> 	sub	eax, eax
  2423 00009B88 88FC                <1> 	mov	ah, bh
  2424 00009B8A BE00010900          <1> 	mov	esi, Logical_DOSDisks
  2425 00009B8F 01C6                <1> 	add	esi, eax
  2426                              <1> 
  2427 00009B91 807E0301            <1> 	cmp	byte [esi+LD_FATType], 1
  2428 00009B95 7312                <1> 	jnb	short loc_del_fat_file 
  2429                              <1>               
  2430 00009B97 807E04A1            <1> 	cmp	byte [esi+LD_FSType], 0A1h
  2431 00009B9B 7406                <1> 	je	short loc_del_fs_file
  2432                              <1> 
  2433                              <1> loc_del_file_invalid_format:
  2434 00009B9D 30E4                <1> 	xor	ah, ah
  2435 00009B9F B00B                <1> 	mov	al, 0Bh ; Invalid Format
  2436 00009BA1 F9                  <1> 	stc 
  2437 00009BA2 C3                  <1> 	retn
  2438                              <1> 
  2439                              <1> loc_del_fs_file:
  2440 00009BA3 E8200F0000          <1> 	call	delete_fs_file
  2441 00009BA8 C3                  <1> 	retn
  2442                              <1> 
  2443                              <1> loc_del_fat_file:
  2444 00009BA9 E808000000          <1> 	call	delete_directory_entry
  2445 00009BAE 7205                <1> 	jc	short loc_del_file_err_retn 
  2446                              <1> 
  2447                              <1> loc_delfile_unlink_cluster_chain:
  2448 00009BB0 E834170000          <1> 	call	truncate_cluster_chain
  2449                              <1> 	;jc	short loc_del_file_err_retn
  2450                              <1> 
  2451                              <1> loc_delfile_return:
  2452                              <1> loc_del_file_err_retn:
  2453 00009BB5 C3                  <1> 	retn
  2454                              <1> 
  2455                              <1> delete_directory_entry:
  2456                              <1> 	; 28/02/2016 (TRDOS 386 = TRDOS v2.0)
  2457                              <1> 	; 01/08/2011 (DIR.ASM, 'proc_delete_directory_entry')
  2458                              <1> 	; 10/04/2011 
  2459                              <1> 	; INPUT ->
  2460                              <1> 	; 	ESI = Logical Dos Drive Descripton Table Address 
  2461                              <1> 	;	EDI = Directory Buffer Entry Address
  2462                              <1> 	;	 CX = Directory Buffer Entry Counter/Index
  2463                              <1> 	;	 BL = Longname Entry Length
  2464                              <1> 	; OUTPUT ->
  2465                              <1> 	; 	ESI = Logical dos drive descripton table address 
  2466                              <1> 	;	EAX = First cluster to be truncated/unlinked
  2467                              <1> 	;       CF = 1 -> Error code in EAX (AL)
  2468                              <1> 	;       CF = 0 & BH <> 0 -> LMDT write error  (BH = 1)
  2469                              <1> 	;       CF = 0 & BL <> 0 -> Long name delete error (BL = FFh) 
  2470                              <1> 	;
  2471                              <1> 	;  (EDI, EBX, ECX register contents will be changed)
  2472                              <1> 
  2473 00009BB6 881D[DA2A0100]      <1> 	mov	[DelFile_LNEL], bl
  2474 00009BBC 66890D[D82A0100]    <1> 	mov	[DelFile_EntryCounter], cx
  2475                              <1> 
  2476 00009BC3 668B4714            <1> 	mov	ax, [edi+20] ; First Cluster High Word
  2477 00009BC7 C1E010              <1> 	shl	eax, 16
  2478 00009BCA 668B471A            <1> 	mov	ax, [edi+26] ; First Cluster Low Word
  2479                              <1> 
  2480 00009BCE A3[D42A0100]        <1> 	mov	[DelFile_FCluster], eax
  2481                              <1> 
  2482                              <1> loc_del_short_name:
  2483 00009BD3 C607E5              <1> 	mov	byte [edi], 0E5h  ; Deleted sign
  2484                              <1> 
  2485 00009BD6 C605[98280100]02    <1> 	mov	byte [DirBuff_ValidData], 2
  2486 00009BDD E85AFCFFFF          <1> 	call	save_directory_buffer
  2487 00009BE2 723D                <1> 	jc	short loc_delete_direntry_err_return
  2488                              <1>  
  2489                              <1> loc_del_long_name:
  2490 00009BE4 0FB615[DA2A0100]    <1> 	movzx	edx, byte [DelFile_LNEL]
  2491 00009BEB 08D2                <1> 	or	dl, dl
  2492 00009BED 7416                <1> 	jz	short loc_del_dir_entry_update_parent_dir_lm_date
  2493                              <1> 
  2494 00009BEF 8835[DA2A0100]      <1> 	mov	byte [DelFile_LNEL], dh ; 0              
  2495                              <1>   
  2496 00009BF5 0FB705[D82A0100]    <1> 	movzx	eax,  word [DelFile_EntryCounter]
  2497 00009BFC 29D0                <1> 	sub	eax, edx
  2498                              <1> 	;jnc	short loc_del_long_name_continue
  2499 00009BFE 7205                <1> 	jc	short loc_del_dir_entry_update_parent_dir_lm_date   
  2500                              <1> 
  2501                              <1> ;loc_del_direntry_inv_data_return:
  2502                              <1> ;	mov	eax, 0Dh ; Invalid data
  2503                              <1> ;	retn
  2504                              <1> 
  2505                              <1> loc_del_long_name_continue: 
  2506                              <1> 	; AX = Directory Entry Number of the long name last entry
  2507 00009C00 E897FDFFFF          <1> 	call	delete_longname
  2508                              <1> 	;jc	short loc_delete_direntry_err_return
  2509                              <1> 
  2510                              <1> loc_del_dir_entry_update_parent_dir_lm_date:
  2511 00009C05 801D[DA2A0100]00    <1> 	sbb	byte [DelFile_LNEL], 0 ; 0FFh if cf = 1
  2512                              <1> 
  2513 00009C0C E8C6FCFFFF          <1> 	call	update_parent_dir_lmdt
  2514 00009C11 B700                <1> 	mov	bh, 0
  2515 00009C13 80D700              <1> 	adc	bh, 0
  2516                              <1> 
  2517 00009C16 8A1D[DA2A0100]      <1> 	mov	bl, byte [DelFile_LNEL]
  2518                              <1>  
  2519                              <1> loc_delete_direntry_return:
  2520 00009C1C A1[D42A0100]        <1> 	mov	eax, [DelFile_FCluster]
  2521                              <1> loc_delete_direntry_err_return:
  2522 00009C21 C3                  <1> 	retn
  2523                              <1> 
  2524                              <1> rename_directory_entry:
  2525                              <1> 	; 06/03/2016 (TRDOS 386 = TRDOS v2.0)
  2526                              <1> 	; 01/08/2011 (DIR.ASM, 'proc_rename_directory_entry')
  2527                              <1> 	; 19/11/2010
  2528                              <1> 	; INPUT -> (Current Directory)
  2529                              <1> 	;	CX = Directory Entry Number
  2530                              <1> 	;      EAX = First Cluster number of file or directory
  2531                              <1> 	;      EBX = Longname Length (dir entry count) (< 256)
  2532                              <1> 	;      ESI = New file (or directory) name (no path).
  2533                              <1> 	;           (ASCIIZ string)  
  2534                              <1> 	; OUTPUT -> 
  2535                              <1> 	;      CF = 0 -> successfull
  2536                              <1> 	;      CF = 1 -> error code in EAX (AL)
  2537                              <1> 	;
  2538                              <1> 	; (EAX, EBX, ECX, EDX, ESI, EDI will be changed)
  2539                              <1> 
  2540 00009C22 803D[6D200100]00    <1> 	cmp	byte [Current_FATType], 0
  2541 00009C29 7706                <1> 	ja	short loc_rename_directory_entry
  2542                              <1> 
  2543 00009C2B E8990E0000          <1> 	call	rename_fs_file_or_directory
  2544 00009C30 C3                  <1> 	retn 
  2545                              <1> 	
  2546                              <1> loc_rename_directory_entry:
  2547 00009C31 881D[DA2A0100]      <1> 	mov	[DelFile_LNEL], bl
  2548 00009C37 66890D[D82A0100]    <1> 	mov	[DelFile_EntryCounter], cx
  2549 00009C3E A3[D42A0100]        <1> 	mov	[DelFile_FCluster], eax
  2550                              <1> 
  2551 00009C43 0FB7C1              <1> 	movzx	eax, cx
  2552 00009C46 E8BBFDFFFF          <1> 	call	locate_current_dir_entry
  2553 00009C4B 7308                <1> 	jnc	short loc_rename_direntry_check_fcluster
  2554                              <1> 
  2555                              <1> loc_rename_direntry_pop_retn:
  2556 00009C4D C3                  <1> 	retn
  2557                              <1> 
  2558                              <1> loc_rename_direntry_pop_invd_retn:
  2559 00009C4E F9                  <1> 	stc
  2560                              <1> loc_rename_direntry_invd_retn:
  2561 00009C4F B80D000000          <1> 	mov	eax, 0Dh ; Invalid data
  2562                              <1> loc_rename_retn:
  2563 00009C54 C3                  <1> 	retn 
  2564                              <1> 
  2565                              <1> loc_rename_direntry_check_fcluster:
  2566 00009C55 668B5714            <1> 	mov	dx, [edi+20] ; First Cluster HW
  2567 00009C59 66C1E210            <1> 	shl	dx, 16
  2568 00009C5D 668B571A            <1> 	mov	dx, [edi+26] ; First Cluster LW
  2569 00009C61 3B15[D42A0100]      <1> 	cmp	edx, [DelFile_FCluster]
  2570 00009C67 75E5                <1> 	jne	short loc_rename_direntry_pop_invd_retn
  2571                              <1> 	; ESI = New file (or directory) name. (ASCIIZ string)
  2572                              <1> 	; 06/03/2016
  2573                              <1> 	; TRDOS v2 - NOTE: 'convert_file_name' procedure
  2574                              <1> 	; has been modified for eliminating following situation.
  2575                              <1> 	; 
  2576                              <1> 	; TRDOS v1 - NOTE: If file/dir name is more than 11 bytes
  2577                              <1> 	; without a dot, attributes (edi+11) byte will be overwritten !
  2578                              <1> 	; (Dot file name input must be proper for 11 byte dir entry
  2579                              <1> 	;  type file name output.) 
  2580 00009C69 E89FF6FFFF          <1> 	call	convert_file_name
  2581                              <1> 
  2582 00009C6E C605[98280100]02    <1>         mov     byte [DirBuff_ValidData], 2
  2583 00009C75 E8C2FBFFFF          <1> 	call	save_directory_buffer
  2584 00009C7A 72D8                <1> 	jc	short loc_rename_retn
  2585                              <1> 
  2586                              <1> loc_rename_direntry_del_ln:
  2587 00009C7C 0FB615[DA2A0100]    <1> 	movzx	edx, byte [DelFile_LNEL]
  2588 00009C83 08D2                <1> 	or	dl, dl
  2589 00009C85 7410                <1> 	jz	short loc_rename_direntry_update_parent_dir_lm_date
  2590                              <1> 
  2591 00009C87 0FB705[D82A0100]    <1> 	movzx	eax, word [DelFile_EntryCounter]
  2592 00009C8E 29D0                <1> 	sub	eax, edx
  2593 00009C90 72BD                <1> 	jc	short loc_rename_direntry_invd_retn
  2594                              <1> 
  2595                              <1> loc_rename_direntry_del_ln_continue: 
  2596                              <1> 	; EAX = Directory Entry Number of the long name last entry
  2597 00009C92 E805FDFFFF          <1> 	call	delete_longname
  2598                              <1> 
  2599                              <1> loc_rename_direntry_update_parent_dir_lm_date:
  2600 00009C97 E83BFCFFFF          <1> 	call	update_parent_dir_lmdt
  2601 00009C9C 31C0                <1> 	xor	eax, eax 
  2602 00009C9E C3                  <1> 	retn
  2603                              <1> 
  2604                              <1> move_source_file_to_destination_file:
  2605                              <1> 	; 11/03/2016
  2606                              <1> 	; 10/03/2016 (TRDOS 386 = TRDOS v2.0)
  2607                              <1> 	; 01/08/2011 (FILE.ASM)
  2608                              <1> 	; 04/08/2010
  2609                              <1> 	;
  2610                              <1> 	;   Phase 1 -> Check destination file, 
  2611                              <1> 	;              'not found' is required
  2612                              <1> 	;   Phase 2 -> Check source file
  2613                              <1> 	;              'found' and proper attributes is required
  2614                              <1> 	;   Phase 3 -> Make destination directory entry,
  2615                              <1> 	;           add new dir cluster or section if it is required
  2616                              <1> 	;   Phase 4 -> Delete source directory entry.
  2617                              <1> 	;       cf = 1 causes to return before the phase 4.
  2618                              <1> 	;    (source file protection against any possible errors)    
  2619                              <1> 	;
  2620                              <1> 	; 08/05/2011 major modification
  2621                              <1> 	;            -> destination file deleting is removed   
  2622                              <1> 	;            for msdos move/rename compatibility.
  2623                              <1> 	;            (Access denied error will return if
  2624                              <1> 	;            the destination file is found...)
  2625                              <1> 	; INPUT ->
  2626                              <1> 	;	 ESI = Source File Pathname (Asciiz)
  2627                              <1> 	;        EDI = Destination File Pathname (Asciiz)
  2628                              <1> 	;        AL = 0 --> Interrupt (System call)
  2629                              <1> 	;        AL > 0 --> Command Interpreter (Question)
  2630                              <1> 	;        AL = 1 --> Question Phase
  2631                              <1> 	;        AL = 2 --> Progress Phase        
  2632                              <1> 	; OUTPUT -> 
  2633                              <1> 	;	 cf = 0 -> OK
  2634                              <1> 	;        EAX = Destination directory first cluster
  2635                              <1> 	;        ESI = Logical DOS drive description table 
  2636                              <1> 	;        EBX = Destination file structure offset
  2637                              <1> 	;        CX = 0 (CX > 0 --> calculate free space error)
  2638                              <1> 	;        cf = 1 -> Error code in EAX (AL) 
  2639                              <1> 	;
  2640                              <1> 	;  (EDX, ECX, EBX, ESI, EDI will be changed)
  2641                              <1> 
  2642 00009C9F 3C02                <1> 	cmp	al, 2
  2643 00009CA1 0F846D010000        <1> 	je	msftdf_df2_check_directory
  2644 00009CA7 A2[562C0100]        <1> 	mov	[move_cmd_phase], al
  2645                              <1> 
  2646                              <1> msftdf_parse_sf_path:
  2647                              <1> 	; ESI = ASCIIZ pathname (Source)
  2648 00009CAC 57                  <1> 	push	edi 
  2649 00009CAD BF[542B0100]        <1> 	mov	edi, SourceFile_Drv
  2650 00009CB2 E821F7FFFF          <1> 	call	parse_path_name
  2651 00009CB7 5E                  <1> 	pop	esi
  2652 00009CB8 7211                <1> 	jc	short msftdf_psf_retn
  2653                              <1> 
  2654                              <1> msftdf_parse_df_path:
  2655                              <1> 	; ESI = ASCIIZ pathname	(Destination)
  2656 00009CBA BF[D42B0100]        <1> 	mov	edi, DestinationFile_Drv
  2657 00009CBF E814F7FFFF          <1> 	call	parse_path_name
  2658 00009CC4 7306                <1> 	jnc	short msftdf_check_sf_drv
  2659                              <1> 
  2660 00009CC6 3C01                <1> 	cmp	al, 1 ; File or directory name is not existing
  2661 00009CC8 7602                <1> 	jna	short msftdf_check_sf_drv
  2662                              <1> 
  2663                              <1> msftdf_stc_retn:
  2664 00009CCA F9                  <1> 	stc
  2665                              <1> msftdf_psf_retn:
  2666 00009CCB C3                  <1> 	retn 
  2667                              <1> 
  2668                              <1> msftdf_check_sf_drv:
  2669 00009CCC A0[542B0100]        <1> 	mov	al, [SourceFile_Drv]
  2670                              <1> 
  2671                              <1> msftdf_check_df_drv:
  2672 00009CD1 8A15[D42B0100]      <1> 	mov	dl, [DestinationFile_Drv]
  2673                              <1> 
  2674                              <1> msftdf_compare_sf_df_drv:
  2675 00009CD7 29DB                <1> 	sub	ebx, ebx
  2676 00009CD9 8A3D[6E200100]      <1> 	mov	bh, [Current_Drv]
  2677 00009CDF 38C2                <1> 	cmp	dl, al
  2678 00009CE1 7409                <1> 	je	short msftdf_check_sf_df_drv_ok
  2679                              <1> 
  2680                              <1> msftdf_not_same_drv:
  2681                              <1>         ; DL = source file's drive number
  2682 00009CE3 88C6                <1> 	mov	dh, al ; destination file's drive number
  2683 00009CE5 B811000000          <1> 	mov	eax, 11h ; Not the same drive
  2684 00009CEA F9                  <1> 	stc
  2685 00009CEB C3                  <1> 	retn 
  2686                              <1> 
  2687                              <1> msftdf_check_sf_df_drv_ok:
  2688 00009CEC 8815[572C0100]      <1> 	mov	[msftdf_sf_df_drv], dl
  2689                              <1> 
  2690 00009CF2 29C0                <1>         sub	eax, eax
  2691 00009CF4 88D4                <1> 	mov	ah, dl
  2692 00009CF6 0500010900          <1> 	add	eax, Logical_DOSDisks
  2693 00009CFB A3[582C0100]        <1> 	mov	[msftdf_drv_offset], eax
  2694                              <1> 
  2695 00009D00 38FA                <1> 	cmp	dl, bh ; byte [Current_Drv]
  2696 00009D02 7407                <1> 	je	short msftdf_df_check_directory
  2697                              <1> 
  2698                              <1> msftdf_change_drv:
  2699 00009D04 E829C1FFFF          <1> 	call 	change_current_drive
  2700 00009D09 725B                <1> 	jc	short msftdf_df_error_retn
  2701                              <1> 	  
  2702                              <1> msftdf_check_destination_file:
  2703                              <1> msftdf_df_check_directory:
  2704 00009D0B BE[D52B0100]        <1> 	mov	esi, DestinationFile_Directory
  2705 00009D10 803E20              <1> 	cmp	byte [esi], 20h
  2706 00009D13 760F                <1> 	jna	short msftdf_df_find_1
  2707                              <1> 
  2708                              <1> msftdf_df_change_directory:
  2709 00009D15 FE05[E4DD0000]      <1> 	inc	byte [Restore_CDIR]
  2710 00009D1B 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
  2711 00009D1D E8A2F0FFFF          <1> 	call	change_current_directory
  2712 00009D22 7242                <1> 	jc	short msftdf_df_error_retn
  2713                              <1> 
  2714                              <1> ;msftdf_df_change_prompt_dir_string:
  2715                              <1> ;	call 	change_prompt_dir_string
  2716                              <1> 
  2717                              <1> msftdf_df_find_1:
  2718 00009D24 BE[162C0100]        <1>         mov     esi, DestinationFile_Name
  2719 00009D29 803E20              <1> 	cmp	byte [esi], 20h
  2720 00009D2C 761F                <1> 	jna	short msftdf_df_copy_sf_name
  2721                              <1> 
  2722                              <1> msftdf_df_find_2:
  2723 00009D2E 6631C0              <1> 	xor	ax, ax ; DestinationFile_AttributesMask -> any/zero
  2724 00009D31 E898D4FFFF          <1> 	call	find_first_file
  2725 00009D36 737F                <1> 	jnc	short msftdf_permission_denied_retn
  2726                              <1> 
  2727                              <1> msftdf_df_check_error_code:
  2728                              <1> 	;cmp	eax, 2 ; File not found error
  2729 00009D38 3C02                <1> 	cmp	al, 2
  2730 00009D3A 7529                <1> 	jne	short msftdf_df_stc_retn
  2731                              <1>               
  2732                              <1> msftdf_convert_df_direntry_name:
  2733 00009D3C BE[162C0100]        <1> 	mov	esi, DestinationFile_Name
  2734 00009D41 BF[262C0100]        <1> 	mov	edi, DestinationFile_DirEntry
  2735 00009D46 E8C2F5FFFF          <1> 	call	convert_file_name
  2736 00009D4B EB1A                <1>   	jmp	short msftdf_restore_current_dir_1
  2737                              <1> 
  2738                              <1> msftdf_df_copy_sf_name:
  2739 00009D4D 89F7                <1> 	mov	edi, esi
  2740 00009D4F 57                  <1> 	push	edi 
  2741 00009D50 BE[962B0100]        <1>         mov     esi, SourceFile_Name
  2742 00009D55 B90C000000          <1> 	mov	ecx, 12
  2743                              <1> msftdf_df_copy_sf_name_loop:
  2744 00009D5A AC                  <1> 	lodsb
  2745 00009D5B AA                  <1>         stosb
  2746 00009D5C 08C0                <1> 	or	al, al
  2747 00009D5E 7402                <1> 	jz	short msftdf_df_copy_sf_name_ok	
  2748 00009D60 E2F8                <1>         loop    msftdf_df_copy_sf_name_loop
  2749                              <1> msftdf_df_copy_sf_name_ok:	
  2750 00009D62 5E                  <1> 	pop	esi  
  2751 00009D63 EBC9                <1> 	jmp	short msftdf_df_find_2
  2752                              <1> 
  2753                              <1> msftdf_df_stc_retn:
  2754 00009D65 F9                  <1> 	stc
  2755                              <1> msftdf_restore_cdir_failed:
  2756                              <1> msftdf_df_error_retn:
  2757 00009D66 C3                  <1> 	retn
  2758                              <1> 
  2759                              <1> msftdf_restore_current_dir_1:
  2760 00009D67 803D[E4DD0000]00    <1> 	cmp	byte [Restore_CDIR], 0
  2761 00009D6E 760D                <1> 	jna	short msftdf_sf_check_directory
  2762 00009D70 8B35[582C0100]      <1> 	mov	esi, [msftdf_drv_offset] 
  2763 00009D76 E869C1FFFF          <1> 	call	restore_current_directory
  2764 00009D7B 72E9                <1> 	jc	short msftdf_restore_cdir_failed
  2765                              <1> 
  2766                              <1> msftdf_sf_check_directory:
  2767 00009D7D BE[552B0100]        <1> 	mov	esi, SourceFile_Directory
  2768 00009D82 803E20              <1> 	cmp	byte [esi], 20h
  2769 00009D85 760F                <1> 	jna	short msftdf_sf_find
  2770                              <1> msftdf_sf_change_directory:
  2771 00009D87 FE05[E4DD0000]      <1> 	inc	byte [Restore_CDIR]
  2772 00009D8D 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
  2773 00009D8F E830F0FFFF          <1> 	call	change_current_directory
  2774 00009D94 7227                <1> 	jc	short msftdf_return
  2775                              <1> 
  2776                              <1> ;msftdf_sf_change_prompt_dir_string:
  2777                              <1> ;	call	change_prompt_dir_string
  2778                              <1> 
  2779                              <1> msftdf_sf_find:
  2780 00009D96 BE[962B0100]        <1>         mov     esi, SourceFile_Name  ; Offset 66
  2781 00009D9B 66B80018            <1> 	mov	ax, 1800h ; Only files
  2782 00009D9F E82AD4FFFF          <1> 	call	find_first_file
  2783 00009DA4 7217                <1> 	jc	short msftdf_return
  2784                              <1> 
  2785                              <1> msftdf_sf_ambgfn_check:
  2786 00009DA6 6609D2              <1> 	or	dx, dx ; Ambiguous filename chars used sign (DX>0)
  2787 00009DA9 7407                <1> 	jz	short msftdf_sf_found
  2788                              <1> 
  2789                              <1> msftdf_ambiguous_file_name_error:
  2790 00009DAB B802000000          <1> 	mov	eax, 2 ; File not found error
  2791 00009DB0 F9                  <1> 	stc
  2792 00009DB1 C3                  <1> 	retn
  2793                              <1> 
  2794                              <1> msftdf_sf_found:
  2795 00009DB2 80E31F              <1> 	and	bl, 1Fh ; Attributes, D-V-S-H-R
  2796 00009DB5 7416                <1> 	jz	short msftdf_save_sf_structure
  2797                              <1> 
  2798                              <1> msftdf_permission_denied_retn:
  2799 00009DB7 B805000000          <1> 	mov	eax, 05h ; Access (Permission) denied !
  2800 00009DBC F9                  <1> 	stc
  2801                              <1> msftdf_rest_cdir_err_retn:
  2802                              <1> msftdf_return:
  2803 00009DBD C3                  <1> 	retn
  2804                              <1> 
  2805                              <1> msftdf_phase_1_return:
  2806 00009DBE 31C0                <1> 	xor	eax, eax
  2807 00009DC0 A2[562C0100]        <1> 	mov	[move_cmd_phase], al ; 0
  2808 00009DC5 FEC0                <1> 	inc	al ; mov al, 1
  2809 00009DC7 BB[149E0000]        <1> 	mov	ebx, msftdf_df2_check_directory
  2810                              <1> 	;mov	edx, 0FFFFFFFFh 
  2811 00009DCC C3                  <1> 	retn
  2812                              <1> 
  2813                              <1> msftdf_save_sf_structure:
  2814 00009DCD BE[642A0100]        <1> 	mov	esi, FindFile_DirEntry
  2815 00009DD2 BF[A62B0100]        <1> 	mov	edi, SourceFile_DirEntry
  2816 00009DD7 B908000000          <1> 	mov	ecx, 8
  2817 00009DDC F3A5                <1> 	rep	movsd
  2818                              <1> 
  2819                              <1> msftdf_df_copy_sf_parameters:
  2820 00009DDE BE0B000000          <1> 	mov	esi, 11
  2821 00009DE3 89F7                <1> 	mov	edi, esi
  2822 00009DE5 81C6[A62B0100]      <1> 	add	esi, SourceFile_DirEntry
  2823 00009DEB 81C7[262C0100]      <1> 	add	edi, DestinationFile_DirEntry
  2824                              <1> 	;mov	ecx, 21
  2825 00009DF1 B115                <1> 	mov	cl, 21
  2826 00009DF3 F3A4                <1> 	rep	movsb
  2827                              <1> 
  2828                              <1> msftdf_restore_current_dir_2:
  2829 00009DF5 803D[E4DD0000]00    <1> 	cmp	byte [Restore_CDIR], 0
  2830 00009DFC 760D                <1> 	jna	short msftdf_df2_check_move_cmd_phase
  2831 00009DFE 8B35[582C0100]      <1>  	mov	esi, [msftdf_drv_offset]
  2832 00009E04 E8DBC0FFFF          <1> 	call	restore_current_directory
  2833 00009E09 72B2                <1> 	jc	short msftdf_rest_cdir_err_retn
  2834                              <1> 
  2835                              <1> msftdf_df2_check_move_cmd_phase:
  2836 00009E0B 803D[562C0100]01    <1> 	cmp	byte [move_cmd_phase], 1
  2837 00009E12 74AA                <1> 	je	short msftdf_phase_1_return
  2838                              <1> 
  2839                              <1> msftdf_df2_check_directory:
  2840 00009E14 BE[D52B0100]        <1> 	mov	esi, DestinationFile_Directory
  2841 00009E19 803E20              <1> 	cmp	byte [esi], 20h
  2842 00009E1C 760F                <1> 	jna	short msftdf_make_dfde_locate_ffe_on_directory
  2843                              <1> msftdf_df2_change_directory:
  2844 00009E1E FE05[E4DD0000]      <1> 	inc	byte [Restore_CDIR]
  2845 00009E24 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
  2846 00009E26 E899EFFFFF          <1> 	call	change_current_directory
  2847 00009E2B 7290                <1> 	jc	short msftdf_return
  2848                              <1> 
  2849                              <1> ;msftdf_df2_change_prompt_dir_string:
  2850                              <1> ;	call	change_prompt_dir_string
  2851                              <1> 
  2852                              <1> msftdf_make_dfde_locate_ffe_on_directory:
  2853                              <1> 	; Current directory fcluster <> Directory buffer cluster
  2854                              <1> 	; Current directory will be reloaded by
  2855                              <1> 	; 'locate_current_dir_file' procedure
  2856                              <1> 	;
  2857                              <1> 	;xor	ax, ax
  2858 00009E2D 31C0                <1> 	xor	eax, eax
  2859 00009E2F 89C1                <1> 	mov	ecx, eax
  2860 00009E31 6649                <1> 	dec	cx ; FFFFh  
  2861                              <1> 		; CX = FFFFh -> find first deleted or free entry
  2862                              <1> 		; ESI would be ASCIIZ filename address if the call
  2863                              <1> 		; would not be for first free or deleted dir entry  
  2864 00009E33 E8E0F1FFFF          <1> 	call	locate_current_dir_file
  2865 00009E38 733F                <1> 	jnc	msftdf_make_dfde_set_ff_dir_entry
  2866                              <1> 	
  2867                              <1> 	;cmp	eax, 2
  2868 00009E3A 3C02                <1>         cmp	al, 2
  2869 00009E3C 7537                <1> 	jne	short msftdf_error_retn
  2870                              <1> 
  2871                              <1> msftdf_add_new_dir_entry_check_fs:
  2872 00009E3E 8B35[582C0100]      <1> 	mov	esi, [msftdf_drv_offset]
  2873 00009E44 A1[9D280100]        <1> 	mov 	eax, [DirBuff_Cluster]
  2874 00009E49 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
  2875 00009E4D 7711                <1> 	ja	short msftdf_add_new_subdir_cluster
  2876                              <1> 
  2877                              <1> msftdf_add_new_fs_subdir_section:
  2878                              <1> 	;CL=0, CH=E5h --> deleted entry, CH=0 --> free entry
  2879                              <1>         ;xor	cx, cx
  2880 00009E4F 30ED                <1> 	xor	ch, ch ; cx = 0 --> add a new subdir section
  2881 00009E51 E8750C0000          <1> 	call	add_new_fs_section
  2882 00009E56 721E                <1>         jc	short msftdf_dsfde_error_retn
  2883                              <1> 	;mov	[createfile_LastDirCluster], eax
  2884                              <1> 
  2885 00009E58 E8950E0000          <1> 	call	load_FS_sub_directory 
  2886                              <1> 	;mov	ebx, Directory_Buffer 
  2887 00009E5D 7318                <1> 	jnc	short msftdf_add_new_fs_subdir_section_ok
  2888 00009E5F C3                  <1> 	retn	 
  2889                              <1> 
  2890                              <1> msftdf_add_new_subdir_cluster:
  2891 00009E60 E863150000          <1> 	call	add_new_cluster
  2892 00009E65 720F                <1> 	jc	short msftdf_dsfde_error_retn
  2893                              <1> 	
  2894                              <1> 	;mov	[createfile_LastDirCluster], eax
  2895                              <1> 
  2896 00009E67 E8490E0000          <1> 	call	load_FAT_sub_directory
  2897 00009E6C 7309                <1> 	jnc	short msftdf_add_new_subdir_cluster_ok
  2898                              <1> 	; EBX = Directory buffer address
  2899                              <1> 
  2900                              <1> msftdf_ansdc_update_parent_dir_lmdt:
  2901                              <1> msftdf_make_dfde_err_upd_pdir_lmdt:
  2902 00009E6E 50                  <1> 	push	eax
  2903 00009E6F E863FAFFFF          <1> 	call	update_parent_dir_lmdt
  2904 00009E74 58                  <1> 	pop	eax
  2905                              <1> 
  2906                              <1> msftdf_error_retn:
  2907 00009E75 F9                  <1> 	stc
  2908                              <1> msftdf_dsfde_restore_cdir_failed:
  2909                              <1> msftdf_dsfde_error_retn:
  2910 00009E76 C3                  <1> 	retn
  2911                              <1> 
  2912                              <1> msftdf_add_new_fs_subdir_section_ok:
  2913                              <1> msftdf_add_new_subdir_cluster_ok:
  2914 00009E77 89DF                <1> 	mov	edi, ebx ; Directory buffer address
  2915                              <1> 
  2916                              <1> msftdf_make_dfde_set_ff_dir_entry:
  2917 00009E79 8B15[68200100]      <1> 	mov	edx, [Current_Dir_FCluster]
  2918 00009E7F 8915[BC2C0100]      <1> 	mov	[createfile_FFCluster], edx
  2919                              <1> 	; EDI = Directory entry offset
  2920 00009E85 BE[262C0100]        <1> 	mov	esi, DestinationFile_DirEntry
  2921 00009E8A B908000000          <1> 	mov	ecx, 8
  2922 00009E8F F3A5                <1> 	rep	movsd
  2923                              <1> 
  2924 00009E91 C605[98280100]02    <1> 	mov	byte [DirBuff_ValidData], 2 
  2925 00009E98 E89FF9FFFF          <1> 	call	save_directory_buffer
  2926 00009E9D 72CF                <1> 	jc	short msftdf_make_dfde_err_upd_pdir_lmdt
  2927                              <1> 
  2928                              <1> msftdf_make_dfde_update_pdir_lmdt:
  2929 00009E9F E833FAFFFF          <1> 	call	update_parent_dir_lmdt
  2930                              <1> 
  2931                              <1> msftdf_dsfde_restore_current_dir_1:
  2932 00009EA4 803D[E4DD0000]00    <1> 	cmp	byte [Restore_CDIR], 0
  2933 00009EAB 760D                <1> 	jna	short msftdf_dsfde_check_directory
  2934 00009EAD 8B35[582C0100]      <1>  	mov	esi, [msftdf_drv_offset]
  2935 00009EB3 E82CC0FFFF          <1> 	call	restore_current_directory
  2936 00009EB8 72BC                <1> 	jc	short msftdf_dsfde_restore_cdir_failed
  2937                              <1> 
  2938                              <1> msftdf_dsfde_check_directory:
  2939 00009EBA BE[552B0100]        <1> 	mov	esi, SourceFile_Directory
  2940 00009EBF 803E20              <1> 	cmp	byte [esi], 20h
  2941 00009EC2 760F                <1> 	jna	short msftdf_dsfde_find_file
  2942                              <1> 
  2943                              <1> msftdf_dsfde_change_directory:
  2944 00009EC4 FE05[E4DD0000]      <1> 	inc	byte [Restore_CDIR]
  2945 00009ECA 28E4                <1> 	sub	ah, ah ; CD_COMMAND sign -> 0 
  2946 00009ECC E8F3EEFFFF          <1> 	call	change_current_directory
  2947 00009ED1 72A3                <1> 	jc	short msftdf_dsfde_error_retn
  2948                              <1> 
  2949                              <1> ;msftdf_dsfde_sf_change_prompt_dir_string:
  2950                              <1> ;	call	change_prompt_dir_string
  2951                              <1> 
  2952                              <1> msftdf_dsfde_find_file:
  2953 00009ED3 BE[962B0100]        <1> 	mov	esi, SourceFile_Name  ; Offset 66
  2954 00009ED8 668B460E            <1> 	mov	ax, [esi+14] ; 80 -> SourceFile_AttributesMask
  2955 00009EDC E8EDD2FFFF          <1> 	call	find_first_file
  2956 00009EE1 7293                <1> 	jc	short msftdf_dsfde_error_retn
  2957                              <1> 
  2958                              <1> msftdf_dsfde_delete_direntry:
  2959 00009EE3 8B35[582C0100]      <1> 	mov	esi, [msftdf_drv_offset]
  2960                              <1> 	
  2961 00009EE9 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
  2962 00009EED 770A                <1> 	ja	short msftdf_delete_FAT_direntry
  2963                              <1> 	
  2964 00009EEF 30DB                <1> 	xor	bl, bl
  2965                              <1> 	; BL = 0 -> File
  2966                              <1> 	; EDI -> Directory buffer entry offset/address 
  2967 00009EF1 E8D60B0000          <1> 	call	delete_fs_directory_entry
  2968 00009EF6 7315                <1> 	jnc	short msftdf_dsfde_restore_current_dir_2
  2969 00009EF8 C3                  <1> 	retn
  2970                              <1> 
  2971                              <1> msftdf_delete_FAT_direntry:	
  2972 00009EF9 8A1D[612A0100]      <1> 	mov	bl, [FindFile_LongNameEntryLength]
  2973 00009EFF 668B0D[8C2A0100]    <1> 	mov	cx, [FindFile_DirEntryNumber]
  2974                              <1> 	; ESI = Logical DOS drive description table address
  2975                              <1> 	; EDI = Directory buffer entry offset/address 
  2976 00009F06 E8ABFCFFFF          <1> 	call	delete_directory_entry
  2977 00009F0B 721C                <1> 	jc	short msftdf_retn
  2978                              <1> 
  2979                              <1> msftdf_dsfde_restore_current_dir_2:
  2980 00009F0D 803D[E4DD0000]00    <1> 	cmp	byte [Restore_CDIR], 0
  2981 00009F14 7607                <1> 	jna	short msftdf_new_dir_fcluster_retn
  2982                              <1> 	;mov	esi, [msftdf_drv_offset]
  2983 00009F16 E8C9BFFFFF          <1> 	call	restore_current_directory
  2984 00009F1B 720C                <1> 	jc	short msftdf_retn
  2985                              <1> 
  2986                              <1> msftdf_new_dir_fcluster_retn:
  2987 00009F1D 31C9                <1> 	xor	ecx, ecx 
  2988 00009F1F A1[BC2C0100]        <1> 	mov	eax, [createfile_FFCluster]
  2989 00009F24 BB[D42B0100]        <1> 	mov	ebx, DestinationFile_Drv
  2990                              <1> 
  2991                              <1> msftdf_retn:
  2992 00009F29 C3                  <1> 	retn
  2993                              <1> 
  2994                              <1> 
  2995                              <1> copy_source_file_to_destination_file:
  2996                              <1> 	; 31/03/2016
  2997                              <1> 	; 30/03/2016
  2998                              <1> 	; 24/03/2016, 25/03/2016, 28/03/2016
  2999                              <1> 	; 21/03/2016, 22/03/2016, 23/03/2016
  3000                              <1> 	; 16/03/2016, 17/03/2016, 18/03/2016
  3001                              <1> 	; 15/03/2016 (TRDOS 386 = TRDOS v2.0)
  3002                              <1> 	; 02/09/2011 (FILE.ASM 'copy_source_file_to_destination_file')
  3003                              <1> 	; 01/08/2010 - 18/05/2011
  3004                              <1> 	;
  3005                              <1> 	;   Command Interpreter phase 1 enter ->
  3006                              <1> 	;           AL = 1 -> Caller is command interpreter
  3007                              <1> 	;           AL = 2 -> The second call, re-enter/continue
  3008                              <1> 	;   Phase 1 -> Check source file
  3009                              <1> 	;              'found' is required
  3010                              <1> 	;   Phase 2 -> Check destination file, 
  3011                              <1> 	;              save 'found' or 'not found' status
  3012                              <1> 	;              'permission denied' error will be return
  3013                              <1> 	;              if attributes have not for ordinary file 
  3014                              <1> 	;              without readonly attribute
  3015                              <1> 	;   Command Interpreter phase 1 return ->
  3016                              <1> 	;              DH = Source file attributes
  3017                              <1> 	;              DL = Destination file found status
  3018                              <1> 	;              EAX = 0 
  3019                              <1> 	;   Command Interpeter phase 2 enter ->
  3020                              <1> 	;              AL = 2 -> Continue from the last position
  3021                              <1> 	;              AH = 
  3022                              <1> 	;   Phase 3 -> Load source file or use read/write cluster method
  3023                              <1> 	;   Phase 4 -> Create destination file if it is not found
  3024                              <1> 	;   Phase 5 -> Open destination file
  3025                              <1> 	;   Phase 6 -> Read from source and write to destination
  3026                              <1> 	;   Phase 7 -> Unload source file, if it is loaded at memory
  3027                              <1> 	;       cf = 1 causes to return before the phase 7
  3028                              <1> 	;              but loaded file will be unloaded
  3029                              <1> 	;	       (allocated memory block will be deallocated) 
  3030                              <1> 	;
  3031                              <1> 	; INPUT -> 
  3032                              <1> 	;	 ESI = Source File Pathname (Asciiz)
  3033                              <1> 	;        EDI = Destination File Pathname (Asciiz)
  3034                              <1> 	;        AL = 0 --> Interrupt (System call)
  3035                              <1> 	;        AL > 0 --> Command Interpreter (Question)
  3036                              <1> 	;        AL = 1 --> Question Phase
  3037                              <1> 	;        AL = 2 --> Progress Phase        
  3038                              <1> 	;
  3039                              <1> 	; OUTPUT -> 
  3040                              <1> 	;	cf = 0 -> OK
  3041                              <1> 	;	EAX = Destination file first cluster
  3042                              <1> 	;
  3043                              <1> 	;        CL > 0 if there is file reading error before EOF
  3044                              <1> 	;	        (incomplete copy) 
  3045                              <1> 	;        CH > 0 if file is (full) loaded at memory
  3046                              <1> 	;
  3047                              <1> 	;	cf = 1 -> Error code in AL (EAX) 
  3048                              <1> 	;
  3049                              <1> 	; (EBX, ECX, ESI, EDI register contents will be changed)           
  3050                              <1> 
  3051                              <1> 
  3052 00009F2A 3C02                <1> 	cmp	al, 2
  3053 00009F2C 0F844C020000        <1> 	je	csftdf2_check_cdrv
  3054                              <1> 
  3055                              <1> ; Phase 1
  3056                              <1> 
  3057 00009F32 A2[7C2C0100]        <1> 	mov	byte [copy_cmd_phase], al
  3058                              <1> 
  3059 00009F37 57                  <1> 	push	edi ; *
  3060                              <1> 
  3061                              <1> csftdf_parse_sf_path:
  3062 00009F38 BF[542B0100]        <1> 	mov	edi, SourceFile_Drv
  3063 00009F3D E896F4FFFF          <1> 	call	parse_path_name
  3064 00009F42 721C                <1> 	jc	short csftdf_parse_sf_path_failed
  3065                              <1> 
  3066                              <1> csftdf_parse_df_path:	
  3067 00009F44 5E                  <1> 	pop	esi ; * (pushed edi) 
  3068                              <1> 
  3069                              <1> csftdf_sf_check_filename_exists:
  3070 00009F45 803D[962B0100]21    <1> 	cmp	byte [SourceFile_Name], 21h
  3071 00009F4C 7215                <1> 	jb	short csftdf_sf_file_not_found_error
  3072                              <1> 
  3073 00009F4E BF[D42B0100]        <1> 	mov	edi, DestinationFile_Drv
  3074 00009F53 E880F4FFFF          <1> 	call	parse_path_name
  3075 00009F58 7310                <1> 	jnc	short csftdf_check_sf_cdrv
  3076                              <1> 	
  3077 00009F5A 3C01                <1> 	cmp	al, 1 ; File or directory name is not existing
  3078 00009F5C 760C                <1> 	jna	short csftdf_check_sf_cdrv
  3079                              <1> 
  3080                              <1> csftdf_parse_df_path_failed:
  3081 00009F5E F9                  <1> 	stc 
  3082                              <1> csftdf_sf_error_retn: 
  3083 00009F5F C3                  <1> 	retn
  3084                              <1> 
  3085                              <1> csftdf_parse_sf_path_failed:	
  3086 00009F60 5F                  <1> 	pop	edi ; *
  3087 00009F61 EBFC                <1> 	jmp	short csftdf_sf_error_retn
  3088                              <1> 
  3089                              <1> csftdf_sf_file_not_found_error:
  3090 00009F63 B802000000          <1> 	mov	eax, 2 ; File not found 
  3091 00009F68 EBF5                <1> 	jmp	short csftdf_sf_error_retn
  3092                              <1> 
  3093                              <1> csftdf_check_sf_cdrv:
  3094 00009F6A 8A3D[6E200100]      <1> 	mov	bh, [Current_Drv]
  3095                              <1> 
  3096 00009F70 883D[7F2C0100]      <1> 	mov	[csftdf_cdrv], bh ; 23/03/2016
  3097                              <1> 
  3098 00009F76 8A15[542B0100]      <1> 	mov	dl, [SourceFile_Drv]
  3099 00009F7C 38FA                <1> 	cmp	dl, bh ; byte [Current_Drv]
  3100 00009F7E 7407                <1> 	je	short csftdf_sf_check_directory
  3101                              <1> 
  3102 00009F80 E8ADBEFFFF          <1> 	call	change_current_drive
  3103 00009F85 72D8                <1> 	jc	short csftdf_sf_error_retn
  3104                              <1> 
  3105                              <1> csftdf_sf_check_directory:
  3106 00009F87 BE[552B0100]        <1> 	mov	esi, SourceFile_Directory
  3107 00009F8C 803E20              <1> 	cmp	byte [esi], 20h
  3108 00009F8F 760F                <1> 	jna	short csftdf_find_sf
  3109                              <1> 
  3110                              <1> csftdf_sf_change_directory:
  3111 00009F91 FE05[E4DD0000]      <1> 	inc	byte [Restore_CDIR]
  3112 00009F97 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
  3113 00009F99 E826EEFFFF          <1> 	call	change_current_directory
  3114 00009F9E 72BF                <1> 	jc	short csftdf_sf_error_retn
  3115                              <1> 
  3116                              <1> ;csftdf_sf_change_prompt_dir_string:
  3117                              <1> ;	call	change_prompt_dir_string
  3118                              <1> 
  3119                              <1> csftdf_find_sf:
  3120 00009FA0 BE[962B0100]        <1> 	mov	esi, SourceFile_Name
  3121 00009FA5 66B80018            <1> 	mov	ax, 1800h ; Except volume label and dirs
  3122 00009FA9 E820D2FFFF          <1> 	call	find_first_file
  3123 00009FAE 72AF                <1> 	jc	short csftdf_sf_error_retn
  3124                              <1> 
  3125                              <1> csftdf_sf_ambgfn_check:
  3126 00009FB0 6621D2              <1> 	and	dx, dx ; Ambiguous filename chars used sign (DX>0)
  3127 00009FB3 7407                <1> 	jz	short csftdf_sf_found
  3128                              <1> 
  3129                              <1> csftdf_ambiguous_file_name_error:
  3130 00009FB5 B802000000          <1> 	mov	eax, 2 ; File not found error
  3131 00009FBA F9                  <1> 	stc
  3132 00009FBB C3                  <1> 	retn
  3133                              <1> 
  3134                              <1> csftdf_sf_found:
  3135 00009FBC A3[802C0100]        <1> 	mov	[csftdf_filesize], eax
  3136                              <1> 
  3137 00009FC1 09C0                <1> 	or	eax, eax
  3138 00009FC3 7507                <1> 	jnz	short csftdf_set_source_file_direnry
  3139                              <1> 
  3140                              <1> csftdf_sf_file_size_zero:
  3141 00009FC5 B80E000000          <1> 	mov	eax, 0Eh ; TRDOS zero length error
  3142 00009FCA F9                  <1> 	stc
  3143 00009FCB C3                  <1> 	retn
  3144                              <1> 
  3145                              <1> csftdf_set_source_file_direnry:
  3146 00009FCC BE[642A0100]        <1> 	mov	esi, FindFile_DirEntry
  3147 00009FD1 BF[A62B0100]        <1> 	mov	edi, SourceFile_DirEntry
  3148 00009FD6 B908000000          <1> 	mov	ecx, 8
  3149 00009FDB F3A5                <1> 	rep	movsd
  3150                              <1> 
  3151                              <1> csftdf_sf_restore_cdrv:
  3152                              <1> 	; 22/03/2016
  3153 00009FDD 8A15[7F2C0100]      <1> 	mov	dl, [csftdf_cdrv]
  3154 00009FE3 3A15[6E200100]      <1> 	cmp	dl, [Current_Drv]
  3155 00009FE9 7407                <1> 	je	short csftdf_sf_restore_cdir
  3156 00009FEB E842BEFFFF          <1> 	call	change_current_drive 
  3157 00009FF0 724F                <1> 	jc	short csftdf_df_error_retn ; 30/03/2016
  3158                              <1> 
  3159                              <1> csftdf_sf_restore_cdir:
  3160 00009FF2 803D[E4DD0000]00    <1> 	cmp	byte [Restore_CDIR], 0
  3161 00009FF9 7612                <1> 	jna	short csftdf_df_check_filename_exists
  3162 00009FFB 29C0                <1> 	sub	eax, eax
  3163 00009FFD BE00010900          <1> 	mov	esi, Logical_DOSDisks
  3164 0000A002 88D4                <1> 	mov	ah, dl ; byte [csftdf_cdrv]
  3165 0000A004 01C6                <1> 	add	esi, eax
  3166 0000A006 E8D9BEFFFF          <1> 	call	restore_current_directory
  3167 0000A00B 7234                <1> 	jc	short csftdf_df_error_retn
  3168                              <1>   
  3169                              <1> csftdf_df_check_filename_exists:
  3170 0000A00D 803D[162C0100]20    <1> 	cmp	byte [DestinationFile_Name], 20h
  3171 0000A014 7716                <1> 	ja	short csftdf_check_df_cdrv
  3172                              <1> 
  3173                              <1> csftdf_copy_sf_name:
  3174 0000A016 BF[162C0100]        <1> 	mov	edi, DestinationFile_Name
  3175 0000A01B BE[962B0100]        <1> 	mov	esi, SourceFile_Name
  3176 0000A020 B10C                <1> 	mov	cl, 12
  3177                              <1> 
  3178                              <1> csftdf_df_copy_sf_name_loop:
  3179 0000A022 AC                  <1> 	lodsb
  3180 0000A023 AA                  <1> 	stosb
  3181 0000A024 08C0                <1> 	or	al, al
  3182 0000A026 7404                <1> 	jz	short csftdf_check_df_cdrv             
  3183 0000A028 FEC9                <1> 	dec	cl
  3184 0000A02A 75F6                <1> 	jnz	csftdf_df_copy_sf_name_loop
  3185                              <1> 
  3186                              <1> csftdf_check_df_cdrv:
  3187 0000A02C 8A15[D42B0100]      <1> 	mov	dl, [DestinationFile_Drv]
  3188 0000A032 3A15[6E200100]      <1> 	cmp	dl, [Current_Drv]
  3189 0000A038 7408                <1> 	je	short csftdf_df_check_directory
  3190                              <1> 
  3191 0000A03A E8F3BDFFFF          <1> 	call	change_current_drive
  3192 0000A03F 7301                <1> 	jnc	short csftdf_df_check_directory
  3193                              <1> 
  3194                              <1> csftdf_df_error_retn:
  3195 0000A041 C3                  <1> 	retn
  3196                              <1> 
  3197                              <1> csftdf_df_check_directory:
  3198 0000A042 BE[D52B0100]        <1> 	mov	esi, DestinationFile_Directory
  3199 0000A047 803E20              <1>         cmp     byte [esi], 20h
  3200 0000A04A 760F                <1> 	jna	short csftdf_find_df
  3201                              <1> 
  3202                              <1> csftdf_df_change_directory:
  3203 0000A04C FE05[E4DD0000]      <1> 	inc	byte [Restore_CDIR]
  3204 0000A052 28E4                <1> 	sub	ah, ah ; CD_COMMAND sign -> 0 
  3205 0000A054 E86BEDFFFF          <1> 	call	change_current_directory
  3206 0000A059 72E6                <1> 	jc	short csftdf_df_error_retn
  3207                              <1> 
  3208                              <1> ;csftdf_df_change_prompt_dir_string:
  3209                              <1> ;	call	change_prompt_dir_string
  3210                              <1> 
  3211                              <1> csftdf_find_df:
  3212                              <1> 	; 23/03/2016
  3213 0000A05B 29DB                <1> 	sub	ebx, ebx
  3214 0000A05D 8A3D[D42B0100]      <1> 	mov	bh,  [DestinationFile_Drv]
  3215 0000A063 81C300010900        <1> 	add	ebx, Logical_DOSDisks
  3216 0000A069 891D[AC2C0100]      <1> 	mov	[csftdf_df_drv_dt], ebx
  3217                              <1> 
  3218 0000A06F BE[162C0100]        <1> 	mov	esi, DestinationFile_Name
  3219 0000A074 6631C0              <1> 	xor	ax, ax 
  3220                              <1> 		; DestinationFile_AttributesMask -> any/zero
  3221 0000A077 E852D1FFFF          <1> 	call	find_first_file
  3222 0000A07C 7218                <1> 	jc	short csftdf_df_check_error_code
  3223                              <1> 
  3224                              <1> csftdf_df_ambgfn_check:
  3225 0000A07E 6609D2              <1> 	or	dx, dx ; Ambiguous filename chars used sign (DX>0)
  3226 0000A081 7511                <1> 	jnz	short csftdf_df_error_stc_retn
  3227                              <1> 	
  3228                              <1> csftdf_df_found:
  3229 0000A083 C605[7E2C0100]01    <1> 	mov	byte [DestinationFileFound], 1
  3230 0000A08A 80E11F              <1> 	and	cl, 1Fh ; Attributes, D-V-S-H-R
  3231 0000A08D 7451                <1> 	jz	short csftdf_df_save_first_cluster
  3232                              <1> 
  3233                              <1> csftdf_df_permission_denied_retn:	 
  3234 0000A08F B805000000          <1> 	mov	eax, 05h ; Access/Permisson denied.
  3235                              <1> csftdf_df_error_stc_retn:
  3236 0000A094 F9                  <1> 	stc
  3237 0000A095 C3                  <1> 	retn
  3238                              <1> 
  3239                              <1> csftdf_df_check_error_code:
  3240                              <1> 	;cmp	eax, 2
  3241 0000A096 3C02                <1> 	cmp	al, 2
  3242 0000A098 75FA                <1> 	jne	short csftdf_df_error_stc_retn
  3243                              <1> 
  3244                              <1> 	; 21/03/2016
  3245                              <1> 	; (Capitalized file name)
  3246 0000A09A BE[542A0100]        <1> 	mov	esi, FindFile_Name
  3247 0000A09F BF[162C0100]        <1> 	mov	edi, DestinationFile_Name
  3248 0000A0A4 A5                  <1> 	movsd
  3249 0000A0A5 A5                  <1> 	movsd	
  3250 0000A0A6 A5                  <1> 	movsd
  3251                              <1> 	;movsb
  3252                              <1> 
  3253 0000A0A7 C605[7E2C0100]00    <1> 	mov	byte [DestinationFileFound], 0
  3254                              <1> 
  3255                              <1> csftdf_check_disk_free_size_0:
  3256 0000A0AE A1[C22B0100]        <1> 	mov	eax, [SourceFile_DirEntry+DirEntry_FileSize]
  3257                              <1> 
  3258                              <1> csftdf_check_disk_free_size_1:
  3259                              <1> 	;sub	ebx, ebx
  3260                              <1> 	;mov 	esi, Logical_DOSDisks
  3261                              <1> 	;mov	bh,  [DestinationFile_Drv]
  3262                              <1> 	;add	esi, ebx
  3263                              <1> 	
  3264 0000A0B3 8B35[AC2C0100]      <1> 	mov	esi, [csftdf_df_drv_dt] ; 23/03/2016
  3265                              <1> 
  3266 0000A0B9 0FB74E11            <1> 	movzx	ecx, word [esi+LD_BPB+BytesPerSec] ; 17, LD_BPB + 0Bh
  3267 0000A0BD 01C8                <1> 	add	eax, ecx
  3268 0000A0BF 48                  <1> 	dec	eax  ; file size (additional bytes) + 511 (round up)
  3269                              <1> csftdf_check_disk_free_size_3: ; 16/03/2016
  3270 0000A0C0 29D2                <1> 	sub	edx, edx
  3271 0000A0C2 F7F1                <1> 	div	ecx ; bytes per sector
  3272                              <1> 
  3273                              <1> csftdf_check_disk_free_size:
  3274 0000A0C4 3B4674              <1> 	cmp	eax, [esi+LD_FreeSectors]
  3275 0000A0C7 0F8294000000        <1>         jb      csftdf_check_disk_free_size_ok
  3276 0000A0CD 770A                <1> 	ja	short csftdf_df_insufficient_disk_space
  3277                              <1> 
  3278 0000A0CF 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0 ; FS needs FDT sector also.
  3279 0000A0D3 0F8788000000        <1>         ja      csftdf_check_disk_free_size_ok 
  3280                              <1> 
  3281                              <1> csftdf_df_insufficient_disk_space:
  3282 0000A0D9 B827000000          <1> 	mov	eax, 27h ; insufficient disk space
  3283 0000A0DE EBB4                <1> 	jmp	short csftdf_df_error_stc_retn
  3284                              <1> 
  3285                              <1> csftdf_df_save_first_cluster:
  3286                              <1> 	; ESI = FindFile_DirEntry (for the old destination file)
  3287                              <1> 	; EAX = Old destination file size
  3288                              <1> 	; 24/03/2016
  3289                              <1> 	; EDI = Directory entry address (within Dir Buffer boundaries)
  3290 0000A0E0 81EF00000800        <1> 	sub	edi, Directory_Buffer  ; (<65536)
  3291 0000A0E6 66C1EF05            <1> 	shr	di, 5 ; Convert entry offset to entry index/number
  3292 0000A0EA 66893D[4E2C0100]    <1> 	mov	[DestinationFile_DirEntryNumber], di ; (<2048)
  3293                              <1> 
  3294                              <1> csftdf_df_check_sf_df_fcluster:
  3295 0000A0F1 668B5614            <1> 	mov	dx, [esi+DirEntry_FstClusHI]
  3296 0000A0F5 C1E210              <1> 	shl	edx, 16
  3297 0000A0F8 668B561A            <1> 	mov	dx, [esi+DirEntry_FstClusLO]
  3298 0000A0FC 8915[902C0100]      <1> 	mov	[csftdf_df_cluster], edx
  3299                              <1> csftdf_df_check_sf_df_fcluster_1:
  3300 0000A102 668B15[BA2B0100]    <1> 	mov	dx, [SourceFile_DirEntry+DirEntry_FstClusHI]
  3301 0000A109 C1E210              <1> 	shl	edx, 16
  3302 0000A10C 668B15[C02B0100]    <1> 	mov	dx, [SourceFile_DirEntry+DirEntry_FstClusLO]
  3303 0000A113 3B15[902C0100]      <1> 	cmp	edx, [csftdf_df_cluster]
  3304 0000A119 7512                <1> 	jne	short csftdf_df_check_sf_df_fcluster_ok
  3305                              <1> csftdf_df_check_sf_df_drv:
  3306 0000A11B 8A15[542B0100]      <1> 	mov	dl, [SourceFile_Drv]
  3307 0000A121 3A15[D42B0100]      <1> 	cmp	dl, [DestinationFile_Drv]
  3308 0000A127 7504                <1> 	jne	short csftdf_df_check_sf_df_fcluster_ok
  3309                              <1> 
  3310                              <1> 	; source and destination files are same !
  3311                              <1> 	; (they have same first cluster value on same logical disk)
  3312                              <1> 
  3313 0000A129 31C0                <1> 	xor	eax, eax ; mov eax, 0 -> Bad command or file name !
  3314 0000A12B F9                  <1> 	stc
  3315 0000A12C C3                  <1> 	retn 
  3316                              <1>    
  3317                              <1> csftdf_df_check_sf_df_fcluster_ok:
  3318                              <1> csftdf_df_move_findfile_struct:
  3319                              <1> 	; mov	esi, FindFile_DirEntry
  3320 0000A12D BF[262C0100]        <1> 	mov	edi, DestinationFile_DirEntry
  3321 0000A132 B908000000          <1> 	mov	ecx, 8
  3322 0000A137 F3A5                <1> 	rep	movsd
  3323                              <1> 	
  3324                              <1> csftdf_check_disk_free_size_2:
  3325 0000A139 89C2                <1> 	mov	edx, eax ; Old destination file size
  3326                              <1> 
  3327                              <1> 	;mov	eax, [SourceFile_DirEntry+DirEntry_FileSize]
  3328 0000A13B A1[802C0100]        <1> 	mov	eax, [csftdf_filesize] ; 23/03/2016
  3329                              <1> 
  3330                              <1> 	;;sub	ecx, ecx ; 0
  3331                              <1> 	;mov 	esi, Logical_DOSDisks
  3332                              <1> 	;mov	ch,  [DestinationFile_Drv]
  3333                              <1> 	;add	esi, ecx
  3334                              <1> 	;
  3335                              <1> 	;mov	[csftdf_df_drv_dt], esi
  3336                              <1> 
  3337 0000A140 8B35[AC2C0100]      <1> 	mov	esi, [csftdf_df_drv_dt] ; 23/03/2016
  3338                              <1> 
  3339 0000A146 668B4E11            <1> 	mov	cx, [esi+LD_BPB+BytesPerSec] ; 17, LD_BPB + 0Bh
  3340 0000A14A 01CA                <1> 	add	edx, ecx ; + 512
  3341 0000A14C 01C8                <1> 	add	eax, ecx ; + 512
  3342 0000A14E 4A                  <1> 	dec	edx ; old file size + 511 (round up)
  3343 0000A14F 48                  <1> 	dec	eax ; new file size + 511 (round up)
  3344 0000A150 F7D9                <1> 	neg	ecx ; -512 ; 0FFFFFE00h
  3345 0000A152 21CA                <1> 	and	edx, ecx ; = old sector count * 512 
  3346 0000A154 21C8                <1> 	and	eax, ecx ; = new sector count * 512 
  3347                              <1> 
  3348 0000A156 29D0                <1> 	sub	eax, edx ; new file size - old file size (on disk)
  3349 0000A158 7607                <1> 	jna	short csftdf_check_disk_free_size_ok
  3350                              <1> 
  3351 0000A15A F7D9                <1> 	neg	ecx ; 512 (bytes per sector) ; 200h
  3352                              <1> 	; check free space for additional sectors
  3353                              <1> 	; eax = number of additional sectors * bytes per sector
  3354                              <1> 	; esi = Logical DOS drive number (of destination disk)
  3355 0000A15C E95FFFFFFF          <1>         jmp     csftdf_check_disk_free_size_3
  3356                              <1>  
  3357                              <1> csftdf_check_disk_free_size_ok:
  3358                              <1> 	; 18/03/2016
  3359                              <1> csftdf_df_check_copy_cmd_phase:
  3360 0000A161 A0[7C2C0100]        <1> 	mov	al, [copy_cmd_phase]
  3361 0000A166 3C01                <1> 	cmp	al, 1
  3362 0000A168 7514                <1> 	jne	short csftdf2_check_cdrv
  3363                              <1> 	
  3364 0000A16A 31C0                <1> 	xor	eax, eax
  3365 0000A16C A2[7C2C0100]        <1> 	mov	[copy_cmd_phase], al ; 0
  3366                              <1> 
  3367 0000A171 8A15[7E2C0100]      <1> 	mov	dl, [DestinationFileFound]            
  3368 0000A177 8A35[B12B0100]      <1> 	mov	dh, [SourceFile_DirEntry+11] ; Attributes
  3369                              <1>  
  3370                              <1> csftdf_return:	
  3371 0000A17D C3                  <1> 	retn
  3372                              <1> 
  3373                              <1> ; Phase 2
  3374                              <1> 
  3375                              <1> csftdf2_check_cdrv:
  3376                              <1> 	; 18/03/2016
  3377                              <1> 	; Here, destination drive and directory are ready !
  3378                              <1> 	; (checking/restoring is not needed)
  3379                              <1> 	; (Since at the end of the phase 1)
  3380                              <1> 
  3381                              <1> ;	mov	dl, [DestinationFile_Drv]
  3382                              <1> ;	cmp	dl, [Current_Drv]
  3383                              <1> ;	je	short csftdf2_df_check_directory
  3384                              <1> ;
  3385                              <1> ;	call	change_current_drive
  3386                              <1> ;	jc	short csftdf2_read_error
  3387                              <1> ;
  3388                              <1> ;csftdf2_df_check_directory:
  3389                              <1> ;	mov	esi, DestinationFile_Directory  
  3390                              <1> ;	cmp	byte [esi], 20h
  3391                              <1> ;	jna	short csftdf2_df_check_found_or_not
  3392                              <1> ;
  3393                              <1> ;csftdf2_df_change_directory:
  3394                              <1> ;	inc	byte [Restore_CDIR]
  3395                              <1> ;	xor	ah, ah ; CD_COMMAND sign -> 0 
  3396                              <1> ;	call	change_current_directory
  3397                              <1> ;	jc	short csftdf2_stc_return
  3398                              <1> ;
  3399                              <1> ;;csftdf2_df_change_prompt_dir_string:
  3400                              <1> ;;	call	change_prompt_dir_string
  3401                              <1> 
  3402                              <1> csftdf2_df_check_found_or_not:
  3403                              <1> 	; 21/03/2016
  3404 0000A17E 803D[7E2C0100]00    <1> 	cmp	byte [DestinationFileFound], 0 
  3405 0000A185 7739                <1> 	ja	short csftdf2_set_sf_percentage
  3406                              <1> 
  3407                              <1> csftdf2_create_file:
  3408 0000A187 BE[162C0100]        <1> 	mov	esi, DestinationFile_Name
  3409 0000A18C A1[802C0100]        <1> 	mov	eax, [csftdf_filesize]
  3410 0000A191 30C9                <1> 	xor	cl, cl ; 0
  3411                              <1> 
  3412 0000A193 31DB                <1> 	xor	ebx, ebx ; 0
  3413 0000A195 4B                  <1> 	dec	ebx ; 0FFFFFFFFh 
  3414                              <1> 
  3415                              <1> 	; INPUT ->
  3416                              <1> 	; 	EAX -> File Size
  3417                              <1> 	; 	ESI = ASCIIZ File name
  3418                              <1> 	;	 CL = File attributes
  3419                              <1> 	;	EBX = FFFFFFFFh -> empty file sign for FAT fs
  3420                              <1> 	;	EBX <> FFFFFFFFh -> use file size for FAT fs 
  3421                              <1> 	;
  3422                              <1> 	; OUTPUT ->
  3423                              <1> 	;	EAX = New file's first cluster
  3424                              <1> 	;	ESI = Logical Dos Drv Descr. Table Addr.
  3425                              <1> 	;	EBX = CreateFile_Size address
  3426                              <1> 	;	ECX = Sectors per cluster (<256)
  3427                              <1> 	;	EDX = Directory Entry Index/Number (<65536)
  3428                              <1> 	;		
  3429                              <1> 	;	cf = 1 -> error code in AL (EAX)
  3430                              <1> 
  3431 0000A196 E8EC050000          <1> 	call	create_file
  3432                              <1> 	;pop	esi
  3433 0000A19B 0F82A3050000        <1>         jc      csftdf2_rw_error
  3434                              <1> 
  3435                              <1> csftdf2_create_file_OK:
  3436 0000A1A1 A3[902C0100]        <1> 	mov	[csftdf_df_cluster], eax
  3437                              <1> 	
  3438                              <1> 	; 24/03/2016
  3439 0000A1A6 668915[4E2C0100]    <1> 	mov	[DestinationFile_DirEntryNumber], dx 
  3440                              <1> 
  3441                              <1> 	; 21/03/2016
  3442 0000A1AD BE00000800          <1> 	mov	esi, Directory_Buffer
  3443 0000A1B2 C1E205              <1> 	shl	edx, 5 ; 32 * index number
  3444 0000A1B5 01D6                <1> 	add	esi, edx
  3445 0000A1B7 BF[262C0100]        <1> 	mov	edi, DestinationFile_DirEntry	
  3446 0000A1BC B108                <1> 	mov	cl, 8 ; 32 bytes
  3447 0000A1BE F3A5                <1> 	rep	movsd
  3448                              <1> 
  3449                              <1> csftdf2_set_sf_percentage:
  3450                              <1> 	; 17/03/2016
  3451 0000A1C0 31C0                <1> 	xor	eax, eax	
  3452 0000A1C2 A2[A42C0100]        <1> 	mov 	[csftdf_percentage], al ; 0, reset
  3453                              <1> 
  3454 0000A1C7 A3[9C2C0100]        <1> 	mov	[csftdf_sf_rbytes], eax ; 0, reset
  3455 0000A1CC A3[A02C0100]        <1> 	mov	[csftdf_df_wbytes], eax ; 0, reset
  3456                              <1> 
  3457 0000A1D1 8A25[542B0100]      <1> 	mov	ah, [SourceFile_Drv]	
  3458 0000A1D7 BE00010900          <1> 	mov	esi, Logical_DOSDisks
  3459 0000A1DC 01C6                <1> 	add	esi, eax
  3460                              <1> 	
  3461 0000A1DE 8935[A82C0100]      <1> 	mov	[csftdf_sf_drv_dt], esi ; 23/03/2016
  3462                              <1> 
  3463 0000A1E4 668B15[BA2B0100]    <1> 	mov	dx, [SourceFile_DirEntry+DirEntry_FstClusHI]
  3464 0000A1EB C1E210              <1> 	shl	edx, 16
  3465 0000A1EE 668B15[C02B0100]    <1> 	mov	dx, [SourceFile_DirEntry+DirEntry_FstClusLO]
  3466 0000A1F5 8915[8C2C0100]      <1> 	mov	[csftdf_sf_cluster], edx
  3467                              <1> 
  3468                              <1> 	; 16/03/2016
  3469                              <1> 	; Note: Singlix FS boot sector parameters (for cluster
  3470                              <1> 	;	related calculations) has same offset
  3471                              <1> 	;	values from LD_BPB as in FAT file system.
  3472                              <1> 	;	[esi+LD_BPB+SecPerClust] is 1 for Singlix FS.
  3473                              <1> 	;	
  3474 0000A1FB 0FB64E13            <1> 	movzx	ecx, byte [esi+LD_BPB+SecPerClust]
  3475 0000A1FF 880D[D22B0100]      <1> 	mov	[SourceFile_SecPerClust], cl
  3476                              <1> 
  3477                              <1> 	; 17/03/2016
  3478 0000A205 386E03              <1> 	cmp	[esi+LD_FATType], ch ; 0
  3479 0000A208 7707                <1> 	ja	short csftdf2_set_sf_percent_rsize1
  3480                              <1> 
  3481 0000A20A B800000100          <1> 	mov	eax, 65536 ; read/write buffer size for Singlix FS
  3482 0000A20F EB06                <1> 	jmp	short csftdf2_set_sf_percent_rsize2	
  3483                              <1>  
  3484                              <1> csftdf2_set_sf_percent_rsize1:
  3485 0000A211 668B4611            <1> 	mov	ax, [esi+LD_BPB+BytesPerSec]
  3486 0000A215 F7E1                <1> 	mul	ecx
  3487                              <1> 	;sub	edx, edx
  3488                              <1> csftdf2_set_sf_percent_rsize2:
  3489 0000A217 A3[942C0100]        <1> 	mov	[csftdf_r_size], eax
  3490                              <1> 
  3491                              <1> csftdf2_set_df_percentage:
  3492                              <1> 	;sub	eax, eax
  3493                              <1> 	;mov	ah, [DestinationFile_Drv]	
  3494                              <1> 	;mov	edi, Logical_DOSDisks
  3495                              <1> 	;add	edi, eax
  3496                              <1> 	;mov	[csftdf_df_drv_dt], edi ; 17/03/2016
  3497                              <1> 
  3498 0000A21C 8B3D[AC2C0100]      <1> 	mov	edi, [csftdf_df_drv_dt] ; 23/03/2016
  3499                              <1> 
  3500                              <1> 	; 16/03/2016
  3501                              <1> 	; Note: Singlix FS boot sector parameters (for cluster
  3502                              <1> 	;	related calculations) has same offset
  3503                              <1> 	;	values from LD_BPB as in FAT file system.
  3504                              <1> 	;	[edi+LD_BPB+SecPerClust] is 1 for Singlix FS.
  3505                              <1> 	;	
  3506                              <1> 	;movzx	ecx, byte [edi+LD_BPB+SecPerClust]
  3507 0000A222 8A4F13              <1> 	mov	cl, [edi+LD_BPB+SecPerClust]
  3508 0000A225 880D[522C0100]      <1> 	mov	[DestinationFile_SecPerClust], cl
  3509                              <1> 
  3510                              <1> 	; 17/03/2016
  3511 0000A22B 386F03              <1> 	cmp	[edi+LD_FATType], ch ; 0
  3512 0000A22E 7707                <1> 	ja	short csftdf2_set_df_percent_wsize1
  3513                              <1> 	
  3514 0000A230 B800000100          <1> 	mov	eax, 65536 ; read/write buffer size for Singlix FS
  3515 0000A235 EB06                <1> 	jmp	short csftdf2_set_df_percent_wsize2	
  3516                              <1> 
  3517                              <1> csftdf2_set_df_percent_wsize1:
  3518 0000A237 0FB74711            <1> 	movzx	eax, word [edi+LD_BPB+BytesPerSec]
  3519 0000A23B F7E1                <1> 	mul	ecx
  3520                              <1> 	;sub	edx, edx
  3521                              <1> csftdf2_set_df_percent_wsize2:
  3522 0000A23D A3[982C0100]        <1> 	mov	[csftdf_w_size], eax
  3523                              <1> 
  3524 0000A242 A1[802C0100]        <1> 	mov	eax, [csftdf_filesize]
  3525                              <1> 
  3526 0000A247 3D00000100          <1> 	cmp	eax, 65536 ; 64KB	; small file
  3527 0000A24C 721F                <1> 	jb	short csftdf2_load_file ; do not display percentage
  3528                              <1> 	
  3529                              <1> csftdf2_reset_wf_percent_ptr_chk_64k:
  3530 0000A24E B201                <1> 	mov	dl, 1 ; 25/03/2016
  3531                              <1> 
  3532 0000A250 3D00000400          <1> 	cmp	eax, 65536*4 ; 256KB
  3533 0000A255 7310                <1> 	jnb	short csftdf2_enable_percentage_display ; big file
  3534                              <1> 
  3535                              <1> 	; 64-128KB file size for floppy disks
  3536 0000A257 3815[542B0100]      <1> 	cmp	byte [SourceFile_Drv], dl ; 1 ; read from floppy disk ?
  3537 0000A25D 7608                <1> 	jna	short csftdf2_enable_percentage_display
  3538                              <1> 
  3539 0000A25F 3815[D42B0100]      <1> 	cmp	byte [DestinationFile_Drv], dl ; 1 ; write to floppy disk ?
  3540 0000A265 7706                <1> 	ja	short csftdf2_load_file
  3541                              <1> 
  3542                              <1> csftdf2_enable_percentage_display:	
  3543 0000A267 8815[A42C0100]      <1> 	mov	[csftdf_percentage], dl ; 1	
  3544                              <1> 	
  3545                              <1> csftdf2_load_file:
  3546                              <1> 	; 13/05/2016
  3547                              <1> 	; 19/03/2016
  3548                              <1> 	; 18/03/2016
  3549                              <1> 	; 17/03/2016
  3550 0000A26D B40F                <1> 	mov	ah, 0Fh
  3551 0000A26F E8D370FFFF          <1> 	call	_int10h
  3552                              <1> 	; 13/05/2016
  3553 0000A274 883D[A52C0100]      <1> 	mov	[csftdf_videopage], bh ; active video page
  3554 0000A27A B403                <1> 	mov	ah, 03h
  3555 0000A27C E8C670FFFF          <1> 	call	_int10h
  3556 0000A281 668915[A62C0100]    <1> 	mov	[csftdf_cursorpos], dx
  3557                              <1> 
  3558 0000A288 29C0                <1> 	sub	eax, eax
  3559 0000A28A A2[7D2C0100]        <1> 	mov	[csftdf_rw_err], al ; 0 
  3560                              <1> 
  3561                              <1> ; ///
  3562                              <1> csftdf_sf_amb: ; 15/03/2016
  3563 0000A28F 8B0D[802C0100]      <1> 	mov	ecx, [csftdf_filesize]	; 23/03/2016
  3564                              <1> 
  3565                              <1> 	; TRDOS 386 (TRDOS v2.0)
  3566                              <1> 	; Allocate contiguous memory block for loading the file
  3567                              <1> 	
  3568                              <1> 	;mov	ecx, [SourceFile_DirEntry+DirEntry_FileSize]
  3569                              <1> 	
  3570                              <1> 	;sub	eax, eax ; First free memory aperture
  3571                              <1> 	
  3572                              <1> 	; eax = 0 (Allocate memory from the beginning)
  3573                              <1> 	; ecx = File (Allocation) size in bytes
  3574                              <1> 	
  3575 0000A295 E899ABFFFF          <1> 	call	allocate_memory_block
  3576 0000A29A 7304                <1> 	jnc	short loc_check_sf_save_loading_parms
  3577                              <1> 
  3578 0000A29C 29C0                <1> 	sub	eax, eax
  3579 0000A29E 29C9                <1> 	sub	ecx, ecx
  3580                              <1> 	
  3581                              <1> loc_check_sf_save_loading_parms:
  3582 0000A2A0 A3[842C0100]        <1> 	mov	[csftdf_sf_mem_addr], eax ; loading address
  3583 0000A2A5 890D[882C0100]      <1> 	mov	[csftdf_sf_mem_bsize], ecx ; block size
  3584                              <1> ; ///   
  3585                              <1> 	; 19/03/2016
  3586 0000A2AB 8B35[A82C0100]      <1> 	mov	esi, [csftdf_sf_drv_dt] ; logical dos drv desc. tbl.
  3587                              <1> 
  3588                              <1> 	; 17/03/2016
  3589 0000A2B1 09C0                <1> 	or	eax, eax ; contiguous free memory block address 
  3590 0000A2B3 0F845B010000        <1>         jz      csftdf2_read_sf_cluster
  3591                              <1> 
  3592                              <1> 	; 18/03/2016
  3593 0000A2B9 8B1D[842C0100]      <1> 	mov	ebx, [csftdf_sf_mem_addr] ; memory block address
  3594                              <1> 
  3595 0000A2BF 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
  3596 0000A2C3 0F8605020000        <1>         jna     csftdf2_load_fs_file
  3597                              <1> 
  3598                              <1> csftdf2_load_fat_file:
  3599 0000A2C9 53                  <1> 	push	ebx ; *
  3600                              <1> 
  3601                              <1> csftdf2_load_fat_file_next:
  3602 0000A2CA BE[39E40000]        <1> 	mov	esi, msg_reading
  3603 0000A2CF E85EB2FFFF          <1> 	call	print_msg
  3604                              <1> 
  3605 0000A2D4 803D[A42C0100]00    <1> 	cmp	byte [csftdf_percentage], 0
  3606 0000A2DB 7605                <1> 	jna	short csftdf2_load_fat_file_1
  3607                              <1> 	
  3608 0000A2DD E87C000000          <1> 	call	csftdf2_print_percentage ; 19/03/2016
  3609                              <1> 
  3610                              <1> csftdf2_load_fat_file_1:
  3611 0000A2E2 8B35[A82C0100]      <1> 	mov	esi, [csftdf_sf_drv_dt]	
  3612 0000A2E8 5B                  <1> 	pop	ebx ; *
  3613                              <1> 
  3614                              <1> csftdf2_load_fat_file_2:
  3615 0000A2E9 E8B8000000          <1> 	call	csftdf2_read_fat_file_sectors ; 19/03/2016
  3616 0000A2EE 0F8250040000        <1>         jc      csftdf2_rw_error ; eocc! or disk error! 
  3617                              <1> 
  3618 0000A2F4 09D2                <1> 	or	edx, edx ; edx > 0 -> EOF
  3619 0000A2F6 7520                <1> 	jnz	short csftdf2_load_fat_file_ok
  3620                              <1> 
  3621 0000A2F8 803D[A42C0100]00    <1> 	cmp	byte [csftdf_percentage], 0
  3622 0000A2FF 76E8                <1> 	jna	short csftdf2_load_fat_file_2
  3623                              <1> 
  3624 0000A301 53                  <1> 	push	ebx ; *	
  3625                              <1> 
  3626                              <1> 	; Set cursor position
  3627                              <1> 	; AH= 02h, BH= Page Number, DH= Row, DL= Column
  3628 0000A302 8A3D[A52C0100]      <1> 	mov	bh, [csftdf_videopage]
  3629 0000A308 668B15[A62C0100]    <1> 	mov	dx, [csftdf_cursorpos]
  3630 0000A30F B402                <1> 	mov	ah, 2
  3631 0000A311 E83170FFFF          <1> 	call	_int10h
  3632 0000A316 EBB2                <1> 	jmp	short csftdf2_load_fat_file_next
  3633                              <1> 	
  3634                              <1> csftdf2_load_fat_file_ok:
  3635 0000A318 803D[A42C0100]00    <1> 	cmp	byte [csftdf_percentage], 0
  3636 0000A31F 0F8651020000        <1>         jna     csftdf2_save_file ; 25/03/2016
  3637                              <1> 	
  3638                              <1> 	; "Reading... 100%"
  3639 0000A325 BF[51E40000]        <1> 	mov	edi, percentagestr
  3640 0000A32A B031                <1> 	mov	al, '1'
  3641 0000A32C AA                  <1> 	stosb
  3642 0000A32D B030                <1> 	mov	al, '0'
  3643 0000A32F AA                  <1> 	stosb
  3644 0000A330 AA                  <1> 	stosb
  3645                              <1> 
  3646 0000A331 8A3D[A52C0100]      <1> 	mov	bh, [csftdf_videopage]
  3647 0000A337 668B15[A62C0100]    <1> 	mov	dx, [csftdf_cursorpos]
  3648 0000A33E B402                <1> 	mov	ah, 2
  3649 0000A340 E80270FFFF          <1> 	call	_int10h
  3650                              <1> 
  3651 0000A345 BE[39E40000]        <1> 	mov	esi, msg_reading
  3652 0000A34A E8E3B1FFFF          <1> 	call	print_msg
  3653                              <1> 	
  3654 0000A34F BE[51E40000]        <1> 	mov	esi, percentagestr
  3655 0000A354 E8D9B1FFFF          <1> 	call	print_msg
  3656                              <1> 
  3657 0000A359 E918020000          <1>         jmp     csftdf2_save_file ; 25/03/2016
  3658                              <1> 
  3659                              <1> csftdf2_print_percentage:
  3660                              <1> 	; 19/03/2016
  3661                              <1> 	; 18/03/2016
  3662 0000A35E B020                <1> 	mov	al, 20h
  3663 0000A360 BF[51E40000]        <1> 	mov	edi, percentagestr
  3664 0000A365 AA                  <1> 	stosb
  3665 0000A366 AA                  <1> 	stosb
  3666 0000A367 A1[9C2C0100]        <1> 	mov	eax, [csftdf_sf_rbytes]
  3667 0000A36C BA64000000          <1> 	mov	edx, 100
  3668 0000A371 F7E2                <1> 	mul	edx
  3669 0000A373 8B0D[802C0100]      <1> 	mov	ecx, [csftdf_filesize]	
  3670 0000A379 F7F1                <1> 	div	ecx
  3671 0000A37B B10A                <1> 	mov	cl, 10
  3672 0000A37D F6F1                <1> 	div	cl
  3673 0000A37F 80C430              <1> 	add	ah, '0'
  3674 0000A382 8827                <1> 	mov	[edi], ah
  3675 0000A384 20C0                <1> 	and	al, al
  3676 0000A386 740A                <1> 	jz	short csftdf2_print_percent_1
  3677 0000A388 4F                  <1> 	dec	edi
  3678 0000A389 6698                <1> 	cbw
  3679 0000A38B F6F1                <1> 	div	cl
  3680 0000A38D 80C430              <1> 	add	ah, '0'
  3681 0000A390 8827                <1> 	mov	[edi], ah
  3682                              <1> 	;and	al, al
  3683                              <1> 	;jz	short csftdf2_print_percent_1
  3684                              <1> 	;dec	edi
  3685                              <1> 	;mov	[edi], '1' ; 100%		
  3686                              <1> 
  3687                              <1> csftdf2_print_percent_1:
  3688 0000A392 BE[51E40000]        <1> 	mov	esi, percentagestr
  3689                              <1> 	;call	print_msg
  3690                              <1> 	;retn
  3691 0000A397 E996B1FFFF          <1> 	jmp	print_msg
  3692                              <1> 
  3693                              <1> csftdf2_read_file_sectors:
  3694                              <1> 	; 19/03/2016
  3695 0000A39C 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
  3696 0000A3A0 0F8627070000        <1>         jna     csftdf2_read_fs_file_sectors
  3697                              <1> 
  3698                              <1> csftdf2_read_fat_file_sectors:
  3699                              <1> 	; 19/03/2016
  3700                              <1> 	; 18/03/2016
  3701                              <1> 	; return:
  3702                              <1> 	;   CF = 0 & EDX > 0 -> END OF FILE
  3703                              <1> 	;   CF = 0 & EDX = 0 -> not EOF
  3704                              <1> 	;   CF = 1 -> read error (error code in AL)	
  3705                              <1> 
  3706                              <1> csftdf2_read_fat_file_secs_0:
  3707 0000A3A6 8B15[802C0100]      <1> 	mov	edx, [csftdf_filesize]
  3708 0000A3AC 2B15[9C2C0100]      <1> 	sub	edx, [csftdf_sf_rbytes]
  3709 0000A3B2 3B15[942C0100]      <1> 	cmp	edx, [csftdf_r_size]	
  3710 0000A3B8 7306                <1> 	jnb	short csftdf2_read_fat_file_secs_1
  3711 0000A3BA 8915[942C0100]      <1> 	mov	[csftdf_r_size], edx
  3712                              <1> 		
  3713                              <1> csftdf2_read_fat_file_secs_1:
  3714 0000A3C0 A1[942C0100]        <1> 	mov	eax, [csftdf_r_size]
  3715 0000A3C5 29D2                <1> 	sub	edx, edx
  3716 0000A3C7 0FB74E11            <1> 	movzx	ecx, word [esi+LD_BPB+BytesPerSec]
  3717 0000A3CB 01C8                <1> 	add	eax, ecx
  3718 0000A3CD 48                  <1> 	dec	eax
  3719 0000A3CE F7F1                <1> 	div	ecx
  3720 0000A3D0 89C1                <1> 	mov	ecx, eax ; sector count
  3721 0000A3D2 A1[8C2C0100]        <1> 	mov	eax, [csftdf_sf_cluster]
  3722                              <1> 
  3723                              <1> 	; EBX = memory block address (current)
  3724                              <1> 	
  3725 0000A3D7 E821090000          <1> 	call	read_fat_file_sectors
  3726 0000A3DC 7235                <1> 	jc	short csftdf2_read_fat_file_secs_3
  3727                              <1> 
  3728                              <1> 	; EBX = next memory address
  3729                              <1> 
  3730 0000A3DE A1[9C2C0100]        <1> 	mov	eax, [csftdf_sf_rbytes]
  3731 0000A3E3 0305[942C0100]      <1> 	add	eax, [csftdf_r_size]
  3732 0000A3E9 8B15[802C0100]      <1> 	mov	edx, [csftdf_filesize]
  3733 0000A3EF 39D0                <1> 	cmp	eax, edx
  3734 0000A3F1 7320                <1> 	jnb	short csftdf2_read_fat_file_secs_3 ; edx > 0
  3735 0000A3F3 A3[9C2C0100]        <1> 	mov	[csftdf_sf_rbytes], eax
  3736                              <1> 
  3737 0000A3F8 53                  <1> 	push	ebx ; *
  3738                              <1> 	; get next cluster (csftdf_r_size! bytes)
  3739 0000A3F9 A1[8C2C0100]        <1> 	mov	eax, [csftdf_sf_cluster]
  3740 0000A3FE E8CC060000          <1> 	call	get_next_cluster
  3741 0000A403 5B                  <1> 	pop	ebx ; *
  3742 0000A404 7306                <1> 	jnc	short csftdf2_read_fat_file_secs_2
  3743                              <1> 
  3744 0000A406 B815000000          <1> 	mov	eax, 15h ; Read error !
  3745 0000A40B C3                  <1> 	retn
  3746                              <1> 
  3747                              <1> csftdf2_read_fat_file_secs_2:
  3748 0000A40C 29D2                <1> 	sub	edx, edx ; 0
  3749 0000A40E A3[8C2C0100]        <1> 	mov	[csftdf_sf_cluster], eax ; next cluster
  3750                              <1> 
  3751                              <1> csftdf2_read_fat_file_secs_3:
  3752 0000A413 C3                  <1> 	retn
  3753                              <1> 
  3754                              <1> csftdf2_read_sf_cluster:
  3755                              <1> 	; 19/03/2016
  3756 0000A414 BB00000700          <1> 	mov	ebx, Cluster_Buffer ; buffer address (64KB)
  3757                              <1> 
  3758 0000A419 803D[A42C0100]00    <1> 	cmp	byte [csftdf_percentage], 0
  3759 0000A420 760D                <1> 	jna	short csftdf2_read_sf_clust_2
  3760                              <1> 
  3761 0000A422 53                  <1> 	push	ebx ; *	
  3762                              <1> 
  3763                              <1> csftdf2_read_sf_clust_next:
  3764 0000A423 E836FFFFFF          <1> 	call	csftdf2_print_percentage
  3765                              <1> 
  3766                              <1> csftdf2_read_sf_clust_0:
  3767 0000A428 8B35[A82C0100]      <1> 	mov	esi, [csftdf_sf_drv_dt]	
  3768                              <1> csftdf2_read_sf_clust_1:
  3769 0000A42E 5B                  <1> 	pop	ebx ; *
  3770                              <1> 
  3771                              <1> csftdf2_read_sf_clust_2:
  3772 0000A42F 89DA                <1> 	mov	edx, ebx
  3773 0000A431 0315[942C0100]      <1> 	add	edx, [csftdf_r_size]
  3774 0000A437 81FA00000800        <1> 	cmp	edx, Cluster_Buffer + 65536
  3775 0000A43D 772F                <1> 	ja	short csftdf2_write_df_cluster
  3776                              <1> 
  3777 0000A43F E858FFFFFF          <1> 	call	csftdf2_read_file_sectors ; 19/03/2016
  3778 0000A444 0F8280020000        <1>         jc      csftdf2_save_fat_file_err2 ; eocc! or disk error! 
  3779                              <1> 
  3780 0000A44A 09D2                <1> 	or	edx, edx ; edx > 0 -> EOF
  3781 0000A44C 7520                <1> 	jnz	short csftdf2_write_df_cluster
  3782                              <1> 
  3783 0000A44E 803D[A42C0100]00    <1> 	cmp	byte [csftdf_percentage], 0
  3784 0000A455 76D8                <1> 	jna	short csftdf2_read_sf_clust_2
  3785                              <1> 
  3786 0000A457 53                  <1> 	push	ebx ; *	
  3787                              <1> 
  3788                              <1> 	; Set cursor position
  3789                              <1> 	; AH= 02h, BH= Page Number, DH= Row, DL= Column
  3790 0000A458 8A3D[A52C0100]      <1> 	mov	bh, [csftdf_videopage]
  3791 0000A45E 668B15[A62C0100]    <1> 	mov	dx, [csftdf_cursorpos]
  3792 0000A465 B402                <1> 	mov	ah, 2
  3793 0000A467 E8DB6EFFFF          <1> 	call	_int10h
  3794 0000A46C EBB5                <1> 	jmp	short csftdf2_read_sf_clust_next
  3795                              <1> 
  3796                              <1> csftdf2_write_df_cluster:
  3797                              <1> 	; 19/03/2016
  3798 0000A46E 8B35[AC2C0100]      <1> 	mov	esi, [csftdf_df_drv_dt]	
  3799 0000A474 BB00000700          <1> 	mov	ebx, Cluster_Buffer ; buffer address (64KB)
  3800                              <1> 
  3801                              <1> csftdf2_write_df_clust_next:
  3802 0000A479 E855000000          <1> 	call	csftdf2_write_file_sectors ; 19/03/2016
  3803 0000A47E 0F8246020000        <1>         jc      csftdf2_save_fat_file_err2 ; eocc! or disk error! 
  3804                              <1> 
  3805 0000A484 09D2                <1> 	or	edx, edx ; edx > 0 -> EOF
  3806 0000A486 750A                <1> 	jnz	short csftdf2_rw_f_clust_ok
  3807                              <1> 
  3808 0000A488 81FB00000800        <1> 	cmp	ebx, Cluster_Buffer + 65536
  3809 0000A48E 72E9                <1> 	jb	short csftdf2_write_df_clust_next
  3810                              <1> 	
  3811 0000A490 EB82                <1> 	jmp	short csftdf2_read_sf_cluster
  3812                              <1>  
  3813                              <1> csftdf2_rw_f_clust_ok:
  3814 0000A492 803D[A42C0100]00    <1> 	cmp	byte [csftdf_percentage], 0
  3815 0000A499 0F86B2010000        <1>         jna     csftdf2_save_fat_file_4 ; 25/03/2016
  3816                              <1> 
  3817                              <1> 	; "100%"
  3818 0000A49F BF[51E40000]        <1> 	mov	edi, percentagestr
  3819 0000A4A4 B031                <1> 	mov	al, '1'
  3820 0000A4A6 AA                  <1> 	stosb
  3821 0000A4A7 B030                <1> 	mov	al, '0'
  3822 0000A4A9 AA                  <1> 	stosb
  3823 0000A4AA AA                  <1> 	stosb
  3824                              <1> 
  3825 0000A4AB 8A3D[A52C0100]      <1> 	mov	bh, [csftdf_videopage]
  3826 0000A4B1 668B15[A62C0100]    <1> 	mov	dx, [csftdf_cursorpos]
  3827 0000A4B8 B402                <1> 	mov	ah, 2
  3828 0000A4BA E8886EFFFF          <1> 	call	_int10h
  3829                              <1> 
  3830 0000A4BF BE[51E40000]        <1> 	mov	esi, percentagestr
  3831 0000A4C4 E869B0FFFF          <1> 	call	print_msg
  3832                              <1> 
  3833 0000A4C9 E983010000          <1>         jmp     csftdf2_save_fat_file_4
  3834                              <1> 
  3835                              <1> csftdf2_load_fs_file:
  3836                              <1> 	; temporary - 18/03/2016
  3837 0000A4CE E96F020000          <1>         jmp     csftdf2_read_error
  3838                              <1> 
  3839                              <1> csftdf2_write_file_sectors:
  3840                              <1> 	; 19/03/2016
  3841 0000A4D3 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
  3842 0000A4D7 0F86F1050000        <1>         jna     csftdf2_write_fs_file_sectors
  3843                              <1> 
  3844                              <1> csftdf2_write_fat_file_sectors:
  3845                              <1> 	; 19/03/2016
  3846                              <1> 	; 18/03/2016
  3847                              <1> 	; return:
  3848                              <1> 	;   CF = 0 & EDX > 0 -> END OF FILE
  3849                              <1> 	;   CF = 0 & EDX = 0 -> not EOF
  3850                              <1> 	;   CF = 1 -> write error (error code in AL)	
  3851                              <1> 
  3852                              <1> csftdf2_write_fat_file_secs_0:
  3853 0000A4DD 8B15[802C0100]      <1> 	mov	edx, [csftdf_filesize]
  3854 0000A4E3 2B15[A02C0100]      <1> 	sub	edx, [csftdf_df_wbytes]
  3855 0000A4E9 3B15[982C0100]      <1> 	cmp	edx, [csftdf_w_size]	
  3856 0000A4EF 7306                <1> 	jnb	short csftdf2_write_fat_file_secs_1
  3857 0000A4F1 8915[982C0100]      <1> 	mov	[csftdf_w_size], edx		
  3858                              <1> 
  3859                              <1> csftdf2_write_fat_file_secs_1:
  3860 0000A4F7 A1[982C0100]        <1> 	mov	eax, [csftdf_w_size]
  3861 0000A4FC 29D2                <1> 	sub	edx, edx
  3862 0000A4FE 0FB74E11            <1> 	movzx	ecx, word [esi+LD_BPB+BytesPerSec]
  3863 0000A502 01C8                <1> 	add	eax, ecx
  3864 0000A504 48                  <1> 	dec	eax
  3865 0000A505 F7F1                <1> 	div	ecx
  3866 0000A507 89C1                <1> 	mov	ecx, eax ; sector count
  3867 0000A509 A1[902C0100]        <1> 	mov	eax, [csftdf_df_cluster]
  3868                              <1> 
  3869                              <1> 	; EBX = memory block address (current)	
  3870                              <1> 
  3871 0000A50E E8920F0000          <1> 	call	write_fat_file_sectors
  3872 0000A513 7259                <1> 	jc	short csftdf2_write_fat_file_secs_4
  3873                              <1> 
  3874                              <1> 	; EBX = next memory address
  3875                              <1> 
  3876 0000A515 A1[A02C0100]        <1> 	mov	eax, [csftdf_df_wbytes]
  3877 0000A51A 0305[982C0100]      <1> 	add	eax, [csftdf_w_size]
  3878 0000A520 8B15[802C0100]      <1> 	mov	edx, [csftdf_filesize]
  3879 0000A526 39D0                <1> 	cmp	eax, edx
  3880 0000A528 7344                <1> 	jnb	short csftdf2_write_fat_file_secs_4
  3881 0000A52A A3[A02C0100]        <1> 	mov	[csftdf_df_wbytes], eax
  3882                              <1> 	;
  3883 0000A52F A3[422C0100]        <1> 	mov	[DestinationFile_DirEntry+DirEntry_FileSize], eax
  3884                              <1> 
  3885 0000A534 53                  <1> 	push	ebx ; *
  3886                              <1> 
  3887 0000A535 803D[7E2C0100]01    <1> 	cmp	byte [DestinationFileFound], 1
  3888 0000A53C 7210                <1> 	jb	short csftdf2_write_fat_file_secs_2
  3889                              <1> 
  3890                              <1> 	; get next cluster (csftdf_w_size! bytes)
  3891 0000A53E A1[902C0100]        <1> 	mov	eax, [csftdf_df_cluster]
  3892 0000A543 E887050000          <1> 	call	get_next_cluster
  3893 0000A548 731C                <1> 	jnc	short csftdf2_write_fat_file_secs_3
  3894                              <1> 
  3895 0000A54A 21C0                <1> 	and	eax, eax ; end of cluster chain!?
  3896 0000A54C 7521                <1> 	jnz	short csftdf2_write_fat_file_secs_5 ; disk error !
  3897                              <1> 
  3898                              <1> csftdf2_write_fat_file_secs_2:
  3899 0000A54E A1[902C0100]        <1> 	mov	eax, [csftdf_df_cluster] ; last cluster
  3900 0000A553 E8700E0000          <1> 	call	add_new_cluster		
  3901 0000A558 7215                <1> 	jc	short csftdf2_write_fat_file_secs_5
  3902                              <1> 
  3903                              <1> 	; NOTE: Destination file size may be bigger than
  3904                              <1> 	; source file size when the last reading fails after here.
  3905                              <1> 	; (The last -empty- cluster of destination file must be 
  3906                              <1> 	; truncated and LMDT must be current date&time for partial
  3907                              <1> 	; copy result!) 
  3908 0000A55A 8B15[982C0100]      <1> 	mov	edx, [csftdf_w_size] ; bytes per cluster
  3909 0000A560 0115[422C0100]      <1> 	add	[DestinationFile_DirEntry+DirEntry_FileSize], edx
  3910                              <1> 
  3911                              <1> csftdf2_write_fat_file_secs_3:
  3912 0000A566 5B                  <1> 	pop	ebx ; *
  3913 0000A567 29D2                <1> 	sub	edx, edx ; 0
  3914 0000A569 A3[902C0100]        <1> 	mov	[csftdf_df_cluster], eax ; next cluster
  3915                              <1> 
  3916                              <1> csftdf2_write_fat_file_secs_4:
  3917 0000A56E C3                  <1> 	retn
  3918                              <1> 
  3919                              <1> csftdf2_write_fat_file_secs_5:
  3920 0000A56F 5B                  <1> 	pop	ebx ; *
  3921 0000A570 B81D000000          <1> 	mov	eax, 1Dh ; Write error !
  3922 0000A575 C3                  <1> 	retn
  3923                              <1> 
  3924                              <1> csftdf2_save_file:
  3925                              <1> 	; 25/03/2016
  3926                              <1> 	; 19/03/2016
  3927                              <1> 	; 18/03/2016
  3928 0000A576 8B35[AC2C0100]      <1> 	mov	esi, [csftdf_df_drv_dt] ; logical dos drv desc. tbl.
  3929                              <1> 
  3930 0000A57C 8B1D[842C0100]      <1> 	mov	ebx, [csftdf_sf_mem_addr] ; memory block address
  3931                              <1> 
  3932 0000A582 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
  3933 0000A586 0F86F4010000        <1>         jna     csftdf2_save_fs_file
  3934                              <1> 
  3935                              <1> csftdf2_save_fat_file:
  3936 0000A58C 53                  <1> 	push	ebx; *
  3937                              <1> 
  3938 0000A58D 803D[A42C0100]00    <1> 	cmp	byte [csftdf_percentage], 0
  3939 0000A594 7724                <1> 	ja	short csftdf2_save_fat_file_0
  3940                              <1> 
  3941                              <1> 	; Set cursor position
  3942                              <1> 	; AH= 02h, BH= Page Number, DH= Row, DL= Column
  3943 0000A596 8A3D[A52C0100]      <1> 	mov	bh, [csftdf_videopage]
  3944 0000A59C 668B15[A62C0100]    <1> 	mov	dx, [csftdf_cursorpos]
  3945 0000A5A3 B402                <1> 	mov	ah, 2
  3946 0000A5A5 E89D6DFFFF          <1> 	call	_int10h
  3947                              <1> 	
  3948 0000A5AA BE[45E40000]        <1> 	mov	esi, msg_writing
  3949 0000A5AF E87EAFFFFF          <1> 	call	print_msg
  3950                              <1> 
  3951                              <1> csftdf2_save_fat_file_next:
  3952 0000A5B4 8B35[AC2C0100]      <1> 	mov	esi, [csftdf_df_drv_dt] ; 25/03/2016
  3953                              <1> 
  3954                              <1> csftdf2_save_fat_file_0:
  3955 0000A5BA 5B                  <1> 	pop	ebx ; *
  3956                              <1> 
  3957                              <1> csftdf2_save_fat_file_1:
  3958 0000A5BB E813FFFFFF          <1> 	call	csftdf2_write_file_sectors ; 19/03/2016	
  3959 0000A5C0 0F827E010000        <1>         jc      csftdf2_rw_error ; eocc! or disk error! 
  3960                              <1> 
  3961 0000A5C6 09D2                <1> 	or	edx, edx ; edx > 0 -> EOF
  3962 0000A5C8 756D                <1>         jnz     short csftdf2_save_fat_file_3 ; 25/03/2016
  3963                              <1> 
  3964 0000A5CA 803D[A42C0100]00    <1> 	cmp	byte [csftdf_percentage], 0
  3965 0000A5D1 76E8                <1> 	jna	short csftdf2_save_fat_file_1
  3966                              <1> 
  3967 0000A5D3 B020                <1> 	mov	al, 20h
  3968 0000A5D5 BF[51E40000]        <1> 	mov	edi, percentagestr
  3969 0000A5DA AA                  <1> 	stosb
  3970 0000A5DB AA                  <1> 	stosb
  3971 0000A5DC A1[A02C0100]        <1> 	mov	eax, [csftdf_df_wbytes]
  3972 0000A5E1 BA64000000          <1> 	mov	edx, 100
  3973 0000A5E6 F7E2                <1> 	mul	edx
  3974 0000A5E8 8B0D[802C0100]      <1> 	mov	ecx, [csftdf_filesize]	
  3975 0000A5EE F7F1                <1> 	div	ecx
  3976 0000A5F0 B10A                <1> 	mov	cl, 10
  3977 0000A5F2 F6F1                <1> 	div	cl
  3978 0000A5F4 80C430              <1> 	add	ah, '0'
  3979 0000A5F7 8827                <1> 	mov	[edi], ah
  3980 0000A5F9 20C0                <1> 	and	al, al
  3981 0000A5FB 740A                <1> 	jz	short csftdf2_save_fat_file_2
  3982 0000A5FD 4F                  <1> 	dec	edi
  3983 0000A5FE 6698                <1> 	cbw
  3984 0000A600 F6F1                <1> 	div	cl
  3985 0000A602 80C430              <1> 	add	ah, '0'
  3986 0000A605 8827                <1> 	mov	[edi], ah
  3987                              <1> 	;and	al, al
  3988                              <1> 	;jz	short csftdf2_save_fat_file_2
  3989                              <1> 	;dec	edi
  3990                              <1> 	;mov	[edi], '1' ; 100%		
  3991                              <1> 
  3992                              <1> csftdf2_save_fat_file_2:
  3993 0000A607 53                  <1> 	push	ebx ; *
  3994                              <1> 
  3995 0000A608 E802000000          <1> 	call	csftdf2_print_wr_percentage ; 25/03/2016
  3996                              <1> 
  3997 0000A60D EBA5                <1>         jmp     csftdf2_save_fat_file_next
  3998                              <1> 
  3999                              <1> csftdf2_print_wr_percentage:
  4000                              <1> 	; Set cursor position
  4001                              <1> 	; AH= 02h, BH= Page Number, DH= Row, DL= Column
  4002 0000A60F 8A3D[A52C0100]      <1> 	mov	bh, [csftdf_videopage]
  4003 0000A615 668B15[A62C0100]    <1> 	mov	dx, [csftdf_cursorpos]
  4004 0000A61C B402                <1> 	mov	ah, 2
  4005 0000A61E E8246DFFFF          <1> 	call	_int10h
  4006                              <1> 
  4007 0000A623 BE[45E40000]        <1> 	mov	esi, msg_writing
  4008 0000A628 E805AFFFFF          <1> 	call	print_msg
  4009                              <1> 
  4010 0000A62D BE[51E40000]        <1> 	mov	esi, percentagestr
  4011                              <1> 	;call	print_msg
  4012                              <1> 	;retn
  4013 0000A632 E9FBAEFFFF          <1> 	jmp	print_msg
  4014                              <1> 
  4015                              <1> csftdf2_save_fat_file_3:
  4016 0000A637 803D[A42C0100]00    <1> 	cmp	byte [csftdf_percentage], 0
  4017 0000A63E 7611                <1>         jna     csftdf2_save_fat_file_4 ; 25/03/2016
  4018                              <1> 
  4019                              <1> 	; "100%"
  4020 0000A640 BF[51E40000]        <1> 	mov	edi, percentagestr
  4021 0000A645 B031                <1> 	mov	al, '1'
  4022 0000A647 AA                  <1> 	stosb
  4023 0000A648 B030                <1> 	mov	al, '0'
  4024 0000A64A AA                  <1> 	stosb
  4025 0000A64B AA                  <1> 	stosb
  4026                              <1> 
  4027 0000A64C E8BEFFFFFF          <1> 	call	csftdf2_print_wr_percentage
  4028                              <1> 
  4029                              <1> csftdf2_save_fat_file_4:
  4030 0000A651 803D[7E2C0100]00    <1> 	cmp	byte [DestinationFileFound], 0
  4031 0000A658 7647                <1> 	jna	short csftdf2_save_fat_file_6
  4032                              <1> 
  4033 0000A65A 8B35[AC2C0100]      <1> 	mov	esi, [csftdf_df_drv_dt] ; 31/03/2016	
  4034                              <1> 
  4035 0000A660 A1[902C0100]        <1> 	mov	eax, [csftdf_df_cluster] ; last cluster
  4036 0000A665 E865040000          <1> 	call	get_next_cluster
  4037 0000A66A 7235                <1> 	jc	short csftdf2_save_fat_file_6 ; eocc! or disk error!
  4038                              <1> 
  4039 0000A66C A1[902C0100]        <1> 	mov	eax, [csftdf_df_cluster] ; last cluster
  4040                              <1> 	;xor	ecx, ecx
  4041                              <1> 	;mov	[FAT_ClusterCounter], ecx ; 0 ; reset
  4042                              <1> 	;dec	ecx ; 0FFFFFFFFh
  4043                              <1> 	;shr	ecx, 4 ; 28 bit ; 0FFFFFFFh
  4044 0000A671 B9FFFFFF0F          <1> 	mov	ecx, 0FFFFFFFh
  4045 0000A676 E87E070000          <1> 	call	update_cluster
  4046 0000A67B 7224                <1> 	jc	short csftdf2_save_fat_file_6 ; really last cluster!?
  4047                              <1> 
  4048 0000A67D A3[902C0100]        <1> 	mov	[csftdf_df_cluster], eax ; next cluster
  4049                              <1> 	
  4050                              <1> 	; byte [FAT_BuffValidData] = 2 
  4051 0000A682 E82F0A0000          <1> 	call	save_fat_buffer
  4052 0000A687 730E                <1> 	jnc	short csftdf2_save_fat_file_5
  4053                              <1> 	
  4054 0000A689 8B15[802C0100]      <1> 	mov	edx, [csftdf_filesize]
  4055 0000A68F 8915[422C0100]      <1> 	mov	[DestinationFile_DirEntry+DirEntry_FileSize], edx
  4056 0000A695 EB58                <1> 	jmp	short csftdf2_save_fat_file_err3
  4057                              <1> 
  4058                              <1> csftdf2_save_fat_file_5:
  4059 0000A697 A1[902C0100]        <1> 	mov	eax, [csftdf_df_cluster]
  4060                              <1> 
  4061                              <1> 	; EAX = First cluster to be truncated/unlinked
  4062                              <1> 	; ESI = Logical dos drive description table address
  4063 0000A69C E8480C0000          <1> 	call	truncate_cluster_chain
  4064                              <1> 
  4065                              <1> csftdf2_save_fat_file_6:
  4066                              <1> 	; 28/03/2016
  4067 0000A6A1 BE[B12B0100]        <1> 	mov	esi, SourceFile_DirEntry+DirEntry_Attr ; +11 to + 18
  4068 0000A6A6 BF[312C0100]        <1> 	mov	edi, DestinationFile_DirEntry+DirEntry_Attr ; +11 to + 18
  4069 0000A6AB A4                  <1> 	movsb ; +11
  4070 0000A6AC A5                  <1> 	movsd ; +12 .. +15
  4071 0000A6AD 66A5                <1> 	movsw ; +16 .. +17
  4072                              <1> 		; + 18
  4073 0000A6AF 83C604              <1> 	add	esi, 4
  4074 0000A6B2 83C704              <1> 	add	edi, 4
  4075 0000A6B5 A5                  <1> 	movsd	; DirEntry_WrtTime ; +22 .. +25
  4076                              <1> 
  4077 0000A6B6 8B15[802C0100]      <1> 	mov	edx, [csftdf_filesize]
  4078 0000A6BC 8915[422C0100]      <1> 	mov	[DestinationFile_DirEntry+DirEntry_FileSize], edx
  4079                              <1> 
  4080 0000A6C2 E8D7F0FFFF          <1> 	call	convert_current_date_time
  4081                              <1> 	; DX = Date in dos dir entry format
  4082                              <1> 	; AX = Time in dos dir entry format
  4083 0000A6C7 EB4D                <1> 	jmp	short csftdf2_save_fat_file_7
  4084                              <1> 
  4085                              <1> csftdf2_save_fat_file_err1:
  4086 0000A6C9 5B                  <1> 	pop	ebx ; *	
  4087                              <1> csftdf2_save_fat_file_err2:
  4088 0000A6CA A1[A02C0100]        <1> 	mov	eax, [csftdf_df_wbytes]
  4089 0000A6CF 8B15[422C0100]      <1> 	mov	edx, [DestinationFile_DirEntry+DirEntry_FileSize]
  4090 0000A6D5 39C2                <1> 	cmp	edx, eax
  4091 0000A6D7 7616                <1> 	jna	short csftdf2_save_fat_file_err3
  4092 0000A6D9 A1[902C0100]        <1> 	mov	eax, [csftdf_df_cluster] ; last (empty) cluster
  4093                              <1> 	; ESI = Logical dos drive description table address
  4094 0000A6DE E8060C0000          <1> 	call	truncate_cluster_chain
  4095 0000A6E3 720A                <1> 	jc	short csftdf2_save_fat_file_err3
  4096 0000A6E5 A1[A02C0100]        <1> 	mov	eax, [csftdf_df_wbytes]	
  4097 0000A6EA A3[422C0100]        <1> 	mov	[DestinationFile_DirEntry+DirEntry_FileSize], eax
  4098                              <1> csftdf2_save_fat_file_err3:
  4099 0000A6EF E8AAF0FFFF          <1> 	call	convert_current_date_time
  4100                              <1> 	; DX = Date in dos dir entry format
  4101                              <1> 	; AX = Time in dos dir entry format
  4102 0000A6F4 C605[332C0100]00    <1> 	mov	byte [DestinationFile_DirEntry+DirEntry_CrtTimeTenth], 0
  4103 0000A6FB 66A3[342C0100]      <1> 	mov	[DestinationFile_DirEntry+DirEntry_CrtTime], ax
  4104 0000A701 668915[362C0100]    <1> 	mov	[DestinationFile_DirEntry+DirEntry_CrtDate], dx		
  4105 0000A708 66A3[3C2C0100]      <1> 	mov	[DestinationFile_DirEntry+DirEntry_WrtTime], ax
  4106 0000A70E 668915[3E2C0100]    <1> 	mov	[DestinationFile_DirEntry+DirEntry_WrtDate], dx
  4107 0000A715 F9                  <1> 	stc
  4108                              <1> csftdf2_save_fat_file_7:
  4109 0000A716 9C                  <1> 	pushf
  4110 0000A717 668915[382C0100]    <1> 	mov	[DestinationFile_DirEntry+DirEntry_LastAccDate], dx
  4111 0000A71E BE[262C0100]        <1> 	mov	esi, DestinationFile_DirEntry
  4112 0000A723 BF00000800          <1> 	mov	edi, Directory_Buffer
  4113 0000A728 0FB70D[4E2C0100]    <1> 	movzx	ecx, word [DestinationFile_DirEntryNumber] ; (<2048)
  4114 0000A72F 66C1E105            <1> 	shl	cx, 5 ; 32 * directory entry number
  4115 0000A733 01CF                <1> 	add	edi, ecx
  4116                              <1> 	;mov	ecx, 8
  4117 0000A735 66B90800            <1> 	mov	cx, 8
  4118 0000A739 F3A5                <1> 	rep	movsd
  4119 0000A73B 9D                  <1> 	popf
  4120 0000A73C 730B                <1> 	jnc	short csftdf2_write_file_OK
  4121                              <1> 	 		
  4122                              <1> csftdf2_write_error:
  4123                              <1> 	; 18/03/2016
  4124 0000A73E B01D                <1> 	mov	al, 1Dh ; write error
  4125 0000A740 EB02                <1> 	jmp	short csftdf2_rw_error
  4126                              <1> 
  4127                              <1> 	; 16/03/2016
  4128                              <1> csftdf2_read_error:
  4129 0000A742 B015                <1> 	mov	al, 15h ; ; Drive not ready or read error!
  4130                              <1> csftdf2_rw_error:
  4131 0000A744 A2[7D2C0100]        <1> 	mov	[csftdf_rw_err], al 
  4132                              <1> 
  4133                              <1> csftdf2_write_file_OK:
  4134                              <1> 	; 18/03/2016
  4135 0000A749 C605[98280100]02    <1> 	mov	byte [DirBuff_ValidData], 2
  4136 0000A750 E8E7F0FFFF          <1> 	call	save_directory_buffer
  4137                              <1> 
  4138                              <1>  	; Update last modification date&time of destination
  4139                              <1> 	; file's (parent) directory
  4140 0000A755 E87DF1FFFF          <1> 	call	update_parent_dir_lmdt
  4141                              <1> 	;
  4142 0000A75A A1[842C0100]        <1> 	mov	eax, [csftdf_sf_mem_addr] ; start address
  4143                              <1> 
  4144 0000A75F 21C0                <1> 	and	eax, eax
  4145 0000A761 750E                <1> 	jnz	short csftdf2_dealloc_mblock
  4146                              <1> 
  4147 0000A763 88C5                <1> 	mov	ch, al ; 0 (Cluster r/w, not full loading)
  4148                              <1> csftdf2_dealloc_retn:
  4149 0000A765 8A0D[7D2C0100]      <1> 	mov	cl, [csftdf_rw_err]
  4150 0000A76B A1[902C0100]        <1> 	mov	eax, [csftdf_df_cluster]
  4151 0000A770 C3                  <1> 	retn
  4152                              <1> 
  4153                              <1> csftdf2_dealloc_mblock:
  4154 0000A771 8B0D[882C0100]      <1> 	mov	ecx, [csftdf_sf_mem_bsize] ; block size	
  4155 0000A777 E8B8A8FFFF          <1> 	call	deallocate_memory_block
  4156 0000A77C B5FF                <1>         mov     ch, 0FFh ; (File was full loaded at memory)
  4157 0000A77E EBE5                <1> 	jmp	short csftdf2_dealloc_retn
  4158                              <1> 
  4159                              <1> csftdf2_save_fs_file:
  4160                              <1> 	; temporary - (21/03/2016)
  4161 0000A780 B81D000000          <1> 	mov	eax, 1Dh ; write error
  4162 0000A785 F9                  <1> 	stc
  4163 0000A786 C3                  <1> 	retn
  4164                              <1> 
  4165                              <1> create_file:
  4166                              <1> 	; 31/03/2016
  4167                              <1> 	; 24/03/2016
  4168                              <1> 	; 23/03/2016
  4169                              <1> 	; 21/03/2016
  4170                              <1> 	; 20/03/2016
  4171                              <1> 	; 19/03/2016 (TRDOS 396 = TRDOS v2.0)
  4172                              <1> 	; 03/09/2011 (FILE.ASM, 'proc_create_file')
  4173                              <1> 	; 09/08/2010
  4174                              <1> 	;
  4175                              <1> 	; INPUT ->
  4176                              <1> 	; 	EAX = File Size
  4177                              <1> 	; 	ESI = ASCIIZ File Name
  4178                              <1> 	; 	CL = File Attributes 
  4179                              <1> 	;	EBX = FFFFFFFFh -> create empty file 
  4180                              <1> 	;			 (only for FAT fs) 
  4181                              <1> 	; OUTPUT ->
  4182                              <1> 	;     CF = 0 ->
  4183                              <1> 	;	EAX = New file's first cluster
  4184                              <1> 	; 	ESI = Logical Dos Drv Descr. Table Addr.
  4185                              <1> 	; 	EBX = offset CreateFile_Size
  4186                              <1> 	; 	ECX = Sectors per cluster (<256) 
  4187                              <1> 	; 	EDX = Directory entry index/number (<65536)
  4188                              <1> 	;     CF = 1 -> error code in AL
  4189                              <1> 
  4190                              <1> ;	test	cl, 18h (directory or volume name)
  4191                              <1> ;	jnz	short loc_createfile_access_denied
  4192 0000A787 80E107              <1> 	and	cl, 07h ; S, H, R
  4193 0000A78A 880D[CC2C0100]      <1>         mov     [createfile_attrib], cl 
  4194                              <1> 
  4195 0000A790 89D9                <1> 	mov	ecx, ebx
  4196 0000A792 89F3                <1> 	mov	ebx, esi ; ASCIIZ File Name address
  4197 0000A794 29D2                <1> 	sub	edx, edx
  4198 0000A796 8A35[6E200100]      <1>         mov     dh, [Current_Drv]
  4199 0000A79C BE00010900          <1>         mov     esi, Logical_DOSDisks
  4200 0000A7A1 01D6                <1> 	add	esi, edx
  4201                              <1> 
  4202 0000A7A3 8815[D72C0100]      <1> 	mov	[createfile_UpdatePDir], dl ; 0 ; 31/03/2016 
  4203                              <1> 
  4204                              <1> 	; LD_DiskType = 0 for write protection (read only) 
  4205 0000A7A9 807E0101            <1> 	cmp	byte [esi+LD_DiskType], 1 ; 0 = Invalid
  4206 0000A7AD 730A                <1> 	jnb	short loc_createfile_check_file_sytem
  4207 0000A7AF B813000000          <1> 	mov	eax, 13h ; MSDOS err => Disk write-protected 
  4208 0000A7B4 66BA0000            <1> 	mov	dx, 0
  4209                              <1> 	; err retn: EDX = 0, EBX = File name offset
  4210                              <1> 	; ESI -> Dos drive description table address	
  4211 0000A7B8 C3                  <1> 	retn
  4212                              <1> 
  4213                              <1> ;loc_createfile_access_denied:
  4214                              <1> ;	mov	eax, 05h ; access denied (invalid attributes input)
  4215                              <1> ;	stc
  4216                              <1> ;	retn
  4217                              <1> 
  4218                              <1> loc_createfile_check_file_sytem:
  4219 0000A7B9 807E0301            <1> 	cmp	byte [esi+LD_FATType], 1
  4220 0000A7BD 730A                <1> 	jnb	short loc_createfile_chk_empty_FAT_file_sign1
  4221                              <1> 
  4222 0000A7BF A3[B82C0100]        <1> 	mov	[createfile_size], eax
  4223                              <1> 	; ESI = Logical Dos Drive Description Table address
  4224                              <1> 	; EBX = ASCIIZ File Name address
  4225 0000A7C4 E9FE020000          <1> 	jmp	create_fs_file
  4226                              <1> 
  4227                              <1> loc_createfile_chk_empty_FAT_file_sign1:
  4228                              <1> 	; ECX = FFFFFFFFh -> create empty file if drive has FAT fs
  4229 0000A7C9 41                  <1> 	inc	ecx
  4230 0000A7CA 7506                <1> 	jnz	short loc_createfile_chk_empty_FAT_file_sign2
  4231 0000A7CC 890D[B82C0100]      <1> 	mov	[createfile_size], ecx ; 0 ; empty file
  4232                              <1> 
  4233                              <1> loc_createfile_chk_empty_FAT_file_sign2:
  4234                              <1> 	; 23/03/2016
  4235 0000A7D2 668B4E11            <1> 	mov	cx, [esi+LD_BPB+BytesPerSec]
  4236 0000A7D6 66890D[D42C0100]    <1> 	mov	[createfile_BytesPerSec], cx
  4237                              <1> 	
  4238                              <1> 	; EBX = ASCIIZ File Name address
  4239 0000A7DD 0FB65613            <1> 	movzx	edx, byte [esi+LD_BPB+SecPerClust]
  4240 0000A7E1 8815[CD2C0100]      <1> 	mov	[createfile_SecPerClust], dl
  4241 0000A7E7 8B4E74              <1> 	mov	ecx, [esi+LD_FreeSectors]
  4242 0000A7EA 39D1                <1> 	cmp	ecx, edx ; byte [createfile_SecPerClust]
  4243 0000A7EC 7306                <1> 	jnb	short loc_create_fat_file
  4244                              <1> 	  
  4245                              <1> loc_createfile_insufficient_disk_space:
  4246 0000A7EE B827000000          <1> 	mov	eax, 27h
  4247                              <1> loc_createfile_gffc_retn:
  4248 0000A7F3 C3                  <1> 	retn
  4249                              <1> 
  4250                              <1> loc_create_fat_file:
  4251 0000A7F4 891D[B02C0100]      <1> 	mov	[createfile_Name_Offset], ebx
  4252 0000A7FA 890D[B42C0100]      <1> 	mov	[createfile_FreeSectors], ecx
  4253                              <1> 
  4254                              <1> loc_createfile_gffc_1:
  4255 0000A800 E821050000          <1> 	call	get_first_free_cluster
  4256 0000A805 72EC                <1> 	jc	short loc_createfile_gffc_retn
  4257                              <1> 
  4258 0000A807 A3[BC2C0100]        <1> 	mov	[createfile_FFCluster], eax
  4259                              <1> 
  4260                              <1> loc_createfile_locate_ffe_on_directory:
  4261                              <1> 	; Current directory fcluster <> Directory buffer cluster
  4262                              <1> 	; Current directory will be reloaded by
  4263                              <1> 	; 'locate_current_dir_file' procedure
  4264                              <1> 	;
  4265                              <1> 	; ESI = Logical Dos Drv Desc. Table Adress
  4266 0000A80C 56                  <1> 	push	esi ; *
  4267 0000A80D 31C0                <1> 	xor	eax, eax
  4268                              <1> 
  4269 0000A80F A3[8E280100]        <1> 	mov	dword [FAT_ClusterCounter], eax ; 0
  4270                              <1> 	; 21/03/2016
  4271 0000A814 A2[D62C0100]        <1> 	mov	byte [createfile_wfc], al ; 0 
  4272                              <1> 
  4273 0000A819 89C1                <1>  	mov	ecx, eax
  4274 0000A81B 6649                <1> 	dec	cx ; FFFFh  
  4275                              <1> 	; CX = FFFFh -> find first deleted or free entry
  4276                              <1> 	; ESI would be ASCIIZ filename Address if the call
  4277                              <1> 	; would not be for first free or deleted dir entry  
  4278 0000A81D E8F6E7FFFF          <1> 	call	locate_current_dir_file
  4279 0000A822 0F83EE000000        <1> 	jnc	loc_createfile_set_ff_dir_entry
  4280 0000A828 5E                  <1> 	pop	esi ; *
  4281                              <1> 	 ; ESI = Logical DOS Drv. Description Table Address 
  4282 0000A829 83F802              <1> 	cmp	eax, 2
  4283 0000A82C 7402                <1> 	je	short loc_createfile_add_new_cluster
  4284                              <1> loc_createfile_locate_file_stc_retn:
  4285 0000A82E F9                  <1> 	stc
  4286 0000A82F C3                  <1> 	retn
  4287                              <1> 
  4288                              <1> loc_createfile_add_new_cluster:
  4289 0000A830 803D[6D200100]02    <1> 	cmp	byte [Current_FATType], 2
  4290                              <1> 	;cmp	byte [esi+LD_FATType], 2
  4291 0000A837 770C                <1> 	ja	short loc_createfile_add_new_cluster_check_fsc
  4292 0000A839 803D[6C200100]01    <1> 	cmp	byte [Current_Dir_Level], 1
  4293                              <1> 	;cmp	byte [esi+LD_CDirLevel], 1
  4294 0000A840 7303                <1> 	jnb	short loc_createfile_add_new_cluster_check_fsc
  4295                              <1> 	
  4296                              <1> 	;mov	eax, 12
  4297 0000A842 B00C                <1> 	mov	al, 12 ; No more files 
  4298                              <1> 
  4299                              <1> loc_createfile_anc_retn:
  4300 0000A844 C3                  <1> 	retn
  4301                              <1> 
  4302                              <1> loc_createfile_add_new_cluster_check_fsc:
  4303 0000A845 8B0D[B42C0100]      <1> 	mov	ecx, [createfile_FreeSectors]
  4304 0000A84B 0FB605[CD2C0100]    <1> 	movzx	eax, byte [createfile_SecPerClust]
  4305 0000A852 66D1E0              <1> 	shl	ax, 1 ; AX = 2 * AX
  4306 0000A855 39C1                <1> 	cmp	ecx, eax
  4307 0000A857 7295                <1>         jb	short loc_createfile_insufficient_disk_space
  4308                              <1> 
  4309                              <1> loc_createfile_add_new_subdir_cluster:
  4310 0000A859 8B15[9D280100]      <1> 	mov	edx, [DirBuff_Cluster]
  4311 0000A85F 8915[C02C0100]      <1> 	mov	[createfile_LastDirCluster], edx	
  4312                              <1> 
  4313 0000A865 A1[BC2C0100]        <1> 	mov	eax, [createfile_FFCluster]
  4314 0000A86A E846040000          <1> 	call	load_FAT_sub_directory 
  4315 0000A86F 72D3                <1> 	jc	short loc_createfile_anc_retn
  4316                              <1> 
  4317                              <1> pass_createfile_add_new_subdir_cluster:
  4318                              <1> 	;movzx	eax, word [esi+LD_BPB+BytesPerSec]
  4319 0000A871 0FB705[D42C0100]    <1> 	movzx	eax, word [createfile_BytesPerSec] ; 23/03/2016
  4320 0000A878 F7E1                <1> 	mul	ecx ; ecx = directory buffer sector count
  4321 0000A87A 89C1                <1> 	mov	ecx, eax
  4322 0000A87C C1E902              <1> 	shr	ecx, 2 ; dword count
  4323 0000A87F 29C0                <1> 	sub	eax, eax ; 0
  4324 0000A881 F3AB                <1> 	rep	stosd 
  4325                              <1> 	;
  4326 0000A883 C605[98280100]02    <1> 	mov	byte [DirBuff_ValidData], 2 
  4327 0000A88A E8ADEFFFFF          <1> 	call	save_directory_buffer
  4328 0000A88F 72B3                <1> 	jc	short loc_createfile_anc_retn
  4329                              <1> 
  4330                              <1> loc_createfile_save_added_subdir_cluster:
  4331 0000A891 A1[C02C0100]        <1> 	mov	eax, [createfile_LastDirCluster]
  4332 0000A896 8B0D[BC2C0100]      <1> 	mov	ecx, [createfile_FFCluster]
  4333 0000A89C E858050000          <1> 	call	update_cluster
  4334 0000A8A1 7304                <1> 	jnc	short loc_createfile_save_fat_buffer_0
  4335 0000A8A3 09C0                <1> 	or	eax, eax ; EAX = 0 -> cluster value is 0 or eocc
  4336 0000A8A5 751A                <1> 	jnz	short loc_createfile_save_fat_buffer_stc_retn
  4337                              <1> 
  4338                              <1> loc_createfile_save_fat_buffer_0:
  4339 0000A8A7 A1[BC2C0100]        <1> 	mov	eax, [createfile_FFCluster]
  4340 0000A8AC A3[C02C0100]        <1> 	mov	[createfile_LastDirCluster], eax
  4341 0000A8B1 B9FFFFFF0F          <1> 	mov	ecx, 0FFFFFFFh ; 28 bit
  4342 0000A8B6 E83E050000          <1> 	call	update_cluster
  4343 0000A8BB 7306                <1> 	jnc	short loc_createfile_save_fat_buffer_1
  4344 0000A8BD 09C0                <1> 	or	eax, eax ; Was it free cluster
  4345 0000A8BF 7402                <1> 	jz	short loc_createfile_save_fat_buffer_1
  4346                              <1> 
  4347                              <1> loc_createfile_save_fat_buffer_stc_retn:
  4348 0000A8C1 F9                  <1> 	stc
  4349                              <1> loc_createfile_save_fat_buffer_retn:
  4350                              <1> loc_createfile_gffc_2_stc_retn:
  4351 0000A8C2 C3                  <1> 	retn
  4352                              <1> 
  4353                              <1> loc_createfile_save_fat_buffer_1:
  4354                              <1> 	; byte [FAT_BuffValidData] = 2 
  4355 0000A8C3 E8EE070000          <1> 	call	save_fat_buffer
  4356 0000A8C8 72F8                <1> 	jc	short loc_createfile_save_fat_buffer_retn
  4357                              <1> 
  4358 0000A8CA 803D[8E280100]01    <1> 	cmp	byte [FAT_ClusterCounter], 1
  4359 0000A8D1 7222                <1> 	jb	short loc_createfile_save_fat_buffer_2
  4360                              <1> 
  4361                              <1> 	; ESI = Logical DOS Drive Description Table address 
  4362 0000A8D3 A1[8E280100]        <1> 	mov	eax, [FAT_ClusterCounter]
  4363                              <1> 
  4364 0000A8D8 C605[8E280100]00    <1> 	mov	byte [FAT_ClusterCounter], 0 ; 21/03/2016
  4365                              <1> 
  4366 0000A8DF 66BB01FF            <1> 	mov	bx, 0FF01h ; add free clusters 
  4367 0000A8E3 E863080000          <1> 	call	calculate_fat_freespace
  4368                              <1> 
  4369                              <1> 	;inc	eax ; 0FFFFFFFFh -> 0 ; recalculation is needed!
  4370                              <1> 	;jnz	short loc_createfile_save_fat_buffer_2
  4371                              <1> 
  4372                              <1> 	; ecx > 0 -> Recalculation is needed
  4373 0000A8E8 09C9                <1> 	or	ecx, ecx 
  4374 0000A8EA 7409                <1> 	jz	short loc_createfile_save_fat_buffer_2
  4375                              <1> 
  4376 0000A8EC 66BB00FF            <1> 	mov	bx, 0FF00h ; ; recalculate free space
  4377 0000A8F0 E856080000          <1> 	call	calculate_fat_freespace
  4378                              <1> 
  4379                              <1> loc_createfile_save_fat_buffer_2:
  4380                              <1> 	;call	update_parent_dir_lmdt
  4381                              <1> 
  4382                              <1> loc_createfile_gffc_2:
  4383 0000A8F5 E82C040000          <1> 	call	get_first_free_cluster
  4384 0000A8FA 72C6                <1> 	jc	short loc_createfile_gffc_2_stc_retn
  4385                              <1> 
  4386 0000A8FC A3[BC2C0100]        <1> 	mov	[createfile_FFCluster], eax
  4387                              <1> 
  4388 0000A901 A1[C02C0100]        <1> 	mov	eax, [createfile_LastDirCluster]
  4389                              <1> 	
  4390 0000A906 E8AA030000          <1> 	call	load_FAT_sub_directory 
  4391 0000A90B 72B5                <1> 	jc	short loc_createfile_gffc_2_stc_retn
  4392                              <1> 
  4393 0000A90D BF00000800          <1> 	mov	edi, Directory_Buffer
  4394                              <1> 
  4395 0000A912 6629DB              <1> 	sub	bx, bx ; directory entry index/number = 0
  4396                              <1> 
  4397 0000A915 56                  <1> 	push	esi ; * ; 23/03/2016
  4398                              <1> 
  4399                              <1> loc_createfile_set_ff_dir_entry:
  4400 0000A916 66891D[CE2C0100]    <1> 	mov	[createfile_DirIndex], bx
  4401                              <1> 
  4402                              <1>         ; EDI = Directory entry address
  4403 0000A91D 8B35[B02C0100]      <1> 	mov	esi, [createfile_Name_Offset]
  4404 0000A923 A1[BC2C0100]        <1> 	mov	eax, [createfile_FFCluster]
  4405 0000A928 A3[C42C0100]        <1> 	mov	[createfile_Cluster], eax ; 24/03/2016
  4406 0000A92D B5FF                <1> 	mov	ch, 0FFh
  4407 0000A92F 8A0D[CC2C0100]      <1>         mov	cl, [createfile_attrib] ; file attributes
  4408                              <1> 	; CH > 0 -> File size is in EBX
  4409 0000A935 BB[B82C0100]        <1> 	mov	ebx, createfile_size
  4410                              <1>   
  4411 0000A93A E820EEFFFF          <1> 	call	make_directory_entry
  4412                              <1> 	
  4413 0000A93F 5E                  <1> 	pop	esi ; * ; ESI = Logical Dos Drv Desc. Table address
  4414                              <1> 
  4415 0000A940 C605[98280100]02    <1> 	mov	byte [DirBuff_ValidData], 2 
  4416 0000A947 E8F0EEFFFF          <1> 	call	save_directory_buffer
  4417 0000A94C 7221                <1> 	jc	short loc_createfile_set_ff_dir_entry_retn
  4418                              <1> 
  4419 0000A94E C605[D72C0100]01    <1> 	mov	byte [createfile_UpdatePDir], 1 ; 31/03/2016 
  4420                              <1> 
  4421                              <1> loc_createfile_get_set_write_file_cluster:
  4422 0000A955 A1[B82C0100]        <1> 	mov	eax, [createfile_size]
  4423 0000A95A 09C0                <1> 	or	eax, eax
  4424 0000A95C 7570                <1> 	jnz	short loc_createfile_get_set_wfc_cont
  4425 0000A95E 40                  <1> 	inc	eax
  4426                              <1> 	; 23/03/2016
  4427 0000A95F 0FB61D[CD2C0100]    <1> 	movzx	ebx, byte [createfile_SecPerClust]
  4428                              <1> 	;movzx	ecx, word [esi+LD_BPB+BytesPerSec] ; 512
  4429 0000A966 0FB70D[D42C0100]    <1>         movzx   ecx, word [createfile_BytesPerSec] ; 512
  4430 0000A96D EB7C                <1> 	jmp	loc_createfile_set_cluster_count 
  4431                              <1> 
  4432                              <1> loc_createfile_set_ff_dir_entry_retn:
  4433 0000A96F C3                  <1> 	retn
  4434                              <1> 
  4435                              <1> loc_createfile_write_fcluster_to_disk:
  4436 0000A970 034668              <1> 	add	eax, [esi+LD_DATABegin] ; convert to physical address
  4437 0000A973 BB00000700          <1> 	mov	ebx, Cluster_Buffer
  4438                              <1> 	; ESI = Logical DOS Drv. Desc. Tbl. address
  4439                              <1> 	; EAX = Disk address
  4440                              <1> 	; EBX = Sector Buffer
  4441                              <1> 	; ECX = sectors per cluster
  4442 0000A978 E86C300000          <1> 	call	disk_write
  4443 0000A97D 7211                <1> 	jc	short loc_createfile_dsk_wr_err
  4444                              <1> 
  4445                              <1> loc_createfile_update_fat_cluster:
  4446                              <1> 	; 21/03/2016	
  4447 0000A97F 803D[D62C0100]00    <1> 	cmp	byte [createfile_wfc], 0 
  4448 0000A986 7712                <1> 	ja	short loc_createfile_update_fat_cluster_n1
  4449                              <1> 
  4450 0000A988 FE05[D62C0100]      <1> 	inc	byte [createfile_wfc] ; 1
  4451 0000A98E EB24                <1> 	jmp	short loc_createfile_update_fat_cluster_n2
  4452                              <1> 
  4453                              <1> loc_createfile_dsk_wr_err:
  4454                              <1> 	; 23/03/2016
  4455 0000A990 B81D000000          <1> 	mov	eax, 1Dh ; Drive not ready or write error !
  4456 0000A995 E9BD000000          <1> 	jmp	loc_createfile_stc_retn
  4457                              <1> 
  4458                              <1> loc_createfile_update_fat_cluster_n1:
  4459 0000A99A A1[C82C0100]        <1> 	mov	eax, [createfile_PCluster]
  4460 0000A99F 8B0D[C42C0100]      <1> 	mov	ecx, [createfile_Cluster]
  4461 0000A9A5 E84F040000          <1> 	call	update_cluster
  4462 0000A9AA 7308                <1> 	jnc	short loc_createfile_update_fat_cluster_n2
  4463 0000A9AC 09C0                <1> 	or	eax, eax ; EAX = 0 -> cluster value is 0 or eocc
  4464 0000A9AE 0F85A3000000        <1> 	jnz	loc_createfile_stc_retn
  4465                              <1> 
  4466                              <1> loc_createfile_update_fat_cluster_n2:
  4467 0000A9B4 A1[C42C0100]        <1>         mov	eax, [createfile_Cluster]
  4468 0000A9B9 B9FFFFFF0F          <1> 	mov	ecx, 0FFFFFFFh
  4469 0000A9BE E836040000          <1> 	call	update_cluster
  4470 0000A9C3 734E                <1> 	jnc	short loc_createfile_save_fat_buffer_3
  4471 0000A9C5 09C0                <1> 	or	eax, eax ; EAX = 0 -> cluster value is 0 or eocc
  4472 0000A9C7 744A                <1> 	jz	short loc_createfile_save_fat_buffer_3
  4473                              <1> 
  4474                              <1> loc_createfile_upd_fat_fcluster_stc_retn:
  4475 0000A9C9 E989000000          <1> 	jmp	loc_createfile_stc_retn
  4476                              <1> 
  4477                              <1> loc_createfile_get_set_wfc_cont:
  4478                              <1> 	;movzx	ecx, word [esi+LD_BPB+BytesPerSec] ; 512	
  4479 0000A9CE 0FB70D[D42C0100]    <1> 	movzx	ecx, word [createfile_BytesPerSec] ; 512
  4480 0000A9D5 01C8                <1> 	add	eax, ecx
  4481 0000A9D7 48                  <1> 	dec	eax  ; add eax, 511
  4482 0000A9D8 29D2                <1> 	sub	edx, edx
  4483 0000A9DA F7F1                <1> 	div	ecx
  4484 0000A9DC 0FB61D[CD2C0100]    <1> 	movzx	ebx, byte [createfile_SecPerClust]
  4485 0000A9E3 01D8                <1> 	add	eax, ebx
  4486 0000A9E5 48                  <1> 	dec	eax  ; add eax, SecPerClust - 1
  4487 0000A9E6 6631D2              <1> 	xor	dx, dx
  4488 0000A9E9 F7F3                <1> 	div	ebx
  4489                              <1> 
  4490                              <1> loc_createfile_set_cluster_count:
  4491 0000A9EB A3[D02C0100]        <1> 	mov 	[createfile_CCount], eax
  4492                              <1> 	
  4493 0000A9F0 BF00000700          <1> 	mov	edi, Cluster_Buffer
  4494 0000A9F5 89C8                <1> 	mov	eax, ecx ; Bytes per Sector
  4495 0000A9F7 F7E3                <1> 	mul	ebx ; Sectors per Cluster 
  4496                              <1> 	; EAX = Bytes per Cluster
  4497 0000A9F9 89C1                <1> 	mov	ecx, eax
  4498 0000A9FB C1E902              <1> 	shr	ecx, 2 ; dword count
  4499 0000A9FE 31C0                <1> 	xor	eax, eax
  4500 0000AA00 F3AB                <1> 	rep	stosd ; clear cluster buffer
  4501                              <1> 
  4502 0000AA02 A1[C42C0100]        <1> 	mov	eax, [createfile_Cluster] ; 24/03/2016
  4503                              <1> 
  4504 0000AA07 89D9                <1> 	mov	ecx, ebx
  4505                              <1> 
  4506                              <1> loc_createfile_get_set_wf_fclust_cont:
  4507 0000AA09 83E802              <1> 	sub	eax, 2
  4508 0000AA0C F7E1                <1> 	mul	ecx
  4509                              <1> 	; EAX = Logical DOS disk address (offset)
  4510 0000AA0E E95DFFFFFF          <1>         jmp     loc_createfile_write_fcluster_to_disk
  4511                              <1> 
  4512                              <1> loc_createfile_save_fat_buffer_3:
  4513                              <1> 	; byte [FAT_BuffValidData] = 2
  4514 0000AA13 E89E060000          <1> 	call	save_fat_buffer
  4515 0000AA18 723D                <1> 	jc	loc_createfile_stc_retn
  4516                              <1> 
  4517                              <1> 	; 21/03/2016
  4518 0000AA1A 803D[8E280100]01    <1> 	cmp	byte [FAT_ClusterCounter], 1
  4519 0000AA21 721B                <1> 	jb	short loc_createfile_save_fat_buffer_4
  4520                              <1> 
  4521                              <1> 	; ESI = Logical DOS Drive Description Table address 
  4522 0000AA23 A1[8E280100]        <1> 	mov	eax, [FAT_ClusterCounter]
  4523 0000AA28 66BB01FF            <1> 	mov	bx, 0FF01h ; add free clusters 
  4524 0000AA2C E81A070000          <1> 	call	calculate_fat_freespace
  4525                              <1> 
  4526                              <1> 	;inc	eax ; 0FFFFFFFFh -> 0 ; recalculation is needed!
  4527                              <1> 	;jnz	short loc_createfile_save_fat_buffer_4
  4528                              <1> 
  4529                              <1> 	; ecx > 0 -> Recalculation is needed
  4530 0000AA31 09C9                <1> 	or	ecx, ecx 
  4531 0000AA33 7409                <1> 	jz	short loc_createfile_save_fat_buffer_4
  4532                              <1> 
  4533 0000AA35 66BB00FF            <1> 	mov	bx, 0FF00h ; ; recalculate free space
  4534 0000AA39 E80D070000          <1> 	call	calculate_fat_freespace
  4535                              <1> 
  4536                              <1> loc_createfile_save_fat_buffer_4:
  4537 0000AA3E FF0D[D02C0100]      <1> 	dec	dword [createfile_CCount]
  4538                              <1> 	;jz	short loc_createfile_upd_dir_modif_date_time
  4539 0000AA44 743F                <1> 	jz	short loc_createfile_stc_retn_cc ; 31/03/2016
  4540                              <1> 
  4541                              <1> loc_createfile_get_set_write_next_cluster:
  4542 0000AA46 E8DB020000          <1> 	call	get_first_free_cluster
  4543 0000AA4B 720A                <1> 	jc	short loc_createfile_stc_retn
  4544                              <1> 
  4545                              <1> loc_createfile_get_set_write_next_cluster_1:
  4546 0000AA4D 83F8FF              <1> 	cmp	eax, 0FFFFFFFFh
  4547 0000AA50 7213                <1> 	jb	short loc_createfile_get_set_write_next_cluster_2
  4548                              <1> 
  4549                              <1> loc_createfile_wnc_insufficient_disk_space:	
  4550 0000AA52 B827000000          <1> 	mov	eax, 27h ; Insufficient disk space
  4551                              <1> 
  4552                              <1> loc_createfile_stc_retn:
  4553 0000AA57 803D[D62C0100]01    <1> 	cmp	byte [createfile_wfc], 1
  4554 0000AA5E 7324                <1> 	jnb	short loc_createfile_err_retn
  4555 0000AA60 C3                  <1> 	retn
  4556                              <1> 
  4557                              <1> loc_createfile_wnc_inv_format_retn:
  4558                              <1> 	;mov	eax, 0Bh
  4559 0000AA61 B00B                <1> 	mov	al, 0Bh ; Invalid format
  4560 0000AA63 EBF2                <1> 	jmp	short loc_createfile_stc_retn
  4561                              <1> 	         
  4562                              <1> loc_createfile_get_set_write_next_cluster_2:
  4563 0000AA65 83F802              <1> 	cmp	eax, 2
  4564 0000AA68 72F7                <1> 	jb	short loc_createfile_wnc_inv_format_retn
  4565                              <1> 
  4566                              <1> loc_createfile_get_set_write_next_cluster_3:
  4567 0000AA6A 8B0D[C42C0100]      <1> 	mov	ecx, [createfile_Cluster]
  4568 0000AA70 A3[C42C0100]        <1> 	mov	[createfile_Cluster], eax
  4569 0000AA75 890D[C82C0100]      <1> 	mov	[createfile_PCluster], ecx
  4570 0000AA7B 0FB60D[CD2C0100]    <1> 	movzx	ecx, byte [createfile_SecPerClust]
  4571 0000AA82 EB85                <1> 	jmp	short loc_createfile_get_set_wf_fclust_cont
  4572                              <1> 
  4573                              <1> loc_createfile_err_retn:
  4574 0000AA84 F9                  <1> 	stc
  4575                              <1> 
  4576                              <1> ;loc_createfile_upd_dir_modif_date_time:
  4577                              <1> loc_createfile_stc_retn_cc: ; 31/03/2016
  4578 0000AA85 9C                  <1> 	pushf	; cpu is here for an error return or completion 
  4579 0000AA86 50                  <1> 	push	eax ; error code if cf = 1
  4580                              <1> 
  4581                              <1> 	;call	update_parent_dir_lmdt
  4582                              <1> 
  4583                              <1> ;loc_createfile_stc_retn_cc:
  4584 0000AA87 A1[8E280100]        <1> 	mov	eax, [FAT_ClusterCounter]
  4585 0000AA8C 09C0                <1> 	or	eax, eax
  4586 0000AA8E 741A                <1> 	jz	short loc_createfile_stc_retn_pop_eax
  4587 0000AA90 8A3D[6E200100]      <1> 	mov	bh, [Current_Drv]
  4588 0000AA96 B301                <1> 	mov	bl, 01h ; BL = 1 -> add clusters
  4589                              <1> 	; NOTE: EAX value will be added to Free Cluster Count
  4590                              <1> 	; (If EAX value is negative, Free Cluster Count will be decreased)
  4591 0000AA98 E8AE060000          <1>   	call	calculate_fat_freespace
  4592                              <1>         ; ESI = Logical DOS Drive Description Table Address 
  4593                              <1>         ;jc	short loc_createfile_stc_retn_pop_eax_cf
  4594 0000AA9D 21C9                <1> 	and	ecx, ecx ; cx = 0 -> valid free sector count
  4595 0000AA9F 7409                <1> 	jz	short loc_createfile_stc_retn_pop_eax
  4596                              <1> 
  4597                              <1> loc_createfile_stc_retn_recalc_FAT_freespace:
  4598 0000AAA1 66BB00FF            <1> 	mov	bx, 0FF00h ; bh = 0FFh -> 
  4599                              <1> 	; ESI = Logical DOS Drv DT Addr
  4600                              <1> 	; BL = 0 -> Recalculate 
  4601 0000AAA5 E8A1060000          <1> 	call	calculate_fat_freespace
  4602                              <1> 
  4603                              <1> loc_createfile_stc_retn_pop_eax:
  4604 0000AAAA 58                  <1> 	pop	eax
  4605 0000AAAB 9D                  <1> 	popf
  4606 0000AAAC 7218                <1> 	jc	short loc_createfile_retn
  4607                              <1> 
  4608                              <1> loc_createfile_retn_fcluster:
  4609 0000AAAE A1[BC2C0100]        <1> 	mov	eax, [createfile_FFCluster]
  4610 0000AAB3 BB[B82C0100]        <1> 	mov	ebx, createfile_size
  4611                              <1> 	;movzx	ecx, byte [esi+LD_BPB+SecPerClust]
  4612 0000AAB8 0FB60D[CD2C0100]    <1> 	movzx	ecx, byte [createfile_SecPerClust] ; 23/03/2016
  4613 0000AABF 0FB715[CE2C0100]    <1> 	movzx	edx, word [createfile_DirIndex]
  4614                              <1> 
  4615                              <1> loc_createfile_retn:
  4616 0000AAC6 C3                  <1> 	retn
  4617                              <1> 
  4618                              <1> create_fs_file:
  4619                              <1> 	; temporary (21/03/2016)
  4620 0000AAC7 C3                  <1> 	retn
  4621                              <1> 
  4622                              <1> delete_fs_file:
  4623                              <1> 	; temporary (28/02/2016)
  4624 0000AAC8 C3                  <1> 	retn
  4625                              <1> 
  4626                              <1> rename_fs_file_or_directory:
  4627 0000AAC9 C3                  <1> 	retn
  4628                              <1> 
  4629                              <1> make_fs_directory:
  4630                              <1> 	; temporary (21/02/2016)
  4631 0000AACA C3                  <1> 	retn
  4632                              <1> 
  4633                              <1> add_new_fs_section:
  4634                              <1> 	; temporary (11/03/2016)
  4635 0000AACB C3                  <1> 	retn
  4636                              <1> 
  4637                              <1> delete_fs_directory_entry:
  4638                              <1> 	; temporary (11/03/2016)
  4639 0000AACC C3                  <1> 	retn
  4640                              <1> 
  4641                              <1> csftdf2_read_fs_file_sectors:
  4642                              <1> 	; temporary (19/03/2016)
  4643 0000AACD C3                  <1> 	retn
  4644                              <1> 
  4645                              <1> csftdf2_write_fs_file_sectors:
  4646                              <1> 	; temporary (19/03/2016)
  4647 0000AACE C3                  <1> 	retn
  1922                                  %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: 16/05/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> 	; 23/03/2016
    17                              <1> 	; 01/02/2016 (TRDOS 386 =  TRDOS v2.0)
    18                              <1> 	; 05/07/2011
    19                              <1> 	; 07/07/2009
    20                              <1> 	; 2005
    21                              <1> 	; INPUT ->
    22                              <1> 	;	EAX = Cluster Number (32 bit)
    23                              <1> 	;	ESI = Logical DOS Drive Parameters Table
    24                              <1> 	; OUTPUT ->
    25                              <1> 	;	cf = 0 -> No Error, EAX valid
    26                              <1> 	;	cf = 1 & EAX = 0 -> End Of Cluster Chain
    27                              <1> 	;	cf = 1 & EAX > 0 -> Error
    28                              <1> 	;	ECX = Current/Previous cluster (if CF = 0)
    29                              <1> 	;	EAX = Next Cluster Number (32 bit)
    30                              <1> 	;
    31                              <1> 	; (Modified registers: EAX, ECX, EBX, EDX)
    32                              <1> 
    33 0000AACF A3[82280100]        <1> 	mov	[FAT_CurrentCluster], eax
    34                              <1> check_next_cluster_fat_type:
    35 0000AAD4 29D2                <1> 	sub	edx, edx ; 0
    36 0000AAD6 807E0302            <1>         cmp     byte [esi+LD_FATType], 2
    37 0000AADA 7250                <1> 	jb	short get_FAT12_next_cluster
    38 0000AADC 0F87AF000000        <1>         ja      get_FAT32_next_cluster
    39                              <1> get_FAT16_next_cluster:
    40 0000AAE2 BB00030000          <1> 	mov	ebx, 300h ;768
    41 0000AAE7 F7F3                <1> 	div	ebx
    42                              <1> 	; EAX = Count of 3 FAT sectors
    43                              <1> 	; EDX = Cluster Offset (< 768)
    44 0000AAE9 66D1E2              <1> 	shl	dx, 1 ; Multiply by 2
    45 0000AAEC 89D3                <1> 	mov	ebx, edx ; Byte Offset
    46 0000AAEE 81C3001C0900        <1> 	add	ebx, FAT_Buffer
    47 0000AAF4 66BA0300            <1> 	mov	dx, 3
    48 0000AAF8 F7E2                <1> 	mul	edx  
    49                              <1> 	; EAX = FAT Sector (<= 256)
    50                              <1> 	; EDX = 0
    51 0000AAFA 8A0E                <1> 	mov	cl, [esi+LD_Name]
    52 0000AAFC 803D[86280100]00    <1> 	cmp	byte [FAT_BuffValidData], 0
    53 0000AB03 0F86CC000000        <1>         jna     load_FAT_sectors0
    54 0000AB09 3A0D[87280100]      <1> 	cmp	cl, [FAT_BuffDrvName]
    55 0000AB0F 0F85C0000000        <1>         jne     load_FAT_sectors0
    56 0000AB15 3B05[8A280100]      <1> 	cmp	eax, [FAT_BuffSector]
    57 0000AB1B 0F85BA000000        <1>         jne     load_FAT_sectors1
    58                              <1> 	;movzx	eax, word [ebx]
    59 0000AB21 668B03              <1> 	mov	ax, [ebx]
    60                              <1> 	; 01/02/2016
    61                              <1> 	; DRV_FAT.ASM (21/08/2011) had a FATal bug here !
    62                              <1> 	; (cmp ah, 0Fh) ! (ax >= FF7h)
    63                              <1> 	; (how can i do a such mistake!?)
    64                              <1> 	;cmp	al, 0F7h
    65                              <1> 	;jb	short loc_pass_gnc_FAT16_eoc_check
    66                              <1> 	;cmp	ah, 0FFh
    67                              <1> 	;jb	short loc_pass_gnc_FAT16_eoc_check
    68 0000AB24 6683F8F7            <1> 	cmp	ax, 0FFF7h
    69 0000AB28 725A                <1> 	jb	short loc_pass_gnc_FAT16_eoc_check
    70                              <1> 	; ax >= FFF7h (cluster 0002h to FFF6h is valid, in use)
    71 0000AB2A EB56                <1> 	jmp	short loc_pass_gnc_FAT16_eoc_check_xor_eax
    72                              <1> 
    73                              <1> get_FAT12_next_cluster:
    74 0000AB2C BB00040000          <1> 	mov	ebx, 400h ;1024
    75 0000AB31 F7F3                <1> 	div	ebx
    76                              <1> 	; EAX = Count of 3 FAT sectors
    77                              <1> 	; EDX = Cluster Offset (< 1024)
    78 0000AB33 6650                <1> 	push	ax
    79 0000AB35 66B80300            <1> 	mov	ax, 3	
    80 0000AB39 66F7E2              <1> 	mul	dx    	; Multiply by 3
    81 0000AB3C 66D1E8              <1> 	shr	ax, 1	; Divide by 2
    82 0000AB3F 6689C3              <1>         mov	bx, ax 	; Byte Offset
    83 0000AB42 81C3001C0900        <1> 	add	ebx, FAT_Buffer
    84 0000AB48 6658                <1> 	pop	ax
    85 0000AB4A 66BA0300            <1> 	mov	dx, 3
    86 0000AB4E F7E2                <1> 	mul	edx 
    87                              <1> 	; EAX = FAT Sector (<= 12)
    88                              <1> 	; EDX = 0
    89 0000AB50 8A0E                <1> 	mov	cl, [esi+LD_Name]
    90 0000AB52 803D[86280100]00    <1> 	cmp	byte [FAT_BuffValidData], 0
    91 0000AB59 767A                <1> 	jna	short load_FAT_sectors0
    92 0000AB5B 3A0D[87280100]      <1> 	cmp	cl, [FAT_BuffDrvName]
    93 0000AB61 7572                <1> 	jne	short load_FAT_sectors0
    94 0000AB63 3B05[8A280100]      <1> 	cmp	eax, [FAT_BuffSector]
    95 0000AB69 7570                <1> 	jne	short load_FAT_sectors1
    96 0000AB6B A1[82280100]        <1> 	mov	eax, [FAT_CurrentCluster]
    97 0000AB70 66D1E8              <1> 	shr	ax, 1
    98                              <1> 	;movzx	eax, word [ebx]
    99 0000AB73 668B03              <1> 	mov	ax, [ebx]
   100 0000AB76 7314                <1> 	jnc	short get_FAT12_nc_even
   101 0000AB78 66C1E804            <1> 	shr	ax, 4
   102                              <1> loc_gnc_fat12_eoc_check:
   103                              <1> 	;cmp	al, 0F7h
   104                              <1> 	;jb	short loc_pass_gnc_FAT16_eoc_check
   105                              <1> 	;cmp	ah, 0Fh
   106                              <1> 	;jb	short loc_pass_gnc_FAT16_eoc_check
   107 0000AB7C 663DF70F            <1> 	cmp	ax, 0FF7h
   108 0000AB80 7202                <1> 	jb	short loc_pass_gnc_FAT16_eoc_check
   109                              <1> 	; ax >= FF7h (cluster 0002h to FF6h is valid, in use)
   110                              <1> 
   111                              <1> loc_pass_gnc_FAT16_eoc_check_xor_eax:
   112 0000AB82 31C0                <1> 	xor	eax, eax ; 0
   113                              <1> loc_pass_gnc_FAT16_eoc_check:
   114                              <1> loc_pass_gnc_FAT32_eoc_check:
   115 0000AB84 8B0D[82280100]      <1> 	mov	ecx, [FAT_CurrentCluster]
   116 0000AB8A F5                  <1> 	cmc
   117 0000AB8B C3                  <1> 	retn
   118                              <1> 
   119                              <1> get_FAT12_nc_even:
   120 0000AB8C 80E40F              <1> 	and	ah, 0Fh
   121 0000AB8F EBEB                <1> 	jmp	short loc_gnc_fat12_eoc_check
   122                              <1> 
   123                              <1> get_FAT32_next_cluster:
   124 0000AB91 BB80010000          <1> 	mov	ebx, 180h ;384
   125 0000AB96 F7F3                <1> 	div	ebx
   126                              <1> 	; EAX = Count of 3 FAT sectors
   127                              <1> 	; EDX = Cluster Offset (< 384)
   128 0000AB98 66C1E202            <1> 	shl	dx, 2	; Multiply by 4
   129 0000AB9C 89D3                <1> 	mov	ebx, edx ; Byte Offset
   130 0000AB9E 81C3001C0900        <1> 	add	ebx, FAT_Buffer
   131 0000ABA4 66BA0300            <1> 	mov	dx, 3
   132 0000ABA8 F7E2                <1> 	mul	edx	
   133                              <1>         ; EAX = FAT Sector (<= 2097152) ; (FFFFFF7h * 4) / 512
   134                              <1> 	; 	for 32KB cluster size:
   135                              <1> 	;	EAX <= 1024 = (4GB / 32KB) * 4) / 512 	
   136                              <1> 	; EDX = 0
   137 0000ABAA 8A0E                <1> 	mov	cl, [esi+LD_Name]
   138 0000ABAC 803D[86280100]00    <1> 	cmp	byte [FAT_BuffValidData], 0
   139 0000ABB3 7620                <1> 	jna	short load_FAT_sectors0
   140 0000ABB5 3A0D[87280100]      <1> 	cmp	cl, [FAT_BuffDrvName]
   141 0000ABBB 7518                <1> 	jne	short load_FAT_sectors0
   142 0000ABBD 3B05[8A280100]      <1> 	cmp	eax, [FAT_BuffSector] ; 0, 3, 6, 9 ...
   143 0000ABC3 7516                <1> 	jne	short load_FAT_sectors1
   144 0000ABC5 8B03                <1> 	mov	eax, [ebx]
   145 0000ABC7 25FFFFFF0F          <1>  	and	eax, 0FFFFFFFh ; 28 bit Cluster
   146 0000ABCC 3DF7FFFF0F          <1> 	cmp	eax, 0FFFFFF7h
   147 0000ABD1 72B1                <1> 	jb	short loc_pass_gnc_FAT32_eoc_check
   148                              <1> 	; eax >= FFFFFF7h (cluster 0002h to FFFFFF6h is valid)
   149 0000ABD3 EBAD                <1> 	jmp	short loc_pass_gnc_FAT16_eoc_check_xor_eax
   150                              <1> 
   151                              <1> load_FAT_sectors0:
   152 0000ABD5 880D[87280100]      <1> 	mov	[FAT_BuffDrvName], cl
   153                              <1> load_FAT_sectors1:
   154 0000ABDB A3[8A280100]        <1> 	mov	[FAT_BuffSector], eax
   155 0000ABE0 89C3                <1> 	mov	ebx, eax
   156 0000ABE2 034660              <1>         add     eax, [esi+LD_FATBegin]
   157 0000ABE5 807E0302            <1> 	cmp	byte [esi+LD_FATType], 2
   158 0000ABE9 7706                <1>         ja      short load_FAT_sectors3
   159 0000ABEB 0FB74E1C            <1> 	movzx	ecx, word [esi+LD_BPB+BPB_FATSz16]
   160 0000ABEF EB03                <1> 	jmp	short load_FAT_sectors4
   161                              <1> load_FAT_sectors3:
   162 0000ABF1 8B4E2A              <1> 	mov	ecx, [esi+LD_BPB+BPB_FATSz32]
   163                              <1> load_FAT_sectors4:
   164 0000ABF4 29D9                <1> 	sub	ecx, ebx ; [FAT_BuffSector]
   165 0000ABF6 83F903              <1>         cmp     ecx, 3
   166 0000ABF9 7605                <1>         jna     short load_FAT_sectors5
   167 0000ABFB B903000000          <1> 	mov	ecx, 3
   168                              <1> load_FAT_sectors5:
   169 0000AC00 BB001C0900          <1> 	mov	ebx, FAT_Buffer
   170 0000AC05 E8EE2D0000          <1> 	call	disk_read
   171 0000AC0A 730D                <1> 	jnc	short load_FAT_sectors_ok
   172                              <1> 	; 23/03/2016
   173 0000AC0C B815000000          <1> 	mov	eax, 15h ; Drive not ready or read error
   174 0000AC11 C605[86280100]00    <1> 	mov	byte [FAT_BuffValidData], 0
   175 0000AC18 C3                  <1> 	retn
   176                              <1> load_FAT_sectors_ok:
   177 0000AC19 C605[86280100]01    <1> 	mov	byte [FAT_BuffValidData], 1
   178 0000AC20 A1[82280100]        <1> 	mov	eax, [FAT_CurrentCluster]
   179 0000AC25 E9AAFEFFFF          <1>         jmp     check_next_cluster_fat_type
   180                              <1> 
   181                              <1> load_FAT_root_directory:
   182                              <1> 	; 07/02/2016
   183                              <1> 	; 02/02/2016
   184                              <1> 	; 01/02/2016 (TRDOS 386 =  TRDOS v2.0)
   185                              <1> 	; 21/05/2011
   186                              <1> 	; 22/08/2009
   187                              <1> 	;
   188                              <1> 	; INPUT ->
   189                              <1> 	;	ESI = Logical DOS Drive Description Table
   190                              <1> 	; OUTPUT ->
   191                              <1> 	;	cf = 1 -> Root directory could not be loaded
   192                              <1> 	;	    EAX > 0 -> Error number
   193                              <1> 	;	cf = 0 -> EAX = 0
   194                              <1> 	;	ECX = Directory buffer size in sectors (CL)
   195                              <1> 	;	EBX = Directory buffer address
   196                              <1> 	; 	NOTE: DirBuffer_Size is in bytes ! (word)
   197                              <1> 	;
   198                              <1> 	; (Modified registers: EAX, ECX, EBX, EDX)
   199                              <1> 
   200                              <1> 	; NOTE: Only for FAT12 and FAT16 file systems !
   201                              <1> 	; (FAT32 fs root dir must be loaded as sub directory)
   202                              <1> 
   203 0000AC2A 8A1E                <1> 	mov	bl, [esi+LD_Name]
   204 0000AC2C 8A7E03              <1> 	mov	bh, [esi+LD_FATType]
   205                              <1> 
   206                              <1> 	;mov	[DirBuff_DRV], bl
   207                              <1> 	;mov	[DirBuff_FATType], bh
   208 0000AC2F 66891D[96280100]    <1> 	mov	[DirBuff_DRV], bx
   209                              <1> 	
   210                              <1> 	;cmp	bh, 2
   211                              <1> 	;ja	short load_FAT32_root_dir0 ; FAT32 root dir
   212                              <1> 
   213 0000AC36 0FB75617            <1> 	movzx	edx, word [esi+LD_BPB+RootDirEnts]
   214                              <1> 
   215                              <1> 	;or	dx, dx ; 0 for FAT32 file systems
   216                              <1> 	;jz	short load_FAT32_root_dir0 ; FAT32 root dir
   217                              <1> 
   218 0000AC3A 6681FA0002          <1> 	cmp	dx, 512 ; Number of Root Dir Entries
   219 0000AC3F 7414                <1> 	je	short lrd_mov_ecx_32
   220 0000AC41 89D0                <1> 	mov	eax, edx
   221 0000AC43 6683C00F            <1> 	add	ax, 15 ; round up 
   222 0000AC47 66C1E804            <1> 	shr	ax, 4  ; 16 entries per sector (512/32)
   223 0000AC4B 89C1                <1> 	mov	ecx, eax ; Root directory size in sectors
   224 0000AC4D 66C1E009            <1> 	shl	ax, 9 ; Root directory size in bytes
   225 0000AC51 664A                <1> 	dec	dx    ; Last entry number of root dir
   226                              <1> 	; cx = Dir Buffer sector count             
   227 0000AC53 EB0B                <1> 	jmp	short lrd_check_dir_buffer
   228                              <1> 
   229                              <1> lrd_mov_ecx_32:
   230 0000AC55 B920000000          <1> 	mov	ecx, 32
   231 0000AC5A 664A                <1> 	dec	dx ; 511
   232 0000AC5C 66B80040            <1> 	mov	ax, 32*512 
   233                              <1>  
   234                              <1> lrd_check_dir_buffer:
   235 0000AC60 29DB                <1> 	sub	ebx, ebx ; 0
   236 0000AC62 881D[98280100]      <1> 	mov	[DirBuff_ValidData], bl ; 0
   237 0000AC68 668915[9B280100]    <1> 	mov	[DirBuff_LastEntry], dx
   238 0000AC6F 891D[9D280100]      <1> 	mov	[DirBuff_Cluster], ebx ; 0
   239 0000AC75 66A3[A1280100]      <1> 	mov	[DirBuffer_Size], ax
   240                              <1> 
   241 0000AC7B 8B4664              <1> 	mov	eax, [esi+LD_ROOTBegin]
   242                              <1> read_directory:
   243 0000AC7E BB00000800          <1> 	mov	ebx, Directory_Buffer
   244 0000AC83 51                  <1> 	push	ecx ; Directory buffer sector count
   245 0000AC84 53                  <1> 	push	ebx
   246 0000AC85 E86E2D0000          <1> 	call	disk_read
   247 0000AC8A 5B                  <1> 	pop	ebx
   248 0000AC8B 720B                <1> 	jc	short load_DirBuff_error
   249                              <1> 
   250                              <1> validate_DirBuff_and_return:
   251 0000AC8D 59                  <1> 	pop	ecx ; Number of loaded sectors
   252 0000AC8E C605[98280100]01    <1> 	mov	byte [DirBuff_ValidData], 1
   253 0000AC95 31C0                <1> 	xor	eax, eax ; 0 = no error
   254 0000AC97 C3                  <1> 	retn
   255                              <1> 
   256                              <1> load_DirBuff_error:
   257 0000AC98 89C8                <1> 	mov	eax, ecx ; remaining sectors
   258 0000AC9A 59                  <1> 	pop	ecx ; sector count
   259 0000AC9B 29C1                <1> 	sub	ecx, eax ; Number of loaded sectors
   260 0000AC9D B815000000          <1> 	mov	eax, 15h ; DRV NOT READY OR READ ERROR !
   261 0000ACA2 F9                  <1> 	stc
   262 0000ACA3 C3                  <1>         retn
   263                              <1> 
   264                              <1> load_FAT32_root_directory:
   265                              <1> 	; 02/02/2016 (TRDOS 386 =  TRDOS v2.0)
   266                              <1> 	;
   267                              <1> 	; INPUT ->
   268                              <1> 	;	ESI = Logical DOS Drive Description Table
   269                              <1> 	; OUTPUT ->
   270                              <1> 	;	cf = 1 -> Root directory could not be loaded
   271                              <1> 	;	    EAX > 0 -> Error number
   272                              <1> 	;	cf = 0 -> EAX = 0
   273                              <1> 	;	ECX = Directory buffer size in sectors (CL)
   274                              <1> 	;	EBX = Directory buffer address
   275                              <1> 	; 	NOTE: DirBuffer_Size is in bytes ! (word)
   276                              <1> 	;
   277                              <1> 	; (Modified registers: EAX, ECX, EBX, EDX)
   278                              <1> 
   279                              <1> 
   280 0000ACA4 8A1E                <1> 	mov	bl, [esi+LD_Name]
   281 0000ACA6 8A7E03              <1> 	mov	bh, [esi+LD_FATType]
   282                              <1> 
   283                              <1> 	;mov	[DirBuff_DRV], bl
   284                              <1> 	;mov	[DirBuff_FATType], bh
   285 0000ACA9 66891D[96280100]    <1> 	mov	[DirBuff_DRV], bx
   286                              <1> 
   287                              <1> load_FAT32_root_dir0:
   288 0000ACB0 8B4632              <1> 	mov	eax, [esi+LD_BPB+FAT32_RootFClust]
   289 0000ACB3 EB0C                <1> 	jmp	short load_FAT_sub_dir0
   290                              <1> 	
   291                              <1> load_FAT_sub_directory:
   292                              <1> 	; 01/02/2016 (TRDOS 386 =  TRDOS v2.0)
   293                              <1> 	; 05/07/2011
   294                              <1> 	; 23/08/2009
   295                              <1> 	;
   296                              <1> 	; INPUT ->
   297                              <1> 	;	ESI = Logical DOS Drive Description Table
   298                              <1> 	;	EAX = Cluster Number
   299                              <1> 	; OUTPUT ->
   300                              <1> 	;	cf = 1 -> Sub directory could not be loaded
   301                              <1> 	;	    EAX > 0 -> Error number
   302                              <1> 	;	cf = 0 -> EAX = 0
   303                              <1> 	;	ECX = Directory buffer size in sectors (CL)
   304                              <1> 	;	EBX = Directory buffer address
   305                              <1> 	;
   306                              <1> 	; 	NOTE: DirBuffer_Size is in bytes ! (word)
   307                              <1> 	;
   308                              <1> 	; (Modified registers: EAX, ECX, EBX, EDX)
   309                              <1> 
   310 0000ACB5 8A1E                <1> 	mov	bl, [esi+LD_Name]
   311 0000ACB7 8A7E03              <1> 	mov	bh, [esi+LD_FATType]
   312                              <1> 
   313                              <1> 	;mov	[DirBuff_DRV], bl
   314                              <1> 	;mov	[DirBuff_FATType], bh
   315 0000ACBA 66891D[96280100]    <1> 	mov	[DirBuff_DRV], bx
   316                              <1> 
   317                              <1> load_FAT_sub_dir0:
   318 0000ACC1 0FB64E13            <1> 	movzx	ecx, byte [esi+LD_BPB+SecPerClust]
   319                              <1> 
   320 0000ACC5 882D[98280100]      <1> 	mov	[DirBuff_ValidData], ch ; 0
   321 0000ACCB A3[9D280100]        <1> 	mov	[DirBuff_Cluster], eax
   322                              <1> 
   323 0000ACD0 0FB74611            <1> 	movzx	eax, word [esi+LD_BPB+BytesPerSec]
   324 0000ACD4 F7E1                <1> 	mul	ecx
   325 0000ACD6 C1E805              <1> 	shr	eax, 5 ; directory entry count (dir size / 32)
   326 0000ACD9 6648                <1> 	dec	ax ; last entry
   327 0000ACDB 66A3[9B280100]      <1> 	mov	[DirBuff_LastEntry], ax
   328                              <1> 
   329 0000ACE1 A1[9D280100]        <1> 	mov	eax, [DirBuff_Cluster]
   330 0000ACE6 83E802              <1> 	sub	eax, 2
   331 0000ACE9 F7E1                <1> 	mul	ecx
   332 0000ACEB 034668              <1> 	add	eax, [esi+LD_DATABegin]
   333                              <1> 	; ecx = sector per cluster (dir buffer size = 32 sectors)
   334 0000ACEE EB8E                <1> 	jmp	short read_directory
   335                              <1> 
   336                              <1> ; DRV_FS.ASM
   337                              <1> 
   338                              <1> load_current_FS_directory:
   339 0000ACF0 C3                  <1> 	retn
   340                              <1> load_FS_root_directory:
   341 0000ACF1 C3                  <1> 	retn
   342                              <1> load_FS_sub_directory:
   343 0000ACF2 C3                  <1> 	retn
   344                              <1> 
   345                              <1> read_cluster:
   346                              <1> 	; 18/03/2016
   347                              <1> 	; 16/03/2016
   348                              <1> 	; 17/02/2016
   349                              <1> 	; 15/02/2016 (TRDOS 386 =  TRDOS v2.0)
   350                              <1> 	;
   351                              <1> 	; INPUT ->
   352                              <1> 	;	EAX = Cluster Number (Sector index for SINGLIX FS)
   353                              <1> 	;	ESI = Logical DOS Drive Description Table address
   354                              <1> 	;	EBX = Cluster (File R/W) Buffer address (max. 64KB)
   355                              <1> 	;	Only for SINGLIX FS:
   356                              <1> 	;	EDX = File Number (The 1st FDT address) 
   357                              <1> 	; OUTPUT ->
   358                              <1> 	;	cf = 1 -> Cluster can not be loaded at the buffer
   359                              <1> 	;	    EAX > 0 -> Error number
   360                              <1> 	;	cf = 0 -> Cluster has been loaded at the buffer
   361                              <1> 	;
   362                              <1> 	; (Modified registers: EAX, ECX, EBX, EDX)
   363                              <1> 	
   364 0000ACF3 0FB64E13            <1> 	movzx	ecx, byte [esi+LD_BPB+BPB_SecPerClust] 
   365                              <1> 	; CL = 1 = [esi+LD_FS_Reserved2] ; SectPerClust for Singlix FS
   366                              <1> 
   367                              <1> read_file_sectors: ; 16/03/2016
   368 0000ACF7 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
   369 0000ACFB 761C                <1> 	jna	short read_fs_cluster
   370                              <1> 
   371                              <1> read_fat_file_sectors: ; 18/03/2016
   372 0000ACFD 83E802              <1> 	sub	eax, 2 ; Beginning cluster number is always 2
   373 0000AD00 0FB65613            <1> 	movzx	edx, byte [esi+LD_BPB+BPB_SecPerClust] ; 18/03/2016 
   374 0000AD04 F7E2                <1> 	mul	edx
   375 0000AD06 034668              <1> 	add	eax, [esi+LD_DATABegin] ; absolute address of the cluster
   376                              <1> 
   377                              <1> 	; EAX = Disk sector address
   378                              <1> 	; ECX = Sector count
   379                              <1> 	; EBX = Buffer address
   380                              <1> 	; (EDX = 0)
   381                              <1> 	; ESI = Logical DOS drive description table address	
   382                              <1> 
   383 0000AD09 E8EA2C0000          <1> 	call	disk_read
   384 0000AD0E 7306                <1> 	jnc	short rclust_retn
   385                              <1> 	
   386 0000AD10 B815000000          <1> 	mov	eax, 15h ; Drive not ready or read error !
   387 0000AD15 C3                  <1> 	retn
   388                              <1> 
   389                              <1> rclust_retn:
   390 0000AD16 29C0                <1> 	sub	eax, eax ; 0
   391 0000AD18 C3                  <1> 	retn
   392                              <1> 
   393                              <1> read_fs_cluster:
   394                              <1> 	; 15/02/2016 (TRDOS 386 =  TRDOS v2.0)
   395                              <1> 	; Singlix FS
   396                              <1> 	
   397                              <1> 	; EAX = Cluster number is sector index number of the file (eax)
   398                              <1> 	
   399                              <1> 	; EDX = File number is the first File Descriptor Table address 
   400                              <1> 	;	of the file. (Absolute address of the FDT).
   401                              <1> 	
   402                              <1> 	; eax = sector index (0 for the first sector)
   403                              <1> 	; edx = FDT0 address
   404                              <1> 		; 64 KB buffer = 128 sectors (limit) 
   405 0000AD19 B980000000          <1> 	mov	ecx, 128 ; maximum count of sectors (before eof) 
   406 0000AD1E E801000000          <1> 	call	read_fs_sectors
   407 0000AD23 C3                  <1> 	retn
   408                              <1> 
   409                              <1> read_fs_sectors:
   410                              <1> 	; 15/02/2016 (TRDOS 386 =  TRDOS v2.0)
   411 0000AD24 F9                  <1> 	stc
   412 0000AD25 C3                  <1> 	retn
   413                              <1> 
   414                              <1> get_first_free_cluster:
   415                              <1> 	; 02/03/2016
   416                              <1> 	; 21/02/2016 (TRDOS 386 =  TRDOS v2.0)
   417                              <1> 	; 26/10/2010 (DRV_FAT.ASM, 'proc_get_first_free_cluster')
   418                              <1> 	; 10/07/2010
   419                              <1> 	; INPUT ->
   420                              <1> 	;	ESI = Logical DOS Drive Description Table address
   421                              <1> 	; OUTPUT ->
   422                              <1> 	;	cf = 1 -> Error code in AL (EAX)
   423                              <1> 	;	cf = 0 -> 
   424                              <1> 	;	  EAX = Cluster number 
   425                              <1> 	;	  If EAX = FFFFFFFFh -> no free space
   426                              <1> 	;	If the drive has FAT32 fs:
   427                              <1> 	;	  EBX = FAT32 FSI sector buffer address (if > 0)
   428                              <1> 
   429 0000AD26 8B4678              <1> 	mov	eax, [esi+LD_Clusters]
   430 0000AD29 40                  <1> 	inc	eax ; add eax, 1
   431 0000AD2A A3[202B0100]        <1> 	mov	[gffc_last_free_cluster], eax
   432                              <1> 
   433 0000AD2F 31DB                <1> 	xor	ebx, ebx ; 0 ; 02/03/2016
   434                              <1> 
   435 0000AD31 807E0302            <1> 	cmp	byte [esi+LD_FATType], 2
   436 0000AD35 760E                <1> 	jna	short loc_gffc_get_first_fat_free_cluster0
   437                              <1> 
   438                              <1> loc_gffc_get_first_fat32_free_cluster:
   439                              <1> 	; 02/03/2016
   440 0000AD37 E834060000          <1> 	call	get_fat32_fsinfo_sector_parms
   441 0000AD3C 7207                <1> 	jc	short loc_gffc_get_first_fat_free_cluster0 
   442                              <1> 
   443                              <1> loc_gffc_check_fsinfo_parms:
   444                              <1> 	;;mov	ebx, DOSBootSectorBuff
   445                              <1> 	;cmp	dword [ebx], 41615252h
   446                              <1> 	;jne	short loc_gffc_fat32_fsinfo_err
   447                              <1> 	;cmp	dword [ebx+484], 61417272h
   448                              <1> 	;jne	short loc_gffc_fat32_fsinfo_err
   449                              <1> 	;mov	eax, [ebx+492] ; FSI_Next_Free
   450                              <1> 	;EAX = First free cluster 
   451                              <1> 	;(from FAT32 FSInfo sector)
   452 0000AD3E 89D0                <1> 	mov	eax, edx ; FSI_Next_Free (First Free Cluster)
   453 0000AD40 83F8FF              <1> 	cmp	eax, 0FFFFFFFFh ; invalid (unknown) !
   454 0000AD43 7205                <1> 	jb	short loc_gffc_get_first_fat_free_cluster1
   455                              <1> 
   456                              <1> 	; Start from the 1st cluster of the FAT(32) file system
   457                              <1> loc_gffc_get_first_fat_free_cluster0:
   458 0000AD45 B802000000          <1> 	mov	eax, 2
   459                              <1> 	;xor	edx, edx
   460                              <1> 
   461                              <1> loc_gffc_get_first_fat_free_cluster1:
   462 0000AD4A 53                  <1> 	push	ebx ; 02/03/2016 
   463                              <1> 
   464                              <1> loc_gffc_get_first_fat_free_cluster2:   
   465 0000AD4B A3[1C2B0100]        <1> 	mov	[gffc_first_free_cluster], eax
   466 0000AD50 A3[182B0100]        <1> 	mov	[gffc_next_free_cluster], eax
   467                              <1> 
   468                              <1> 	; EBX = FAT32 FSINFO sector buffer address
   469                              <1> 	; (EBX = 0, if the drive has not got FAT32 fs or
   470                              <1> 	; FAT32 FSINFO sector buffer is invalid.)
   471                              <1> 
   472                              <1> loc_gffc_get_first_fat_free_cluster3:
   473 0000AD55 E875FDFFFF          <1> 	call	get_next_cluster
   474 0000AD5A 7307                <1> 	jnc	short loc_gffc_get_first_fat_free_cluster4
   475 0000AD5C 09C0                <1> 	or	eax, eax
   476 0000AD5E 740B                <1> 	jz	short loc_gffc_first_free_fat_cluster_next
   477 0000AD60 5B                  <1> 	pop	ebx ; 02/03/2016
   478 0000AD61 F5                  <1> 	cmc 	; stc
   479 0000AD62 C3                  <1> 	retn
   480                              <1> 
   481                              <1> loc_gffc_get_first_fat_free_cluster4:
   482 0000AD63 21C0                <1> 	and	eax, eax ; next cluster value
   483 0000AD65 7504                <1> 	jnz	short loc_gffc_first_free_fat_cluster_next
   484 0000AD67 89C8                <1> 	mov	eax, ecx ; current (previous cluster) value
   485 0000AD69 EB22                <1> 	jmp	short loc_gffc_check_for_set
   486                              <1>  
   487                              <1> loc_gffc_first_free_fat_cluster_next:
   488 0000AD6B A1[182B0100]        <1> 	mov	eax, [gffc_next_free_cluster]
   489 0000AD70 3B05[202B0100]      <1> 	cmp	eax, [gffc_last_free_cluster]
   490 0000AD76 7308                <1> 	jnb	short retn_stc_from_get_first_free_cluster
   491                              <1> pass_gffc_last_cluster_eax_check:
   492 0000AD78 40                  <1> 	inc	eax ; add eax, 1
   493 0000AD79 A3[182B0100]        <1> 	mov	[gffc_next_free_cluster], eax
   494 0000AD7E EBD5                <1> 	jmp	short loc_gffc_get_first_fat_free_cluster3
   495                              <1> 
   496                              <1> retn_stc_from_get_first_free_cluster:
   497 0000AD80 A1[1C2B0100]        <1> 	mov	eax, [gffc_first_free_cluster]
   498 0000AD85 83F802              <1> 	cmp	eax, 2
   499 0000AD88 7709                <1> 	ja	short loc_gffc_check_previous_clusters
   500 0000AD8A 29C0                <1> 	sub	eax, eax
   501 0000AD8C 48                  <1> 	dec	eax ; FFFFFFFFh
   502                              <1> 
   503                              <1> loc_gffc_check_for_set:
   504                              <1> 	; 02/03/2016
   505 0000AD8D 5B                  <1> 	pop	ebx
   506                              <1> 
   507                              <1> 	; EBX = FAT32 FSINFO sector buffer address
   508                              <1> 	; (EBX = 0, if the drive has not got FAT32 fs or
   509                              <1> 	; FAT32 FSINFO sector buffer is invalid.)
   510                              <1> 
   511 0000AD8E 09DB                <1> 	or	ebx, ebx
   512 0000AD90 750E                <1> 	jnz	short loc_gffc_set_ffree_fat32_cluster
   513                              <1> 
   514                              <1> 	;cmp	byte [esi+LD_FATType], 3
   515                              <1> 	;jnb	short loc_gffc_set_ffree_fat32_cluster
   516                              <1> 
   517                              <1> 	;xor	ebx, ebx ; 0
   518                              <1> 
   519                              <1> loc_gffc_retn:
   520 0000AD92 C3                  <1> 	retn
   521                              <1> 
   522                              <1> loc_gffc_check_previous_clusters:
   523 0000AD93 48                  <1> 	dec	eax ; sub eax, 1
   524 0000AD94 A3[202B0100]        <1> 	mov	[gffc_last_free_cluster], eax 
   525 0000AD99 B802000000          <1> 	mov	eax, 2
   526                              <1> 	;xor	edx, edx
   527 0000AD9E EBAB                <1> 	jmp	short loc_gffc_get_first_fat_free_cluster2
   528                              <1> 
   529                              <1> loc_gffc_set_ffree_fat32_cluster:
   530                              <1> 	;call	set_first_free_cluster
   531                              <1> 	;retn
   532                              <1> 	;jmp	short set_first_free_cluster	
   533                              <1> 
   534                              <1> set_first_free_cluster:
   535                              <1> 	; 23/03/2016
   536                              <1> 	; 02/03/2016
   537                              <1> 	; 29/02/2016
   538                              <1> 	; 26/02/2016
   539                              <1> 	; 21/02/2016 (TRDOS 386 =  TRDOS v2.0)
   540                              <1> 	; 21/08/2011 (DRV_FAT.ASM, 'proc_set_first_free_cluster')
   541                              <1> 	; 11/07/2010
   542                              <1> 	; INPUT -> 
   543                              <1> 	;	ESI = Logical DOS Drive Description Table address
   544                              <1> 	;	EAX = First free cluster
   545                              <1> 	;	EBX = FSINFO sector buffer address
   546                              <1> 	;  	;;If EBX > 0, it is FSINFO sector buffer address
   547                              <1> 	;	;;EBX = 0, if FSINFO sector is not loaded
   548                              <1> 	; OUTPUT->
   549                              <1> 	;	ESI = Logical DOS Drive Description Table address
   550                              <1> 	;  	If EBX > 0, it is FSINFO sector buffer address
   551                              <1> 	;	EBX = 0, if FSINFO sector could not be loaded
   552                              <1> 	; 	CF = 1 -> Error code in AL (EAX)
   553                              <1> 	;	CF = 0 -> first free cluster is successfully updated 
   554                              <1> 
   555                              <1> 	;cmp	byte [esi+LD_FATType], 3
   556                              <1> 	;jb	short loc_sffc_invalid_drive
   557                              <1> 
   558                              <1> 	; Save First Free Cluster value for 'update_cluster'
   559 0000ADA0 89463E              <1> 	mov	[esi+LD_BPB+BPB_Reserved+4], eax ; First free Cluster	
   560                              <1> 
   561                              <1> 	;or	ebx, ebx
   562                              <1> 	;jnz	short loc_sffc_read_fsinfo_sector
   563                              <1> 
   564 0000ADA3 813B52526141        <1> 	cmp     dword [ebx], 41615252h
   565 0000ADA9 7540                <1> 	jne	short loc_sffc_read_fsinfo_sector
   566 0000ADAB 81BBE4010000727241- <1> 	cmp	dword [ebx+484], 61417272h
   566 0000ADB4 61                  <1>
   567 0000ADB5 7534                <1> 	jne	short loc_sffc_read_fsinfo_sector
   568                              <1> 
   569 0000ADB7 3B83EC010000        <1> 	cmp	eax, [ebx+492]  ; FSI_Next_Free
   570 0000ADBD 741F                <1> 	je	short loc_sffc_retn
   571                              <1> 
   572                              <1> loc_sffc_write_fsinfo_sector:
   573                              <1> 	; EBX = FSINFO sector buffer
   574                              <1> 	; [CFS_FAT32FSINFOSEC] is set in 'get_fat32_fsinfo_sector_parms'
   575 0000ADBF 8983EC010000        <1> 	mov	[ebx+492], eax
   576 0000ADC5 A1[302B0100]        <1> 	mov	eax, [CFS_FAT32FSINFOSEC] 
   577 0000ADCA B901000000          <1> 	mov	ecx, 1
   578 0000ADCF 53                  <1> 	push	ebx
   579 0000ADD0 E8142C0000          <1> 	call	disk_write
   580 0000ADD5 7208                <1> 	jc      short loc_sffc_read_fsinfo_sector_err1
   581 0000ADD7 5B                  <1> 	pop	ebx
   582                              <1> 
   583 0000ADD8 8B83EC010000        <1> 	mov	eax, [ebx+492] ; First (Next) Free Cluster
   584                              <1> 
   585                              <1> loc_sffc_retn:
   586 0000ADDE C3                  <1> 	retn
   587                              <1> 
   588                              <1> ;loc_sffc_invalid_drive:
   589                              <1> ;	mov	eax, 0Fh ; MSDOS Error : Invalid drive
   590                              <1> ;	push	edx
   591                              <1> 
   592                              <1> loc_sffc_read_fsinfo_sector_err1:
   593 0000ADDF BB00000000          <1> 	mov	ebx, 0
   594                              <1> 	; 23/03/2016
   595 0000ADE4 B81D000000          <1> 	mov	eax, 1Dh ; Drive not ready or write error
   596                              <1> 
   597                              <1> loc_sffc_read_fsinfo_sector_err2:
   598 0000ADE9 5A                  <1> 	pop	edx
   599 0000ADEA C3                  <1> 	retn
   600                              <1> 	
   601                              <1> loc_sffc_read_fsinfo_sector:
   602 0000ADEB 50                  <1> 	push	eax
   603                              <1> 
   604 0000ADEC E87F050000          <1> 	call	get_fat32_fsinfo_sector_parms
   605 0000ADF1 72F6                <1> 	jc	short loc_sffc_read_fsinfo_sector_err2
   606                              <1> 
   607 0000ADF3 58                  <1> 	pop	eax
   608                              <1> 	; EDX = First (Next) Free Cluster value from FSINFO sector
   609                              <1> 	; EAX = First Free Cluster value from 'get_next_cluster'
   610                              <1> 	; (edx = old value)
   611 0000ADF4 39D0                <1> 	cmp	eax, edx ; First free Cluster (eax = new value) 
   612 0000ADF6 75C7                <1> 	jne	short loc_sffc_write_fsinfo_sector
   613                              <1> 
   614 0000ADF8 C3                  <1> 	retn	
   615                              <1> 
   616                              <1> update_cluster:
   617                              <1> 	; 02/03/2016
   618                              <1> 	; 01/03/2016
   619                              <1> 	; 29/02/2016
   620                              <1> 	; 27/02/2016
   621                              <1> 	; 26/02/2016
   622                              <1> 	; 22/02/2016 (TRDOS 386 =  TRDOS v2.0)
   623                              <1> 	; 11/08/2011  
   624                              <1> 	; 09/02/2005
   625                              <1> 	; INPUT ->
   626                              <1> 	;	EAX = Cluster Number
   627                              <1> 	;	ECX = New Cluster Value
   628                              <1> 	;	ESI = Logical Dos Drive Parameters Table
   629                              <1> 	;
   630                              <1> 	;	/// dword [FAT_ClusterCounter] ///
   631                              <1> 	;
   632                              <1> 	; OUTPUT ->
   633                              <1> 	;	cf = 0 -> No Error, EAX is valid
   634                              <1> 	;	cf = 1 & EAX = 0 -> End Of Cluster Chain
   635                              <1> 	; 	cf = 1 & EAX > 0 -> Error
   636                              <1> 	;		(ECX -> any value)
   637                              <1> 	; 	EAX = Next Cluster
   638                              <1> 	;	ECX = New Cluster Value
   639                              <1> 	;
   640                              <1> 	;	/// [FAT_ClusterCounter] is updated,
   641                              <1> 	;	/// decreased when a free cluster is assigned,
   642                              <1> 	;	/// increased if an assigned cluster is freed.	
   643                              <1> 	;		
   644                              <1> 	;
   645                              <1> 	; (Modified registers: EAX, EBX, -ECX-, EDX)
   646                              <1> 	
   647 0000ADF9 A3[82280100]        <1> 	mov	[FAT_CurrentCluster], eax
   648 0000ADFE 890D[242B0100]      <1> 	mov	[ClusterValue], ecx
   649                              <1> 
   650                              <1> loc_update_cluster_check_fat_buffer:
   651 0000AE04 8A1E                <1> 	mov	bl, [esi+LD_Name]
   652 0000AE06 381D[87280100]      <1> 	cmp	[FAT_BuffDrvName], bl
   653 0000AE0C 741A                <1> 	je	short loc_update_cluster_check_fat_type
   654 0000AE0E 803D[86280100]02    <1> 	cmp	byte [FAT_BuffValidData], 2
   655 0000AE15 0F84C2000000        <1>         je      loc_uc_save_fat_buffer
   656                              <1> 
   657                              <1> loc_uc_reset_fat_buffer_validation:
   658 0000AE1B C605[86280100]00    <1> 	mov	byte [FAT_BuffValidData], 0
   659                              <1> 
   660                              <1> loc_uc_check_fat_type_reset_drvname:
   661 0000AE22 881D[87280100]      <1> 	mov	[FAT_BuffDrvName], bl
   662                              <1> 
   663                              <1> loc_update_cluster_check_fat_type:
   664 0000AE28 29D2                <1> 	sub	edx, edx ; 26/02/2016
   665 0000AE2A 8A5E03              <1> 	mov	bl, [esi+LD_FATType]
   666 0000AE2D 83F802              <1> 	cmp	eax, 2
   667 0000AE30 0F82BE000000        <1>         jb      update_cluster_inv_data
   668 0000AE36 80FB02              <1> 	cmp	bl, 2 
   669 0000AE39 0F877A010000        <1>         ja      update_fat32_cluster
   670                              <1> 	;cmp	bl, 1
   671                              <1> 	;jb	short update_cluster_inv_data
   672 0000AE3F 8B4E78              <1> 	mov	ecx, [esi+LD_Clusters]
   673 0000AE42 41                  <1> 	inc	ecx  
   674 0000AE43 890D[92280100]      <1> 	mov	[LastCluster], ecx
   675 0000AE49 39C8                <1> 	cmp	eax, ecx ; dword [LastCluster]
   676 0000AE4B 0F87A6000000        <1>         ja      return_uc_fat_stc
   677                              <1> 	; TRDOS v1 has a FATal bug here ! 
   678                              <1> 		; or bl, bl ; cmp bl, 0
   679                              <1> 		; jz short update_fat12_cluster
   680                              <1> 	; !! It would destroy FAT12 floppy disk fs here !!
   681                              <1> 	; ('A:' disks of TRDOS v1 operating system project
   682                              <1> 	; had 'singlix fs', so, I could not differ this mistake
   683                              <1> 	; on a drive 'A:')
   684 0000AE51 80FB01              <1> 	cmp	bl, 1 ; correct comparison is this !
   685 0000AE54 0F86A2000000        <1>         jna     update_fat12_cluster 
   686                              <1> 
   687                              <1> update_fat16_cluster:
   688                              <1> pass_uc_fat16_errc:
   689                              <1> 	;sub	edx, edx
   690 0000AE5A BB00030000          <1> 	mov	ebx, 300h ;768
   691 0000AE5F F7F3                <1> 	div	ebx
   692                              <1> 	; EAX = Count of 3 FAT sectors
   693                              <1> 	; DX = Cluster offset in FAT buffer
   694 0000AE61 6689D3              <1> 	mov	bx, dx  
   695 0000AE64 66D1E3              <1> 	shl	bx, 1 ; Multiply by 2
   696 0000AE67 66BA0300            <1> 	mov	dx, 3
   697 0000AE6B F7E2                <1> 	mul	edx  
   698                              <1> 	; EAX = FAT Sector
   699                              <1> 	; EDX = 0
   700                              <1> 	; EBX = Byte offset in FAT buffer
   701 0000AE6D 8A0D[86280100]      <1> 	mov	cl, [FAT_BuffValidData]
   702 0000AE73 80F902              <1> 	cmp	cl, 2
   703 0000AE76 750A                <1> 	jne	short loc_uc_check_fat16_buff_sector_load
   704                              <1> 
   705                              <1> loc_uc_check_fat16_buff_sector_save:
   706 0000AE78 3B05[8A280100]      <1> 	cmp	eax, [FAT_BuffSector]
   707 0000AE7E 755D                <1> 	jne	short loc_uc_save_fat_buffer
   708 0000AE80 EB15                <1> 	jmp	short loc_update_fat16_cell
   709                              <1> 
   710                              <1> loc_uc_check_fat16_buff_sector_load:
   711 0000AE82 80F901              <1> 	cmp	cl, 1 ; byte [FAT_BuffValidData]
   712 0000AE85 0F85FB010000        <1>         jne     loc_uc_load_fat_sectors
   713 0000AE8B 3B05[8A280100]      <1> 	cmp	eax, [FAT_BuffSector]
   714 0000AE91 0F85EF010000        <1>         jne     loc_uc_load_fat_sectors
   715                              <1> 
   716                              <1> loc_update_fat16_cell:
   717                              <1> loc_update_fat16_buffer:
   718 0000AE97 81C3001C0900        <1> 	add	ebx, FAT_Buffer ; 26/02/2016
   719                              <1> 	;movzx	eax, word [ebx]
   720 0000AE9D 668B03              <1> 	mov	ax, [ebx]
   721                              <1> 	; 01/03/2016
   722 0000AEA0 89C2                <1> 	mov	edx, eax ; old value of the cluster
   723 0000AEA2 A3[82280100]        <1> 	mov	[FAT_CurrentCluster], eax
   724 0000AEA7 8B0D[242B0100]      <1> 	mov	ecx, [ClusterValue] ; 32 bits
   725 0000AEAD 66890B              <1> 	mov	[ebx], cx ; 16 bits !
   726                              <1> 
   727 0000AEB0 C605[86280100]02    <1> 	mov	byte [FAT_BuffValidData], 2
   728                              <1> 	
   729 0000AEB7 6683F802            <1> 	cmp	ax, 2
   730 0000AEBB 723A                <1> 	jb	short return_uc_fat_stc
   731 0000AEBD 3B05[92280100]      <1> 	cmp	eax, [LastCluster]
   732 0000AEC3 7732                <1> 	ja	short return_uc_fat_stc
   733                              <1> 
   734                              <1> loc_fat_buffer_updated:
   735                              <1> 	; 01/03/2016
   736 0000AEC5 F8                  <1> 	clc
   737                              <1> loc_fat_buffer_stc_1:
   738 0000AEC6 9C                  <1> 	pushf
   739 0000AEC7 21C9                <1> 	and	ecx, ecx
   740 0000AEC9 7506                <1> 	jnz	short loc_fat_buffer_updated_1
   741                              <1> 
   742                              <1> 	; 01/03/2016 
   743                              <1> 	; new value of the cluster = 0 (free)
   744                              <1> 	; increase free(d) cluster count
   745 0000AECB FF05[8E280100]      <1> 	inc	dword [FAT_ClusterCounter]
   746                              <1> 
   747                              <1> loc_fat_buffer_updated_1: ; new value of the cluster > 0
   748 0000AED1 09D2                <1> 	or	edx, edx ; 02/03/2016
   749 0000AED3 7506                <1> 	jnz	short loc_fat_buffer_updated_2
   750                              <1> 	; old value of the cluster = 0 (it was free cluster)
   751                              <1> 	; decrease free(d) cluster count
   752 0000AED5 FF0D[8E280100]      <1> 	dec	dword [FAT_ClusterCounter] ; it may be negative number
   753                              <1> 
   754                              <1> loc_fat_buffer_updated_2:
   755 0000AEDB 9D                  <1> 	popf
   756 0000AEDC C3                  <1> 	retn
   757                              <1> 
   758                              <1> loc_uc_save_fat_buffer:
   759                              <1> 	; byte [FAT_BuffValidData] = 2 
   760 0000AEDD E8D4010000          <1> 	call	save_fat_buffer
   761 0000AEE2 0F8297010000        <1>         jc      loc_fat_sectors_rw_error2
   762                              <1> 	;mov	byte [FAT_BuffValidData], 1
   763 0000AEE8 A1[82280100]        <1> 	mov	eax, [FAT_CurrentCluster]
   764                              <1> 	;mov	ecx, [ClusterValue]
   765                              <1> 	;jmp	short loc_update_cluster_check_fat_buffer
   766 0000AEED 8A1E                <1> 	mov	bl, [esi+LD_Name] ; 01/03/2016
   767 0000AEEF E927FFFFFF          <1>         jmp     loc_uc_reset_fat_buffer_validation
   768                              <1> 
   769                              <1> update_cluster_inv_data:
   770                              <1> 	;mov	eax, 0Dh
   771 0000AEF4 B00D                <1> 	mov	al, 0Dh  ; Invalid Data
   772 0000AEF6 C3                  <1> 	retn 
   773                              <1> 
   774                              <1> return_uc_fat_stc:
   775                              <1> 	; 01/03/2016
   776 0000AEF7 31C0                <1> 	xor	eax, eax
   777 0000AEF9 F9                  <1> 	stc
   778 0000AEFA EBCA                <1> 	jmp	short loc_fat_buffer_stc_1
   779                              <1> 
   780                              <1> update_fat12_cluster:
   781                              <1> pass_uc_fat12_errc:
   782                              <1> 	;sub	edx, edx
   783 0000AEFC BB00040000          <1> 	mov	ebx, 400h ;1024
   784 0000AF01 F7F3                <1> 	div	ebx
   785                              <1> 	; EAX = Count of 3 FAT sectors
   786                              <1> 	; DX = Cluster offset in FAT buffer
   787 0000AF03 66B90300            <1> 	mov	cx, 3
   788 0000AF07 6689C3              <1> 	mov	bx, ax
   789 0000AF0A 6689C8              <1> 	mov	ax, cx ; 3
   790 0000AF0D 66F7E2              <1> 	mul	dx     ; Multiply by 3
   791 0000AF10 66D1E8              <1> 	shr	ax, 1  ; Divide by 2
   792 0000AF13 6693                <1> 	xchg	bx, ax
   793                              <1> 	; EAX = Count of 3 FAT sectors
   794                              <1> 	; EBX = Byte Offset in FAT buffer   
   795 0000AF15 66F7E1              <1> 	mul	cx  ; 3 * AX
   796                              <1> 	; EAX = FAT Beginning Sector
   797                              <1> 	; EDX = 0
   798 0000AF18 8A0D[86280100]      <1> 	mov	cl, [FAT_BuffValidData]
   799                              <1> 	; TRDOS v1 has a FATal bug here ! 
   800                              <1> 	; (it does not have 'cmp cl, 2' instruction here !
   801                              <1> 	;  while 'jne' is existing !)
   802 0000AF1E 80F902              <1> 	cmp	cl, 2 ; 2 = dirty buffer (must be written to disk)
   803 0000AF21 750A                <1> 	jne	short loc_uc_check_fat12_buff_sector_load
   804                              <1> 
   805                              <1> loc_uc_check_fat12_buff_sector_save:
   806 0000AF23 3B05[8A280100]      <1> 	cmp	eax, [FAT_BuffSector]
   807 0000AF29 75B2                <1>         jne     short loc_uc_save_fat_buffer
   808 0000AF2B EB15                <1> 	jmp	short loc_update_fat12_cell
   809                              <1> 
   810                              <1> loc_uc_check_fat12_buff_sector_load:
   811 0000AF2D 80F901              <1> 	cmp	cl, 1 ; byte ptr [FAT_BuffValidData]
   812 0000AF30 0F8550010000        <1>         jne     loc_uc_load_fat_sectors
   813 0000AF36 3B05[8A280100]      <1> 	cmp	eax, [FAT_BuffSector]
   814 0000AF3C 0F8544010000        <1>         jne     loc_uc_load_fat_sectors
   815                              <1> 
   816                              <1> loc_update_fat12_cell:
   817 0000AF42 81C3001C0900        <1> 	add	ebx, FAT_Buffer ; 26/02/2016
   818 0000AF48 668B0D[82280100]    <1> 	mov	cx, [FAT_CurrentCluster]
   819 0000AF4F 66D1E9              <1> 	shr	cx, 1
   820 0000AF52 668B03              <1> 	mov	ax, [ebx]
   821 0000AF55 6689C2              <1> 	mov	dx, ax
   822 0000AF58 7344                <1> 	jnc	short uc_fat12_nc_even
   823                              <1> 
   824 0000AF5A 6683E00F            <1> 	and	ax, 0Fh
   825 0000AF5E 8B0D[242B0100]      <1> 	mov	ecx, [ClusterValue] ; 32 bits
   826 0000AF64 66C1E104            <1> 	shl	cx, 4
   827 0000AF68 6609C1              <1> 	or	cx, ax
   828 0000AF6B 6689D0              <1> 	mov	ax, dx
   829 0000AF6E 66890B              <1> 	mov	[ebx], cx  ; 16 bits !
   830 0000AF71 66C1E804            <1> 	shr	ax, 4 ; al(bit4..7)+ah(bit0..7)
   831                              <1> 
   832                              <1> update_fat12_buffer:
   833 0000AF75 A3[82280100]        <1> 	mov	[FAT_CurrentCluster], eax
   834 0000AF7A 89C2                <1> 	mov	edx, eax ; 01/03/2016
   835 0000AF7C C605[86280100]02    <1> 	mov	byte [FAT_BuffValidData], 2
   836 0000AF83 6683F802            <1> 	cmp	ax, 2
   837 0000AF87 0F826AFFFFFF        <1>         jb      return_uc_fat_stc
   838 0000AF8D 3B05[92280100]      <1> 	cmp	eax, [LastCluster]
   839 0000AF93 0F875EFFFFFF        <1>         ja      return_uc_fat_stc
   840 0000AF99 E927FFFFFF          <1>         jmp     loc_fat_buffer_updated
   841                              <1> 
   842                              <1> uc_fat12_nc_even:
   843 0000AF9E 662500F0            <1> 	and	ax, 0F000h
   844 0000AFA2 8B0D[242B0100]      <1> 	mov	ecx, [ClusterValue] ; 32 bits
   845 0000AFA8 80E50F              <1> 	and	ch, 0Fh
   846 0000AFAB 6609C1              <1> 	or	cx, ax
   847 0000AFAE 6689D0              <1> 	mov	ax, dx
   848 0000AFB1 66890B              <1> 	mov	[ebx], cx ; 16 bits !
   849 0000AFB4 80E40F              <1> 	and	ah, 0Fh ; al(bit0..7)+ah(bit0..3)
   850 0000AFB7 EBBC                <1> 	jmp	short update_fat12_buffer
   851                              <1> 
   852                              <1> update_fat32_cluster:
   853 0000AFB9 8B4E78              <1> 	mov	ecx, [esi+LD_Clusters]
   854 0000AFBC 41                  <1> 	inc	ecx
   855 0000AFBD 890D[92280100]      <1> 	mov	[LastCluster], ecx
   856                              <1> 
   857 0000AFC3 39C8                <1> 	cmp	eax, ecx
   858 0000AFC5 0F872CFFFFFF        <1>         ja      return_uc_fat_stc
   859                              <1> 
   860                              <1> pass_uc_fat32_errc:
   861                              <1> 	;sub	edx, edx
   862 0000AFCB BB80010000          <1> 	mov	ebx, 180h ;384
   863 0000AFD0 F7F3                <1> 	div	ebx
   864                              <1> 	; EAX = Count of 3 FAT sectors
   865                              <1> 	; DX = Cluster offset in FAT buffer
   866 0000AFD2 89D3                <1> 	mov	ebx, edx
   867 0000AFD4 C1E302              <1> 	shl	ebx, 2 ; Multiply by 4
   868 0000AFD7 BA03000000          <1> 	mov	edx, 3	
   869 0000AFDC F7E2                <1> 	mul	edx
   870                              <1> 	; EBX = Cluster Offset in FAT buffer
   871                              <1> 	; EAX = FAT Sector
   872                              <1> 	; EDX = 0
   873 0000AFDE 8A0D[86280100]      <1> 	mov	cl, [FAT_BuffValidData]
   874 0000AFE4 80F902              <1> 	cmp	cl, 2
   875 0000AFE7 750E                <1> 	jne	short loc_uc_check_fat32_buff_sector_load
   876                              <1> 
   877                              <1> loc_uc_check_fat32_buff_sector_save:
   878 0000AFE9 3B05[8A280100]      <1> 	cmp	eax, [FAT_BuffSector]
   879 0000AFEF 0F85E8FEFFFF        <1>         jne     loc_uc_save_fat_buffer
   880 0000AFF5 EB11                <1> 	jmp	short loc_update_fat32_cell
   881                              <1> 
   882                              <1> loc_uc_check_fat32_buff_sector_load:
   883 0000AFF7 80F901              <1> 	cmp	cl, 1 ; byte [FAT_BuffValidData]
   884 0000AFFA 0F8586000000        <1>         jne     loc_uc_load_fat_sectors
   885 0000B000 3B05[8A280100]      <1> 	cmp	eax, [FAT_BuffSector]
   886 0000B006 757E                <1>         jne     loc_uc_load_fat_sectors
   887                              <1> 
   888                              <1> loc_update_fat32_cell:
   889                              <1> loc_update_fat32_buffer:
   890 0000B008 81C3001C0900        <1> 	add	ebx, FAT_Buffer ; 26/02/2016
   891 0000B00E 8B03                <1> 	mov	eax, [ebx]
   892 0000B010 25FFFFFF0F          <1> 	and	eax, 0FFFFFFFh ; 28 bit cluster value
   893                              <1> 	
   894 0000B015 8B15[82280100]      <1> 	mov	edx, [FAT_CurrentCluster] ; 01/03/2016
   895                              <1> 
   896 0000B01B A3[82280100]        <1> 	mov 	[FAT_CurrentCluster], eax
   897 0000B020 8B0D[242B0100]      <1> 	mov	ecx, [ClusterValue]
   898 0000B026 890B                <1> 	mov	[ebx], ecx ; 29/02/2016 
   899                              <1> 
   900 0000B028 C605[86280100]02    <1> 	mov	byte [FAT_BuffValidData], 2
   901                              <1> 
   902                              <1> 	; 01/03/2016
   903 0000B02F 21C0                <1> 	and	eax, eax ; was it free cluster ?
   904 0000B031 7514                <1> 	jnz	short loc_upd_fat32_c0
   905                              <1> 
   906                              <1> 	;or	ecx, ecx ; it will be left free ?!
   907                              <1> 	;jz	short loc_upd_fat32_c3
   908                              <1> 
   909 0000B033 3B563E              <1> 	cmp	edx, [esi+LD_BPB+BPB_Reserved+4] ; First free cluster
   910 0000B036 7520                <1> 	jne	short loc_upd_fat32_c3
   911                              <1> 
   912 0000B038 3B15[92280100]      <1> 	cmp	edx, [LastCluster]
   913 0000B03E 7207                <1> 	jb	short loc_upd_fat32_c0
   914                              <1> 
   915 0000B040 BA02000000          <1> 	mov	edx, 2 ; rewind !
   916 0000B045 EB0E                <1> 	jmp	short loc_upd_fat32_c2
   917                              <1> 
   918                              <1> loc_upd_fat32_c0:
   919 0000B047 FF463E              <1> 	inc	dword [esi+LD_BPB+BPB_Reserved+4] ; set it to next cluster		
   920 0000B04A EB0C                <1> 	jmp	short loc_upd_fat32_c3
   921                              <1> 
   922                              <1> loc_upd_fat32_c1:
   923 0000B04C 09C9                <1> 	or	ecx, ecx ; will it be free cluster ?
   924 0000B04E 7508                <1> 	jnz	short loc_upd_fat32_c3
   925                              <1> 
   926 0000B050 3B563E              <1> 	cmp	edx, [esi+LD_BPB+BPB_Reserved+4] ; First free cluster
   927 0000B053 7303                <1> 	jnb	short loc_upd_fat32_c3
   928                              <1> 
   929                              <1> loc_upd_fat32_c2:	
   930 0000B055 89563E              <1> 	mov	[esi+LD_BPB+BPB_Reserved+4], edx			
   931                              <1> 
   932                              <1> loc_upd_fat32_c3:
   933 0000B058 89C2                <1> 	mov	edx, eax
   934                              <1> 
   935                              <1> loc_upd_fat32_c4:
   936 0000B05A 83F802              <1> 	cmp	eax, 2
   937 0000B05D 0F8294FEFFFF        <1>         jb      return_uc_fat_stc
   938                              <1> 
   939                              <1> pass_uc_fat32_c_zero_check_2:
   940 0000B063 3B05[92280100]      <1> 	cmp	eax, [LastCluster]
   941 0000B069 0F8788FEFFFF        <1>         ja      return_uc_fat_stc
   942                              <1> 	
   943 0000B06F E951FEFFFF          <1> 	jmp     loc_fat_buffer_updated
   944                              <1> 
   945                              <1> loc_fat_sectors_rw_error1:
   946                              <1> 	;mov	byte [FAT_BuffValidData], 0
   947                              <1> 	; 23/03/2016
   948 0000B074 B815000000          <1> 	mov	eax, 15h ; Drive not ready or read error
   949 0000B079 8825[86280100]      <1> 	mov	[FAT_BuffValidData], ah ; 0
   950                              <1> 
   951                              <1> loc_fat_sectors_rw_error2:
   952                              <1> 	;mov	eax, error code
   953                              <1> 	;mov	edx, 0
   954 0000B07F 8B0D[242B0100]      <1> 	mov	ecx, [ClusterValue]
   955 0000B085 C3                  <1> 	retn
   956                              <1> 
   957                              <1> loc_uc_load_fat_sectors:
   958 0000B086 A3[8A280100]        <1> 	mov	[FAT_BuffSector], eax
   959                              <1> 
   960                              <1> load_uc_fat_sectors_zero:
   961 0000B08B 034660              <1> 	add	eax, [esi+LD_FATBegin]
   962 0000B08E BB001C0900          <1> 	mov	ebx, FAT_Buffer
   963 0000B093 B903000000          <1> 	mov	ecx, 3
   964 0000B098 E85B290000          <1> 	call	disk_read
   965 0000B09D 72D5                <1> 	jc	short loc_fat_sectors_rw_error1
   966                              <1> 
   967 0000B09F C605[86280100]01    <1>         mov     byte [FAT_BuffValidData], 1
   968 0000B0A6 A1[82280100]        <1> 	mov 	eax, [FAT_CurrentCluster]
   969 0000B0AB 8B0D[242B0100]      <1> 	mov	ecx, [ClusterValue]
   970 0000B0B1 E972FDFFFF          <1>         jmp     loc_update_cluster_check_fat_type
   971                              <1> 
   972                              <1> save_fat_buffer:
   973                              <1> 	; 01/03/2016
   974                              <1> 	; 22/02/2016 (TRDOS 386 =  TRDOS v2.0)
   975                              <1> 	; 11/08/2011
   976                              <1> 	; 09/02/2005 
   977                              <1> 	; INPUT ->
   978                              <1> 	;	None
   979                              <1> 	; OUTPUT ->
   980                              <1> 	;	cf = 0 -> OK.
   981                              <1> 	;	cf = 1 -> error code in AL (EAX)
   982                              <1> 	;
   983                              <1> 	;	EBX = FAT_Buffer address
   984                              <1> 	;
   985                              <1> 	; (EAX, EDX, ECX will be modified)
   986                              <1> 
   987                              <1> 	;cmp	byte [FAT_BuffValidData], 2 
   988                              <1> 	;je	short loc_save_fat_buff
   989                              <1> 
   990                              <1> ;loc_save_fat_buffer_retn:
   991                              <1> ;	xor	eax, eax
   992                              <1> ;	retn
   993                              <1> 
   994                              <1> loc_save_fat_buff:
   995 0000B0B6 31D2                <1> 	xor	edx, edx
   996 0000B0B8 8A35[87280100]      <1> 	mov	dh, [FAT_BuffDrvName]
   997 0000B0BE 80FE41              <1> 	cmp	dh, 'A'
   998 0000B0C1 722E                <1> 	jb	short loc_save_fat_buffer_inv_data_retn
   999 0000B0C3 80EE41              <1> 	sub	dh, 'A'
  1000 0000B0C6 56                  <1> 	push	esi ; *
  1001 0000B0C7 BE00010900          <1>         mov     esi, Logical_DOSDisks
  1002 0000B0CC 01D6                <1> 	add	esi, edx
  1003                              <1> 	
  1004 0000B0CE 8A5603              <1> 	mov	dl, [esi+LD_FATType]
  1005 0000B0D1 20D2                <1> 	and	dl, dl
  1006 0000B0D3 741B                <1> 	jz	short loc_save_fat_buffer_inv_data_pop_retn 
  1007                              <1> 
  1008 0000B0D5 A1[8A280100]        <1> 	mov	eax, [FAT_BuffSector]
  1009 0000B0DA 80FA02              <1> 	cmp	dl, 2
  1010 0000B0DD 770A                <1> 	ja	short loc_save_fat32_buff
  1011                              <1> 
  1012                              <1> loc_save_fat_12_16_buff:
  1013                              <1> 	; 01/03/2016
  1014                              <1> 	; TRDOS v1 has a FATal bug here!
  1015                              <1> 	; Correct code: mov dx, word ptr [FAT_BuffSector]+2
  1016                              <1> 	; (DX:AX in TRDOS v1 -> EAX in TRDOS v2)
  1017                              <1> 	;
  1018 0000B0DF 0FB74E1C            <1> 	movzx	ecx, word [esi+LD_BPB+FATSecs] 
  1019 0000B0E3 29C1                <1> 	sub	ecx, eax
  1020                              <1> 	; TRDOS v1 has a bug here... ('pop esi' was forgotten!)
  1021                              <1> 	;jna	short loc_save_fat_buffer_inv_data_retn ; wrong addr!
  1022 0000B0E5 7609                <1> 	jna	short loc_save_fat_buffer_inv_data_pop_retn ; correct addr.
  1023 0000B0E7 EB15                <1> 	jmp	short loc_save_fat_buffer_check_rs3
  1024                              <1> 
  1025                              <1> loc_save_fat32_buff:
  1026 0000B0E9 8B4E2A              <1> 	mov	ecx, [esi+LD_BPB+FAT32_FAT_Size]
  1027 0000B0EC 29C1                <1> 	sub	ecx, eax
  1028 0000B0EE 770E                <1> 	ja	short loc_save_fat_buffer_check_rs3
  1029                              <1> 
  1030                              <1> loc_save_fat_buffer_inv_data_pop_retn:
  1031 0000B0F0 5E                  <1> 	pop	esi ; *
  1032                              <1> loc_save_fat_buffer_inv_data_retn:
  1033 0000B0F1 B80D000000          <1> 	mov	eax, 0Dh ; Invalid DATA
  1034 0000B0F6 C3                  <1> 	retn
  1035                              <1> 
  1036                              <1> loc_save_fat_buff_remain_sectors_3:
  1037 0000B0F7 B903000000          <1> 	mov	ecx, 3
  1038 0000B0FC EB05                <1> 	jmp	short loc_save_fat_buff_continue
  1039                              <1> 
  1040                              <1> loc_save_fat_buffer_check_rs3:
  1041 0000B0FE 83F903              <1> 	cmp	ecx, 3
  1042 0000B101 77F4                <1> 	ja	short loc_save_fat_buff_remain_sectors_3
  1043                              <1> 
  1044                              <1> loc_save_fat_buff_continue:
  1045 0000B103 BB001C0900          <1> 	mov	ebx, FAT_Buffer
  1046 0000B108 034660              <1> 	add	eax, [esi+LD_FATBegin]
  1047 0000B10B 51                  <1> 	push	ecx
  1048 0000B10C E8D8280000          <1> 	call	disk_write
  1049 0000B111 59                  <1> 	pop	ecx
  1050 0000B112 722B                <1> 	jc	short loc_save_FAT_buff_write_err
  1051                              <1> 	
  1052 0000B114 807E0302            <1> 	cmp	byte [esi+LD_FATType], 2
  1053 0000B118 7605                <1> 	jna	short loc_calc_2nd_fat12_16_addr
  1054                              <1> 
  1055                              <1> loc_calc_2nd_fat32_addr:
  1056 0000B11A 8B462A              <1> 	mov	eax, [esi+LD_BPB+FAT32_FAT_Size]
  1057 0000B11D EB04                <1> 	jmp	short loc_calc_2nd_fat_addr
  1058                              <1> 
  1059                              <1> loc_calc_2nd_fat12_16_addr:
  1060 0000B11F 0FB7461C            <1> 	movzx	eax, word [esi+LD_BPB+FATSecs]
  1061                              <1> 
  1062                              <1> loc_calc_2nd_fat_addr:
  1063 0000B123 034660              <1> 	add	eax, [esi+LD_FATBegin]
  1064 0000B126 0305[8A280100]      <1> 	add	eax, [FAT_BuffSector]
  1065 0000B12C BB001C0900          <1> 	mov	ebx, FAT_Buffer
  1066                              <1> 	; ecx = 1 to 3
  1067 0000B131 E8B3280000          <1> 	call	disk_write
  1068 0000B136 7207                <1> 	jc	short loc_save_FAT_buff_write_err
  1069                              <1>  	; Valid  buffer (1 = valid but do not save)
  1070 0000B138 C605[86280100]01    <1> 	mov	byte [FAT_BuffValidData], 1
  1071                              <1> 
  1072                              <1> loc_save_FAT_buff_write_err:
  1073 0000B13F 5E                  <1> 	pop	esi ; *
  1074 0000B140 BB001C0900          <1> 	mov	ebx, FAT_Buffer
  1075                              <1> 	; 23/03/2016
  1076 0000B145 B81D000000          <1> 	mov	eax, 1Dh ; Drive not ready or write error
  1077 0000B14A C3                  <1> 	retn
  1078                              <1> 
  1079                              <1> calculate_fat_freespace:
  1080                              <1> 	; 23/03/2016
  1081                              <1> 	; 02/03/2016
  1082                              <1> 	; 01/03/2016
  1083                              <1> 	; 29/02/2016
  1084                              <1> 	; 22/02/2016 (TRDOS 386 =  TRDOS v2.0)
  1085                              <1> 	; 30/04/2011
  1086                              <1> 	; 03/04/2010
  1087                              <1> 	; 2005
  1088                              <1> 	; INPUT ->
  1089                              <1> 	;	EAX = Cluster count to be added or subtracted
  1090                              <1> 	; 	If BH = FFh, ESI = TR-DOS Logical Drive Description Table
  1091                              <1> 	; 	If BH < FFh, BH = TR-DOS Logical Drive Number
  1092                              <1> 	; 	BL: 
  1093                              <1> 	;	0 = Calculate, 1 = Add, 2 = Subtract, 3 = Get (Not Set/Calc)
  1094                              <1> 	; OUTPUT ->
  1095                              <1> 	;	EAX = Free Space in sectors
  1096                              <1> 	;	ESI = Logical Dos Drive Description Table address
  1097                              <1> 	;	BH = Logical Dos Drive Number (same with input value of BH)
  1098                              <1> 	;	BL = Type of operation (same with input value of BL)
  1099                              <1> 	;	ECX = 0 -> valid
  1100                              <1> 	;	ECX > 0 -> error or invalid
  1101                              <1> 	;	If EAX = FFFFFFFFh, it is 're-calculation needed'
  1102                              <1> 	;			          sign due to r/w error   
  1103                              <1> 
  1104 0000B14B 66891D[2A2B0100]    <1> 	mov	[CFS_OPType], bx
  1105 0000B152 A3[2C2B0100]        <1> 	mov	[CFS_CC], eax
  1106                              <1> 	
  1107 0000B157 80FFFF              <1> 	cmp	bh, 0FFh
  1108 0000B15A 740B                <1> 	je	short pass_calculate_freespace_get_drive_dt_offset
  1109                              <1> 
  1110                              <1> loc_calculate_freespace_get_drive_dt_offset:     
  1111 0000B15C 31C0                <1> 	xor	eax, eax
  1112 0000B15E 88FC                <1>         mov     ah, bh
  1113 0000B160 BE00010900          <1> 	mov	esi, Logical_DOSDisks
  1114 0000B165 01C6                <1>         add     esi, eax
  1115                              <1> 
  1116                              <1> pass_calculate_freespace_get_drive_dt_offset:
  1117 0000B167 08DB                <1> 	or	bl, bl
  1118 0000B169 7435                <1> 	jz	short loc_reset_fcc
  1119                              <1> 	
  1120                              <1> loc_get_free_sectors:
  1121 0000B16B 8B4674              <1> 	mov	eax, [esi+LD_FreeSectors]
  1122                              <1> 
  1123                              <1> 	;xor	ecx, ecx
  1124                              <1> 	;dec	ecx ; 0FFFFFFFFh
  1125                              <1> 	;cmp	eax, ecx ; 29/02/2016
  1126                              <1> 	;je	short loc_get_free_sectors_retn ; recalculation is needed!
  1127                              <1> 	
  1128                              <1> 	; 23/03/2016
  1129 0000B16E 8B4E70              <1> 	mov	ecx, [esi+LD_TotalSectors]
  1130 0000B171 39C1                <1> 	cmp	ecx, eax ; Total sectors must be greater than Free sectors !
  1131 0000B173 7707                <1> 	ja	short loc_get_free_sectors_check_optype
  1132                              <1> 	
  1133 0000B175 31C0                <1> 	xor	eax, eax
  1134 0000B177 48                  <1> 	dec	eax ; 0FFFFFFFFh  ; recalculation is needed!
  1135 0000B178 894674              <1> 	mov	[esi+LD_FreeSectors], eax ; reset (for recalculation)
  1136                              <1> 		
  1137                              <1> loc_get_free_sectors_retn:
  1138 0000B17B C3                  <1> 	retn
  1139                              <1> 	
  1140                              <1> loc_get_free_sectors_check_optype:
  1141 0000B17C 80FB03              <1> 	cmp	bl, 3
  1142 0000B17F 7203                <1> 	jb	short loc_set_fcc
  1143                              <1> 
  1144 0000B181 29C9                <1> 	sub	ecx, ecx ; 0
  1145                              <1> 
  1146 0000B183 C3                  <1> 	retn	
  1147                              <1> 
  1148                              <1> loc_set_fcc:
  1149 0000B184 807E0302            <1> 	cmp	byte [esi+LD_FATType], 2
  1150 0000B188 0F87DF000000        <1>         ja      loc_update_FAT32_fs_info_fcc
  1151                              <1> 
  1152                              <1> 	;mov	eax, [esi+LD_FreeSectors]
  1153 0000B18E 0FB64E13            <1> 	movzx	ecx, byte [esi+LD_BPB+SecPerClust]
  1154 0000B192 29D2                <1> 	sub	edx, edx
  1155 0000B194 F7F1                <1> 	div	ecx
  1156                              <1> 	;or	dx, dx 
  1157                              <1> 	;	; DX -> Remain sectors < SecPerClust
  1158                              <1> 	;	; DX > 0 -> invalid free sector count
  1159                              <1> 	;jnz	short loc_reset_fcc 
  1160                              <1> 
  1161                              <1> ;pass_set_fcc_div32:
  1162 0000B196 A3[A3280100]        <1> 	mov	[FreeClusterCount], eax
  1163 0000B19B E988000000          <1>         jmp     loc_set_free_sectors_FAT12_FAT16
  1164                              <1> 
  1165                              <1> loc_reset_fcc:
  1166 0000B1A0 31C0                <1> 	xor	eax, eax
  1167 0000B1A2 A3[A3280100]        <1> 	mov	[FreeClusterCount], eax ; 0
  1168 0000B1A7 8B5678              <1> 	mov	edx, [esi+LD_Clusters]
  1169 0000B1AA 42                  <1> 	inc	edx
  1170 0000B1AB 8915[92280100]      <1> 	mov	[LastCluster], edx
  1171                              <1> 
  1172 0000B1B1 807E0302            <1> 	cmp	byte [esi+LD_FATType], 2
  1173 0000B1B5 7647                <1> 	jna	short loc_count_free_fat_clusters_0  
  1174                              <1> 
  1175 0000B1B7 48                  <1> 	dec	eax ; FFFFFFFFh
  1176 0000B1B8 A3[342B0100]        <1> 	mov	[CFS_FAT32FC], eax
  1177                              <1> 
  1178                              <1> 	; 29/02/2016
  1179 0000B1BD 89463A              <1> 	mov	[esi+LD_BPB+BPB_Reserved], eax ; reset
  1180 0000B1C0 89463E              <1> 	mov	[esi+LD_BPB+BPB_Reserved+4], eax ; reset
  1181                              <1> 	
  1182 0000B1C3 B802000000          <1> 	mov 	eax, 2
  1183                              <1> 
  1184                              <1> loc_count_fc_next_cluster_0:
  1185 0000B1C8 50                  <1> 	push	eax
  1186 0000B1C9 E801F9FFFF          <1> 	call	get_next_cluster
  1187 0000B1CE 7310                <1> 	jnc	short loc_check_fat32_ff_cluster
  1188 0000B1D0 09C0                <1> 	or	eax, eax
  1189 0000B1D2 741E                <1> 	jz	short pass_inc_cfs_fcc_0
  1190                              <1> 
  1191                              <1> loc_put_fcc_unknown_sign:
  1192 0000B1D4 58                  <1> 	pop	eax
  1193                              <1> 	; "Free count is Unknown" sign
  1194                              <1> 	;mov	dword [FreeClusterCount], 0FFFFFFFFh
  1195                              <1> 
  1196                              <1> 	; 29/02/2016
  1197                              <1> 	; Save Free Cluster Count value in FAT32 'BPB_Reserved' area
  1198                              <1> 	;mov	[esi+LD_BPB+BPB_Reserved], 0FFFFFFFFh ; unknown!
  1199 0000B1D5 8B15[342B0100]      <1> 	mov	edx, [CFS_FAT32FC] ; First Free Cluster
  1200                              <1> 	; Save First Free Cluster value in FAT32 'BPB_Reserved+4' area
  1201 0000B1DB 89563E              <1> 	mov	[esi+LD_BPB+BPB_Reserved+4], edx
  1202                              <1> 	
  1203 0000B1DE EB7D                <1>         jmp     loc_put_fcc_invalid_sign
  1204                              <1> 
  1205                              <1> loc_check_fat32_ff_cluster:
  1206 0000B1E0 09C0                <1> 	or	eax, eax
  1207 0000B1E2 750E                <1> 	jnz	short pass_inc_cfs_fcc_0
  1208 0000B1E4 58                  <1> 	pop	eax
  1209 0000B1E5 A3[342B0100]        <1> 	mov	[CFS_FAT32FC], eax
  1210                              <1> 	;mov	dword [FreeClusterCount], 1
  1211 0000B1EA FF05[A3280100]      <1> 	inc	dword [FreeClusterCount]
  1212 0000B1F0 EB27                <1> 	jmp	short pass_inc_cfs_fcc_1
  1213                              <1> 
  1214                              <1> pass_inc_cfs_fcc_0:
  1215 0000B1F2 58                  <1> 	pop	eax
  1216                              <1> 
  1217                              <1> pass_inc_cfs_fcc_0c:
  1218 0000B1F3 40                  <1> 	inc	eax ; add eax, 1
  1219 0000B1F4 3B05[92280100]      <1> 	cmp	eax, [LastCluster]
  1220 0000B1FA 76CC                <1> 	jna 	short loc_count_fc_next_cluster_0
  1221 0000B1FC EB6F                <1> 	jmp	short loc_update_FAT32_fs_info_fcc
  1222                              <1> 
  1223                              <1> loc_count_free_fat_clusters_0:
  1224                              <1> 	;mov	eax, 2
  1225 0000B1FE B002                <1> 	mov	al, 2
  1226                              <1> 
  1227                              <1> loc_count_fc_next_cluster:
  1228 0000B200 50                  <1> 	push	eax
  1229 0000B201 E8C9F8FFFF          <1> 	call	get_next_cluster
  1230 0000B206 720C                <1> 	jc	short loc_count_fcc_stc
  1231                              <1> 
  1232                              <1> loc_count_free_clusters_1:
  1233 0000B208 21C0                <1> 	and	eax, eax
  1234 0000B20A 750C                <1> 	jnz	short pass_inc_cfs_fcc
  1235                              <1> 
  1236 0000B20C FF05[A3280100]      <1> 	inc	dword [FreeClusterCount]
  1237 0000B212 EB04                <1> 	jmp	short pass_inc_cfs_fcc
  1238                              <1> 
  1239                              <1> loc_count_fcc_stc:
  1240 0000B214 09C0                <1> 	or	eax, eax
  1241 0000B216 75BC                <1> 	jnz	short loc_put_fcc_unknown_sign ; 29/02/2016
  1242                              <1> 
  1243                              <1> pass_inc_cfs_fcc:
  1244 0000B218 58                  <1> 	pop	eax
  1245                              <1> 
  1246                              <1> pass_inc_cfs_fcc_1:
  1247 0000B219 40                  <1> 	inc	eax ; add eax, 1
  1248 0000B21A 3B05[92280100]      <1> 	cmp	eax, [LastCluster]
  1249 0000B220 76DE                <1> 	jna	short loc_count_fc_next_cluster
  1250                              <1> 
  1251                              <1> loc_set_free_sectors:
  1252 0000B222 807E0302            <1> 	cmp	byte [esi+LD_FATType], 2
  1253 0000B226 7745                <1> 	ja	short loc_update_FAT32_fs_info_fcc
  1254                              <1> 
  1255                              <1> loc_set_free_sectors_FAT12_FAT16:
  1256 0000B228 803D[2A2B0100]00    <1> 	cmp	byte [CFS_OPType], 0
  1257 0000B22F 761C                <1> 	jna	short pass_FAT_add_sub_fcc
  1258 0000B231 A1[2C2B0100]        <1> 	mov	eax, [CFS_CC]
  1259 0000B236 803D[2A2B0100]01    <1> 	cmp	byte [CFS_OPType], 1
  1260 0000B23D 7708                <1> 	ja	short pass_FAT_add_fcc
  1261 0000B23F 0105[A3280100]      <1> 	add 	[FreeClusterCount], eax
  1262 0000B245 EB06                <1> 	jmp	short pass_FAT_add_sub_fcc
  1263                              <1> 
  1264                              <1> pass_FAT_add_fcc:
  1265 0000B247 2905[A3280100]      <1> 	sub	[FreeClusterCount], eax
  1266                              <1> 
  1267                              <1> pass_FAT_add_sub_fcc:
  1268 0000B24D 0FB64613            <1> 	movzx	eax, byte [esi+LD_BPB+SecPerClust]
  1269 0000B251 8B15[A3280100]      <1> 	mov	edx, [FreeClusterCount]
  1270 0000B257 F7E2                <1> 	mul	edx
  1271                              <1> 
  1272 0000B259 31C9                <1> 	xor	ecx, ecx 
  1273 0000B25B EB05                <1> 	jmp	short loc_cfs_retn_params
  1274                              <1> 
  1275                              <1> loc_put_fcc_invalid_sign:
  1276 0000B25D 29C0                <1>        	sub	eax, eax ; 0
  1277 0000B25F 48                  <1> 	dec	eax ; FFFFFFFFh
  1278                              <1> loc_fat32_ffc_recalc_needed:
  1279 0000B260 89C1                <1> 	mov	ecx, eax
  1280                              <1> 
  1281                              <1> loc_cfs_retn_params:
  1282 0000B262 894674              <1> 	mov 	[esi+LD_FreeSectors], eax
  1283 0000B265 0FB71D[2A2B0100]    <1> 	movzx	ebx, word [CFS_OPType]
  1284 0000B26C C3                  <1> 	retn
  1285                              <1> 
  1286                              <1> loc_update_FAT32_fs_info_fcc:
  1287                              <1> loc_check_fcc_FSINFO_op:
  1288                              <1> 	; 29/02/2016
  1289                              <1> 	; EAX = Free cluster count (before this update) ; value from disk
  1290                              <1> 	; EDX = First Free Cluster (before this update) ; value from disk
  1291 0000B26D 803D[2A2B0100]01    <1> 	cmp	byte [CFS_OPType], 1
  1292 0000B274 7221                <1> 	jb	short loc_cfs_FAT32_get_rcalc_parms ; 0 = recalculated
  1293 0000B276 7406                <1> 	je	short loc_check_fcc_FSINFO_op1 ; 1 = add
  1294                              <1> loc_check_fcc_FSINFO_op2: ; subtract
  1295 0000B278 F71D[2C2B0100]      <1> 	neg	dword [CFS_CC] ; prepare to subtract ; 2 = sub (add negative)
  1296                              <1> loc_check_fcc_FSINFO_op1:
  1297                              <1> 	; 01/03/2016
  1298 0000B27E 31D2                <1> 	xor	edx, edx ; 0
  1299 0000B280 4A                  <1> 	dec	edx ; 0FFFFFFFFh
  1300 0000B281 8B463A              <1> 	mov	eax, [esi+LD_BPB+BPB_Reserved]
  1301 0000B284 39D0                <1> 	cmp	eax, edx
  1302 0000B286 73D5                <1> 	jnb	short loc_put_fcc_invalid_sign
  1303 0000B288 0305[2C2B0100]      <1>         add     eax, [CFS_CC] ; free cluster count on disk + current count
  1304 0000B28E 72CD                <1> 	jc	short loc_put_fcc_invalid_sign
  1305                              <1> 	
  1306 0000B290 A3[A3280100]        <1> 	mov	[FreeClusterCount], eax
  1307 0000B295 EB0E                <1> 	jmp	short loc_cfs_write_FSINFO_sector
  1308                              <1> 
  1309                              <1> loc_cfs_FAT32_get_rcalc_parms:
  1310 0000B297 8B15[342B0100]      <1> 	mov	edx, [CFS_FAT32FC]
  1311 0000B29D A1[A3280100]        <1> 	mov	eax, [FreeClusterCount]
  1312 0000B2A2 89563E              <1> 	mov	[esi+LD_BPB+BPB_Reserved+4], edx ; First Free Cluster
  1313                              <1> loc_cfs_write_FSINFO_sector:
  1314 0000B2A5 89463A              <1> 	mov	[esi+LD_BPB+BPB_Reserved], eax ; Free cluster count
  1315                              <1> 	; 01/03/2016
  1316 0000B2A8 E89A000000          <1> 	call	set_fat32_fsinfo_sector_parms
  1317 0000B2AD 72AE                <1>         jc      short loc_put_fcc_invalid_sign
  1318                              <1> 
  1319                              <1> loc_set_FAT32_free_sectors:
  1320                              <1> 	; 29/02/2016
  1321                              <1> 	;mov	eax, [FreeClusterCount]
  1322                              <1> 	;mov	ecx, eax
  1323                              <1> 	;cmp	eax, 0FFFFFFFFh ; Invalid !
  1324                              <1> 	;je	short loc_cfs_retn_params
  1325                              <1> 	;
  1326 0000B2AF 8B0D[A3280100]      <1> 	mov	ecx, [FreeClusterCount]
  1327 0000B2B5 0FB64613            <1> 	movzx	eax, byte [esi+LD_BPB+SecPerClust]
  1328 0000B2B9 F7E1                <1> 	mul	ecx
  1329                              <1> 	; 29/02/2016
  1330 0000B2BB 31C9                <1> 	xor	ecx, ecx ; 0
  1331 0000B2BD 09D2                <1> 	or	edx, edx ; 0 ?
  1332 0000B2BF 759C                <1>         jnz     loc_put_fcc_invalid_sign
  1333 0000B2C1 394670              <1> 	cmp	[esi+LD_TotalSectors], eax ; Volume size in sectors
  1334 0000B2C4 7697                <1>         jna     short loc_put_fcc_invalid_sign
  1335                              <1> 	;
  1336                              <1> loc_set_FAT32_free_sectors_ok:
  1337 0000B2C6 31D2                <1> 	xor	edx, edx ; 0
  1338 0000B2C8 EB98                <1>         jmp     short loc_cfs_retn_params 
  1339                              <1> 	;
  1340                              <1> 
  1341                              <1> get_last_cluster:
  1342                              <1> 	; 27/02/2016 (TRDOS 386 =  TRDOS v2.0)
  1343                              <1> 	; 12/06/2010 (DRV_FAT.ASM, 'proc_get_last_custer')
  1344                              <1> 	; 06/06/2010
  1345                              <1> 	; INPUT ->
  1346                              <1> 	;	EAX = First Cluster Number
  1347                              <1> 	; 	ESI = Logical Dos Drive Parameters Table
  1348                              <1> 	; OUTPUT ->
  1349                              <1> 	;	cf = 0 -> No Error, EAX is valid
  1350                              <1> 	;	cf = 1 -> EAX > 0 -> Error
  1351                              <1> 	;	EAX = Last Cluster Number
  1352                              <1> 	;       ECX = Previous Cluster -just before the last cluster-
  1353                              <1> 	;
  1354                              <1> 	; (Modified registers: EAX, ECX, EBX, EDX)
  1355                              <1> 
  1356 0000B2CA 89C1                <1> 	mov	ecx, eax	
  1357                              <1> 
  1358                              <1> loc_glc_get_next_cluster_1:
  1359 0000B2CC 890D[382B0100]      <1> 	mov	[glc_prevcluster], ecx
  1360                              <1> 
  1361                              <1> loc_glc_get_next_cluster_2:
  1362 0000B2D2 E8F8F7FFFF          <1> 	call	get_next_cluster
  1363                              <1> 	; ecx = current/previous cluster 
  1364                              <1> 	; eax = next/last cluster
  1365 0000B2D7 73F3                <1> 	jnc	short loc_glc_get_next_cluster_1
  1366                              <1> 
  1367 0000B2D9 09C0                <1> 	or	eax, eax
  1368 0000B2DB 7509                <1> 	jnz	short loc_glc_stc_retn
  1369                              <1> 
  1370                              <1> 	; ecx = previous cluster
  1371 0000B2DD 89C8                <1>         mov	eax, ecx
  1372                              <1> 
  1373                              <1> 	; previous cluster becomes last cluster (ecx -> eax)
  1374                              <1> 	; previous of previous cluster becomes previous cluster (ecx)
  1375                              <1> 
  1376                              <1> loc_glc_prev_cluster_retn:
  1377 0000B2DF 8B0D[382B0100]      <1> 	mov	ecx, [glc_prevcluster] 
  1378 0000B2E5 C3                  <1> 	retn
  1379                              <1> 
  1380                              <1> loc_glc_stc_retn:
  1381 0000B2E6 F5                  <1> 	cmc	;stc
  1382 0000B2E7 EBF6                <1>         jmp	short loc_glc_prev_cluster_retn
  1383                              <1> 
  1384                              <1> truncate_cluster_chain:
  1385                              <1> 	; 01/03/2016
  1386                              <1> 	; 28/02/2016 (TRDOS 386 =  TRDOS v2.0)
  1387                              <1> 	; 22/01/2011 (DRV_FAT.ASM, 'proc_truncate_cluster_chain')
  1388                              <1> 	; 11/09/2010
  1389                              <1> 	; INPUT ->
  1390                              <1> 	;	ESI = Logical dos drive description table address
  1391                              <1> 	;	EAX = First cluster to be truncated/unlinked 
  1392                              <1> 	; OUTPUT ->
  1393                              <1> 	;	ESI = Logical dos drive description table address
  1394                              <1> 	; 	ECX = Count of truncated/removed clusters
  1395                              <1> 	; 	CF = 0 -> EAX = Free sectors
  1396                              <1> 	; 	CF = 1 -> Error code in EAX (AL)
  1397                              <1> 
  1398                              <1> 	; NOTE: This procedure does not update lm date&time ! 
  1399                              <1> 
  1400                              <1> loc_truncate_cc:	
  1401 0000B2E9 31C9                <1> 	xor	ecx, ecx ; mov ecx, 0
  1402                              <1> 	;mov	byte [FAT_BuffValidData], 0
  1403 0000B2EB 890D[8E280100]      <1> 	mov	[FAT_ClusterCounter], ecx ; 0 ; reset
  1404                              <1> 
  1405                              <1> loc_tcc_unlink_clusters:
  1406 0000B2F1 E803FBFFFF          <1> 	call	update_cluster
  1407                              <1> 	; EAX = Next Cluster
  1408                              <1> 	; ECX = Cluster Value
  1409                              <1> 	; Note:
  1410                              <1> 	; Returns count of unlinked clusters in
  1411                              <1> 	; dword ptr FAT_ClusterCounter
  1412 0000B2F6 73F9                <1> 	jnc short loc_tcc_unlink_clusters
  1413                              <1> 
  1414                              <1> pass_tcc_unlink_clusters:
  1415 0000B2F8 A2[3F2B0100]        <1> 	mov	byte [TCC_FATErr], al
  1416 0000B2FD 803D[86280100]02    <1> 	cmp	byte [FAT_BuffValidData], 2
  1417 0000B304 750E                <1> 	jne	short loc_tcc_calculate_FAT_freespace
  1418 0000B306 E8ABFDFFFF          <1> 	call	save_fat_buffer
  1419 0000B30B 7307                <1> 	jnc	short loc_tcc_calculate_FAT_freespace
  1420 0000B30D A2[3F2B0100]        <1> 	mov	byte [TCC_FATErr], al ; Error
  1421                              <1> 	;mov	byte [FAT_BuffValidData], 0
  1422                              <1> 
  1423                              <1> 	; 01/03/2016
  1424 0000B312 EB12                <1> 	jmp	short loc_tcc_recalculate_FAT_freespace
  1425                              <1> 
  1426                              <1> loc_tcc_calculate_FAT_freespace:
  1427 0000B314 A1[8E280100]        <1> 	mov	eax, [FAT_ClusterCounter] ; signed (+-) number
  1428 0000B319 66BB01FF            <1> 	mov	bx, 0FF01h ; BH = FFh -> ESI = Dos drv desc. table
  1429                              <1> 			   ; BL = 1 -> add cluster
  1430 0000B31D E829FEFFFF          <1> 	call	calculate_fat_freespace
  1431 0000B322 21C9                <1> 	and	ecx, ecx ; cx = 0 -> valid free sector count
  1432 0000B324 7409                <1> 	jz	short pass_truncate_cc_recalc_FAT_freespace
  1433                              <1> 
  1434                              <1> loc_tcc_recalculate_FAT_freespace:
  1435 0000B326 66BB00FF            <1> 	mov	bx, 0FF00h ; recalculate !
  1436 0000B32A E81CFEFFFF          <1> 	call	calculate_fat_freespace
  1437                              <1>               
  1438                              <1> loc_tcc_calculate_FAT_freespace_err:
  1439                              <1> pass_truncate_cc_recalc_FAT_freespace:
  1440 0000B32F 8B0D[8E280100]      <1> 	mov	ecx, [FAT_ClusterCounter]
  1441                              <1> 
  1442 0000B335 803D[3F2B0100]00    <1> 	cmp	byte [TCC_FATErr], 0
  1443 0000B33C 7608                <1> 	jna	short loc_tcc_unlink_clusters_retn
  1444                              <1> 
  1445                              <1> loc_tcc_unlink_clusters_error:
  1446 0000B33E 0FB605[3F2B0100]    <1> 	movzx	eax, byte [TCC_FATErr]
  1447 0000B345 F9                  <1> 	stc
  1448                              <1> loc_tcc_unlink_clusters_retn:
  1449 0000B346 C3                  <1> 	retn
  1450                              <1> 
  1451                              <1> set_fat32_fsinfo_sector_parms:
  1452                              <1> 	; 23/03/2016
  1453                              <1> 	; 29/02/2016 (TRDOS 386 =  TRDOS v2.0)
  1454                              <1> 	; INPUT ->
  1455                              <1> 	;	ESI = Logical dos drive description table address
  1456                              <1> 	;	[esi+LD_BPB+BPB_Reserved] = Free Cluster Count
  1457                              <1> 	;	[esi+LD_BPB+BPB_Reserved+4] = First Free Cluster 
  1458                              <1> 	; OUTPUT ->
  1459                              <1> 	;	ESI = Logical dos drive description table address
  1460                              <1> 	; 	CF = 0 -> OK..
  1461                              <1> 	; 	CF = 1 -> Error code in EAX (AL)
  1462                              <1> 	;
  1463                              <1> 	; (Modified registers: EAX, EBX, ECX, EDX)
  1464                              <1> 
  1465 0000B347 E824000000          <1> 	call	get_fat32_fsinfo_sector_parms
  1466 0000B34C 7221                <1> 	jc	short update_fat32_fsinfo_sector_retn
  1467                              <1> 
  1468 0000B34E 8B463A              <1> 	mov	eax, [esi+LD_BPB+BPB_Reserved] ; Free Cluster Count
  1469 0000B351 8B563E              <1> 	mov	edx, [esi+LD_BPB+BPB_Reserved+4] ; First free Cluster	
  1470                              <1> 
  1471                              <1>         ;mov	ebx, DOSBootSectorBuff
  1472 0000B354 8983E8010000        <1> 	mov	[ebx+488], eax
  1473 0000B35A 8993EC010000        <1> 	mov	[ebx+492], edx	
  1474                              <1> 
  1475 0000B360 A1[302B0100]        <1> 	mov	eax, [CFS_FAT32FSINFOSEC]
  1476 0000B365 B901000000          <1> 	mov	ecx, 1
  1477 0000B36A E87A260000          <1> 	call	disk_write
  1478                              <1> 	;jnc     short update_fat32_fsinfo_sector_retn
  1479                              <1> 
  1480                              <1> 	; 23/03/2016
  1481                              <1> 	;mov	eax, 1Dh ; Drive not ready or write error
  1482                              <1> 
  1483                              <1> update_fat32_fsinfo_sector_retn:
  1484 0000B36F C3                  <1> 	retn
  1485                              <1> 
  1486                              <1> get_fat32_fsinfo_sector_parms:
  1487                              <1> 	; 23/03/2016
  1488                              <1> 	; 01/03/2016
  1489                              <1> 	; 29/02/2016 (TRDOS 386 =  TRDOS v2.0)
  1490                              <1> 	; INPUT ->
  1491                              <1> 	;	ESI = Logical dos drive description table address
  1492                              <1> 	; OUTPUT ->
  1493                              <1> 	;	ESI = Logical dos drive description table address
  1494                              <1> 	;	EBX = FSINFO sector buffer address (DOSBootSectorBuff)	
  1495                              <1> 	;	CF = 0 -> OK..
  1496                              <1> 	;	   EAX = FsInfo sector address
  1497                              <1> 	;	   ECX = Free cluster count
  1498                              <1> 	;	   EDX = First free cluster 	
  1499                              <1> 	;	CF = 1 -> Error code in AL (EAX)
  1500                              <1> 	;	   EBX = 0
  1501                              <1> 	;	
  1502                              <1> 	;	[CFS_FAT32FSINFOSEC] = FAT32 FSINFO sector address
  1503                              <1>         ;
  1504                              <1> 	; (Modified registers: EAX, EBX, ECX, EDX)
  1505                              <1> 
  1506 0000B370 0FB74636            <1> 	movzx	eax, word [esi+LD_BPB+FAT32_FSInfoSec]
  1507 0000B374 03466C              <1> 	add	eax, [esi+LD_StartSector]
  1508 0000B377 A3[302B0100]        <1> 	mov	[CFS_FAT32FSINFOSEC], eax
  1509                              <1> 	
  1510 0000B37C BB[82260100]        <1>         mov     ebx, DOSBootSectorBuff
  1511 0000B381 B901000000          <1> 	mov	ecx, 1
  1512 0000B386 E86D260000          <1> 	call	disk_read
  1513 0000B38B 7232                <1> 	jc	short loc_read_FAT32_fsinfo_sec_err
  1514                              <1> 
  1515 0000B38D BB[82260100]        <1> 	mov	ebx, DOSBootSectorBuff
  1516                              <1> 
  1517 0000B392 813B52526141        <1> 	cmp	dword [ebx], 41615252h
  1518 0000B398 751E                <1> 	jne	short loc_read_FAT32_fsinfo_sec_stc
  1519                              <1> 
  1520 0000B39A 81BBE4010000727241- <1> 	cmp	dword [ebx+484], 61417272h
  1520 0000B3A3 61                  <1>
  1521 0000B3A4 7512                <1> 	jne	short loc_read_FAT32_fsinfo_sec_stc
  1522                              <1> 
  1523 0000B3A6 A1[302B0100]        <1> 	mov	eax, [CFS_FAT32FSINFOSEC]
  1524 0000B3AB 8B8BE8010000        <1> 	mov	ecx, [ebx+488] ; free cluster count
  1525 0000B3B1 8B93EC010000        <1> 	mov	edx, [ebx+492] ; first (next) free cluster	
  1526                              <1> 
  1527 0000B3B7 C3                  <1> 	retn
  1528                              <1> 
  1529                              <1> loc_read_FAT32_fsinfo_sec_stc:
  1530 0000B3B8 B80B000000          <1> 	mov	eax, 0Bh ; Invalid format!
  1531 0000B3BD EB05                <1> 	jmp	short loc_read_FAT32_fsinfo_sec_stc_retn
  1532                              <1> 
  1533                              <1> loc_read_FAT32_fsinfo_sec_err:
  1534                              <1> 	; 23/03/2016
  1535 0000B3BF B815000000          <1> 	mov	eax, 15h ; Drive not ready or read error
  1536                              <1> 
  1537                              <1> loc_read_FAT32_fsinfo_sec_stc_retn:
  1538 0000B3C4 29DB                <1> 	sub	ebx, ebx ; 0
  1539 0000B3C6 F9                  <1> 	stc
  1540 0000B3C7 C3                  <1> 	retn
  1541                              <1> 
  1542                              <1> add_new_cluster:
  1543                              <1> 	; 16/05/2016
  1544                              <1> 	; 24/03/2016
  1545                              <1> 	; 18/03/2016
  1546                              <1> 	; 11/03/2016 (TRDOS 386 =  TRDOS v2.0)
  1547                              <1> 	; 30/07/2011 (DRV_FAT.ASM)
  1548                              <1> 	; 11/09/2010
  1549                              <1> 	; INPUT ->
  1550                              <1> 	;	ESI = Logical dos drv desc. table address
  1551                              <1> 	;	EAX = Last cluster
  1552                              <1> 	; OUTPUT ->
  1553                              <1> 	;	ESI = Logical dos drv desc. table address
  1554                              <1> 	;	EAX = New Last cluster (next cluster)
  1555                              <1> 	;	cf = 1 -> error code in EAX (AL)
  1556                              <1> 	;	cf = 1 -> DX = sectors per cluster
  1557                              <1> 	;	ECX = Free sectors
  1558                              <1> 	; NOTE:
  1559                              <1> 	; This procedure does not update lm date&time !
  1560                              <1> 	;
  1561                              <1> 	; (Modified registers: EAX, EBX, ECX, EDX, EDI)
  1562                              <1> 	;
  1563                              <1> 
  1564 0000B3C8 A3[5C2C0100]        <1> 	mov	[FAT_anc_LCluster], eax
  1565                              <1> 	
  1566 0000B3CD E854F9FFFF          <1> 	call	get_first_free_cluster
  1567 0000B3D2 720B                <1> 	jc	short loc_add_new_cluster_retn
  1568                              <1> 	; EAX >= 2 and EAX < FFFFFFFFh is valid
  1569                              <1> 
  1570 0000B3D4 89C2                <1> 	mov	edx, eax
  1571                              <1> 
  1572 0000B3D6 42                  <1> 	inc	edx
  1573                              <1> 	;jnz	short loc_add_new_cluster_check_ffc_eax
  1574 0000B3D7 7516                <1> 	jnz	short loc_add_new_cluster_save_fcc
  1575                              <1> 
  1576                              <1> loc_add_new_cluster_no_disk_space_retn:
  1577 0000B3D9 B827000000          <1> 	mov	eax, 27h ; MSDOS err => insufficient disk space
  1578                              <1> loc_add_new_cluster_stc_retn:
  1579 0000B3DE F9                  <1> 	stc
  1580                              <1> loc_add_new_cluster_retn:
  1581 0000B3DF 0FB65E13            <1> 	movzx	ebx, byte [esi+LD_BPB+SecPerClust]
  1582 0000B3E3 8B4E74              <1> 	mov	ecx, [esi+LD_FreeSectors]
  1583                              <1> 	;xor	edx, edx
  1584                              <1> 	;stc
  1585 0000B3E6 C3                  <1> 	retn
  1586                              <1> 
  1587                              <1> loc_anc_invalid_format_stc_retn:
  1588 0000B3E7 F9                  <1> 	stc
  1589                              <1> loc_add_new_cluster_invalid_format_retn:
  1590 0000B3E8 B80B000000          <1> 	mov	eax, 0Bh ; Invalid format
  1591 0000B3ED EBF0                <1> 	jmp	short loc_add_new_cluster_retn 
  1592                              <1> 
  1593                              <1> ;loc_add_new_cluster_check_ffc_eax:
  1594                              <1> ;	cmp	eax, 2
  1595                              <1> ;	jb	short loc_add_new_cluster_invalid_format_retn
  1596                              <1> 
  1597                              <1> loc_add_new_cluster_save_fcc:  
  1598 0000B3EF A3[602C0100]        <1> 	mov	[FAT_anc_FFCluster], eax
  1599                              <1> 
  1600 0000B3F4 83E802              <1> 	sub	eax, 2
  1601 0000B3F7 0FB65E13            <1>         movzx   ebx, byte [esi+LD_BPB+SecPerClust]
  1602 0000B3FB F7E3                <1> 	mul	ebx
  1603 0000B3FD 09D2                <1> 	or	edx, edx
  1604 0000B3FF 75E6                <1> 	jnz	short loc_anc_invalid_format_stc_retn
  1605                              <1> 
  1606                              <1> loc_add_new_cluster_allocate_cluster:
  1607                              <1> 	; 18/03/2016
  1608 0000B401 92                  <1> 	xchg	edx, eax ; eax = 0
  1609                              <1> 	; 16/05/2016
  1610                              <1> 	;cmp	[ClusterBuffer_Valid], al ; 0
  1611                              <1> 	;jna	short loc_anc_clear_cluster_buffer
  1612                              <1> 	;; 'copy' command, 
  1613                              <1> 	;; writing destination file clust after reading source file clust
  1614                              <1> 	;mov	[ClusterBuffer_Valid], al ; 0 ; reset
  1615                              <1> 	;jmp	short loc_add_new_cluster_write_nc_to_disk
  1616                              <1> 
  1617                              <1> loc_anc_clear_cluster_buffer:
  1618                              <1> 	; 11/03/2016
  1619                              <1> 	; Clear buffer
  1620 0000B402 BF00000700          <1> 	mov	edi, Cluster_Buffer ; 70000h (for current TRDOS 386 version)
  1621 0000B407 89D9                <1> 	mov	ecx, ebx ; sector count
  1622 0000B409 C1E107              <1> 	shl	ecx, 7 ; 1 sector = 512 bytes -> 128 double words
  1623                              <1> 	;xor	eax, eax ; 0
  1624 0000B40C F3AB                <1> 	rep	stosd
  1625                              <1> 
  1626                              <1> loc_add_new_cluster_write_nc_to_disk:
  1627                              <1> 	; 11/03/2016
  1628                              <1> 	;xchg	eax, edx ; edx = 0, eax = sector offset
  1629 0000B40E 89D0                <1> 	mov	eax, edx
  1630 0000B410 034668              <1>         add     eax, [esi+LD_DATABegin]
  1631 0000B413 72D3                <1> 	jc	short loc_add_new_cluster_invalid_format_retn 
  1632                              <1> 		
  1633 0000B415 89D9                <1> 	mov	ecx, ebx ; ECX = sectors per cluster (<256)
  1634 0000B417 BB00000700          <1> 	mov	ebx, Cluster_Buffer
  1635 0000B41C E8C8250000          <1> 	call	disk_write
  1636 0000B421 7307                <1> 	jnc	short loc_add_new_cluster_update_fat_nlc
  1637                              <1> 	
  1638 0000B423 B81D000000          <1> 	mov	eax, 1Dh ; Write Error
  1639 0000B428 EBB4                <1> 	jmp	short loc_add_new_cluster_stc_retn
  1640                              <1> 
  1641                              <1> loc_add_new_cluster_update_fat_nlc:
  1642 0000B42A A1[602C0100]        <1> 	mov	eax, [FAT_anc_FFCluster]
  1643 0000B42F 31C9                <1> 	xor	ecx, ecx
  1644 0000B431 890D[8E280100]      <1> 	mov	[FAT_ClusterCounter], ecx ; 0 ; reset
  1645 0000B437 49                  <1> 	dec	ecx ; 0FFFFFFFFh
  1646 0000B438 E8BCF9FFFF          <1> 	call	update_cluster
  1647 0000B43D 7304                <1> 	jnc	short loc_add_new_cluster_update_fat_plc
  1648 0000B43F 09C0                <1> 	or	eax, eax ;EAX = 0 -> cluster value is 0 or eocc
  1649 0000B441 759B                <1> 	jnz	short loc_add_new_cluster_stc_retn
  1650                              <1> 
  1651                              <1> loc_add_new_cluster_update_fat_plc:
  1652 0000B443 A1[5C2C0100]        <1> 	mov	eax, [FAT_anc_LCluster]
  1653 0000B448 8B0D[602C0100]      <1> 	mov	ecx, [FAT_anc_FFCluster]
  1654 0000B44E E8A6F9FFFF          <1> 	call	update_cluster
  1655 0000B453 7314                <1> 	jnc	short loc_add_new_cluster_save_fat_buffer
  1656 0000B455 09C0                <1> 	or	eax, eax ; EAX = 0 -> cluster value is 0 or eocc
  1657 0000B457 7410                <1> 	jz	short loc_add_new_cluster_save_fat_buffer
  1658                              <1> 
  1659                              <1> loc_anc_save_fat_buffer_err_retn:
  1660                              <1> 	;cmp	byte [FAT_ClusterCounter], 1
  1661                              <1> 	;jb	short loc_add_new_cluster_retn
  1662                              <1> 
  1663 0000B459 66BB00FF            <1> 	mov	bx, 0FF00h ; recalculate free space (BL = 0)
  1664                              <1> 			   ; (BH = FFh -> Use ESI as Drv Param. Tbl.)
  1665 0000B45D 50                  <1> 	push	eax
  1666 0000B45E E8E8FCFFFF          <1> 	call	calculate_fat_freespace
  1667 0000B463 58                  <1> 	pop	eax
  1668 0000B464 E975FFFFFF          <1>         jmp     loc_add_new_cluster_stc_retn
  1669                              <1> 
  1670                              <1> loc_add_new_cluster_save_fat_buffer:
  1671                              <1> 	;cmp	byte [FAT_BuffValidData], 2
  1672                              <1> 	;jne	short loc_add_new_cluster_calc_FAT_freespace 
  1673                              <1> 	;Byte [FAT_BuffValidData] =  2 
  1674 0000B469 E848FCFFFF          <1> 	call	save_fat_buffer
  1675 0000B46E 72E9                <1> 	jc	short loc_anc_save_fat_buffer_err_retn
  1676                              <1> 
  1677                              <1> loc_add_new_cluster_calc_FAT_freespace:
  1678                              <1> 	;mov	eax, 1 ; Only one Cluster
  1679 0000B470 A1[8E280100]        <1> 	mov	eax, [FAT_ClusterCounter]
  1680 0000B475 66BB01FF            <1> 	mov	bx, 0FF01h ; BH = FFh -> ESI -> Dos drv desc. table
  1681                              <1> 		; BL = 1 -> add cluster
  1682 0000B479 B301                <1> 	mov	bl, 01h ; BL = 1 -> add clusters
  1683                              <1> 	; NOTE: EAX value will be added to Free Cluster Count
  1684                              <1> 	; (Free Cluster Count is decreased when EAX value is negative)
  1685 0000B47B E8CBFCFFFF          <1>         call    calculate_fat_freespace
  1686                              <1> 	;ECX = 0 -> no error, ECX > 0 -> error or invalid return
  1687 0000B480 21C9                <1> 	and	ecx, ecx ; ECX = 0 -> valid free sector count
  1688 0000B482 7409                <1> 	jz	short loc_add_new_cluster_return_cluster_number
  1689                              <1> 
  1690                              <1> loc_add_new_cluster_recalc_FAT_freespace:
  1691 0000B484 66BB00FF            <1> 	mov	bx, 0FF00h  ; recalculate free space
  1692 0000B488 E8BEFCFFFF          <1>         call    calculate_fat_freespace
  1693                              <1> 	; cf = 0
  1694                              <1> loc_add_new_cluster_return_cluster_number:
  1695 0000B48D 89C1                <1> 	mov	ecx, eax ; Free sector count
  1696 0000B48F A1[602C0100]        <1> 	mov	eax, [FAT_anc_FFCluster]
  1697 0000B494 0FB65E13            <1> 	movzx	ebx, byte [esi+LD_BPB+SecPerClust]
  1698                              <1> 	;mov	edi, Cluster_Buffer
  1699 0000B498 31D2                <1> 	xor	edx, edx
  1700 0000B49A C3                  <1>         retn
  1701                              <1> 
  1702                              <1> write_cluster:
  1703                              <1> 	; 21/03/2016 (TRDOS 386 =  TRDOS v2.0)
  1704                              <1> 	;
  1705                              <1> 	; INPUT ->
  1706                              <1> 	;	EAX = Cluster Number (Sector index for SINGLIX FS)
  1707                              <1> 	;	ESI = Logical DOS Drive Description Table address
  1708                              <1> 	;	EBX = Cluster (File R/W) Buffer address (max. 64KB)
  1709                              <1> 	;	Only for SINGLIX FS:
  1710                              <1> 	;	EDX = File Number (The 1st FDT address) 
  1711                              <1> 	; OUTPUT ->
  1712                              <1> 	;	cf = 1 -> Cluster can not be written onto disk
  1713                              <1> 	;	    EAX > 0 -> Error number
  1714                              <1> 	;	cf = 0 -> Cluster has been written successfully
  1715                              <1> 	;
  1716                              <1> 	; (Modified registers: EAX, ECX, EBX, EDX)
  1717                              <1> 	
  1718 0000B49B 0FB64E13            <1> 	movzx	ecx, byte [esi+LD_BPB+BPB_SecPerClust] 
  1719                              <1> 	; CL = 1 = [esi+LD_FS_Reserved2] ; SectPerClust for Singlix FS
  1720                              <1> 
  1721                              <1> write_file_sectors: ; 16/03/2016
  1722 0000B49F 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
  1723 0000B4A3 761C                <1> 	jna	short write_fs_cluster
  1724                              <1> 
  1725                              <1> write_fat_file_sectors: 
  1726 0000B4A5 83E802              <1> 	sub	eax, 2 ; Beginning cluster number is always 2
  1727 0000B4A8 0FB65613            <1> 	movzx	edx, byte [esi+LD_BPB+BPB_SecPerClust] ; 18/03/2016 
  1728 0000B4AC F7E2                <1> 	mul	edx
  1729 0000B4AE 034668              <1> 	add	eax, [esi+LD_DATABegin] ; absolute address of the cluster
  1730                              <1> 
  1731                              <1> 	; EAX = Disk sector address
  1732                              <1> 	; ECX = Sector count
  1733                              <1> 	; EBX = Buffer address
  1734                              <1> 	; (EDX = 0)
  1735                              <1> 	; ESI = Logical DOS drive description table address	
  1736                              <1> 
  1737 0000B4B1 E833250000          <1> 	call	disk_write
  1738 0000B4B6 7306                <1> 	jnc	short wclust_retn
  1739                              <1> 	
  1740 0000B4B8 B81D000000          <1> 	mov	eax, 1Dh ; Drive not ready or write error !
  1741 0000B4BD C3                  <1> 	retn
  1742                              <1> 
  1743                              <1> wclust_retn:
  1744 0000B4BE 29C0                <1> 	sub	eax, eax ; 0
  1745 0000B4C0 C3                  <1> 	retn
  1746                              <1> 
  1747                              <1> write_fs_cluster:
  1748                              <1> 	; 21/03/2016 (TRDOS 386 =  TRDOS v2.0)
  1749                              <1> 	; Singlix FS
  1750                              <1> 	
  1751                              <1> 	; EAX = Cluster number is sector index number of the file (eax)
  1752                              <1> 	
  1753                              <1> 	; EDX = File number is the first File Descriptor Table address 
  1754                              <1> 	;	of the file. (Absolute address of the FDT).
  1755                              <1> 	
  1756                              <1> 	; eax = sector index (0 for the first sector)
  1757                              <1> 	; edx = FDT0 address
  1758                              <1> 		; 64 KB buffer = 128 sectors (limit) 
  1759 0000B4C1 B980000000          <1> 	mov	ecx, 128 ; maximum count of sectors (before eof) 
  1760 0000B4C6 E801000000          <1> 	call	write_fs_sectors
  1761 0000B4CB C3                  <1> 	retn
  1762                              <1> 
  1763                              <1> write_fs_sectors:
  1764                              <1> 	; 21/03/2016 (TRDOS 386 =  TRDOS v2.0)
  1765 0000B4CC F9                  <1> 	stc
  1766 0000B4CD C3                  <1> 	retn
  1767                              <1> 
  1768                              <1> get_cluster_by_index:
  1769                              <1> 	; 29/04/2016 (TRDOS 386 =  TRDOS v2.0)
  1770                              <1> 	; INPUT ->
  1771                              <1> 	; 	EAX = Beginning cluster
  1772                              <1> 	; 	EDX = Sector index in disk/file section
  1773                              <1> 	;	      (Only for SINGLIX file system!)
  1774                              <1> 	; 	ECX = Cluster sequence number after the beginning cluster
  1775                              <1> 	; 	ESI = Logical DOS Drive Description Table address
  1776                              <1> 	; OUTPUT ->
  1777                              <1> 	;	EAX = Cluster number 
  1778                              <1> 	;	cf = 1 -> Error code in AL (EAX)
  1779                              <1> 	;
  1780                              <1> 	;(Modified registers: EAX, ECX, EBX, EDX)
  1781                              <1> 	;	
  1782 0000B4CE 807E0301            <1> 	cmp	byte [esi+LD_FATType], 1
  1783 0000B4D2 721E                <1>         jb      get_fs_section_by_index 
  1784                              <1> 
  1785 0000B4D4 3B4E78              <1> 	cmp	ecx, [esi+LD_Clusters]
  1786 0000B4D7 7207                <1> 	jb	short gcbi_1
  1787                              <1> gcbi_0:
  1788 0000B4D9 F9                  <1> 	stc
  1789 0000B4DA B823000000          <1> 	mov	eax, 23h ; Cluster not available ! 
  1790                              <1> 			 ; MSDOS error code: FCB unavailable
  1791 0000B4DF C3                  <1> 	retn
  1792                              <1> gcbi_1:
  1793 0000B4E0 51                  <1> 	push	ecx
  1794 0000B4E1 E8E9F5FFFF          <1> 	call	get_next_cluster
  1795 0000B4E6 59                  <1> 	pop	ecx
  1796 0000B4E7 7203                <1> 	jc	short gcbi_3
  1797 0000B4E9 E2F5                <1> 	loop	gcbi_1
  1798                              <1> gcbi_2:
  1799 0000B4EB C3                  <1> 	retn
  1800                              <1> gcbi_3:
  1801 0000B4EC 09C0                <1> 	or	eax, eax
  1802 0000B4EE 74E9                <1> 	jz	short gcbi_0
  1803 0000B4F0 F5                  <1> 	cmc 	; stc
  1804 0000B4F1 C3                  <1> 	retn
  1805                              <1> 
  1806                              <1> get_fs_section_by_index:
  1807                              <1> 	; 29/04/2016 (TRDOS 386 =  TRDOS v2.0)
  1808                              <1> 	; INPUT ->
  1809                              <1> 	; 	EAX = Beginning FDT number/address
  1810                              <1> 	; 	EDX = Sector index in disk/file section
  1811                              <1> 	; 	ECX = Sector sequence number after the beginning FDT
  1812                              <1> 	; 	ESI = Logical DOS Drive Description Table address
  1813                              <1> 	; OUTPUT ->
  1814                              <1> 	; 	EAX = FDT number/address
  1815                              <1> 	; 	EDX = Sector index from FDT sector (0,1,2,3,4...)
  1816                              <1> 	;	cf = 1 -> Error code in AL (EAX)
  1817                              <1> 	;
  1818                              <1> 	;(Modified registers: EAX, ECX, EBX, EDX)
  1819                              <1> 	;
  1820 0000B4F2 B8FFFFFFFF          <1> 	mov	eax, 0FFFFFFFFh
  1821 0000B4F7 C3                  <1> 	retn
  1923                                  %include 'trdosk6.s' ; 24/01/2016
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.0) - MAIN PROGRAM : trdosk6.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 11/07/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 '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> 
    14                              <1> sysent: ; < enter to system call >
    15                              <1> 	; 06/06/2016
    16                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
    17                              <1> 	; 16/04/2015 - 19/10/2015 (Retro UNIX 386 v1)
    18                              <1> 	; 10/04/2013 - 18/01/2014 (Retro UNIX 8086 v1)
    19                              <1> 	;
    20                              <1> 	; 'unkni' or 'sysent' is sytem entry from various traps. 
    21                              <1> 	; The trap type is determined and an indirect jump is made to 
    22                              <1> 	; the appropriate system call handler. If there is a trap inside
    23                              <1> 	; the system a jump to panic is made. All user registers are saved 
    24                              <1> 	; and u.sp points to the end of the users stack. The sys (trap)
    25                              <1> 	; instructor is decoded to get the the system code part (see
    26                              <1> 	; trap instruction in the PDP-11 handbook) and from this 
    27                              <1> 	; the indirect jump address is calculated. If a bad system call is
    28                              <1> 	; made, i.e., the limits of the jump table are exceeded, 'badsys'
    29                              <1> 	; is called. If the call is legitimate control passes to the
    30                              <1> 	; appropriate system routine.
    31                              <1> 	;
    32                              <1> 	; Calling sequence:
    33                              <1> 	;	Through a trap caused by any sys call outside the system.
    34                              <1> 	; Arguments:
    35                              <1> 	;	Arguments of particular system call.	
    36                              <1> 	; ...............................................................
    37                              <1> 	;	
    38                              <1> 	; Retro UNIX 8086 v1 modification: 
    39                              <1> 	;       System call number is in EAX register.
    40                              <1> 	;
    41                              <1> 	;       Other parameters are in EDX, EBX, ECX, ESI, EDI, EBP
    42                              <1> 	;	registers depending of function details.
    43                              <1>   	;
    44                              <1> 	; 16/04/2015
    45 0000B4F8 368925[80300100]    <1>         mov     [ss:u.sp], esp ; Kernel stack points to return address
    46                              <1> 	; save user registers
    47 0000B4FF 1E                  <1> 	push	ds
    48 0000B500 06                  <1> 	push	es
    49 0000B501 0FA0                <1> 	push	fs
    50 0000B503 0FA8                <1> 	push	gs
    51 0000B505 60                  <1> 	pushad  ; eax, ecx, edx, ebx, esp -before pushad-, ebp, esi, edi
    52                              <1> 	;
    53                              <1> 	; ESPACE = [ss:u.sp] - esp ; 4*12 = 48 ; 17/09/2015 ; 06/06/2016
    54                              <1> 	; 	(ESPACE is size of space in kernel stack 
    55                              <1> 	;	for saving/restoring user registers.)
    56                              <1> 	;
    57 0000B506 50                  <1> 	push	eax ; 01/07/2015
    58 0000B507 66B81000            <1> 	mov     ax, KDATA
    59 0000B50B 8ED8                <1>         mov     ds, ax
    60 0000B50D 8EC0                <1>         mov     es, ax
    61 0000B50F 8EE0                <1>         mov     fs, ax
    62 0000B511 8EE8                <1>         mov     gs, ax
    63 0000B513 A1[A81F0100]        <1> 	mov	eax, [k_page_dir]
    64 0000B518 0F22D8              <1> 	mov	cr3, eax
    65 0000B51B 58                  <1> 	pop	eax ; 01/07/2015
    66                              <1> 	; 19/10/2015
    67 0000B51C FC                  <1> 	cld
    68                              <1> 	;
    69 0000B51D FE05[7F300100]      <1> 	inc	byte [sysflg]
    70                              <1> 		; incb sysflg / indicate a system routine is in progress
    71 0000B523 FB                  <1>         sti 	; 18/01/2014
    72 0000B524 0F855CA0FFFF        <1> 	jnz     panic ; 24/05/2013
    73                              <1> 		; beq 1f
    74                              <1> 		; jmp panic ; / called if trap inside system
    75                              <1> ;1:
    76                              <1> 	; 16/04/2015
    77 0000B52A A3[88300100]        <1> 	mov	[u.r0], eax
    78 0000B52F 8925[84300100]      <1> 	mov	[u.usp], esp ; kernel stack points to user's registers
    79                              <1> 	;
    80                              <1> 		; mov $s.syst+2,clockp
    81                              <1> 		; mov r0,-(sp) / save user registers 
    82                              <1> 		; mov sp,u.r0 / pointer to bottom of users stack 
    83                              <1> 			   ; / in u.r0
    84                              <1> 		; mov r1,-(sp)
    85                              <1> 		; mov r2,-(sp)
    86                              <1> 		; mov r3,-(sp)
    87                              <1> 		; mov r4,-(sp)
    88                              <1> 		; mov r5,-(sp)
    89                              <1> 		; mov ac,-(sp) / "accumulator" register for extended
    90                              <1> 		             ; / arithmetic unit
    91                              <1> 		; mov mq,-(sp) / "multiplier quotient" register for the
    92                              <1> 		             ; / extended arithmetic unit
    93                              <1> 		; mov sc,-(sp) / "step count" register for the extended
    94                              <1> 		             ; / arithmetic unit
    95                              <1> 		; mov sp,u.sp / u.sp points to top of users stack
    96                              <1> 		; mov 18.(sp),r0 / store pc in r0
    97                              <1> 		; mov -(r0),r0 / sys inst in r0      10400xxx
    98                              <1> 		; sub $sys,r0 / get xxx code
    99 0000B535 C1E002              <1> 	shl	eax, 2
   100                              <1> 		; asl r0 / multiply by 2 to jump indirect in bytes
   101 0000B538 3DA0000000          <1> 	cmp	eax, end_of_syscalls - syscalls
   102                              <1> 		; cmp r0,$2f-1f / limit of table (35) exceeded
   103                              <1> 	;jnb	short badsys
   104                              <1> 		; bhis badsys / yes, bad system call
   105 0000B53D F5                  <1> 	cmc
   106 0000B53E 9C                  <1> 	pushf	
   107 0000B53F 50                  <1> 	push	eax
   108 0000B540 8B2D[80300100]      <1>  	mov 	ebp, [u.sp] ; Kernel stack at the beginning of sys call
   109 0000B546 B0FE                <1> 	mov	al, 0FEh ; 11111110b
   110 0000B548 1400                <1> 	adc	al, 0 ; al = al + cf
   111 0000B54A 204508              <1> 	and	[ebp+8], al ; flags (reset carry flag)
   112                              <1> 		; bic $341,20.(sp) / set users processor priority to 0 
   113                              <1> 				 ; / and clear carry bit
   114 0000B54D 5D                  <1> 	pop	ebp ; eax
   115 0000B54E 9D                  <1> 	popf
   116 0000B54F 0F8254010000        <1>         jc      badsys
   117 0000B555 A1[88300100]        <1> 	mov	eax, [u.r0]
   118                              <1> 	; system call registers: EAX, EDX, ECX, EBX, ESI, EDI
   119 0000B55A FFA5[60B50000]      <1> 	jmp	dword [ebp+syscalls]
   120                              <1> 		; jmp *1f(r0) / jump indirect thru table of addresses
   121                              <1> 		            ; / to proper system routine.
   122                              <1> syscalls: ; 1:
   123                              <1> 	; 20/05/2016
   124                              <1> 	; 19/05/2016
   125                              <1> 	; 16/05/2016
   126                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
   127                              <1> 	; 21/09/2015
   128                              <1> 	; 01/07/2015
   129                              <1> 	; 16/04/2015 (32 bit address modification) 
   130                              <1> 	;dd sysrele	; / 0
   131 0000B560 [85D80000]          <1> 	dd sysver	; 0 ; Get TRDOS 386 version number (v2.0)	
   132 0000B564 [09B70000]          <1> 	dd sysexit 	; / 1
   133 0000B568 [73B80000]          <1> 	dd sysfork 	; / 2
   134 0000B56C [86B90000]          <1> 	dd sysread 	; / 3
   135 0000B570 [A1B90000]          <1> 	dd syswrite 	; / 4
   136 0000B574 [0BBA0000]          <1> 	dd sysopen 	; / 5
   137 0000B578 [45BB0000]          <1> 	dd sysclose 	; / 6
   138 0000B57C [F5B70000]          <1> 	dd syswait 	; / 7
   139 0000B580 [BBBA0000]          <1> 	dd syscreat 	; / 8
   140 0000B584 [52C60000]          <1> 	dd syslink 	; / 9
   141 0000B588 [14C70000]          <1> 	dd sysunlink 	; / 10
   142 0000B58C [E7C70000]          <1> 	dd sysexec 	; / 11
   143 0000B590 [41CC0000]          <1> 	dd syschdir 	; / 12
   144 0000B594 [25CD0000]          <1> 	dd systime 	; / 13
   145 0000B598 [FCBA0000]          <1> 	dd sysmkdir 	; / 14
   146 0000B59C [93CC0000]          <1> 	dd syschmod 	; / 15
   147 0000B5A0 [F5CC0000]          <1> 	dd syschown 	; / 16
   148 0000B5A4 [58CD0000]          <1> 	dd sysbreak 	; / 17
   149 0000B5A8 [B2C90000]          <1> 	dd sysstat 	; / 18
   150 0000B5AC [1DCE0000]          <1> 	dd sysseek 	; / 19
   151 0000B5B0 [2FCE0000]          <1> 	dd systell 	; / 20
   152 0000B5B4 [30CF0000]          <1> 	dd sysmount 	; / 21
   153 0000B5B8 [E2CF0000]          <1> 	dd sysumount 	; / 22
   154 0000B5BC [ADCE0000]          <1> 	dd syssetuid 	; / 23
   155 0000B5C0 [DECE0000]          <1> 	dd sysgetuid 	; / 24
   156 0000B5C4 [34CD0000]          <1> 	dd sysstime 	; / 25
   157 0000B5C8 [A1CE0000]          <1> 	dd sysquit 	; / 26
   158 0000B5CC [95CE0000]          <1> 	dd sysintr 	; / 27
   159 0000B5D0 [8EC90000]          <1> 	dd sysfstat 	; / 28
   160 0000B5D4 [61BB0000]          <1> 	dd sysemt 	; / 29
   161 0000B5D8 [A6BC0000]          <1> 	dd sysmdate 	; / 30
   162                              <1> 	;dd sysstty	; / 31
   163 0000B5DC [F1BC0000]          <1> 	dd sysvideo 	; 31 ; TRDOS 386 Video Functions (16/05/2016)
   164                              <1> 	;dd sysgtty	; / 32
   165 0000B5E0 [40C60000]          <1> 	dd sysaudio 	; 32 ; TRDOS 386 Audio Functions (16/05/2016)
   166                              <1> 	;dd sysilgins	; / 33
   167 0000B5E4 [7ABB0000]          <1> 	dd systimer 	; 33 ; TRDOS 386 Timer Functions (18/05/2016)
   168 0000B5E8 [3DD00000]          <1> 	dd syssleep 	; 34 ; Retro UNIX 8086 v1 feature only !
   169                              <1> 			     ; 11/06/2014
   170 0000B5EC [6CD00000]          <1> 	dd sysmsg	; 35 ; Retro UNIX 386 v1 feature only !
   171                              <1> 			     ; 01/07/2015
   172 0000B5F0 [42D10000]          <1> 	dd sysgeterr	; 36 ; Retro UNIX 386 v1 feature only !
   173                              <1> 			     ; 21/09/2015 - get last error number
   174 0000B5F4 [94D80000]          <1> 	dd sysreserved1 ; 37 ;; TRDOS 386 (19/05/2016)
   175 0000B5F8 [A3D80000]          <1> 	dd syspri 	; 38 ; change priority - TRDOS 386 (20/05/2016)
   176 0000B5FC [73B60000]          <1> 	dd sysrele	; 39 ; TRDOS 386 (19/05/2016) (0 -> 39)
   177                              <1> 
   178                              <1> end_of_syscalls:
   179                              <1> 
   180                              <1> error:
   181                              <1> 	; 18/05/2016
   182                              <1> 	; 13/05/2016
   183                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
   184                              <1> 	; 16/04/2015 - 17/09/2015 (Retro UNIX 386 v1)
   185                              <1> 	; 10/04/2013 - 07/08/2013 (Retro UNIX 8086 v1)
   186                              <1> 	;
   187                              <1> 	; 'error' merely sets the error bit off the processor status (c-bit)
   188                              <1> 	; then falls right into the 'sysret', 'sysrele' return sequence.
   189                              <1> 	;
   190                              <1> 	; INPUTS -> none
   191                              <1> 	; OUTPUTS ->
   192                              <1> 	;	processor status - carry (c) bit is set (means error)
   193                              <1> 	;
   194                              <1> 	; 26/05/2013 (Stack pointer must be reset here! 
   195                              <1> 	; 	      Because, jumps to error procedure
   196                              <1> 	;	      disrupts push-pop nesting balance)
   197                              <1> 	;
   198 0000B600 8B2D[80300100]      <1> 	mov	ebp, [u.sp] ; interrupt (system call) return (iretd) address
   199 0000B606 804D0801            <1> 	or	byte [ebp+8], 1  ; set carry bit of flags register
   200                              <1> 				 ; (system call will return with cf = 1)
   201                              <1> 		; bis $1,20.(r1) / set c bit in processor status word below
   202                              <1> 		               ; / users stack
   203                              <1> 	; 17/09/2015
   204 0000B60A 83ED30              <1> 	sub	ebp, ESPACE ; 48 ; total size of stack frame ('sysdefs.inc')
   205                              <1> 				 ; for saving/restoring user registers	
   206                              <1> 	;cmp	ebp, [u.usp]
   207                              <1> 	;je	short err0	
   208 0000B60D 892D[84300100]      <1> 	mov	[u.usp], ebp
   209                              <1> ;err0:
   210                              <1> 	; 01/09/2015
   211 0000B613 8B25[84300100]      <1> 	mov	esp, [u.usp] 	    ; Retro Unix 8086 v1 modification!
   212                              <1> 				    ; 10/04/2013
   213                              <1> 				    ; (If an I/O error occurs during disk I/O,
   214                              <1> 				    ; related procedures will jump to 'error'
   215                              <1> 				    ; procedure directly without returning to 
   216                              <1> 				    ; the caller procedure. So, stack pointer
   217                              <1>                                     ; must be restored here.)
   218                              <1> 	; 13/05/2016
   219                              <1> 	; NOTE: (The last) error code is in 'u.error', it can be retrieved by
   220                              <1> 	;	'get last error' system call later. 	
   221                              <1> 
   222                              <1> 	; 03/09/2015 - 09/06/2015 - 07/08/2013
   223 0000B619 C605[EF300100]00    <1> 	mov 	byte [u.kcall], 0 ; namei_r, mkdir_w reset
   224                              <1> 
   225                              <1> sysret: ; < return from system call>
   226                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
   227                              <1> 	; 16/04/2015 - 10/09/2015 (Retro UNIX 386 v1)
   228                              <1> 	; 10/04/2013 - 23/02/2014 (Retro UNIX 8086 v1)
   229                              <1> 	;
   230                              <1> 	; 'sysret' first checks to see if process is about to be 
   231                              <1> 	; terminated (u.bsys). If it is, 'sysexit' is called.
   232                              <1> 	; If not, following happens:	 
   233                              <1> 	; 	1) The user's stack pointer is restored.
   234                              <1> 	;	2) r1=0 and 'iget' is called to see if last mentioned
   235                              <1> 	;	   i-node has been modified. If it has, it is written out
   236                              <1> 	;	   via 'ppoke'.
   237                              <1> 	;	3) If the super block has been modified, it is written out
   238                              <1> 	;	   via 'ppoke'.				
   239                              <1> 	;	4) If the dismountable file system's super block has been
   240                              <1> 	;	   modified, it is written out to the specified device
   241                              <1> 	;	   via 'ppoke'.
   242                              <1> 	;	5) A check is made if user's time quantum (uquant) ran out
   243                              <1> 	;	   during his execution. If so, 'tswap' is called to give
   244                              <1> 	;	   another user a chance to run.
   245                              <1> 	;	6) 'sysret' now goes into 'sysrele'. 
   246                              <1> 	;	    (See 'sysrele' for conclusion.)		
   247                              <1> 	;
   248                              <1> 	; Calling sequence:
   249                              <1> 	;	jump table or 'br sysret'
   250                              <1> 	; Arguments: 
   251                              <1> 	;	-	
   252                              <1> 	; ...............................................................
   253                              <1> 	;	
   254                              <1> 	; ((AX=r1 for 'iget' input))
   255                              <1> 	;	
   256 0000B620 6631C0              <1> 	xor	ax, ax ; 04/05/2013
   257                              <1> sysret0: ; 29/07/2015 (eax = 0, jump from sysexec)
   258 0000B623 FEC0                <1> 	inc	al ; 04/05/2013
   259 0000B625 3805[D6300100]      <1> 	cmp	[u.bsys], al ; 1
   260                              <1> 		; tstb u.bsys / is a process about to be terminated because
   261 0000B62B 0F83D8000000        <1>         jnb     sysexit ; 04/05/2013
   262                              <1> 		; bne sysexit / of an error? yes, go to sysexit
   263                              <1> 	;mov	esp, [u.usp] ; 24/05/2013 (that is not needed here)
   264                              <1> 		; mov u.sp,sp / no point stack to users stack
   265 0000B631 FEC8                <1> 	dec 	al ; mov ax, 0
   266                              <1> 		; clr r1 / zero r1 to check last mentioned i-node
   267 0000B633 E89E230000          <1> 	call	iget
   268                              <1> 		; jsr r0,iget / if last mentioned i-node has been modified
   269                              <1> 		            ; / it is written out
   270 0000B638 6631C0              <1> 	xor 	ax, ax ; 0
   271 0000B63B 3805[7D300100]      <1> 	cmp	[smod], al ; 0
   272                              <1> 		; tstb	smod / has the super block been modified
   273 0000B641 7614                <1> 	jna	short sysret1
   274                              <1> 		; beq	1f / no, 1f
   275 0000B643 A2[7D300100]        <1> 	mov	[smod], al ; 0
   276                              <1> 		; clrb smod / yes, clear smod
   277 0000B648 BB[35390100]        <1> 	mov	ebx, sb0 ;; 07/08//2013
   278 0000B64D 66810B0002          <1>    	or	word [ebx], 200h ;;
   279                              <1> 	;or	word [sb0], 200h ; write bit, bit 9
   280                              <1> 		; bis $1000,sb0 / set write bit in I/O queue for super block
   281                              <1> 		      	      ; / output
   282                              <1> 	; AX = 0
   283 0000B652 E880230000          <1> 	call 	poke ; 07/08/2013
   284                              <1> 	; call	ppoke
   285                              <1> 	; AX = 0
   286                              <1> 		; jsr r0,ppoke / write out modified super block to disk
   287                              <1> sysret1: ;1:
   288 0000B657 3805[7E300100]      <1> 	cmp	[mmod], al ; 0
   289                              <1> 		; tstb	mmod / has the super block for the dismountable file
   290                              <1> 		           ; / system
   291 0000B65D 7614                <1> 	jna	short sysrel0
   292                              <1> 		; beq 1f / been modified?  no, 1f
   293 0000B65F A2[7E300100]        <1> 	mov	[mmod], al ; 0	
   294                              <1> 		; clrb	mmod / yes, clear mmod
   295                              <1>         ;mov    ax, [mntd]
   296                              <1>         ;;mov   al, [mdev] ; 26/04/2013
   297 0000B664 BB[3D3B0100]        <1> 	mov	ebx, sb1 ;; 07/08//2013
   298                              <1>         ;;mov	[ebx], al
   299                              <1> 	;mov    [sb1], al
   300                              <1> 		; movb	mntd,sb1 / set the I/O queue
   301 0000B669 66810B0002          <1> 	or	word [ebx], 200h
   302                              <1> 	;or	word [sb1], 200h ; write bit, bit 9
   303                              <1> 		; bis $1000,sb1 / set write bit in I/O queue for detached sb
   304 0000B66E E864230000          <1> 	call	poke ; 07/08/2013
   305                              <1> 	;call	ppoke 
   306                              <1> 		; jsr r0,ppoke / write it out to its device
   307                              <1>         ;xor    al, al ; 26/04/2013       
   308                              <1> ;1:
   309                              <1> 		; tstb uquant / is the time quantum 0?
   310                              <1> 		; bne 1f / no, don't swap it out
   311                              <1> 
   312                              <1> sysrele: ; < release >
   313                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
   314                              <1> 	; 16/04/2015 - 14/10/2015 (Retro UNIX 386 v1)
   315                              <1> 	; 10/04/2013 - 07/03/2014 (Retro UNIX 8086 v1)
   316                              <1> 	;
   317                              <1> 	; 'sysrele' first calls 'tswap' if the time quantum for a user is
   318                              <1> 	;  zero (see 'sysret'). It then restores the user's registers and
   319                              <1> 	; turns off the system flag. It then checked to see if there is
   320                              <1> 	; an interrupt from the user by calling 'isintr'. If there is, 
   321                              <1> 	; the output gets flashed (see isintr) and interrupt action is
   322                              <1> 	; taken by a branch to 'intract'. If there is no interrupt from
   323                              <1> 	; the user, a rti is made.
   324                              <1> 	;
   325                              <1> 	; Calling sequence:
   326                              <1> 	;	Fall through a 'bne' in 'sysret' & ?
   327                              <1> 	; Arguments:
   328                              <1> 	;	-	
   329                              <1> 	; ...............................................................
   330                              <1> 	;	
   331                              <1> 	; 23/02/2014 (swapret)
   332                              <1> 	; 22/09/2013
   333                              <1> sysrel0: ;1:
   334 0000B673 803D[CA300100]00    <1> 	cmp	byte [u.quant], 0 ; 16/05/2013
   335                              <1> 		; tstb uquant / is the time quantum 0?
   336 0000B67A 7705                <1>         ja      short swapret
   337                              <1> 		; bne 1f / no, don't swap it out
   338                              <1> sysrelease: ; 07/12/2013 (jump from 'clock')
   339 0000B67C E8D1200000          <1> 	call	tswap
   340                              <1> 		; jsr r0,tswap / yes, swap it out
   341                              <1> 	
   342                              <1> ; Retro Unix 8086 v1 feature: return from 'swap' to 'swapret' address.
   343                              <1> swapret: ;1:
   344                              <1> 	; 10/09/2015
   345                              <1> 	; 01/09/2015
   346                              <1> 	; 14/05/2015
   347                              <1> 	; 16/04/2015 (Retro UNIX 386 v1 - 32 bit, pm modifications)
   348                              <1> 	; 26/05/2013 (Retro UNIX 8086 v1)
   349                              <1> 	; cli
   350                              <1> 	; 24/07/2015
   351                              <1> 	;
   352                              <1> 	;; 'esp' must be already equal to '[u.usp]' here ! 
   353                              <1> 	;; mov	esp, [u.usp]
   354                              <1> 
   355                              <1> 	; 22/09/2013
   356 0000B681 E852230000          <1> 	call	isintr
   357                              <1> 	; 20/10/2013
   358 0000B686 7405                <1> 	jz	short sysrel1
   359 0000B688 E865000000          <1> 	call	intract
   360                              <1> 		; jsr r0,isintr / is there an interrupt from the user
   361                              <1> 		;     br intract / yes, output gets flushed, take interrupt
   362                              <1> 		               ; / action
   363                              <1> sysrel1:
   364 0000B68D FA                  <1> 	cli ; 14/10/2015
   365 0000B68E FE0D[7F300100]      <1> 	dec	byte [sysflg]
   366                              <1> 		; decb sysflg / turn system flag off
   367 0000B694 A1[E1300100]        <1> 	mov     eax, [u.pgdir]
   368 0000B699 0F22D8              <1> 	mov	cr3, eax  ; 1st PDE points to Kernel Page Table 0 (1st 4 MB)
   369                              <1> 			  ; (others are different than kernel page tables) 
   370                              <1> 	; 10/09/2015
   371 0000B69C 61                  <1> 	popad ; edi, esi, ebp, temp (icrement esp by 4), ebx, edx, ecx, eax
   372                              <1> 		; mov (sp)+,sc / restore user registers
   373                              <1> 		; mov (sp)+,mq
   374                              <1> 		; mov (sp)+,ac
   375                              <1> 		; mov (sp)+,r5
   376                              <1> 		; mov (sp)+,r4
   377                              <1> 		; mov (sp)+,r3
   378                              <1> 		; mov (sp)+,r2
   379                              <1> 	;
   380 0000B69D A1[88300100]        <1> 	mov	eax, [u.r0]  ; ((return value in EAX))
   381 0000B6A2 0FA9                <1> 	pop	gs
   382 0000B6A4 0FA1                <1> 	pop	fs
   383 0000B6A6 07                  <1> 	pop	es
   384 0000B6A7 1F                  <1> 	pop	ds
   385 0000B6A8 CF                  <1> 	iretd	
   386                              <1> 		; rti / no, return from interrupt
   387                              <1> 
   388                              <1> badsys:
   389                              <1> 	; 18/04/2016 (TRDOS 386 = TRDOS v2.0)
   390                              <1> 	; 17/04/2011 (TRDOS v1.0, 'IFC.ASM')
   391                              <1> 	; 03/02/2011 ('trdos_ifc_routine')
   392                              <1> 	;
   393                              <1> 	; 16/04/2015 (Retro UNIX 386 v1, 'badsys')
   394                              <1> 	; (EIP, EAX values will be shown on screen with error message)
   395                              <1> 	; (EIP = 'CD 40h' instruction address -INT 40h-)
   396                              <1> 	; (EAX = Function number)  
   397                              <1> 	;
   398 0000B6A9 FE05[D6300100]      <1> 	inc	byte [u.bsys]
   399                              <1> 	;
   400 0000B6AF 8B1D[80300100]      <1> 	mov	ebx, [u.sp] ; esp at the beginning of 'sysent'
   401 0000B6B5 8B03                <1> 	mov	eax, [ebx] ; EIP (return address, not 'INT 30h' address)
   402 0000B6B7 83E802              <1> 	sub	eax, 2 ; CDh, ##h
   403 0000B6BA E89576FFFF          <1> 	call	dwordtohex
   404 0000B6BF 8915[F7E40000]      <1> 	mov	[eip_str], edx
   405 0000B6C5 A3[FBE40000]        <1> 	mov	[eip_str+4], eax
   406 0000B6CA A1[88300100]        <1> 	mov	eax, [u.r0]
   407 0000B6CF E88076FFFF          <1> 	call	dwordtohex
   408 0000B6D4 8915[E6E40000]      <1> 	mov	[eax_str], edx
   409 0000B6DA A3[EAE40000]        <1> 	mov	[eax_str+4], eax
   410                              <1> 
   411 0000B6DF C605[DBE40000]40    <1> 	mov	byte [int_num_str], 40h
   412                              <1> 
   413 0000B6E6 BE[ADE40000]        <1> 	mov	esi, ifc_msg ; "invalid funtion call !" msg (trdosk9.s)
   414 0000B6EB E8429EFFFF          <1> 	call	print_msg
   415                              <1> 
   416 0000B6F0 EB17                <1> 	jmp	sysexit
   417                              <1> 
   418                              <1> intract: ; / interrupt action
   419                              <1> 	; 14/10/2015
   420                              <1> 	; 16/04/2015 (Retro UNIX 386 v1 - Beginning)
   421                              <1> 	; 09/05/2013 - 07/12/2013 (Retro UNIX 8086 v1)
   422                              <1> 	;
   423                              <1> 	; Retro UNIX 8086 v1 modification !
   424                              <1> 	; (Process/task switching and quit routine by using
   425                              <1> 	; Retro UNIX 8086 v1 keyboard interrupt output.))
   426                              <1> 	;
   427                              <1> 	; input -> 'u.quit'  (also value of 'u.intr' > 0)
   428                              <1> 	; output -> If value of 'u.quit' = FFFFh ('ctrl+brk' sign)
   429                              <1> 	;		'intract' will jump to 'sysexit'.
   430                              <1> 	;	    Intract will return to the caller 
   431                              <1> 	;		if value of 'u.quit' <> FFFFh. 	 
   432                              <1> 	; 14/10/2015
   433 0000B6F2 FB                  <1> 	sti
   434                              <1> 	; 07/12/2013	
   435 0000B6F3 66FF05[CE300100]    <1> 	inc 	word [u.quit]
   436 0000B6FA 7408                <1> 	jz	short intrct0 ; FFFFh -> 0
   437 0000B6FC 66FF0D[CE300100]    <1> 	dec	word [u.quit]
   438                              <1> 	; 16/04/2015
   439 0000B703 C3                  <1> 	retn
   440                              <1> intrct0:	
   441 0000B704 58                  <1> 	pop	eax ; call intract -> retn
   442                              <1> 	;
   443 0000B705 31C0                <1> 	xor 	eax, eax
   444 0000B707 FEC0                <1> 	inc	al  ; mov ax, 1
   445                              <1> ;;;
   446                              <1> 	; UNIX v1 original 'intract' routine... 
   447                              <1> 	; / interrupt action
   448                              <1> 		;cmp *(sp),$rti / are you in a clock interrupt?
   449                              <1> 		; bne 1f / no, 1f
   450                              <1> 		; cmp (sp)+,(sp)+ / pop clock pointer
   451                              <1> 	; 1: / now in user area
   452                              <1> 		; mov r1,-(sp) / save r1
   453                              <1> 		; mov u.ttyp,r1 
   454                              <1> 			; / pointer to tty buffer in control-to r1
   455                              <1> 		; cmpb 6(r1),$177
   456                              <1> 			; / is the interrupt char equal to "del"
   457                              <1> 		; beq 1f / yes, 1f
   458                              <1> 		; clrb 6(r1) 
   459                              <1> 		        ; / no, clear the byte 
   460                              <1> 			; / (must be a quit character)
   461                              <1> 		; mov (sp)+,r1 / restore r1
   462                              <1> 		; clr u.quit / clear quit flag
   463                              <1> 		; bis $20,2(sp) 
   464                              <1> 		    	; / set trace for quit (sets t bit of 
   465                              <1> 			; / ps-trace trap)
   466                              <1> 		; rti   ;  / return from interrupt
   467                              <1> 	; 1: / interrupt char = del
   468                              <1> 		; clrb 6(r1) / clear the interrupt byte 
   469                              <1> 			   ; / in the buffer
   470                              <1> 		; mov (sp)+,r1 / restore r1
   471                              <1> 		; cmp u.intr,$core / should control be 
   472                              <1> 				; / transferred to loc core?
   473                              <1> 		; blo 1f
   474                              <1> 		; jmp *u.intr / user to do rti yes, 
   475                              <1> 				; / transfer to loc core
   476                              <1> 	; 1:
   477                              <1> 		; sys 1 / exit
   478                              <1> 
   479                              <1> sysexit: ; <terminate process>
   480                              <1> 	; 10/06/2016
   481                              <1> 	; 06/06/2016
   482                              <1> 	; 23/05/2016
   483                              <1> 	; 19/05/2016
   484                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
   485                              <1> 	; 16/04/2015 - 01/09/2015 (Retro UNIX 386 v1)
   486                              <1> 	; 19/04/2013 - 14/02/2014 (Retro UNIX 8086 v1)
   487                              <1> 	;
   488                              <1> 	; 'sysexit' terminates a process. First each file that
   489                              <1> 	; the process has opened is closed by 'flose'. The process
   490                              <1> 	; status is then set to unused. The 'p.pid' table is then
   491                              <1> 	; searched to find children of the dying process. If any of
   492                              <1> 	; children are zombies (died by not waited for), they are
   493                              <1> 	; set free. The 'p.pid' table is then searched to find the
   494                              <1> 	; dying process's parent. When the parent is found, it is
   495                              <1> 	; checked to see if it is free or it is a zombie. If it is
   496                              <1> 	; one of these, the dying process just dies. If it is waiting
   497                              <1> 	; for a child process to die, it notified that it doesn't 
   498                              <1> 	; have to wait anymore by setting it's status from 2 to 1
   499                              <1> 	; (waiting to active). It is awakened and put on runq by
   500                              <1> 	; 'putlu'. The dying process enters a zombie state in which
   501                              <1> 	; it will never be run again but stays around until a 'wait'
   502                              <1> 	; is completed by it's parent process. If the parent is not
   503                              <1> 	; found, process just dies. This means 'swap' is called with
   504                              <1> 	; 'u.uno=0'. What this does is the 'wswap' is not called
   505                              <1> 	; to write out the process and 'rswap' reads the new process
   506                              <1> 	; over the one that dies..i.e., the dying process is 
   507                              <1> 	; overwritten and destroyed.	
   508                              <1>  	;
   509                              <1> 	; Calling sequence:
   510                              <1> 	;	sysexit or conditional branch.
   511                              <1> 	; Arguments:
   512                              <1> 	;	-	
   513                              <1> 	; ...............................................................
   514                              <1> 	;	
   515                              <1> 	; Retro UNIX 8086 v1 modification: 
   516                              <1> 	;       System call number (=1) is in EAX register.
   517                              <1> 	;
   518                              <1> 	;       Other parameters are in EDX, EBX, ECX, ESI, EDI, EBP
   519                              <1> 	;       registers depending of function details.
   520                              <1> 	;
   521                              <1> 	; ('swap' procedure is mostly different than original UNIX v1.)
   522                              <1> 	;
   523                              <1> ; / terminate process
   524                              <1> 	; AX = 1
   525 0000B709 6648                <1> 	dec 	ax ; 0
   526 0000B70B 66A3[CC300100]      <1> 	mov	[u.intr], ax ; 0
   527                              <1> 		; clr u.intr / clear interrupt control word
   528                              <1> 		; clr r1 / clear r1
   529                              <1> 	; AX = 0
   530                              <1> sysexit_1: ; 1:
   531                              <1> 	; AX = File descriptor
   532                              <1> 		; / r1 has file descriptor (index to u.fp list)
   533                              <1> 		; / Search the whole list
   534 0000B711 E832130000          <1> 	call	fclose
   535                              <1> 		; jsr r0,fclose / close all files the process opened
   536                              <1> 	;; ignore error return
   537                              <1> 		; br .+2 / ignore error return
   538                              <1> 	;inc	ax
   539 0000B716 FEC0                <1> 	inc	al
   540                              <1> 		; inc r1 / increment file descriptor
   541                              <1> 	;cmp	ax, 10
   542 0000B718 3C0A                <1> 	cmp	al, 10
   543                              <1> 		; cmp r1,$10. / end of u.fp list?
   544 0000B71A 72F5                <1> 	jb	short sysexit_1
   545                              <1> 		; blt 1b / no, go back
   546 0000B71C 0FB61D[D7300100]    <1> 	movzx	ebx, byte [u.uno]
   547                              <1> 		; movb	u.uno,r1 / yes, move dying process's number to r1
   548 0000B723 88A3[FB2D0100]      <1> 	mov	[ebx+p.stat-1], ah ; 0, SFREE
   549                              <1> 		; clrb p.stat-1(r1) / free the process
   550                              <1> 	;shl	bx, 1
   551 0000B729 D0E3                <1> 	shl	bl, 1
   552                              <1> 		; asl r1 / use r1 for index into the below tables
   553 0000B72B 668B8B[6A2D0100]    <1> 	mov	cx, [ebx+p.pid-2]
   554                              <1> 		; mov p.pid-2(r1),r3 / move dying process's name to r3
   555 0000B732 668B93[8A2D0100]    <1> 	mov	dx, [ebx+p.ppid-2]
   556                              <1> 		; mov p.ppid-2(r1),r4 / move its parents name to r4
   557                              <1> 	; xor 	bx, bx ; 0
   558 0000B739 30DB                <1> 	xor	bl, bl ; 0
   559                              <1> 		; clr r2
   560 0000B73B 31F6                <1> 	xor	esi, esi ; 0
   561                              <1> 		; clr r5 / initialize reg
   562                              <1> sysexit_2: ; 1:
   563                              <1> 	        ; / find children of this dying process, 
   564                              <1> 		; / if they are zombies, free them
   565                              <1> 	;add	bx, 2
   566 0000B73D 80C302              <1> 	add	bl, 2
   567                              <1> 		; add $2,r2 / search parent process table 
   568                              <1> 		          ; / for dying process's name
   569 0000B740 66398B[8A2D0100]    <1> 	cmp	[ebx+p.ppid-2], cx
   570                              <1> 		; cmp p.ppid-2(r2),r3 / found it?
   571 0000B747 7513                <1> 	jne	short sysexit_4
   572                              <1> 		; bne 3f / no
   573                              <1> 	;shr	bx, 1
   574 0000B749 D0EB                <1> 	shr	bl, 1
   575                              <1> 		; asr r2 / yes, it is a parent
   576 0000B74B 80BB[FB2D0100]03    <1> 	cmp	byte [ebx+p.stat-1], 3 ; SZOMB
   577                              <1> 		; cmpb p.stat-1(r2),$3 / is the child of this 
   578                              <1> 				     ; / dying process a zombie
   579 0000B752 7506                <1> 	jne	short sysexit_3 
   580                              <1> 		; bne 2f / no
   581 0000B754 88A3[FB2D0100]      <1> 	mov	[ebx+p.stat-1], ah ; 0, SFREE
   582                              <1> 		; clrb p.stat-1(r2) / yes, free the child process
   583                              <1> sysexit_3: ; 2:
   584                              <1> 	;shr	bx, 1
   585 0000B75A D0E3                <1> 	shl	bl, 1
   586                              <1> 		; asl r2
   587                              <1> sysexit_4: ; 3:
   588                              <1> 		; / search the process name table 
   589                              <1> 		; / for the dying process's parent
   590 0000B75C 663993[6A2D0100]    <1> 	cmp	[ebx+p.pid-2], dx
   591                              <1> 		; cmp p.pid-2(r2),r4 / found it?
   592 0000B763 7502                <1> 	jne	short sysexit_5
   593                              <1> 		; bne 3f / no
   594 0000B765 89DE                <1> 	mov	esi, ebx
   595                              <1> 		; mov r2,r5 / yes, put index to p.pid table (parents
   596                              <1> 		          ; / process # x2) in r5
   597                              <1> sysexit_5: ; 3:
   598                              <1> 	;cmp	bx, nproc + nproc
   599 0000B767 80FB20              <1> 	cmp	bl, nproc + nproc
   600                              <1> 		; cmp r2,$nproc+nproc / has whole table been searched?
   601 0000B76A 72D1                <1> 	jb	short sysexit_2
   602                              <1> 		; blt 1b / no, go back
   603                              <1> 		; mov r5,r1 / yes, r1 now has parents process # x2
   604 0000B76C 21F6                <1> 	and	esi, esi ; r5=r1
   605 0000B76E 7431                <1> 	jz	short sysexit_6
   606                              <1> 		; beq 2f / no parent has been found. 
   607                              <1> 		       ; / The process just dies
   608 0000B770 66D1EE              <1> 	shr	si, 1
   609                              <1> 		; asr r1 / set up index to p.stat
   610 0000B773 8A86[FB2D0100]      <1> 	mov	al, [esi+p.stat-1]
   611                              <1> 		; movb p.stat-1(r1),r2 / move status of parent to r2
   612 0000B779 20C0                <1> 	and	al, al
   613 0000B77B 7424                <1> 	jz	short sysexit_6
   614                              <1> 		; beq 2f / if its been freed, 2f
   615 0000B77D 3C03                <1> 	cmp	al, 3
   616                              <1> 		; cmp r2,$3 / is parent a zombie?
   617 0000B77F 7420                <1> 	je	short sysexit_6
   618                              <1> 		; beq 2f / yes, 2f
   619                              <1> 	; BH = 0
   620 0000B781 8A1D[D7300100]      <1> 	mov	bl, [u.uno]
   621                              <1> 		; movb u.uno,r3 / move dying process's number to r3
   622 0000B787 C683[FB2D0100]03    <1> 	mov	byte [ebx+p.stat-1], 3  ; SZOMB
   623                              <1> 		; movb $3,p.stat-1(r3) / make the process a zombie
   624 0000B78E 3C01                <1> 	cmp	al, 1 ; SRUN
   625 0000B790 740F                <1> 	je	short sysexit_6
   626                              <1> 	;cmp	al, 2
   627                              <1> 		; cmp r2,$2 / is the parent waiting for 
   628                              <1> 			  ; / this child to die
   629                              <1> 	;jne	short sysexit_6	
   630                              <1> 		; bne 2f / yes, notify parent not to wait any more
   631                              <1> 	; p.stat = 2 --> waiting
   632                              <1> 	; p.stat = 4 --> sleeping
   633 0000B792 C686[FB2D0100]01    <1> 	mov	byte [esi+p.stat-1], 1 ; SRUN
   634                              <1> 	;dec	byte [esi+p.stat-1]
   635                              <1> 		; decb	p.stat-1(r1) / awaken it by putting it (parent)
   636 0000B799 6689F0              <1> 	mov	ax, si ; r1  (process number in AL)
   637                              <1> 	; 
   638                              <1> 	;mov	ebx, runq + 4
   639                              <1> 		; mov $runq+4,r2 / on the runq
   640 0000B79C E8C4200000          <1> 	call	putlu
   641                              <1> 		; jsr r0, putlu
   642                              <1> sysexit_6: 
   643                              <1> 	; 10/06/2016
   644                              <1> 	; 06/06/2016
   645                              <1> 	; 23/05/2016
   646                              <1> 	; 19/05/2016 - TRDOS 386 (TRDOS v2.0)
   647                              <1> 	; Check and stop/clear timer event(s) of this (dying) process
   648                              <1> 	; if there is.
   649 0000B7A1 8A86[4B2E0100]      <1> 	mov 	al, [esi+p.timer-1]
   650 0000B7A7 20C0                <1> 	and	al, al
   651 0000B7A9 743C                <1> 	jz	short sysexit_12 ; no timer events for this process
   652 0000B7AB C686[4B2E0100]00    <1> 	mov	byte [esi+p.timer-1], 0 ; reset
   653 0000B7B2 A0[2F2D0100]        <1> 	mov	al, [timer_events]
   654                              <1> 	;or	al, al
   655                              <1>  	;jz	short sysexit_12 ; no timer events
   656 0000B7B7 88C1                <1> 	mov	cl, al
   657 0000B7B9 8A25[D7300100]      <1> 	mov	ah, [u.uno]
   658 0000B7BF FA                  <1> 	cli	; disable interrupts 
   659 0000B7C0 B310                <1> 	mov	bl, 16
   660 0000B7C2 BE[4C3D0100]        <1> 	mov	esi, timer_set ; beginning address of timer events
   661                              <1> sysexit_7:
   662 0000B7C7 8A06                <1> 	mov	al, [esi] ; process number (of timer event)
   663 0000B7C9 38E0                <1> 	cmp	al, ah ; process number comparison
   664 0000B7CB 7411                <1> 	je	short sysexit_10
   665 0000B7CD 20C0                <1> 	and	al, al
   666 0000B7CF 7404                <1> 	jz	short sysexit_9
   667                              <1> sysexit_8:
   668 0000B7D1 FEC9                <1> 	dec	cl
   669 0000B7D3 7410                <1> 	jz	short sysexit_11
   670                              <1> sysexit_9:
   671 0000B7D5 FECB                <1> 	dec	bl
   672 0000B7D7 740C                <1> 	jz	short sysexit_11
   673 0000B7D9 83C610              <1> 	add	esi, 16
   674 0000B7DC EBE9                <1> 	jmp	short sysexit_7
   675                              <1> 
   676                              <1> sysexit_10:
   677                              <1> 	;mov	byte [esi], 0
   678 0000B7DE 66C7060000          <1> 	mov	word [esi], 0
   679                              <1> 	;mov	dword [esi+12], 0
   680 0000B7E3 EBEC                <1> 	jmp	short sysexit_8
   681                              <1> 
   682                              <1> sysexit_11:
   683 0000B7E5 30C0                <1> 	xor	al, al
   684                              <1> sysexit_12: ; 2:
   685 0000B7E7 FB                  <1> 	sti	; enable interrupts 
   686                              <1> 	;
   687 0000B7E8 A2[D7300100]        <1> 	mov	[u.uno], al ; 0
   688                              <1> 		; / the process dies
   689                              <1> 	;mov	byte [u.uno], 0
   690                              <1> 		; clrb u.uno / put zero as the process number, 
   691                              <1> 	           ; / so "swap" will
   692 0000B7ED E8831F0000          <1> 	call	swap
   693                              <1> 		; jsr r0,swap / overwrite process with another process
   694                              <1> hlt_sys:
   695                              <1> 	;sti
   696                              <1> hlts0:
   697 0000B7F2 F4                  <1> 	hlt
   698 0000B7F3 EBFD                <1> 	jmp	short hlts0
   699                              <1> 		; 0 / and thereby kill it; halt?
   700                              <1> 
   701                              <1> syswait: ; < wait for a processs to die >
   702                              <1> 	; 17/09/2015
   703                              <1> 	; 02/09/2015
   704                              <1> 	; 01/09/2015
   705                              <1> 	; 16/04/2015 (Retro UNIX 386 v1 - Beginning)
   706                              <1> 	; 24/05/2013 - 05/02/2014 (Retro UNIX 8086 v1)
   707                              <1> 	;
   708                              <1> 	; 'syswait' waits for a process die. 
   709                              <1> 	; It works in following way:
   710                              <1> 	;    1) From the parent process number, the parent's 
   711                              <1> 	; 	process name is found. The p.ppid table of parent
   712                              <1> 	;	names is then searched for this process name.
   713                              <1> 	;	If a match occurs, r2 contains child's process
   714                              <1> 	;	number. The child status is checked to see if it is
   715                              <1> 	;	a zombie, i.e; dead but not waited for (p.stat=3)
   716                              <1> 	;	If it is, the child process is freed and it's name
   717                              <1> 	;	is put in (u.r0). A return is then made via 'sysret'.
   718                              <1> 	;	If the child is not a zombie, nothing happens and
   719                              <1> 	;	the search goes on through the p.ppid table until
   720                              <1> 	;	all processes are checked or a zombie is found.
   721                              <1> 	;    2) If no zombies are found, a check is made to see if
   722                              <1> 	;	there are any children at all. If there are none,
   723                              <1> 	;	an error return is made. If there are, the parent's
   724                              <1> 	;	status is set to 2 (waiting for child to die),
   725                              <1> 	;	the parent is swapped out, and a branch to 'syswait'
   726                              <1> 	;	is made to wait on the next process.
   727                              <1> 	;
   728                              <1> 	; Calling sequence:
   729                              <1> 	;	?
   730                              <1> 	; Arguments:
   731                              <1> 	;	-
   732                              <1> 	; Inputs: - 
   733                              <1> 	; Outputs: if zombie found, it's name put in u.r0.	
   734                              <1> 	; ...............................................................
   735                              <1> 	;				
   736                              <1> 	
   737                              <1> ; / wait for a process to die
   738                              <1> 
   739                              <1> syswait_0:
   740 0000B7F5 0FB61D[D7300100]    <1> 	movzx	ebx, byte [u.uno] ; 01/09/2015
   741                              <1> 		; movb u.uno,r1 / put parents process number in r1
   742 0000B7FC D0E3                <1> 	shl	bl, 1
   743                              <1> 	;shl	bx, 1
   744                              <1> 		; asl r1 / x2 to get index into p.pid table
   745 0000B7FE 668B83[6A2D0100]    <1> 	mov	ax, [ebx+p.pid-2]
   746                              <1> 		; mov p.pid-2(r1),r1 / get the name of this process
   747 0000B805 31F6                <1> 	xor	esi, esi
   748                              <1> 		; clr r2
   749 0000B807 31C9                <1> 	xor	ecx, ecx ; 30/10/2013
   750                              <1> 	;xor 	cl, cl
   751                              <1> 		; clr r3 / initialize reg 3
   752                              <1> syswait_1: ; 1:
   753 0000B809 6683C602            <1> 	add	si, 2
   754                              <1> 		; add $2,r2 / use r2 for index into p.ppid table
   755                              <1> 			  ; / search table of parent processes 
   756                              <1> 			  ; / for this process name
   757 0000B80D 663B86[8A2D0100]    <1> 	cmp	ax, [esi+p.ppid-2]
   758                              <1> 		; cmp p.ppid-2(r2),r1 / r2 will contain the childs 
   759                              <1> 			            ; / process number
   760 0000B814 7535                <1> 	jne	short syswait_3
   761                              <1> 		;bne 3f / branch if no match of parent process name
   762                              <1> 	;inc	cx
   763 0000B816 FEC1                <1> 	inc	cl
   764                              <1> 		;inc r3 / yes, a match, r3 indicates number of children
   765 0000B818 66D1EE              <1> 	shr	si, 1
   766                              <1> 		; asr r2 / r2/2 to get index to p.stat table
   767                              <1> 	; The possible states ('p.stat' values) of a process are:
   768                              <1> 	;	0 = free or unused
   769                              <1> 	;	1 = active
   770                              <1> 	;	2 = waiting for a child process to die
   771                              <1> 	;	3 = terminated, but not yet waited for (zombie).	
   772 0000B81B 80BE[FB2D0100]03    <1> 	cmp	byte [esi+p.stat-1], 3 ; SZOMB, 05/02/2014
   773                              <1> 		; cmpb p.stat-1(r2),$3 / is the child process a zombie?
   774 0000B822 7524                <1> 	jne	short syswait_2
   775                              <1> 		; bne 2f / no, skip it
   776 0000B824 88BE[FB2D0100]      <1> 	mov	[esi+p.stat-1], bh ; 0
   777                              <1> 		; clrb p.stat-1(r2) / yes, free it
   778 0000B82A 66D1E6              <1> 	shl	si, 1
   779                              <1> 		; asl r2 / r2x2 to get index into p.pid table
   780 0000B82D 0FB786[6A2D0100]    <1> 	movzx	eax, word [esi+p.pid-2]
   781 0000B834 A3[88300100]        <1> 	mov	[u.r0], eax
   782                              <1> 		; mov p.pid-2(r2),*u.r0 
   783                              <1> 			      ; / put childs process name in (u.r0)
   784                              <1> 	;
   785                              <1> 	; Retro UNIX 386 v1 modification ! (17/09/2015)
   786                              <1> 	;
   787                              <1> 	; Parent process ID -p.ppid- field (of the child process)
   788                              <1> 	; must be cleared in order to prevent infinitive 'syswait'
   789                              <1> 	; system call loop from the application/program if it calls
   790                              <1> 	; 'syswait' again (mistakenly) while there is not a zombie
   791                              <1> 	; or running child process to wait. ('forktest.s', 17/09/2015)
   792                              <1> 	;
   793                              <1> 	; Note: syswait will return with error if there is not a
   794                              <1> 	;       zombie or running process to wait.	
   795                              <1> 	;
   796 0000B839 6629C0              <1> 	sub	ax, ax
   797 0000B83C 668986[8A2D0100]    <1> 	mov 	[esi+p.ppid-2], ax ; 0 ; 17/09/2015
   798 0000B843 E9DBFDFFFF          <1> 	jmp	sysret0 ; ax = 0
   799                              <1> 	;
   800                              <1> 	;jmp	sysret
   801                              <1> 		; br sysret1 / return cause child is dead
   802                              <1> syswait_2: ; 2:
   803 0000B848 66D1E6              <1> 	shl	si, 1
   804                              <1> 		; asl r2 / r2x2 to get index into p.ppid table
   805                              <1> syswait_3: ; 3:
   806 0000B84B 6683FE20            <1> 	cmp	si, nproc+nproc
   807                              <1> 		; cmp r2,$nproc+nproc / have all processes been checked?
   808 0000B84F 72B8                <1> 	jb	short syswait_1
   809                              <1> 		; blt 1b / no, continue search
   810                              <1> 	;and	cx, cx
   811 0000B851 20C9                <1> 	and	cl, cl
   812                              <1> 		; tst r3 / one gets here if there are no children 
   813                              <1> 		       ; / or children that are still active
   814                              <1> 	; 30/10/2013
   815 0000B853 750B                <1> 	jnz	short syswait_4
   816                              <1> 	;jz	error
   817                              <1> 		; beq error1 / there are no children, error
   818 0000B855 890D[88300100]      <1> 	mov	[u.r0], ecx ; 0
   819 0000B85B E9A0FDFFFF          <1> 	jmp	error
   820                              <1> syswait_4:
   821 0000B860 8A1D[D7300100]      <1> 	mov	bl, [u.uno]
   822                              <1> 		; movb u.uno,r1 / there are children so put 
   823                              <1> 			      ; / parent process number in r1
   824 0000B866 FE83[FB2D0100]      <1> 	inc	byte [ebx+p.stat-1] ; 2, SWAIT, 05/02/2014
   825                              <1> 		; incb p.stat-1(r1) / it is waiting for 
   826                              <1> 				  ; / other children to die
   827                              <1> 	; 04/11/2013
   828 0000B86C E8041F0000          <1> 	call	swap
   829                              <1> 		; jsr r0,swap / swap it out, because it's waiting
   830 0000B871 EB82                <1> 	jmp	syswait_0
   831                              <1> 		; br syswait / wait on next process
   832                              <1> 
   833                              <1> sysfork: ; < create a new process >
   834                              <1> 	; 18/09/2015
   835                              <1> 	; 04/09/2015
   836                              <1> 	; 02/09/2015
   837                              <1> 	; 01/09/2015
   838                              <1> 	; 28/08/2015
   839                              <1> 	; 14/05/2015
   840                              <1> 	; 10/05/2015
   841                              <1> 	; 09/05/2015
   842                              <1> 	; 06/05/2015 (Retro UNIX 386 v1 - Beginning)
   843                              <1> 	; 24/05/2013 - 14/02/2014 (Retro UNIX 8086 v1)
   844                              <1> 	;
   845                              <1> 	; 'sysfork' creates a new process. This process is referred
   846                              <1> 	; to as the child process. This new process core image is
   847                              <1> 	; a copy of that of the caller of 'sysfork'. The only
   848                              <1> 	; distinction is the return location and the fact that (u.r0)
   849                              <1> 	; in the old process (parent) contains the process id (p.pid)
   850                              <1> 	; of the new process (child). This id is used by 'syswait'.
   851                              <1> 	; 'sysfork' works in the following manner: 	
   852                              <1> 	;    1) The process status table (p.stat) is searched to find
   853                              <1> 	;	a process number that is unused. If none are found
   854                              <1> 	;	an error occurs.
   855                              <1> 	;    2) when one is found, it becomes the child process number
   856                              <1> 	;	and it's status (p.stat) is set to active.
   857                              <1> 	;    3) If the parent had a control tty, the interrupt 
   858                              <1> 	;	character in that tty buffer is cleared.
   859                              <1> 	;    4) The child process is put on the lowest priority run 
   860                              <1> 	;	queue via 'putlu'.
   861                              <1> 	;    5) A new process name is gotten from 'mpid' (actually 
   862                              <1> 	;	it is a unique number) and is put in the child's unique
   863                              <1> 	;	identifier; process id (p.pid).
   864                              <1> 	;    6) The process name of the parent is then obtained and
   865                              <1> 	;	placed in the unique identifier of the parent process
   866                              <1> 	;	name is then put in 'u.r0'.	
   867                              <1> 	;    7) The child process is then written out on disk by
   868                              <1> 	;	'wswap',i.e., the parent process is copied onto disk
   869                              <1> 	;	and the child is born. (The child process is written 
   870                              <1> 	;	out on disk/drum with 'u.uno' being the child process
   871                              <1> 	;	number.)
   872                              <1> 	;    8) The parent process number is then restored to 'u.uno'.
   873                              <1> 	;    9) The child process name is put in 'u.r0'.
   874                              <1> 	;   10) The pc on the stack sp + 18 is incremented by 2 to
   875                              <1> 	;	create the return address for the parent process.
   876                              <1> 	;   11) The 'u.fp' list as then searched to see what files
   877                              <1> 	;	the parent has opened. For each file the parent has
   878                              <1> 	;	opened, the corresponding 'fsp' entry must be updated
   879                              <1> 	;	to indicate that the child process also has opened
   880                              <1> 	;	the file. A branch to 'sysret' is then made.	 			 				
   881                              <1> 	;
   882                              <1> 	; Calling sequence:
   883                              <1> 	;	from shell ?
   884                              <1> 	; Arguments:
   885                              <1> 	;	-
   886                              <1> 	; Inputs: -
   887                              <1> 	; Outputs: *u.r0 - child process name
   888                              <1> 	; ...............................................................
   889                              <1> 	;	
   890                              <1> 	; Retro UNIX 8086 v1 modification: 
   891                              <1> 	;	AX = r0 = PID (>0) (at the return of 'sysfork')
   892                              <1> 	;	= process id of child a parent process returns
   893                              <1> 	;	= process id of parent when a child process returns
   894                              <1> 	;
   895                              <1> 	;       In original UNIX v1, sysfork is called and returns as
   896                              <1> 	;	in following manner: (with an example: c library, fork)
   897                              <1> 	;	
   898                              <1> 	;	1:
   899                              <1> 	;		sys	fork
   900                              <1> 	;			br 1f  / child process returns here
   901                              <1> 	;		bes	2f     / parent process returns here
   902                              <1> 	;		/ pid of new process in r0
   903                              <1> 	;		rts	pc
   904                              <1> 	;	2: / parent process condionally branches here
   905                              <1> 	;		mov	$-1,r0 / pid = -1 means error return
   906                              <1> 	;		rts	pc
   907                              <1> 	;
   908                              <1> 	;	1: / child process brances here
   909                              <1> 	;		clr	r0   / pid = 0 in child process
   910                              <1> 	;		rts	pc
   911                              <1> 	;
   912                              <1> 	;	In UNIX v7x86 (386) by Robert Nordier (1999)
   913                              <1> 	;		// pid = fork();
   914                              <1> 	;		//
   915                              <1> 	;		// pid == 0 in child process; 
   916                              <1> 	;		// pid == -1 means error return
   917                              <1> 	;		// in child, 
   918                              <1> 	;		//	parents id is in par_uid if needed
   919                              <1> 	;		
   920                              <1> 	;		_fork:
   921                              <1> 	;			mov	$.fork,eax
   922                              <1> 	;			int	$0x30
   923                              <1> 	;			jmp	1f
   924                              <1> 	;			jnc	2f
   925                              <1> 	;			jmp	cerror
   926                              <1> 	;		1:
   927                              <1> 	;			mov	eax,_par_uid
   928                              <1> 	;			xor	eax,eax
   929                              <1> 	;		2:
   930                              <1> 	;			ret
   931                              <1> 	;
   932                              <1> 	;	In Retro UNIX 8086 v1,
   933                              <1> 	;	'sysfork' returns in following manner:
   934                              <1> 	;	
   935                              <1> 	;		mov	ax, sys_fork
   936                              <1> 	;		mov	bx, offset @f ; routine for child
   937                              <1> 	;		int	20h
   938                              <1> 	;		jc	error
   939                              <1> 	;		
   940                              <1> 	;	; Routine for parent process here (just after 'jc')
   941                              <1> 	;		mov	word ptr [pid_of_child], ax
   942                              <1> 	;		jmp	next_routine_for_parent	
   943                              <1> 	;
   944                              <1> 	;	@@: ; routine for child process here				
   945                              <1> 	;		....	
   946                              <1> 	;	NOTE: 'sysfork' returns to specified offset
   947                              <1> 	;	       for child process by using BX input.
   948                              <1> 	;	      (at first, parent process will return then 
   949                              <1> 	;	      child process will return -after swapped in-
   950                              <1> 	;	      'syswait' is needed in parent process
   951                              <1> 	;	      if return from child process will be waited for.)
   952                              <1> 	;	  				
   953                              <1> 	
   954                              <1> ; / create a new process
   955                              <1> 	; EBX = return address for child process 
   956                              <1> 	     ; (Retro UNIX 8086 v1 modification !)
   957 0000B873 31F6                <1> 	xor 	esi, esi
   958                              <1> 		; clr r1
   959                              <1> sysfork_1: ; 1: / search p.stat table for unused process number
   960 0000B875 46                  <1> 	inc	esi
   961                              <1> 		; inc r1
   962 0000B876 80BE[FB2D0100]00    <1> 	cmp	byte [esi+p.stat-1], 0 ; SFREE, 05/02/2014
   963                              <1> 		; tstb p.stat-1(r1) / is process active, unused, dead
   964 0000B87D 760B                <1> 	jna	short sysfork_2	
   965                              <1> 		; beq 1f / it's unused so branch
   966 0000B87F 6683FE10            <1> 	cmp	si, nproc
   967                              <1> 		; cmp r1,$nproc / all processes checked
   968 0000B883 72F0                <1> 	jb	short sysfork_1
   969                              <1> 		; blt 1b / no, branch back
   970                              <1> 	;
   971                              <1> 	; Retro UNIX 8086 v1. modification:
   972                              <1> 	;	Parent process returns from 'sysfork' to address 
   973                              <1> 	;	which is just after 'sysfork' system call in parent
   974                              <1> 	;	process. Child process returns to address which is put
   975                              <1> 	;	in BX register by parent process for 'sysfork'. 
   976                              <1> 	;
   977                              <1> 		;add $2,18.(sp) / add 2 to pc when trap occured, points
   978                              <1> 		             ; / to old process return
   979                              <1> 		; br error1 / no room for a new process
   980 0000B885 E976FDFFFF          <1> 	jmp	error
   981                              <1> sysfork_2: ; 1:
   982 0000B88A E8338DFFFF          <1> 	call	allocate_page
   983 0000B88F 0F826BFDFFFF        <1> 	jc	error
   984 0000B895 50                  <1> 	push	eax   ; UPAGE (user structure page) address
   985                              <1> 	; Retro UNIX 386 v1 modification!
   986 0000B896 E8368FFFFF          <1> 	call	duplicate_page_dir
   987                              <1> 		; EAX = New page directory 
   988 0000B89B 730B                <1> 	jnc	short sysfork_3
   989 0000B89D 58                  <1> 	pop	eax   ; UPAGE (user structure page) address
   990 0000B89E E8FD8EFFFF          <1> 	call 	deallocate_page
   991 0000B8A3 E958FDFFFF          <1> 	jmp	error
   992                              <1> sysfork_3:
   993                              <1> 	; Retro UNIX 386 v1 modification !
   994 0000B8A8 56                  <1> 	push	esi
   995 0000B8A9 E8551F0000          <1> 	call	wswap ; save current user (u) structure, user registers
   996                              <1> 		      ; and interrupt return components (for IRET)
   997 0000B8AE 8705[E1300100]      <1> 	xchg	eax, [u.pgdir] ; page directory of the child process
   998 0000B8B4 A3[E5300100]        <1> 	mov	[u.ppgdir], eax ; page directory of the parent process
   999 0000B8B9 5E                  <1> 	pop	esi
  1000 0000B8BA 58                  <1> 	pop	eax   ; UPAGE (user structure page) address
  1001                              <1> 		; [u.usp] = esp
  1002 0000B8BB 89F7                <1> 	mov	edi, esi
  1003 0000B8BD 66C1E702            <1> 	shl	di, 2
  1004 0000B8C1 8987[082E0100]      <1> 	mov	[edi+p.upage-4], eax ; memory page for 'user' struct
  1005 0000B8C7 A3[D8300100]        <1> 	mov	[u.upage], eax ; memory page for 'user' struct (child)
  1006                              <1> 	; 28/08/2015
  1007 0000B8CC 0FB605[D7300100]    <1> 	movzx	eax, byte [u.uno] ; parent process number
  1008                              <1> 		; movb u.uno,-(sp) / save parent process number
  1009 0000B8D3 89C7                <1> 	mov	edi, eax
  1010 0000B8D5 50                  <1>         push	eax ; ** 
  1011 0000B8D6 8A87[CB2D0100]      <1> 	mov     al, [edi+p.ttyc-1] ; console tty (parent)
  1012                              <1> 	; 18/09/2015
  1013                              <1> 	;mov     [esi+p.ttyc-1], al ; set child's console tty
  1014                              <1> 	;mov     [esi+p.waitc-1], ah ; 0 ; reset child's wait channel
  1015 0000B8DC 668986[CB2D0100]    <1> 	mov     [esi+p.ttyc-1], ax ; al - set child's console tty
  1016                              <1> 				   ; ah - reset child's wait channel	
  1017 0000B8E3 89F0                <1> 	mov	eax, esi
  1018 0000B8E5 A2[D7300100]        <1> 	mov	[u.uno], al ; child process number
  1019                              <1> 		;movb r1,u.uno / set child process number to r1
  1020 0000B8EA FE86[FB2D0100]      <1>         inc     byte [esi+p.stat-1] ; 1, SRUN, 05/02/2014
  1021                              <1> 		; incb p.stat-1(r1) / set p.stat entry for child 
  1022                              <1> 				; / process to active status
  1023                              <1> 		; mov u.ttyp,r2 / put pointer to parent process' 
  1024                              <1> 			      ; / control tty buffer in r2
  1025                              <1>                 ; beq 2f / branch, if no such tty assigned
  1026                              <1> 		; clrb 6(r2) / clear interrupt character in tty buffer
  1027                              <1> 	; 2:
  1028 0000B8F0 53                  <1> 	push	ebx  ; * return address for the child process
  1029                              <1> 		     ; * Retro UNIX 8086 v1 feature only !	
  1030                              <1> 	; (Retro UNIX 8086 v1 modification!)
  1031                              <1> 		; mov $runq+4,r2
  1032 0000B8F1 E86F1F0000          <1> 	call	putlu 
  1033                              <1>  		; jsr r0,putlu / put child process on lowest priority 
  1034                              <1> 			   ; / run queue
  1035 0000B8F6 66D1E6              <1> 	shl	si, 1
  1036                              <1> 		; asl r1 / multiply r1 by 2 to get index 
  1037                              <1> 		       ; / into p.pid table
  1038 0000B8F9 66FF05[72300100]    <1> 	inc	word [mpid]
  1039                              <1> 		; inc mpid / increment m.pid; get a new process name
  1040 0000B900 66A1[72300100]      <1> 	mov	ax, [mpid]
  1041 0000B906 668986[6A2D0100]    <1> 	mov	[esi+p.pid-2], ax
  1042                              <1> 		;mov mpid,p.pid-2(r1) / put new process name 
  1043                              <1> 				    ; / in child process' name slot
  1044 0000B90D 5A                  <1> 	pop	edx  ; * return address for the child process
  1045                              <1> 		     ; * Retro UNIX 8086 v1 feature only !	
  1046 0000B90E 5B                  <1>   	pop	ebx  ; **
  1047                              <1> 	;mov	ebx, [esp] ; ** parent process number
  1048                              <1> 		; movb (sp),r2 / put parent process number in r2
  1049 0000B90F 66D1E3              <1> 	shl 	bx, 1
  1050                              <1> 		;asl r2 / multiply by 2 to get index into below tables
  1051                              <1> 	;movzx eax, word [ebx+p.pid-2]
  1052 0000B912 668B83[6A2D0100]    <1> 	mov	ax, [ebx+p.pid-2]
  1053                              <1> 		; mov p.pid-2(r2),r2 / get process name of parent
  1054                              <1> 				   ; / process
  1055 0000B919 668986[8A2D0100]    <1> 	mov	[esi+p.ppid-2], ax
  1056                              <1> 		; mov r2,p.ppid-2(r1) / put parent process name 
  1057                              <1> 			  ; / in parent process slot for child
  1058 0000B920 A3[88300100]        <1> 	mov	[u.r0], eax	
  1059                              <1> 		; mov r2,*u.r0 / put parent process name on stack 
  1060                              <1> 			     ; / at location where r0 was saved
  1061 0000B925 8B2D[80300100]      <1> 	mov 	ebp, [u.sp] ; points to return address (EIP for IRET)
  1062 0000B92B 895500              <1> 	mov	[ebp], edx ; *, CS:EIP -> EIP
  1063                              <1> 			   ; * return address for the child process
  1064                              <1> 		; mov $sysret1,-(sp) /
  1065                              <1> 		; mov sp,u.usp / contents of sp at the time when 
  1066                              <1> 			      ; / user is swapped out
  1067                              <1> 		; mov $sstack,sp / point sp to swapping stack space
  1068                              <1> 	; 04/09/2015 - 01/09/2015
  1069                              <1> 	; [u.usp] = esp
  1070 0000B92E 68[20B60000]        <1> 	push	sysret ; ***
  1071 0000B933 8925[84300100]      <1> 	mov	[u.usp], esp ; points to 'sysret' address (***)
  1072                              <1> 			     ; (for child process)	
  1073 0000B939 31C0                <1> 	xor 	eax, eax
  1074 0000B93B 66A3[B8300100]      <1> 	mov 	[u.ttyp], ax ; 0
  1075                              <1> 	;
  1076 0000B941 E8BD1E0000          <1> 	call	wswap ; Retro UNIX 8086 v1 modification !
  1077                              <1> 		;jsr r0,wswap / put child process out on drum
  1078                              <1> 		;jsr r0,unpack / unpack user stack
  1079                              <1> 		;mov u.usp,sp / restore user stack pointer
  1080                              <1> 		; tst (sp)+ / bump stack pointer
  1081                              <1> 	; Retro UNIX 386 v1 modification !
  1082 0000B946 58                  <1> 	pop	eax ; ***
  1083 0000B947 66D1E3              <1> 	shl	bx, 1
  1084 0000B94A 8B83[082E0100]      <1> 	mov     eax, [ebx+p.upage-4] ; UPAGE address ; 14/05/2015
  1085 0000B950 E8D71E0000          <1> 	call	rswap ; restore parent process 'u' structure, 
  1086                              <1> 		      ; registers and return address (for IRET)
  1087                              <1> 		;movb (sp)+,u.uno / put parent process number in u.uno
  1088 0000B955 0FB705[72300100]    <1>         movzx   eax, word [mpid]
  1089 0000B95C A3[88300100]        <1> 	mov	[u.r0], eax
  1090                              <1> 		; mov mpid,*u.r0 / put child process name on stack 
  1091                              <1> 			       ; / where r0 was saved
  1092                              <1> 		; add $2,18.(sp) / add 2 to pc on stack; gives parent
  1093                              <1> 			          ; / process return
  1094                              <1> 	;xor	ebx, ebx
  1095 0000B961 31F6                <1> 	xor     esi, esi
  1096                              <1> 		;clr r1
  1097                              <1> sysfork_4: ; 1: / search u.fp list to find the files 
  1098                              <1> 	      ; / opened by the parent process
  1099                              <1> 	; 01/09/2015
  1100                              <1> 	;xor	bh, bh
  1101                              <1> 	;mov 	bl, [esi+u.fp]
  1102 0000B963 8A86[8E300100]      <1> 	mov 	al, [esi+u.fp]
  1103                              <1> 		; movb u.fp(r1),r2 / get an open file for this process
  1104                              <1>         ;or      bl, bl
  1105 0000B969 08C0                <1> 	or	al, al
  1106 0000B96B 740D                <1> 	jz	short sysfork_5	
  1107                              <1> 		; beq 2f / file has not been opened by parent, 
  1108                              <1> 		       ; / so branch
  1109 0000B96D B40A                <1> 	mov	ah, 10 ; Retro UNIX 386 v1 fsp structure size = 10 bytes
  1110 0000B96F F6E4                <1> 	mul	ah
  1111                              <1> 	;movzx	ebx, ax
  1112 0000B971 6689C3              <1> 	mov	bx, ax
  1113                              <1> 	;shl     bx, 3
  1114                              <1> 		; asl r2 / multiply by 8
  1115                              <1>        		; asl r2 / to get index into fsp table
  1116                              <1>        		; asl r2
  1117 0000B974 FE83[5A2E0100]      <1>   	inc     byte [ebx+fsp-2]
  1118                              <1> 		; incb fsp-2(r2) / increment number of processes
  1119                              <1> 			     ; / using file, because child will now be
  1120                              <1> 			     ; / using this file
  1121                              <1> sysfork_5: ; 2:
  1122 0000B97A 46                  <1>         inc     esi
  1123                              <1> 		; inc r1 / get next open file
  1124 0000B97B 6683FE0A            <1>         cmp     si, 10
  1125                              <1> 		; cmp r1,$10. / 10. files is the maximum number which
  1126                              <1> 			  ; / can be opened
  1127 0000B97F 72E2                <1> 	jb	short sysfork_4	
  1128                              <1> 		; blt 1b / check next entry
  1129 0000B981 E99AFCFFFF          <1> 	jmp	sysret
  1130                              <1> 		; br sysret1
  1131                              <1> 
  1132                              <1> sysread: ; < read from file >
  1133                              <1> 	; 13/05/2015
  1134                              <1> 	; 11/05/2015 (Retro UNIX 386 v1 - Beginning)
  1135                              <1> 	; 23/05/2013 (Retro UNIX 8086 v1)
  1136                              <1> 	;
  1137                              <1> 	; 'sysread' is given a buffer to read into and the number of
  1138                              <1> 	; characters to be read. If finds the file from the file
  1139                              <1> 	; descriptor located in *u.r0 (r0). This file descriptor
  1140                              <1> 	; is returned from a successful open call (sysopen).
  1141                              <1> 	; The i-number of file is obtained via 'rw1' and the data
  1142                              <1> 	; is read into core via 'readi'.
  1143                              <1> 	;
  1144                              <1> 	; Calling sequence:
  1145                              <1> 	;	sysread; buffer; nchars
  1146                              <1> 	; Arguments:
  1147                              <1> 	;	buffer - location of contiguous bytes where 
  1148                              <1> 	;		 input will be placed.
  1149                              <1> 	;	nchars - number of bytes or characters to be read.
  1150                              <1> 	; Inputs: *u.r0 - file descriptor (& arguments)
  1151                              <1> 	; Outputs: *u.r0 - number of bytes read.	
  1152                              <1> 	; ...............................................................
  1153                              <1> 	;				
  1154                              <1> 	; Retro UNIX 8086 v1 modification: 
  1155                              <1> 	;       'sysread' system call has three arguments; so,
  1156                              <1> 	;	* 1st argument, file descriptor is in BX register
  1157                              <1> 	;	* 2nd argument, buffer address/offset in CX register
  1158                              <1> 	;	* 3rd argument, number of bytes is in DX register
  1159                              <1> 	;
  1160                              <1> 	;	AX register (will be restored via 'u.r0') will return
  1161                              <1> 	;	to the user with number of bytes read. 
  1162                              <1> 	;
  1163 0000B986 E83D000000          <1> 	call	rw1
  1164 0000B98B 0F826FFCFFFF        <1> 	jc	error ; 13/05/2015, ax < 1
  1165                              <1> 		; jsr r0,rw1 / get i-number of file to be read into r1
  1166 0000B991 F6C480              <1> 	test	ah, 80h
  1167                              <1> 		; tst r1 / negative i-number?
  1168 0000B994 0F8566FCFFFF        <1> 	jnz	error
  1169                              <1> 		; ble error1 / yes, error 1 to read
  1170                              <1> 			   ; / it should be positive
  1171 0000B99A E8E11A0000          <1> 	call	readi
  1172                              <1> 		; jsr r0,readi / read data into core
  1173 0000B99F EB18                <1> 	jmp	short rw0
  1174                              <1> 		; br 1f
  1175                              <1> syswrite: ; < write to file >
  1176                              <1> 	; 13/05/2015
  1177                              <1> 	; 11/05/2015 (Retro UNIX 386 v1 - Beginning)
  1178                              <1> 	; 23/05/2013 (Retro UNIX 8086 v1)
  1179                              <1> 	;
  1180                              <1> 	; 'syswrite' is given a buffer to write onto an output file
  1181                              <1> 	; and the number of characters to write. If finds the file
  1182                              <1> 	; from the file descriptor located in *u.r0 (r0). This file 
  1183                              <1> 	; descriptor is returned from a successful open or create call
  1184                              <1> 	; (sysopen or syscreat). The i-number of file is obtained via
  1185                              <1> 	; 'rw1' and buffer is written on the output file via 'write'.
  1186                              <1> 	;
  1187                              <1> 	; Calling sequence:
  1188                              <1> 	;	syswrite; buffer; nchars
  1189                              <1> 	; Arguments:
  1190                              <1> 	;	buffer - location of contiguous bytes to be writtten.
  1191                              <1> 	;	nchars - number of characters to be written.
  1192                              <1> 	; Inputs: *u.r0 - file descriptor (& arguments)
  1193                              <1> 	; Outputs: *u.r0 - number of bytes written.	
  1194                              <1> 	; ...............................................................
  1195                              <1> 	;				
  1196                              <1> 	; Retro UNIX 8086 v1 modification: 
  1197                              <1> 	;       'syswrite' system call has three arguments; so,
  1198                              <1> 	;	* 1st argument, file descriptor is in BX register
  1199                              <1> 	;	* 2nd argument, buffer address/offset in CX register
  1200                              <1> 	;	* 3rd argument, number of bytes is in DX register
  1201                              <1> 	;
  1202                              <1> 	;	AX register (will be restored via 'u.r0') will return
  1203                              <1> 	;	to the user with number of bytes written. 
  1204                              <1> 	;
  1205 0000B9A1 E822000000          <1> 	call	rw1
  1206 0000B9A6 0F8254FCFFFF        <1> 	jc	error ; 13/05/2015, ax < 1
  1207                              <1> 		; jsr r0,rw1 / get i-number in r1 of file to write
  1208 0000B9AC F6C480              <1>         test	ah, 80h
  1209                              <1> 		; tst r1 / positive i-number ?
  1210 0000B9AF 744E                <1>         jz	short rw3 ; 13/05/2015
  1211                              <1> 	;jz	error
  1212                              <1> 		; bge error1 / yes, error 1 
  1213                              <1> 			   ; / negative i-number means write
  1214 0000B9B1 66F7D8              <1>         neg	ax
  1215                              <1> 		; neg r1 / make it positive
  1216 0000B9B4 E820200000          <1> 	call	writei
  1217                              <1>         	; jsr r0,writei / write data
  1218                              <1> rw0: ; 1:
  1219 0000B9B9 A1[B0300100]        <1>         mov	eax, [u.nread]
  1220 0000B9BE A3[88300100]        <1> 	mov	[u.r0], eax
  1221                              <1> 		; mov u.nread,*u.r0 / put no. of bytes transferred
  1222                              <1> 				  ; / into (u.r0)
  1223 0000B9C3 E958FCFFFF          <1> 	jmp	sysret
  1224                              <1>         	; br sysret1
  1225                              <1> rw1:	
  1226                              <1> 	; 14/05/2015
  1227                              <1> 	; 13/05/2015
  1228                              <1> 	; 11/05/2015 (Retro UNIX 386 v1 - Beginning)
  1229                              <1> 	; 23/05/2013 - 24/05/2013 (Retro UNIX 8086 v1)
  1230                              <1> 	; System call registers: bx, cx, dx (through 'sysenter')
  1231                              <1> 	;
  1232                              <1> 	;mov	[u.base], ecx 	; buffer address/offset 
  1233                              <1> 				;(in the user's virtual memory space)
  1234                              <1> 	;mov	[u.count], edx 
  1235                              <1> 		; jsr r0,arg; u.base / get buffer pointer
  1236                              <1>         	; jsr r0,arg; u.count / get no. of characters
  1237                              <1> 	;;mov	eax, ebx ; file descriptor
  1238                              <1> 		; mov *u.r0,r1 / put file descriptor 
  1239                              <1> 		             ; / (index to u.fp table) in r1
  1240                              <1> 	; 13/05/2015
  1241 0000B9C8 C705[88300100]0000- <1> 	mov	dword [u.r0], 0 ; r/w transfer count = 0 (reset)
  1241 0000B9D0 0000                <1>
  1242                              <1> 	;
  1243                              <1> 	;; call	getf
  1244                              <1>         ; eBX = File descriptor
  1245 0000B9D2 E8BC100000          <1> 	call	getf1 ; calling point in 'getf' from 'rw1'
  1246                              <1> 		; jsr r0,getf / get i-number of the file in r1
  1247                              <1> 	; AX = I-number of the file ; negative i-number means write
  1248                              <1> 	; 13/05/2015
  1249 0000B9D7 6683F801            <1> 	cmp 	ax, 1
  1250 0000B9DB 7217                <1> 	jb	short rw2
  1251                              <1> 	;
  1252 0000B9DD 890D[A8300100]      <1> 	mov	[u.base], ecx 	; buffer address/offset 
  1253                              <1> 				;(in the user's virtual memory space)
  1254 0000B9E3 8915[AC300100]      <1> 	mov	[u.count], edx 
  1255                              <1> 	; 14/05/2015
  1256 0000B9E9 C705[DD300100]0000- <1>         mov     dword [u.error], 0 ; reset the last error code
  1256 0000B9F1 0000                <1>
  1257 0000B9F3 C3                  <1> 	retn
  1258                              <1>         	; rts r0
  1259                              <1> rw2:
  1260                              <1> 	; 13/05/2015
  1261 0000B9F4 C705[DD300100]0A00- <1> 	mov	dword [u.error], ERR_FILE_NOT_OPEN ; file not open !
  1261 0000B9FC 0000                <1>
  1262 0000B9FE C3                  <1> 	retn
  1263                              <1> rw3: 
  1264                              <1> 	; 13/05/2015
  1265 0000B9FF C705[DD300100]0B00- <1> 	mov	dword [u.error], ERR_FILE_ACCESS ; permission denied !
  1265 0000BA07 0000                <1>
  1266 0000BA09 F9                  <1> 	stc
  1267 0000BA0A C3                  <1> 	retn
  1268                              <1> 
  1269                              <1> sysopen: ;<open file>
  1270                              <1> 	; 14/05/2015 (Retro UNIX 386 v1 - Beginning)
  1271                              <1> 	; 22/05/2013 - 27/05/2013 (Retro UNIX 8086 v1)
  1272                              <1> 	;
  1273                              <1> 	; 'sysopen' opens a file in following manner:
  1274                              <1> 	;    1) The second argument in a sysopen says whether to
  1275                              <1> 	;	open the file ro read (0) or write (>0).
  1276                              <1> 	;    2) I-node of the particular file is obtained via 'namei'.
  1277                              <1> 	;    3) The file is opened by 'iopen'.
  1278                              <1> 	;    4) Next housekeeping is performed on the fsp table
  1279                              <1> 	;	and the user's open file list - u.fp.
  1280                              <1> 	;	a) u.fp and fsp are scanned for the next available slot.
  1281                              <1> 	;	b) An entry for the file is created in the fsp table.
  1282                              <1> 	;	c) The number of this entry is put on u.fp list.
  1283                              <1> 	;	d) The file descriptor index to u.fp list is pointed
  1284                              <1> 	;	   to by u.r0.
  1285                              <1> 	;
  1286                              <1> 	; Calling sequence:
  1287                              <1> 	;	sysopen; name; mode
  1288                              <1> 	; Arguments:
  1289                              <1> 	;	name - file name or path name
  1290                              <1> 	;	mode - 0 to open for reading
  1291                              <1> 	;	       1 to open for writing
  1292                              <1> 	; Inputs: (arguments)
  1293                              <1> 	; Outputs: *u.r0 - index to u.fp list (the file descriptor)
  1294                              <1> 	;		  is put into r0's location on the stack.	
  1295                              <1> 	; ...............................................................
  1296                              <1> 	;				
  1297                              <1> 	; Retro UNIX 8086 v1 modification: 
  1298                              <1> 	;       'sysopen' system call has two arguments; so,
  1299                              <1> 	;	* 1st argument, name is pointed to by BX register
  1300                              <1> 	;	* 2nd argument, mode is in CX register
  1301                              <1> 	;
  1302                              <1> 	;	AX register (will be restored via 'u.r0') will return
  1303                              <1> 	;	to the user with the file descriptor/number 
  1304                              <1> 	;	(index to u.fp list).
  1305                              <1> 	;
  1306                              <1> 	;call	arg2
  1307                              <1> 	; * name - 'u.namep' points to address of file/path name
  1308                              <1> 	;          in the user's program segment ('u.segmnt')
  1309                              <1> 	;          with offset in BX register (as sysopen argument 1).
  1310                              <1> 	; * mode - sysopen argument 2 is in CX register 
  1311                              <1> 	;          which is on top of stack.
  1312                              <1> 	;
  1313                              <1> 	; jsr r0,arg2 / get sys args into u.namep and on stack
  1314                              <1> 	;
  1315                              <1>        	; system call registers: ebx, ecx (through 'sysenter')
  1316                              <1> 
  1317 0000BA0B 891D[A0300100]      <1> 	mov	[u.namep], ebx
  1318 0000BA11 6651                <1> 	push	cx
  1319 0000BA13 E8B2100000          <1> 	call	namei
  1320                              <1> 		; jsr r0,namei / i-number of file in r1
  1321                              <1>      	;and	ax, ax
  1322                              <1> 	;jz	error ; File not found
  1323 0000BA18 723B                <1> 	jc	short fnotfound ; 14/05/2015
  1324                              <1> 	;jc	error ; 27/05/2013
  1325                              <1> 		; br  error2 / file not found
  1326 0000BA1A 665A                <1>    	pop	dx ; mode
  1327 0000BA1C 6652                <1> 	push	dx
  1328                              <1> 	;or	dx, dx
  1329 0000BA1E 08D2                <1> 	or	dl, dl
  1330                              <1> 		; tst (sp) / is mode = 0 (2nd arg of call; 
  1331                              <1> 		         ; / 0 means, open for read)
  1332 0000BA20 7403                <1> 	jz	short sysopen_0
  1333                              <1> 		; beq 1f / yes, leave i-number positive
  1334                              <1> syscreat_0: ; 27/12/2015
  1335 0000BA22 66F7D8              <1> 	neg	ax
  1336                              <1>         	; neg r1 / open for writing so make i-number negative
  1337                              <1> sysopen_0: ;1:
  1338 0000BA25 E8B01F0000          <1> 	call	iopen
  1339                              <1> 		;jsr r0,iopen / open file whose i-number is in r1
  1340 0000BA2A 665A                <1> 	pop	dx
  1341                              <1> 	;and	dx, dx
  1342 0000BA2C 20D2                <1> 	and	dl, dl
  1343                              <1>         	; tst (sp)+ / pop the stack and test the mode
  1344 0000BA2E 7403                <1> 	jz	short sysopen_2
  1345                              <1>         	; beq op1 / is open for read op1
  1346                              <1> sysopen_1: ;op0:
  1347 0000BA30 66F7D8              <1> 	neg	ax
  1348                              <1>         	; neg r1 
  1349                              <1> 		     ;/ make i-number positive if open for writing [???]
  1350                              <1> 	;; NOTE: iopen always make i-number positive.
  1351                              <1> 	;; Here i-number becomes negative again. [22/05/2013]
  1352                              <1> sysopen_2: ;op1:
  1353 0000BA33 31F6                <1>         xor     esi, esi
  1354                              <1>         	; clr r2 / clear registers
  1355 0000BA35 31DB                <1>         xor     ebx, ebx
  1356                              <1> 		; clr r3
  1357                              <1> sysopen_3: ;1: / scan the list of entries in fsp table
  1358 0000BA37 389E[8E300100]      <1>         cmp     [esi+u.fp], bl ; 0
  1359                              <1> 		; tstb u.fp(r2) / test the entry in the u.fp list
  1360 0000BA3D 7625                <1>         jna      short sysopen_4
  1361                              <1> 		; beq 1f / if byte in list is 0 branch
  1362 0000BA3F 46                  <1>         inc     esi
  1363                              <1> 		; inc r2 / bump r2 so next byte can be checked
  1364 0000BA40 6683FE0A            <1>         cmp     si, 10
  1365                              <1> 		; cmp r2,$10. / reached end of list?
  1366 0000BA44 72F1                <1> 	jb	short sysopen_3
  1367                              <1> 		; blt 1b / no, go back
  1368                              <1> toomanyf:
  1369                              <1> 	; 14/05/2015
  1370 0000BA46 C705[DD300100]0D00- <1> 	mov	dword [u.error], ERR_TOO_MANY_FILES ; too many open files !
  1370 0000BA4E 0000                <1>
  1371 0000BA50 E9ABFBFFFF          <1> 	jmp	error
  1372                              <1>         	; br error2 / yes, error (no files open)
  1373                              <1> fnotfound: 
  1374                              <1> 	; 14/05/2015
  1375 0000BA55 C705[DD300100]0C00- <1> 	mov	dword [u.error], ERR_FILE_NOT_FOUND ; file not found !
  1375 0000BA5D 0000                <1>
  1376 0000BA5F E99CFBFFFF          <1> 	jmp	error
  1377                              <1> 
  1378                              <1> sysopen_4: ; 1:
  1379 0000BA64 6683BB[5C2E0100]00  <1>         cmp     word [ebx+fsp], 0
  1380                              <1> 		; tst fsp(r3) / scan fsp entries
  1381 0000BA6C 7610                <1>         jna     short sysopen_5
  1382                              <1> 		; beq 1f / if 0 branch
  1383                              <1> 	; 14/05/2015 - Retro UNIX 386 v1 modification !
  1384 0000BA6E 6683C30A            <1>         add     bx, 10 ; fsp structure size = 10 bytes/entry
  1385                              <1> 		; add $8.,r3 / add 8 to r3 
  1386                              <1> 			; / to bump it to next entry mfsp table
  1387 0000BA72 6681FBF401          <1>         cmp     bx, nfiles*10
  1388                              <1> 		; cmp r3,$[nfiles*8.] / done scanning
  1389 0000BA77 72EB                <1> 	jb	short sysopen_4
  1390                              <1>        		; blt 1b / no, back
  1391 0000BA79 E982FBFFFF          <1> 	jmp	error
  1392                              <1>         	; br error2 / yes, error
  1393                              <1> sysopen_5: ; 1: / r2 has index to u.fp list; r3, has index to fsp table
  1394 0000BA7E 668983[5C2E0100]    <1>         mov     [ebx+fsp], ax
  1395                              <1> 		; mov r1,fsp(r3) / put i-number of open file 
  1396                              <1> 			; / into next available entry in fsp table,
  1397 0000BA85 668B3D[6A300100]    <1> 	mov	di, [cdev] ; word ? byte ?
  1398 0000BA8C 6689BB[5E2E0100]    <1>         mov     [ebx+fsp+2], di ; device number
  1399                              <1> 		; mov cdev,fsp+2(r3) / put # of device in next word
  1400 0000BA93 31FF                <1>         xor	edi, edi
  1401 0000BA95 89BB[602E0100]      <1>         mov     [ebx+fsp+4], edi ; offset pointer (0)
  1402                              <1> 		; clr fsp+4(r3)
  1403 0000BA9B 6689BB[642E0100]    <1>         mov     [ebx+fsp+8], di ; open count (0), deleted flag (0)
  1404                              <1>        		; clr fsp+6(r3) / clear the next two words
  1405 0000BAA2 89D8                <1>   	mov	eax, ebx
  1406 0000BAA4 B30A                <1> 	mov	bl, 10
  1407 0000BAA6 F6F3                <1> 	div	bl 
  1408                              <1> 		; asr r3
  1409                              <1> 		; asr r3 / divide by 8 
  1410                              <1> 		; asr r3 ; / to get number of the fsp entry-1
  1411 0000BAA8 FEC0                <1> 	inc	al
  1412                              <1>         	; inc r3 / add 1 to get fsp entry number
  1413 0000BAAA 8886[8E300100]      <1>         mov     [esi+u.fp], al
  1414                              <1> 		; movb r3,u.fp(r2) / move entry number into 
  1415                              <1> 			; / next available slot in u.fp list
  1416 0000BAB0 8935[88300100]      <1>         mov     [u.r0], esi
  1417                              <1> 		; mov r2,*u.r0 / move index to u.fp list 
  1418                              <1> 			     ; / into r0 loc on stack
  1419 0000BAB6 E965FBFFFF          <1>         jmp	sysret
  1420                              <1> 		; br sysret2
  1421                              <1> 
  1422                              <1> 	;
  1423                              <1> 	; 'fsp' table (10 bytes/entry)
  1424                              <1> 	; bit 15				   bit 0
  1425                              <1> 	; ---|-------------------------------------------
  1426                              <1> 	; r/w|		i-number of open file
  1427                              <1> 	; ---|-------------------------------------------
  1428                              <1> 	;		   device number
  1429                              <1> 	; -----------------------------------------------
  1430                              <1> 	; offset pointer, r/w pointer to file (bit 0-15)
  1431                              <1> 	; -----------------------------------------------
  1432                              <1> 	; offset pointer, r/w pointer to file (bit 16-31)
  1433                              <1> 	; ----------------------|------------------------
  1434                              <1> 	;  flag that says file 	| number of processes
  1435                              <1> 	;   has been deleted	| that have file open 
  1436                              <1> 	; ----------------------|------------------------
  1437                              <1> 	;
  1438                              <1> 
  1439                              <1> syscreat: ; < create file >
  1440                              <1> 	; 27/12/2015 (Retro UNIX 386 v1.1)
  1441                              <1> 	; 14/05/2015 (Retro UNIX 386 v1 - Beginning)
  1442                              <1> 	; 27/05/2013 (Retro UNIX 8086 v1)
  1443                              <1> 	;
  1444                              <1> 	; 'syscreat' called with two arguments; name and mode.
  1445                              <1> 	; u.namep points to name of the file and mode is put
  1446                              <1> 	; on the stack. 'namei' is called to get i-number of the file.		
  1447                              <1> 	; If the file aready exists, it's mode and owner remain 
  1448                              <1> 	; unchanged, but it is truncated to zero length. If the file
  1449                              <1> 	; did not exist, an i-node is created with the new mode via
  1450                              <1> 	; 'maknod' whether or not the file already existed, it is
  1451                              <1> 	; open for writing. The fsp table is then searched for a free
  1452                              <1> 	; entry. When a free entry is found, proper data is placed
  1453                              <1> 	; in it and the number of this entry is put in the u.fp list.
  1454                              <1> 	; The index to the u.fp (also know as the file descriptor)
  1455                              <1> 	; is put in the user's r0. 			
  1456                              <1> 	;
  1457                              <1> 	; Calling sequence:
  1458                              <1> 	;	syscreate; name; mode
  1459                              <1> 	; Arguments:
  1460                              <1> 	;	name - name of the file to be created
  1461                              <1> 	;	mode - mode of the file to be created
  1462                              <1> 	; Inputs: (arguments)
  1463                              <1> 	; Outputs: *u.r0 - index to u.fp list 
  1464                              <1> 	;		   (the file descriptor of new file)
  1465                              <1> 	; ...............................................................
  1466                              <1> 	;				
  1467                              <1> 	; Retro UNIX 8086 v1 modification: 
  1468                              <1> 	;       'syscreate' system call has two arguments; so,
  1469                              <1> 	;	* 1st argument, name is pointed to by BX register
  1470                              <1> 	;	* 2nd argument, mode is in CX register
  1471                              <1> 	;
  1472                              <1> 	;	AX register (will be restored via 'u.r0') will return
  1473                              <1> 	;	to the user with the file descriptor/number 
  1474                              <1> 	;	(index to u.fp list).
  1475                              <1> 	;
  1476                              <1> 	;call	arg2
  1477                              <1> 	; * name - 'u.namep' points to address of file/path name
  1478                              <1> 	;          in the user's program segment ('u.segmnt')
  1479                              <1> 	;          with offset in BX register (as sysopen argument 1).
  1480                              <1> 	; * mode - sysopen argument 2 is in CX register 
  1481                              <1> 	;          which is on top of stack.
  1482                              <1> 	;
  1483                              <1>         	; jsr r0,arg2 / put file name in u.namep put mode 
  1484                              <1> 			    ; / on stack
  1485 0000BABB 891D[A0300100]      <1> 	mov	[u.namep], ebx ; file name address
  1486 0000BAC1 6651                <1> 	push	cx ; mode
  1487 0000BAC3 E802100000          <1> 	call 	namei        	
  1488                              <1> 		; jsr r0,namei / get the i-number
  1489                              <1>         ;and	ax, ax
  1490                              <1> 	;jz	short syscreat_1	       	
  1491 0000BAC8 721E                <1> 	jc	short syscreat_1
  1492                              <1> 		; br  2f / if file doesn't exist 2f
  1493                              <1> 	; 27/12/2015
  1494 0000BACA 6683F829            <1> 	cmp	ax, 41 ; device inode ?
  1495 0000BACE 0F824EFFFFFF        <1>         jb      syscreat_0 ; yes
  1496                              <1> 	;
  1497 0000BAD4 66F7D8              <1> 	neg 	ax
  1498                              <1>         	; neg r1 / if file already exists make i-number 
  1499                              <1> 		       ; / negative (open for writing)
  1500 0000BAD7 E8FE1E0000          <1> 	call	iopen
  1501                              <1>         	; jsr r0,iopen /
  1502 0000BADC E8FB1E0000          <1> 	call	itrunc
  1503                              <1>         	; jsr r0,itrunc / truncate to 0 length
  1504 0000BAE1 6659                <1> 	pop	cx ; pop mode (did not exist in original Unix v1 !?)
  1505 0000BAE3 E948FFFFFF          <1>         jmp     sysopen_1
  1506                              <1>         	; br op0
  1507                              <1> syscreat_1: ; 2: / file doesn't exist
  1508 0000BAE8 6658                <1> 	pop	ax
  1509                              <1>         	; mov (sp)+,r1 / put the mode in r1
  1510 0000BAEA 30E4                <1> 	xor	ah, ah	
  1511                              <1>         	; bic $!377,r1 / clear upper byte
  1512 0000BAEC E8AC120000          <1> 	call 	maknod
  1513                              <1>         	; jsr r0,maknod / make an i-node for this file
  1514 0000BAF1 66A1[BA300100]      <1> 	mov	ax, [u.dirbuf]
  1515                              <1>         	; mov u.dirbuf,r1 / put i-number 
  1516                              <1> 			        ; / for this new file in r1
  1517 0000BAF7 E934FFFFFF          <1>         jmp     sysopen_1
  1518                              <1>         	; br op0 / open the file
  1519                              <1> 
  1520                              <1> sysmkdir: ; < make directory >
  1521                              <1> 	; 14/05/2015 (Retro UNIX 386 v1 - Beginning)
  1522                              <1> 	; 27/05/2013 - 02/08/2013 (Retro UNIX 8086 v1)
  1523                              <1> 	;
  1524                              <1> 	; 'sysmkdir' creates an empty directory whose name is
  1525                              <1> 	; pointed to by arg 1. The mode of the directory is arg 2.	
  1526                              <1> 	; The special entries '.' and '..' are not present.
  1527                              <1> 	; Errors are indicated if the directory already exists or		
  1528                              <1> 	; user is not the super user. 
  1529                              <1> 	;
  1530                              <1> 	; Calling sequence:
  1531                              <1> 	;	sysmkdir; name; mode
  1532                              <1> 	; Arguments:
  1533                              <1> 	;	name - points to the name of the directory
  1534                              <1> 	;	mode - mode of the directory
  1535                              <1> 	; Inputs: (arguments)
  1536                              <1> 	; Outputs: -
  1537                              <1> 	;    (sets 'directory' flag to 1; 
  1538                              <1> 	;    'set user id on execution' and 'executable' flags to 0)
  1539                              <1> 	; ...............................................................
  1540                              <1> 	;				
  1541                              <1> 	; Retro UNIX 8086 v1 modification: 
  1542                              <1> 	;       'sysmkdir' system call has two arguments; so,
  1543                              <1> 	;	* 1st argument, name is pointed to by BX register
  1544                              <1> 	;	* 2nd argument, mode is in CX register
  1545                              <1> 	;
  1546                              <1> 		
  1547                              <1> ; / make a directory
  1548                              <1> 
  1549                              <1> 	;call	arg2
  1550                              <1> 	; * name - 'u.namep' points to address of file/path name
  1551                              <1> 	;          in the user's program segment ('u.segmnt')
  1552                              <1> 	;          with offset in BX register (as sysopen argument 1).
  1553                              <1> 	; * mode - sysopen argument 2 is in CX register 
  1554                              <1> 	;          which is on top of stack.
  1555                              <1> 
  1556                              <1> 		; jsr r0,arg2 / put file name in u.namep put mode 
  1557                              <1> 			    ; / on stack
  1558 0000BAFC 891D[A0300100]      <1> 	mov	[u.namep], ebx
  1559 0000BB02 6651                <1> 	push	cx ; mode
  1560 0000BB04 E8C10F0000          <1> 	call	namei
  1561                              <1>         	; jsr r0,namei / get the i-number
  1562                              <1>         	;     br .+4 / if file not found branch around error
  1563                              <1>         ;xor 	ax, ax
  1564                              <1> 	;jnz	error
  1565 0000BB09 731C                <1> 	jnc	short dir_exists ; 14/05/2015
  1566                              <1> 	;jnc	error	
  1567                              <1> 		; br  error2 / directory already exists (error)
  1568 0000BB0B 803D[D4300100]00    <1> 	cmp	byte [u.uid], 0 ; 02/08/2013
  1569                              <1>         	;tstb u.uid / is user the super user
  1570 0000BB12 7622                <1> 	jna	short dir_access_err ; 14/05/2015
  1571                              <1> 	;jna	error
  1572                              <1>         	;bne error2 / no, not allowed
  1573 0000BB14 6658                <1> 	pop	ax
  1574                              <1>         	;mov (sp)+,r1 / put the mode in r1
  1575 0000BB16 6683E0CF            <1> 	and	ax, 0FFCFh ; 1111111111001111b
  1576                              <1>         	;bic $!317,r1 / all but su and ex
  1577                              <1> 	;or	ax , 4000h ; 1011111111111111b
  1578 0000BB1A 80CC40              <1> 	or	ah, 40h ; Set bit 14 to 1
  1579                              <1>         	;bis $40000,r1 / directory flag
  1580 0000BB1D E87B120000          <1> 	call	maknod
  1581                              <1>         	;jsr r0,maknod / make the i-node for the directory
  1582 0000BB22 E9F9FAFFFF          <1> 	jmp	sysret
  1583                              <1>         	;br sysret2 /
  1584                              <1> dir_exists:
  1585                              <1> 	; 14/05/2015
  1586 0000BB27 C705[DD300100]0E00- <1> 	mov	dword [u.error], ERR_DIR_EXISTS ; dir. already exists !
  1586 0000BB2F 0000                <1>
  1587 0000BB31 E9CAFAFFFF          <1> 	jmp	error
  1588                              <1> dir_access_err:
  1589                              <1> 	; 14/05/2015
  1590 0000BB36 C705[DD300100]0B00- <1> 	mov	dword [u.error], ERR_DIR_ACCESS ; permission denied !
  1590 0000BB3E 0000                <1>
  1591 0000BB40 E9BBFAFFFF          <1> 	jmp	error
  1592                              <1> 
  1593                              <1> sysclose: ;<close file>
  1594                              <1> 	; 14/05/2015 (Retro UNIX 386 v1 - Beginning)
  1595                              <1> 	; 22/05/2013 - 26/05/2013 (Retro UNIX 8086 v1)
  1596                              <1> 	;
  1597                              <1> 	; 'sysclose', given a file descriptor in 'u.r0', closes the
  1598                              <1> 	; associated file. The file descriptor (index to 'u.fp' list)
  1599                              <1> 	; is put in r1 and 'fclose' is called.
  1600                              <1> 	;
  1601                              <1> 	; Calling sequence:
  1602                              <1> 	;	sysclose
  1603                              <1> 	; Arguments:
  1604                              <1> 	;	-  
  1605                              <1> 	; Inputs: *u.r0 - file descriptor
  1606                              <1> 	; Outputs: -
  1607                              <1> 	; ...............................................................
  1608                              <1> 	;				
  1609                              <1> 	; Retro UNIX 8086 v1 modification:
  1610                              <1> 	;	 The user/application program puts file descriptor
  1611                              <1> 	;        in BX register as 'sysclose' system call argument.
  1612                              <1> 	; 	 (argument transfer method 1)
  1613                              <1> 
  1614                              <1> 	; / close the file
  1615                              <1> 	
  1616 0000BB45 89D8                <1> 	mov 	eax, ebx
  1617 0000BB47 E8FC0E0000          <1> 	call 	fclose
  1618                              <1> 		; mov *u.r0,r1 / move index to u.fp list into r1
  1619                              <1> 		; jsr r0,fclose / close the file
  1620                              <1>                	; br error2 / unknown file descriptor
  1621                              <1> 		; br sysret2
  1622                              <1> 	; 14/05/2015
  1623 0000BB4C 0F83CEFAFFFF        <1> 	jnc	sysret
  1624 0000BB52 C705[DD300100]0A00- <1> 	mov	dword [u.error], ERR_FILE_NOT_OPEN ; file not open !
  1624 0000BB5A 0000                <1>
  1625 0000BB5C E99FFAFFFF          <1> 	jmp	error
  1626                              <1> 
  1627                              <1> sysemt: ; enable (or disable) multi tasking -time sharing-
  1628                              <1> 	;
  1629                              <1> 	; 23/05/2016 - TRDOS 386 (TRDOS v2.0)
  1630                              <1> 	; 14/05/2015 (Retro UNIX 386 v1)
  1631                              <1> 	; 10/12/2013 - 20/04/2014 (Retro UNIX 8086 v1)
  1632                              <1> 	;
  1633                              <1> 	; Retro UNIX 8086 v1 modification: 
  1634                              <1> 	;	'Enable Multi Tasking'  system call instead 
  1635                              <1> 	;	of 'Emulator Trap' in original UNIX v1 for PDP-11.
  1636                              <1> 	;
  1637                              <1> 	; Retro UNIX 8086 v1 feature only!
  1638                              <1> 	;	Using purpose: Kernel will start without time-out
  1639                              <1> 	;	(internal clock/timer) functionality.
  1640                              <1> 	;	Then etc/init will enable clock/timer for
  1641                              <1> 	;	multi tasking. 
  1642                              <1> 	;
  1643                              <1> 	; INPUT ->
  1644                              <1> 	;	BL = 0 -> disable multi tasking
  1645                              <1> 	;	BL > 1 -> enable multi tasking (time sharing) 
  1646                              <1> 	; OUTPUT ->
  1647                              <1> 	;	none	
  1648                              <1> 	;
  1649                              <1> 	;  Note: Multi tasking is disabled during system
  1650                              <1> 	;	 initialization, it must be enabled by using
  1651                              <1> 	;	 this system call. (Otherwise, running proces 
  1652                              <1> 	;	 will not be changed by another process within
  1653                              <1> 	;	 run time sequence/schedule, if running process
  1654                              <1> 	;	 will not 'release' itself. Only 'wakeup' procedure
  1655                              <1> 	;	 for waiting processes and programmed timer events
  1656                              <1> 	;	 for other processes can change running process 
  1657                              <1> 	;	 while multi tasking is disabled.) ** 23/05/2016 **
  1658                              <1> 
  1659 0000BB61 803D[D4300100]00    <1> 	cmp	byte [u.uid], 0 ; root ?
  1660                              <1> 	;ja	error
  1661 0000BB68 0F873BFBFFFF        <1> 	ja	badsys ; 14/05/2015
  1662                              <1> 	;
  1663 0000BB6E FA                  <1> 	cli
  1664 0000BB6F 881D[2E2D0100]      <1> 	mov	[multi_tasking], bl ; 0 to disable, >0 to enable
  1665 0000BB75 E9A6FAFFFF          <1> 	jmp	sysret
  1666                              <1> 
  1667                              <1> systimer:
  1668                              <1> 	; 10/06/2016
  1669                              <1> 	; 07/06/2016
  1670                              <1> 	; 06/06/2016
  1671                              <1> 	; 21/05/2016
  1672                              <1> 	; 19/05/2016
  1673                              <1> 	; 18/05/2016 - TRDOS 386 (TRDOS v2.0)
  1674                              <1> 	; (TRDOS 386 feature only!)
  1675                              <1> 	;
  1676                              <1> 	; (start or stop timer event(s))	
  1677                              <1> 	;
  1678                              <1> 	; INPUT ->
  1679                              <1> 	;	BL = Signal return byte (response byte)
  1680                              <1> 	;	     (Any requested value between 0 and 255)
  1681                              <1> 	;	     (Kernel will put it at the requested address)    	
  1682                              <1> 	;	BH = Time count unit
  1683                              <1> 	;	     0 = Stop timer event
  1684                              <1> 	;	     1 = 18.2 ticks per second
  1685                              <1> 	;	     2 = 10 milliseconds  		
  1686                              <1> 	;	     3 = 1 second (for real time clock interrupt) 	 
  1687                              <1> 	;	     4 to 255 = undefined
  1688                              <1> 	;	BH = 0 -> Stop timer event
  1689                              <1> 	;	BL = Timer event number (1 to 255) if BH = 0     	
  1690                              <1> 	;	     If BL = 0, all timer events (which are belongs
  1691                              <1> 	;	      to running process) will be stopped 		    
  1692                              <1> 	;	ECX = Time/Tick count (depending on time count unit)
  1693                              <1> 	;	EDX = Signal return (Response) byte address
  1694                              <1> 	;	      (virtual address in user's memory space)
  1695                              <1> 	; OUTPUT ->
  1696                              <1> 	;	AL = Timer event number	(1 to 255) (max. value = 16)
  1697                              <1> 	;	IF BH Input = 0 & CF = 0 & AL = 0 -> 
  1698                              <1> 	;	     timer event(s) has/have been stopped/finished
  1699                              <1> 	;	CF = 1 & AL = 0 -> no timer setting space to set
  1700                              <1> 	;	CF = 1 & AL > 0 -> timer count unit is not usable
  1701                              <1> 	;
  1702                              <1> 	;	NOTE: To modify a time count for a user function,
  1703                              <1> 	;	      at first, current timer event must be stopped
  1704                              <1> 	;	      then a new timer event (which is related with
  1705                              <1> 	;	      same user function) must be started.
  1706                              <1> 	;		
  1707                              <1> 	;	      Signal return (response) byte may be used for 
  1708                              <1> 	;	      several purposes. Kernel will put this value 
  1709                              <1> 	;	      to requested address during timer interrupt,
  1710                              <1> 	;	      program/user can check this value to understand
  1711                              <1> 	;	      which event has been occurred and what is changed.
  1712                              <1> 	;	      (Multi timer events can share same signal address)
  1713                              <1> 	;	
  1714                              <1> 	;	NOTE: If the process is running while the time count
  1715                              <1> 	;	      is reached, kernel will put signal return (response)
  1716                              <1> 	;	      byte value at requested address during timer
  1717                              <1> 	;	      interrupt and the process will continue to run.
  1718                              <1> 	;	      Program/process must call (jump to) it's timer event
  1719                              <1> 	;	      function as required, for checking the timer event
  1720                              <1> 	;	      status via signal return (response) byte address. 
  1721                              <1> 	;
  1722                              <1> 	;	      If the process is not running (waiting or sleeping
  1723                              <1> 	;	      or released) while the time count is reached,
  1724                              <1> 	;	      it is restarted from where it left, to ensure
  1725                              <1> 	;	      proper multi media (video, audio, clock, timer)
  1726                              <1> 	;	      functionality.
  1727                              <1> 	;
  1728                              <1> 	;	      (It is better to use 'syswait' or 'syssleep',
  1729                              <1> 	;	      or 'sysrele' system call just after the timer
  1730                              <1> 	;	      function. Otherwise, timer events may block other
  1731                              <1> 	;	      processes which are not using timer events.)  	 		 			 		 	
  1732                              <1> 	;	     	      		 			
  1733                              <1> 	; Timer Event Structure: (max. 16 timer events, 16*16 bytes)
  1734                              <1> 	;       Owner:	        resb 1 ; 0 = free
  1735                              <1> 	;		  	       ;>0 = process number (u.uno)
  1736                              <1> 	;	Reserved:	resb 1 ; 0
  1737                              <1> 	;	Interrupt:      resb 1 ; 0 = Timer interrupt (or none)
  1738                              <1> 	;		   	       ; 1 = Real Time Clock interrupt 
  1739                              <1> 	;	Response:       resb 1 ; 0 to 255, signal return value
  1740                              <1> 	;	Count Limit:	resd 1 ; count of ticks (total/set)
  1741                              <1> 	;	Current Count: 	resd 1 ; count of ticks (current)
  1742                              <1> 	;	Response Addr:  resd 1 ; response byte (pointer) address
  1743                              <1> 	;
  1744                              <1> 
  1745 0000BB7A 80FF02              <1> 	cmp	bh, 2
  1746 0000BB7D 7445                <1>         je      short systimer_5  ; only 18.2 ticks per second is usable
  1747                              <1> 				  ; 10 milliseconds (100 Hertz) timer 
  1748                              <1> 				  ; will be set later (18/05/2016)
  1749 0000BB7F 774B                <1>         ja      short systimer_6 
  1750                              <1> 
  1751 0000BB81 20FF                <1> 	and	bh, bh
  1752 0000BB83 0F8490000000        <1>         jz      systimer_9        ; stop timer event(s)
  1753                              <1> 
  1754                              <1> 	; bh = 1 (timer interrupt, 18.2 Hz, IBM PC/AT ROMBIOS default)
  1755                              <1> 
  1756 0000BB89 B00A                <1> 	mov	al, 10 ; (*)
  1757                              <1> 
  1758                              <1> systimer_0:
  1759 0000BB8B B710                <1> 	mov	bh, 16
  1760                              <1> 	;
  1761 0000BB8D 383D[2F2D0100]      <1> 	cmp	[timer_events], bh ; 16 ; 07/06/2016
  1762 0000BB93 7319                <1> 	jnb 	short systimer_3  ; max. 16 timer events
  1763                              <1> 	;
  1764 0000BB95 50                  <1> 	push	eax ; (*)
  1765                              <1> 
  1766 0000BB96 BF[4C3D0100]        <1> 	mov	edi, timer_set  ; beginning address of timer events
  1767                              <1> 				; setting space
  1768 0000BB9B 30C0                <1> 	xor	al, al ; 0
  1769                              <1> systimer_1:
  1770 0000BB9D FEC0                <1> 	inc	al
  1771 0000BB9F 803F00              <1> 	cmp	byte [edi], 0 	; is it free space ?
  1772 0000BBA2 7631                <1> 	jna	short systimer_7 ; yes
  1773 0000BBA4 FECF                <1> 	dec	bh
  1774 0000BBA6 7405                <1> 	jz	short systimer_2
  1775 0000BBA8 83C710              <1> 	add	edi, 16
  1776 0000BBAB EBF0                <1> 	jmp	short  systimer_1 ; next event space
  1777                              <1> 
  1778                              <1> systimer_2:
  1779 0000BBAD 58                  <1> 	pop	eax ; (*) discard
  1780                              <1> systimer_3:
  1781 0000BBAE C605[88300100]00    <1> 	mov	byte [u.r0], 0
  1782                              <1> systimer_4:
  1783 0000BBB5 C705[DD300100]1A00- <1>         mov     dword [u.error], ERR_MISC
  1783 0000BBBD 0000                <1>
  1784                              <1>                                 ; one of miscellaneous/other errors
  1785 0000BBBF E93CFAFFFF          <1> 	jmp	error ; cf -> 1
  1786                              <1> 
  1787                              <1> systimer_5:
  1788 0000BBC4 883D[88300100]      <1> 	mov	[u.r0], bh ; Time count unit (=2 or >3)
  1789 0000BBCA EBE9                <1> 	jmp	short systimer_4 ; 07/06/2016
  1790                              <1> 
  1791                              <1> systimer_6:
  1792 0000BBCC 80FF03              <1> 	cmp	bh, 3
  1793 0000BBCF 77F3                <1>         ja      short systimer_5  ; undefined time count unit
  1794                              <1> 
  1795                              <1> 	; bh = 3
  1796                              <1> 	; timer event via real time clock interrupt
  1797                              <1> 	; interrupt/update frequency: 1 Hz (1 tick per second)
  1798                              <1> 	
  1799 0000BBD1 B0B6                <1> 	mov	al, 182 ; (*) ; 18.2 * 10
  1800 0000BBD3 EBB6                <1>         jmp     short systimer_0
  1801                              <1> 
  1802                              <1> systimer_7:
  1803 0000BBD5 A2[88300100]        <1> 	mov	[u.r0], al ; timer event number
  1804                              <1> 	;
  1805                              <1> 	; edi = address of empty timer event area
  1806 0000BBDA A0[D7300100]        <1> 	mov	al, [u.uno]
  1807 0000BBDF FA                  <1> 	cli 	; disable interrupts 
  1808 0000BBE0 AA                  <1> 	stosb	; process number
  1809 0000BBE1 D0E0                <1> 	shl	al, 1
  1810 0000BBE3 89C6                <1> 	mov	esi, eax
  1811 0000BBE5 28C0                <1> 	sub	al, al
  1812 0000BBE7 AA                  <1> 	stosb 	; reserved (=0)
  1813 0000BBE8 B001                <1> 	mov	al, 1 ; this is for real time clock interrupt
  1814 0000BBEA AA                  <1> 	stosb	; interrupt type
  1815 0000BBEB 88D8                <1> 	mov	al, bl ; Signal return (Response) value
  1816 0000BBED AA                  <1> 	stosb  ; response byte
  1817 0000BBEE 58                  <1> 	pop	eax ; (*) ; 10 or 182
  1818 0000BBEF 89D3                <1> 	mov	ebx, edx ; virtual address for response/signal byte
  1819 0000BBF1 F7E1                <1> 	mul	ecx
  1820                              <1> 	; (eax = 10 * count of 18.2 Hz timer ticks)
  1821                              <1> 	; (count down step = 10)
  1822 0000BBF3 AB                  <1> 	stosd  ; count limit (reset value)
  1823 0000BBF4 AB                  <1> 	stosd  ; current count value
  1824                              <1> 	; ebx = virtual address
  1825                              <1> 	; [u.pgdir] = page directory's physical address
  1826 0000BBF5 E8E090FFFF          <1> 	call	get_physical_addr
  1827 0000BBFA 720D                <1> 	jc	short systimer_8 ; 07/06/2016
  1828                              <1> 	; eax = physical address of the virtual address in user's space
  1829 0000BBFC AB                  <1> 	stosd	; response address (physical)
  1830 0000BBFD FE05[2F2D0100]      <1> 	inc	byte [timer_events] ; 07/06/201
  1831 0000BC03 FB                  <1> 	sti 	; enable interrupts
  1832 0000BC04 E917FAFFFF          <1> 	jmp	sysret
  1833                              <1> 
  1834                              <1> systimer_8:
  1835                              <1> 	; 10/06/2016
  1836                              <1> 	; 07/06/2016
  1837 0000BC09 28C0                <1> 	sub	al, al ; 0
  1838 0000BC0B 8847F4              <1> 	mov	[edi-12], al ; clear process nummber (free timer event)
  1839                              <1> 	;mov	dword [edi], eax ; 0
  1840 0000BC0E FB                  <1> 	sti
  1841 0000BC0F A2[88300100]        <1> 	mov	[u.r0], al ; 0
  1842 0000BC14 E9E7F9FFFF          <1> 	jmp	error
  1843                              <1> 
  1844                              <1> systimer_9:
  1845                              <1> 	; 10/06/2016
  1846                              <1> 	; 07/06/2016
  1847 0000BC19 28C0                <1> 	sub	al, al
  1848 0000BC1B A2[88300100]        <1> 	mov	byte [u.r0], al ; 0
  1849 0000BC20 3805[2F2D0100]      <1> 	cmp     byte [timer_events], al ;  0
  1850 0000BC26 7631                <1> 	jna	short systimer_12
  1851                              <1> 
  1852                              <1> 	; Note: ecx and edx are undefined here
  1853                              <1> 	;	(for stop timer function)
  1854                              <1> 
  1855 0000BC28 BE[4C3D0100]        <1> 	mov	esi, timer_set  ; beginning address of timer events
  1856                              <1> 				; setting space	 
  1857 0000BC2D A0[D7300100]        <1> 	mov	al, [u.uno]
  1858                              <1> 	
  1859 0000BC32 B710                <1> 	mov	bh, 16
  1860                              <1> 
  1861 0000BC34 08DB                <1> 	or	bl, bl
  1862 0000BC36 7544                <1> 	jnz	short systimer_15
  1863                              <1> 
  1864                              <1> 	; clear timer event areas belong to current process
  1865                              <1> 	; (for stopping all timer events belong to current process) 
  1866 0000BC38 FA                  <1> 	cli 	; disable interrupts
  1867                              <1> systimer_10:
  1868                              <1> 	; 10/06/2016
  1869                              <1> 	; 07/06/2016 	
  1870 0000BC39 8A26                <1> 	mov	ah, [esi]
  1871 0000BC3B 08E4                <1> 	or	ah, ah ; 0 ?
  1872 0000BC3D 7411                <1> 	jz	short systimer_11
  1873 0000BC3F 38C4                <1> 	cmp	ah, al ; is the process ID (owner) same ?
  1874 0000BC41 750D                <1>         jne     short systimer_11 ; no
  1875                              <1> 
  1876                              <1> 	;mov	byte [esi], 0
  1877 0000BC43 66C7060000          <1> 	mov	word [esi], 0 ; clear
  1878                              <1> 	;mov	dword [esi+12], 0 ; clear
  1879                              <1> 
  1880 0000BC48 FE0D[2F2D0100]      <1> 	dec	byte [timer_events]
  1881 0000BC4E 7409                <1> 	jz	short systimer_12
  1882                              <1> 
  1883                              <1> systimer_11:
  1884 0000BC50 FECF                <1> 	dec	bh
  1885 0000BC52 7405                <1> 	jz	short systimer_12
  1886 0000BC54 83C610              <1> 	add	esi, 16
  1887 0000BC57 EBE0                <1> 	jmp	short systimer_10
  1888                              <1> 
  1889                              <1> systimer_12:
  1890 0000BC59 0FB635[D7300100]    <1> 	movzx	esi, byte [u.uno]
  1891 0000BC60 08DB                <1> 	or	bl, bl ; all timer events or one timer event ?
  1892 0000BC62 740C                <1> 	jz	short systimer_13
  1893 0000BC64 8A9E[4B2E0100]      <1> 	mov	bl, [esi+p.timer-1]
  1894 0000BC6A 20DB                <1> 	and	bl, bl	; previous number of timer events for the process
  1895 0000BC6C 7408                <1> 	jz	short systimer_14
  1896 0000BC6E FECB                <1> 	dec	bl  ; previous number of timer events for the process - 1
  1897                              <1> systimer_13:
  1898 0000BC70 889E[4B2E0100]      <1> 	mov	[esi+p.timer-1], bl ; 0 ; no timer events for process
  1899                              <1> systimer_14:
  1900 0000BC76 FB                  <1> 	sti	; enable interrupts
  1901 0000BC77 E9A4F9FFFF          <1> 	jmp	sysret
  1902                              <1> 
  1903                              <1> systimer_15:
  1904 0000BC7C 38FB                <1> 	cmp	bl, bh ; 16
  1905 0000BC7E 0F8731FFFFFF        <1>         ja      systimer_4      ; max. 16 timer events !
  1906                              <1> 	;
  1907 0000BC84 88DA                <1> 	mov	dl, bl
  1908 0000BC86 FECA                <1> 	dec	dl  ; 16 -> 15 ... 1 -> 0 
  1909 0000BC88 C0E204              <1> 	shl	dl, 4 ; * 16
  1910 0000BC8B 0FB6FA              <1> 	movzx	edi, dl
  1911 0000BC8E 01F7                <1> 	add	edi, esi ; timer_set 
  1912                              <1> 	
  1913 0000BC90 3A07                <1> 	cmp	al, [edi] ; process number
  1914 0000BC92 0F851DFFFFFF        <1>         jne     systimer_4
  1915                              <1> 	
  1916                              <1> 	; same process ID
  1917 0000BC98 FA                  <1> 	cli	; disable interrupts
  1918                              <1>  	; 10/06/2016
  1919                              <1> 	;mov	byte [esi], 0 
  1920 0000BC99 66C7060000          <1> 	mov	word [esi], 0 ; clear
  1921                              <1> 	;mov	dword [esi+12], 0 ; clear
  1922 0000BC9E FE0D[2F2D0100]      <1> 	dec	byte [timer_events]
  1923 0000BCA4 EBB3                <1> 	jmp	short systimer_12
  1924                              <1> 
  1925                              <1> sysmdate: ; < change the modification time of a file >
  1926                              <1> 	; 16/05/2015 (Retro UNIX 386 v1 - Beginning)
  1927                              <1> 	; 03/06/2013 - 02/08/2013 (Retro UNIX 8086 v1)
  1928                              <1> 	;
  1929                              <1> 	; 'sysmdate' is given a file name. It gets inode of this 
  1930                              <1> 	; file into core. The user is checked if he is the owner 
  1931                              <1> 	; or super user. If he is neither an error occurs.
  1932                              <1> 	; 'setimod' is then called to set the i-node modification
  1933                              <1> 	; byte and the modification time, but the modification time
  1934                              <1> 	; is overwritten by whatever get put on the stack during
  1935                              <1> 	; a 'systime' system call. This calls are restricted to
  1936                              <1> 	; the super user.		
  1937                              <1> 	;
  1938                              <1> 	; Calling sequence:
  1939                              <1> 	;	sysmdate; name
  1940                              <1> 	; Arguments:
  1941                              <1> 	;	name - points to the name of file
  1942                              <1> 	; Inputs: (arguments)
  1943                              <1> 	; Outputs: -
  1944                              <1> 	; ...............................................................
  1945                              <1> 	;				
  1946                              <1> 	; Retro UNIX 8086 v1 modification: 
  1947                              <1> 	;	 The user/application program puts address 
  1948                              <1> 	;	 of the file name in BX register 
  1949                              <1> 	;	 as 'sysmdate' system call argument.
  1950                              <1> 	;
  1951                              <1> ; / change the modification time of a file
  1952                              <1> 		; jsr r0,arg; u.namep / point u.namep to the file name
  1953 0000BCA6 891D[A0300100]      <1>         mov	[u.namep], ebx
  1954 0000BCAC E8190E0000          <1> 	call	namei
  1955                              <1> 		; jsr r0,namei / get its i-number
  1956 0000BCB1 0F829EFDFFFF        <1>         jc	fnotfound ; file not found !
  1957                              <1> 	;jc	error       
  1958                              <1> 		; br error2 / no, such file
  1959 0000BCB7 E81A1D0000          <1> 	call	iget
  1960                              <1> 		; jsr r0,iget / get i-node into core
  1961 0000BCBC A0[D4300100]        <1> 	mov	al, [u.uid]
  1962 0000BCC1 3A05[4F2D0100]      <1> 	cmp	al, [i.uid]
  1963                              <1>         	; cmpb u.uid,i.uid / is user same as owner
  1964 0000BCC7 7413                <1> 	je	short mdate_1
  1965                              <1>         	; beq 1f / yes
  1966 0000BCC9 20C0                <1> 	and	al, al
  1967                              <1> 		; tstb u.uid / no, is user the super user
  1968                              <1> 	;jnz	error
  1969                              <1> 		; bne error2 / no, error
  1970 0000BCCB 740F                <1> 	jz	short mdate_1
  1971 0000BCCD C705[DD300100]0B00- <1> 	mov	dword [u.error], ERR_FILE_ACCESS ; permission denied !
  1971 0000BCD5 0000                <1>
  1972 0000BCD7 E924F9FFFF          <1> 	jmp	error
  1973                              <1> mdate_1: ;1:
  1974 0000BCDC E8FC1C0000          <1> 	call	setimod
  1975                              <1>         	; jsr r0,setimod / fill in modification data,
  1976                              <1> 		               ; / time etc.
  1977 0000BCE1 BE[EC1F0100]        <1> 	mov	esi, p_time
  1978 0000BCE6 BF[662D0100]        <1> 	mov	edi, i.mtim
  1979 0000BCEB A5                  <1> 	movsd
  1980                              <1> 		; mov 4(sp),i.mtim / move present time to
  1981                              <1>         	; mov 2(sp),i.mtim+2 / modification time
  1982 0000BCEC E92FF9FFFF          <1>         jmp	sysret
  1983                              <1> 		; br sysret2
  1984                              <1> 
  1985                              <1> sysvideo: ; VIDEO DATA TRANSFER FUNCTIONS
  1986                              <1> 	; 11/07/2016
  1987                              <1> 	; 13/06/2016
  1988                              <1> 	; 16/05/2016 - TRDOS 386 (TRDOS v2.0)
  1989                              <1> 	;
  1990                              <1> 	;
  1991                              <1> 	; VIDEO DATA TRANSFER FUNCTIONS:
  1992                              <1> 	;
  1993                              <1> 	; Inputs:
  1994                              <1> 	;	BH = 0 = VIDEO BIOS Mode 3, tty/text mode data transfers
  1995                              <1> 	;	     BL = 
  1996                              <1> 	;		Bits 0&1, Transfer direction
  1997                              <1> 	;	     	 	0 - System to system
  1998                              <1> 	;			1 - User to system
  1999                              <1> 	;			2 - System to user
  2000                              <1> 	;			3 - User to user
  2001                              <1> 	;		Bits 2&3, Transfer Type
  2002                              <1> 	;			0 - Display page transfer	
  2003                              <1> 	;	     		1 - Display page window transfer
  2004                              <1> 	;	     		2 - Frame/Viewport/Window address transfer
  2005                              <1> 	;			3 - Window handle transfer		
  2006                              <1> 	;
  2007                              <1> 	;	     /// BL = 0 -> System to system (display page) transfer
  2008                              <1> 	;		 CL = Source page 
  2009                              <1> 	;		 DL = Destination page
  2010                              <1> 	;	     /// BL = 1&2 -> user to system & system to user transfer
  2011                              <1> 	;		 ECX = User buffer
  2012                              <1> 	;		 DL = Video page
  2013                              <1> 	;	     /// BL = 5&6 -> user to system, system to user transfer 
  2014                              <1> 	;		(window in current display page and in current mode)	 	 		
  2015                              <1> 	;		 ESI = User's buffer address
  2016                              <1> 	;		 ECX Low 16 bits = Top left column (X1 position)
  2017                              <1> 	;		 ECX High 16 bits = Top row (Y1 position)
  2018                              <1> 	;		 EDX Low 16 bits = Bottom right column (X2 position)
  2019                              <1> 	;		 EDX High 16 bits = Bottom row (Y2 position)
  2020                              <1>         ;                If BL = 5 ->
  2021                              <1> 	;		 EDI = Swap address (in user's memory space)
  2022                              <1> 	;		 (If swap address > 0, previous content of the window
  2023                              <1> 	;		 will be saved into swap area in user's memory space)		
  2024                              <1> 	;	     /// BL = 4 -> system to system transfer 
  2025                              <1> 	;		 ESI = System's source buffer (video page) address
  2026                              <1> 	;		 ECX Low 16 bits = Top left column (X1 position)
  2027                              <1> 	;		 ECX High 16 bits = Top row (Y1 position)
  2028                              <1> 	;		 EDX Low 16 bits = Bottom right column (X2 position)
  2029                              <1> 	;		 EDX High 16 bits = Bottom row (Y2 position)
  2030                              <1> 	;		 EDI = System's destination buffer (video page) address
  2031                              <1> 	;
  2032                              <1> 	;	BH = 1 = CGA Graphics (0B8000h) data transfers
  2033                              <1> 	;	     BL = 
  2034                              <1> 	;	     	0 = Fill color (color in CL] (32K)
  2035                              <1> 	;		1 = User to system display page transfer
  2036                              <1> 	;		2 = System to user display page transfer
  2037                              <1> 	;		3 = NOT bits in window (ECX, EDX)
  2038                              <1> 	;		4 = Window copy (system to system)	
  2039                              <1> 	;	     	5 = User to system window transfer
  2040                              <1> 	;	     	6 = System to user window transfer
  2041                              <1> 	;		7 = AND display page bytes with CL
  2042                              <1> 	;		8 = OR display page bytes with CL
  2043                              <1> 	;		9 = XOR display page bytes with CL
  2044                              <1> 	;
  2045                              <1> 	;	     /// BL = 0 -> Fill color  (all screen pixels)
  2046                              <1> 	;		 CL = Color value 
  2047                              <1> 	;	     /// BL = 1&2 -> user to system & system to user transfer
  2048                              <1> 	;		 ECX = User buffer
  2049                              <1> 	;	     /// BL = 5&6 -> user to system, system to user transfer 
  2050                              <1> 	;		(window in current display page and in current mode)	 	 		
  2051                              <1> 	;		 ESI = User's buffer address
  2052                              <1> 	;		 ECX Low 16 bits = Top left column (X1 position)
  2053                              <1> 	;		 ECX High 16 bits = Top row (Y1 position)
  2054                              <1> 	;		 EDX Low 16 bits = Bottom right column (X2 position)
  2055                              <1> 	;		 EDX High 16 bits = Bottom row (Y2 position)
  2056                              <1>         ;	     /// BL = 4 -> system to system (window) transfer 
  2057                              <1> 	;		 ESI = System's source buffer (video page) address
  2058                              <1> 	;		 ECX Low 16 bits = Top left column (X1 position)
  2059                              <1> 	;		 ECX High 16 bits = Top row (Y1 position)
  2060                              <1> 	;		 EDX Low 16 bits = Bottom right column (X2 position)
  2061                              <1> 	;		 EDX High 16 bits = Bottom row (Y2 position)
  2062                              <1> 	;		 EDI = System's destination buffer (video page) address
  2063                              <1> 	;	     /// BL = 3 -> NOT byte in display page/memory 
  2064                              <1> 	;		 ECX Low 16 bits = Top left column (X1 position)
  2065                              <1> 	;		 ECX High 16 bits = Top row (Y1 position)
  2066                              <1> 	;		 EDX Low 16 bits = Bottom right column (X2 position)
  2067                              <1> 	;		 EDX High 16 bits = Bottom row (Y2 position)
  2068                              <1> 	;
  2069                              <1> 	;	BH = 2 = VGA Graphics (0A0000h) data transfers
  2070                              <1> 	;	     BL = 
  2071                              <1> 	;	     	x0h = Fill color (color in CL] (64K)
  2072                              <1> 	;		x1h = User to system display page transfer
  2073                              <1> 	;		x2h = System to user display page transfer
  2074                              <1> 	;		x3h = NOT bits in window (ECX, EDX)
  2075                              <1> 	;		x4h = Window copy (system to system)	
  2076                              <1> 	;	     	x5h = User to system window transfer
  2077                              <1> 	;	     	x6h = System to user window transfer
  2078                              <1> 	;		x7h = AND display page bytes with CL
  2079                              <1> 	;		x8h = OR display page bytes with CL
  2080                              <1> 	;		x9h = XOR display page bytes with CL
  2081                              <1> 	;		x = 0 -> screen width = 320
  2082                              <1> 	;		x = 1 -> screen width = 640
  2083                              <1> 	;		x = 2 -> screen width = 800
  2084                              <1> 	;
  2085                              <1> 	;	     /// BL = 0 -> Fill color  (all screen pixels)
  2086                              <1> 	;		 CL = Color value 
  2087                              <1> 	;	     /// BL = 1&2 -> user to system & system to user transfer
  2088                              <1> 	;		 ECX = User buffer
  2089                              <1> 	;	     /// BL = 5&6 -> user to system, system to user transfer 
  2090                              <1> 	;		(window in current display page and in current mode)	 	 		
  2091                              <1> 	;		 ESI = User's buffer address
  2092                              <1> 	;		 ECX Low 16 bits = Top left column (X1 position)
  2093                              <1> 	;		 ECX High 16 bits = Top row (Y1 position)
  2094                              <1> 	;		 EDX Low 16 bits = Bottom right column (X2 position)
  2095                              <1> 	;		 EDX High 16 bits = Bottom row (Y2 position)
  2096                              <1>        	;	     /// BL = 4 -> system to system (window) transfer 
  2097                              <1> 	;		 ESI = System's source buffer (video page) address
  2098                              <1> 	;		 ECX Low 16 bits = Top left column (X1 position)
  2099                              <1> 	;		 ECX High 16 bits = Top row (Y1 position)
  2100                              <1> 	;		 EDX Low 16 bits = Bottom right column (X2 position)
  2101                              <1> 	;		 EDX High 16 bits = Bottom row (Y2 position)
  2102                              <1> 	;		 EDI = System's destination buffer (video page) address
  2103                              <1> 	;	     /// BL = 3 -> NOT byte in display page/memory 
  2104                              <1> 	;		 ECX Low 16 bits = Top left column (X1 position)
  2105                              <1> 	;		 ECX High 16 bits = Top row (Y1 position)
  2106                              <1> 	;		 EDX Low 16 bits = Bottom right column (X2 position)
  2107                              <1> 	;		 EDX High 16 bits = Bottom row (Y2 position)
  2108                              <1> 	;
  2109                              <1> 	;	BH = 3 = Super VGA, LINEAR FRAME BUFFER data transfers
  2110                              <1> 	;	     BL = 
  2111                              <1> 	;	     	0 = Fill color (color in ECX] (Frame buffer size)
  2112                              <1> 	;		1 = User to system display page transfer
  2113                              <1> 	;		2 = System to user display page transfer
  2114                              <1> 	;		3 = NOT bits in window (ECX, EDX)
  2115                              <1> 	;		4 = Window copy (system to system)	
  2116                              <1> 	;	     	5 = User to system window transfer
  2117                              <1> 	;	     	6 = System to user window transfer
  2118                              <1> 	;		7 = AND display page bytes with ECX
  2119                              <1> 	;		8 = OR display page bytes with ECX
  2120                              <1> 	;		9 = XOR display page bytes with ECX
  2121                              <1> 	;
  2122                              <1> 	;	     /// BL = 0 -> Fill color  (all screen pixels)
  2123                              <1> 	;		 CL = Color value 
  2124                              <1> 	;	     /// BL = 1&2 -> user to system & system to user transfer
  2125                              <1> 	;		 ECX = User buffer
  2126                              <1> 	;	     /// BL = 5&6 -> user to system, system to user transfer 
  2127                              <1> 	;		(window in current display page and in current mode)	 	 		
  2128                              <1> 	;		 ESI = User's buffer address
  2129                              <1> 	;		 ECX Low 16 bits = Top left column (X1 position)
  2130                              <1> 	;		 ECX High 16 bits = Top row (Y1 position)
  2131                              <1> 	;		 EDX Low 16 bits = Bottom right column (X2 position)
  2132                              <1> 	;		 EDX High 16 bits = Bottom row (Y2 position)
  2133                              <1> 	;	     /// BL = 4 -> system to system (window) transfer 
  2134                              <1> 	;		 ESI = System's source buffer (video page) address
  2135                              <1> 	;		 ECX Low 16 bits = Top left column (X1 position)
  2136                              <1> 	;		 ECX High 16 bits = Top row (Y1 position)
  2137                              <1> 	;		 EDX Low 16 bits = Bottom right column (X2 position)
  2138                              <1> 	;		 EDX High 16 bits = Bottom row (Y2 position)
  2139                              <1> 	;		 EDI = System's destination buffer (video page) address
  2140                              <1> 	;	     /// BL = 3 -> NOT byte in display page/memory 
  2141                              <1> 	;		 ECX Low 16 bits = Top left column (X1 position)
  2142                              <1> 	;		 ECX High 16 bits = Top row (Y1 position)
  2143                              <1> 	;		 EDX Low 16 bits = Bottom right column (X2 position)
  2144                              <1> 	;		 EDX High 16 bits = Bottom row (Y2 position)
  2145                              <1> 	;
  2146                              <1> 	; Outputs:
  2147                              <1> 	;	EAX = transfer/byte count
  2148                              <1> 	;
  2149                              <1> 	;	NOTE: If the source or destination address passes out of
  2150                              <1> 	;	video pages (display memory limits), data will not be transferred
  2151                              <1> 	;	and EAX will return as 0.
  2152                              <1> 	;
  2153                              <1> 	;
  2154                              <1> 	; DIRECT (STANDARD VGA/CGA) DISPLAY MEMORY ACCESS FUNCTIONS:
  2155                              <1> 	;
  2156                              <1> 	;	BH = 4 = CGA direct video memory (0B8000h, 32K) access
  2157                              <1> 	;		Page directory & page tables of the user's
  2158                              <1> 	;		program will be updated to direct access to
  2159                              <1> 	;		0B8000h (32K) video (CGA, color) memory; if
  2160                              <1> 	;		there is not a permission  conflict or lock!  
  2161                              <1> 	;	        (User's program/process will have permision to
  2162                              <1> 	;		access locked display memory if the owner is
  2163                              <1> 	;		it's parent.)
  2164                              <1>         ;
  2165                              <1> 	;	    Screen width = 320	
  2166                              <1> 	;
  2167                              <1> 	;	BH = 5 = VGA direct video memory (0A0000h, 64K) access
  2168                              <1> 	;		Page directory & page tables of the user's
  2169                              <1> 	;		program will be updated to direct access to
  2170                              <1> 	;		0A0000h (64K) video (VGA) memory; if there is not
  2171                              <1> 	;		a permission conflict or lock!  
  2172                              <1> 	;	        (User's program/process will have permision to
  2173                              <1> 	;		access locked display memory if the owner is
  2174                              <1> 	;		it's parent.)
  2175                              <1> 	;		
  2176                              <1> 	;	    BL = Screen width (320, 640, 800) 
  2177                              <1> 	;			
  2178                              <1> 	; Outputs:
  2179                              <1> 	;	EAX = Display mmory address for direct access
  2180                              <1> 	;	      0A0000h for VGA, 0B8000h for CGA	
  2181                              <1> 	;	(Display memory size: 32K for CGA, 64K for VGA)
  2182                              <1> 	; 	EAX = 0 if display page access permission has been denied. 
  2183                              <1> 	;	      (Locked!) 	
  2184                              <1> 	;	      	 	
  2185                              <1> 	; LINEAR FRAME BUFFER ACCESS FUNCTIONS:
  2186                              <1> 	;
  2187                              <1> 	;	BH = 6 = Linear Frame Buffer direct video memory access
  2188                              <1> 	;
  2189                              <1> 	;		Page directory & page tables of the user's
  2190                              <1> 	;		program will be updated to direct access to
  2191                              <1> 	;		the configured LFB (Linear Frame Buffer) address,
  2192                              <1> 	;		if there is not a permission conflict or lock!  
  2193                              <1> 	;	        (User's program/process will have permision to
  2194                              <1> 	;		access locked display memory if the owner is
  2195                              <1> 	;		it's parent.)
  2196                              <1> 	;			
  2197                              <1> 	;		Return: EAX = Linear Frame Buffer address
  2198                              <1> 	;			EDX = Frame Buffer Size in bytes	
  2199                              <1> 	;	
  2200                              <1> 	;	BH = 7 = Get Linear Frame Buffer info (for current mode)
  2201                              <1> 	;		
  2202                              <1> 	;		Return:
  2203                              <1> 	;		EAX = Frame Buffer Address (0 = is not in use)
  2204                              <1> 	;		EDX = Frame Buffer Size in bytes
  2205                              <1> 	;		BL = Current Video Mode
  2206                              <1> 	;		     BL = 0FFh -> Super VGA (Extended VGA)
  2207                              <1> 	;		     If BL = 0FFh, 
  2208                              <1>         ;                       BH = 0 = 16 colors
  2209                              <1> 	;			BH = 1 = 256 colors
  2210                              <1> 	;			BH = 2 = 66536 colors
  2211                              <1> 	;			BH = 3 = 24 bits TRUE (16M) colors
  2212                              <1> 	;			BH = 4 = 32 bits TRUE (16M) colors
  2213                              <1> 	;		ECX = Pixel resolution
  2214                              <1> 	;		      CX = Width (640, 800, 1024, 1366, 1920)
  2215                              <1> 	;		      High 16 bits of ECX = Height  
  2216                              <1> 	;
  2217                              <1> 	;	NOTE: Each process will have it's own frame buffer
  2218                              <1> 	;	      address and resolution parameters in 'u' area.
  2219                              <1> 	;	      Then, if the current frame buffer & resolution
  2220                              <1> 	;	      is different, frame buffer r/w functions
  2221                              <1> 	;	      will use scale factor to convert process's
  2222                              <1>         ;             pixel coordinates to actual screen coordinates.                            
  2223                              <1> 	;	      resolution -> dimensional scale
  2224                              <1> 	;	      color size -> color scale
  2225                              <1> 	;	     * RGB (TRUE) colors to 256 colors conversion:	
  2226                              <1>         ;             TRUE Colors -> 8,8,8 (R,G,B; byte 0 is R)            
  2227                              <1> 	;	      256 colors -> 2,2,2,2 (R,G,B,L; bit 0&1 is R)
  2228                              <1> 	; 		  bit 6&7 -> luminosity base level (0,1,2,3)
  2229                              <1> 	;		  bit 4&5 -> blue level (0,1,2,3)
  2230                              <1> 	;		  bit 2%3 -> green level (0,1,2,3)
  2231                              <1> 	;		  bit 0&1 -> red level (0,1,2,3)
  2232                              <1> 	;	      Example: total red level : luminosity + red level   				
  2233                              <1> 	;	      Luminosity base level: 0 -> 16
  2234                              <1> 	;		 		     1 -> 32
  2235                              <1> 	;				     2 -> 64
  2236                              <1> 	;				     3 -> 128
  2237                              <1> 	;	      Color level:	
  2238                              <1> 	;				    0 -> 0
  2239                              <1> 	;				    1 -> luminosity level
  2240                              <1> 	;				    2 -> luminosity level + 64
  2241                              <1> 	;				    3 -> 255
  2242                              <1> 	;	     Luminosity base level = min (R,G,B)
  2243                              <1> 	;			if it is <16, it will be set to 16
  2244                              <1> 	;	     Color levels: Color values are fixed to (nearest) 
  2245                              <1> 	;		   one of all possible set level (step) values
  2246                              <1> 	;		   (according to luminosity base level); then
  2247                              <1> 	;		   color levels are set to R-L, G-L, B-L.
  2248                              <1> 	;	 For example: If luminosity base level is 32
  2249                              <1> 	;		  all possible set values are 0, 32, 96, 255. 	 			
  2250                              <1> 	;
  2251                              <1> 	;	    * RGB (TRUE) colors to 16 colors conversion:
  2252                              <1> 	;	    16 colors: R, B,G, L bits (4 bits)
  2253                              <1> 	;	    	   If any one of R,G,B >= 128 L = 1 		     	
  2254                              <1>  	;		   If max. value of (R,G,B) >= 32, it is 1
  2255                              <1> 	;		      else all color bits (R&G&B&L) are 0
  2256                              <1> 	;		   If the second value >= max. value / 2
  2257                              <1> 	;		      it is 1
  2258                              <1> 	;		   If third value value >= max. value / 2
  2259                              <1> 	;		      it is 1
  2260                              <1> 	;	    Example: R = 132, G = 64, B = 78
  2261                              <1> 	;		     L = 1, R = 1
  2262                              <1> 	;		     G < 66 --> G = 0
  2263                              <1> 	;		     B >= 66 --> B = 1	 		 	  								 	 					
  2264                              <1> 
  2265                              <1> 	; 16/05/2016
  2266 0000BCF1 31C0                <1> 	xor	eax, eax
  2267 0000BCF3 A3[88300100]        <1> 	mov	[u.r0], eax
  2268                              <1> 
  2269 0000BCF8 20FF                <1> 	and	bh, bh
  2270 0000BCFA 0F8572020000        <1> 	jnz	sysvideo_13 ; 11/07/2016
  2271                              <1> 	
  2272                              <1> 	; Video mode 0, 80*25 text mode, CGA 16 colors  ; [CRT_MODE] = 3
  2273 0000BD00 88DF                <1> 	mov	bh, bl
  2274 0000BD02 C0EF02              <1> 	shr	bh, 2
  2275 0000BD05 20FF                <1> 	and	bh, bh
  2276 0000BD07 0F8598000000        <1>         jnz     sysvideo_4
  2277 0000BD0D BF00800B00          <1> 	mov	edi, 0B8000h
  2278 0000BD12 20D2                <1> 	and	dl, dl
  2279 0000BD14 7413                <1> 	jz	short sysvideo_1
  2280 0000BD16 80FA07              <1> 	cmp	dl, 7
  2281 0000BD19 0F8701F9FFFF        <1> 	ja	sysret
  2282                              <1> sysvideo_0:
  2283 0000BD1F 81C7A00F0000        <1> 	add	edi, 80*25*2
  2284 0000BD25 FECA                <1> 	dec	dl
  2285 0000BD27 75F6                <1> 	jnz	short sysvideo_0	
  2286                              <1> sysvideo_1:	
  2287 0000BD29 80E303              <1> 	and	bl, 3
  2288 0000BD2C 7530                <1> 	jnz	short sysvideo_2
  2289 0000BD2E 80F907              <1> 	cmp	cl, 7
  2290 0000BD31 0F87E9F8FFFF        <1> 	ja	sysret
  2291                              <1> 	; system to system video/display page transfer (mode 0)
  2292 0000BD37 BE00800B00          <1> 	mov	esi, 0B8000h
  2293 0000BD3C 0FB6C1              <1> 	movzx	eax, cl
  2294 0000BD3F BAA00F0000          <1> 	mov	edx, 80*25*2
  2295 0000BD44 F7E2                <1> 	mul	edx
  2296 0000BD46 01C6                <1> 	add	esi, eax
  2297 0000BD48 B9A00F0000          <1> 	mov	ecx, (80*25*2)
  2298 0000BD4D 890D[88300100]      <1> 	mov	[u.r0], ecx
  2299 0000BD53 66C1E902            <1> 	shr	cx, 2 ; /4
  2300 0000BD57 F3A5                <1> 	rep	movsd
  2301 0000BD59 E9C2F8FFFF          <1> 	jmp	sysret	
  2302                              <1> sysvideo_2:  
  2303 0000BD5E 80FB02              <1> 	cmp	bl, 2
  2304 0000BD61 0F87B9F8FFFF        <1>         ja      sysret
  2305 0000BD67 721F                <1> 	jb	short sysvideo_3
  2306                              <1> 	; system to user video/display page transfer (mode 0)
  2307 0000BD69 89FE                <1> 	mov	esi, edi
  2308 0000BD6B 89CF                <1> 	mov	edi, ecx ; user buffer
  2309 0000BD6D B9A00F0000          <1> 	mov	ecx, 80*25*2
  2310 0000BD72 E8D91B0000          <1> 	call	transfer_to_user_buffer ; fast transfer
  2311 0000BD77 0F82A3F8FFFF        <1> 	jc	sysret
  2312 0000BD7D 890D[88300100]      <1> 	mov	[u.r0], ecx
  2313 0000BD83 E998F8FFFF          <1> 	jmp	sysret 	
  2314                              <1> sysvideo_3: 
  2315                              <1> 	; user to system video/display page transfer (mode 0)	
  2316 0000BD88 89CE                <1> 	mov	esi, ecx ; user buffer
  2317                              <1> 	; edi = video page address
  2318 0000BD8A B9A00F0000          <1> 	mov	ecx, 80*25*2
  2319 0000BD8F E8061C0000          <1> 	call	transfer_from_user_buffer ; fast transfer
  2320 0000BD94 0F8286F8FFFF        <1> 	jc	sysret
  2321 0000BD9A 890D[88300100]      <1> 	mov	[u.r0], ecx		
  2322 0000BDA0 E97BF8FFFF          <1> 	jmp	sysret
  2323                              <1> sysvideo_4:
  2324 0000BDA5 80E303              <1> 	and	bl, 3
  2325 0000BDA8 0F85F6000000        <1>         jnz     sysvideo_9
  2326 0000BDAE 80F907              <1> 	cmp	cl, 7
  2327 0000BDB1 0F8769F8FFFF        <1> 	ja	sysret
  2328                              <1> 	; system to system video/display page window transfer (mode 0)
  2329 0000BDB7 81FE00800B00        <1> 	cmp	esi, 0B8000h
  2330 0000BDBD 0F825DF8FFFF        <1> 	jb	sysret
  2331 0000BDC3 81FE00FD0B00        <1> 	cmp	esi, 0B8000h+(80*25*2*8)
  2332 0000BDC9 0F8351F8FFFF        <1> 	jnb	sysret
  2333 0000BDCF 81FF00800B00        <1> 	cmp	edi, 0B8000h
  2334 0000BDD5 0F8245F8FFFF        <1> 	jb	sysret
  2335 0000BDDB 81FF00FD0B00        <1>         cmp     edi, 0B8000h+(80*25*2*8)
  2336 0000BDE1 0F8339F8FFFF        <1> 	jnb	sysret
  2337                              <1> 	;
  2338 0000BDE7 51                  <1> 	push	ecx
  2339 0000BDE8 52                  <1> 	push	edx
  2340 0000BDE9 0FB7C1              <1> 	movzx	eax, cx ; top left column
  2341 0000BDEC 50                  <1> 	push	eax
  2342 0000BDED C1E910              <1> 	shr	ecx, 16 ; top row
  2343 0000BDF0 66B8A000            <1> 	mov	ax, 80*2 ; 80 colums, 160 bytes per row
  2344 0000BDF4 F7E1                <1> 	mul	ecx
  2345 0000BDF6 01C6                <1> 	add	esi, eax
  2346 0000BDF8 01C7                <1> 	add	edi, eax
  2347 0000BDFA 58                  <1> 	pop	eax
  2348 0000BDFB 66D1E0              <1> 	shl	ax, 1 ; *2 	
  2349 0000BDFE 01C6                <1> 	add	esi, eax
  2350 0000BE00 01C7                <1> 	add	edi, eax
  2351 0000BE02 5A                  <1> 	pop	edx
  2352 0000BE03 59                  <1> 	pop	ecx
  2353 0000BE04 B800FD0B00          <1> 	mov	eax, 0B8000h+(80*25*2*8)
  2354 0000BE09 39C6                <1> 	cmp	esi, eax
  2355 0000BE0B 0F830FF8FFFF        <1> 	jnb	sysret
  2356 0000BE11 39C6                <1> 	cmp	esi, eax
  2357 0000BE13 0F8307F8FFFF        <1> 	jnb	sysret	
  2358                              <1> 
  2359 0000BE19 56                  <1> 	push	esi ; ****
  2360 0000BE1A 57                  <1> 	push	edi ; ***
  2361 0000BE1B 52                  <1> 	push	edx ; **
  2362 0000BE1C 51                  <1> 	push	ecx ; *
  2363 0000BE1D C1E910              <1> 	shr	ecx, 16 ; top row
  2364 0000BE20 C1EA10              <1> 	shr	edx, 16 ; bottom row
  2365 0000BE23 83F918              <1> 	cmp	ecx, 24 ; max. 25 rows
  2366 0000BE26 7773                <1> 	ja	short sysvideo_6
  2367 0000BE28 83FA18              <1> 	cmp	edx, 24 ; max. 25 rows
  2368 0000BE2B 776E                <1> 	ja	short sysvideo_6		
  2369 0000BE2D 28CA                <1> 	sub	dl, cl
  2370 0000BE2F 726A                <1> 	jc	short sysvideo_6
  2371 0000BE31 50                  <1> 	push	eax ; *****
  2372 0000BE32 89D3                <1> 	mov	ebx, edx ; row count - 1
  2373 0000BE34 B8A0000000          <1> 	mov	eax, 80*2
  2374 0000BE39 F7E0                <1> 	mul	eax
  2375 0000BE3B 01C6                <1> 	add	esi, eax
  2376 0000BE3D 01C7                <1> 	add	edi, eax
  2377 0000BE3F 58                  <1> 	pop	eax ; *****
  2378 0000BE40 39C6                <1> 	cmp	esi, eax
  2379 0000BE42 7757                <1> 	ja	short sysvideo_6
  2380 0000BE44 39C7                <1> 	cmp	edi, eax
  2381 0000BE46 7753                <1> 	ja	short sysvideo_6
  2382 0000BE48 59                  <1> 	pop	ecx ; *
  2383 0000BE49 5A                  <1> 	pop	edx ; **
  2384 0000BE4A 81E1FFFF0000        <1> 	and	ecx, 0FFFFh
  2385 0000BE50 81E2FFFF0000        <1> 	and	edx, 0FFFFh
  2386 0000BE56 83F94F              <1> 	cmp	ecx, 79 ; max. 80 columns
  2387 0000BE59 7742                <1> 	ja	short sysvideo_7
  2388 0000BE5B 83FA4F              <1> 	cmp	edx, 79 ; max. 80 columns
  2389 0000BE5E 773D                <1> 	ja	short sysvideo_7
  2390 0000BE60 28CA                <1> 	sub	dl, cl
  2391 0000BE62 7639                <1> 	jna	short sysvideo_7
  2392                              <1> 	; edx = column count (width) - 1
  2393 0000BE64 D0E2                <1> 	shl	dl, 1
  2394 0000BE66 01D6                <1> 	add	esi, edx
  2395 0000BE68 01D7                <1> 	add	edi, edx
  2396 0000BE6A 39C6                <1> 	cmp	esi, eax
  2397 0000BE6C 772F                <1> 	ja	short sysvideo_7
  2398 0000BE6E 39C7                <1> 	cmp	edi, eax
  2399 0000BE70 772B                <1> 	ja	short sysvideo_7
  2400 0000BE72 5F                  <1> 	pop	edi ; ***
  2401 0000BE73 5E                  <1> 	pop	esi ; ****
  2402 0000BE74 FEC3                <1> 	inc	bl
  2403 0000BE76 FEC2                <1> 	inc	dl ; column count
  2404 0000BE78 88D7                <1> 	mov	bh, dl
  2405 0000BE7A D0E2                <1> 	shl	dl, 1
  2406 0000BE7C B8A0000000          <1> 	mov	eax, 80*2
  2407 0000BE81 28D0                <1> 	sub	al, dl ; (80 - columns) * 2
  2408                              <1> sysvideo_5:	
  2409 0000BE83 88F9                <1> 	mov	cl, bh
  2410 0000BE85 0115[88300100]      <1> 	add	[u.r0], edx
  2411 0000BE8B F366A5              <1> 	rep	movsw
  2412 0000BE8E 01C6                <1> 	add	esi, eax ; next row
  2413 0000BE90 01C7                <1> 	add	edi, eax ; next row
  2414 0000BE92 FECB                <1> 	dec	bl
  2415 0000BE94 75ED                <1> 	jnz	short sysvideo_5
  2416 0000BE96 E985F7FFFF          <1> 	jmp	sysret
  2417                              <1> 
  2418                              <1> sysvideo_6:
  2419 0000BE9B 59                  <1> 	pop	ecx ; *
  2420 0000BE9C 5A                  <1> 	pop	edx ; **
  2421                              <1> sysvideo_7:	
  2422 0000BE9D 5F                  <1> 	pop	edi ; ***
  2423 0000BE9E 5E                  <1> 	pop	esi ; ****
  2424 0000BE9F E97CF7FFFF          <1> 	jmp	sysret
  2425                              <1> 
  2426                              <1> sysvideo_9:  
  2427 0000BEA4 80FB02              <1> 	cmp	bl, 2
  2428 0000BEA7 0F8773F7FFFF        <1>         ja      sysret
  2429                              <1> 
  2430 0000BEAD 56                  <1> 	push	esi ; ****
  2431 0000BEAE 57                  <1> 	push	edi ; ***
  2432 0000BEAF 52                  <1> 	push	edx ; **
  2433 0000BEB0 51                  <1> 	push	ecx ; *
  2434                              <1> 
  2435 0000BEB1 C1E910              <1> 	shr	ecx, 16 ; top row
  2436 0000BEB4 C1EA10              <1> 	shr	edx, 16 ; bottom row
  2437 0000BEB7 83F918              <1> 	cmp	ecx, 24 ; max. 25 rows
  2438 0000BEBA 77DF                <1> 	ja	short sysvideo_6
  2439 0000BEBC 83FA18              <1> 	cmp	edx, 24 ; max. 25 rows
  2440 0000BEBF 77DA                <1> 	ja	short sysvideo_6		
  2441 0000BEC1 28CA                <1> 	sub	dl, cl
  2442 0000BEC3 72D6                <1> 	jc	short sysvideo_6
  2443                              <1> 
  2444 0000BEC5 88CD                <1> 	mov	ch, cl ; top row
  2445 0000BEC7 8A0D[D61F0100]      <1> 	mov	cl, [ACTIVE_PAGE]
  2446 0000BECD BFA00F0000          <1> 	mov	edi, 80*25*2
  2447 0000BED2 D3E7                <1> 	shl	edi, cl 
  2448 0000BED4 81C760700B00        <1> 	add	edi, 0B8000h - 80*25*2
  2449                              <1> 
  2450 0000BEDA 88D7                <1> 	mov	bh, dl ; row count - 1
  2451 0000BEDC 88EA                <1> 	mov	dl, ch ; top row
  2452 0000BEDE B8A0000000          <1> 	mov	eax, 80*2
  2453 0000BEE3 F7E2                <1> 	mul	edx
  2454 0000BEE5 01C7                <1> 	add	edi, eax
  2455                              <1> 
  2456 0000BEE7 59                  <1> 	pop	ecx ; *
  2457 0000BEE8 5A                  <1> 	pop	edx ; **
  2458 0000BEE9 81E1FFFF0000        <1> 	and	ecx, 0FFFFh
  2459 0000BEEF 81E2FFFF0000        <1> 	and	edx, 0FFFFh
  2460 0000BEF5 83F94F              <1> 	cmp	ecx, 79 ; max. 80 columns
  2461 0000BEF8 77A3                <1> 	ja	short sysvideo_7
  2462 0000BEFA 83FA4F              <1> 	cmp	edx, 79 ; max. 80 columns
  2463 0000BEFD 779E                <1> 	ja	short sysvideo_7
  2464                              <1> 	
  2465 0000BEFF 28CA                <1> 	sub	dl, cl
  2466 0000BF01 769A                <1> 	jna	short sysvideo_7
  2467                              <1> 	
  2468 0000BF03 0FB6C1              <1> 	movzx	eax, cl ; left column
  2469 0000BF06 D0E0                <1> 	shl	al, 1  ; column * 2
  2470 0000BF08 01C7                <1> 	add	edi, eax
  2471                              <1> 
  2472 0000BF0A FEC2                <1> 	inc	dl ; column count
  2473 0000BF0C D0E2                <1> 	shl	dl, 1
  2474 0000BF0E 88D1                <1> 	mov	cl, dl ; column count * 2
  2475 0000BF10 B2A0                <1> 	mov	dl, 80*2
  2476 0000BF12 58                  <1> 	pop	eax ; *** (swap address)
  2477 0000BF13 5E                  <1> 	pop	esi ; ****
  2478 0000BF14 FEC7                <1> 	inc	bh
  2479                              <1> 	
  2480                              <1> 	;mov	edx, 80*2
  2481 0000BF16 B2A0                <1> 	mov	dl, 80*2
  2482                              <1> 	;
  2483 0000BF18 80FB01              <1> 	cmp	bl, 1
  2484 0000BF1B 7735                <1> 	ja	short sysvideo_11
  2485                              <1> 
  2486                              <1> 	; user to system video/display page window transfer (mode 0)	
  2487 0000BF1D 21C0                <1> 	and	eax, eax ; swap address
  2488 0000BF1F 7413                <1> 	jz	short sysvideo_10 ; no window swap
  2489                              <1> 	; save previous window content in user's buffer (swap address)
  2490 0000BF21 56                  <1> 	push	esi ; user buffer
  2491 0000BF22 57                  <1> 	push	edi ; beginning address of the window
  2492 0000BF23 89FE                <1> 	mov	esi, edi
  2493 0000BF25 89C7                <1> 	mov	edi, eax
  2494 0000BF27 E8241A0000          <1> 	call	transfer_to_user_buffer ; fast transfer
  2495 0000BF2C 5F                  <1> 	pop	edi
  2496 0000BF2D 5E                  <1> 	pop	esi
  2497 0000BF2E 0F82ECF6FFFF        <1> 	jc	sysret
  2498                              <1> sysvideo_10: 
  2499                              <1> 	; user to system video/display page window transfer (mode 0)	
  2500                              <1> 	; esi =	user buffer
  2501 0000BF34 E8611A0000          <1> 	call	transfer_from_user_buffer ; fast transfer
  2502 0000BF39 0F82E1F6FFFF        <1> 	jc	sysret
  2503 0000BF3F 010D[88300100]      <1> 	add	[u.r0], ecx
  2504 0000BF45 01D7                <1> 	add	edi, edx ; next row
  2505 0000BF47 01CE                <1> 	add	esi, ecx
  2506 0000BF49 FECF                <1> 	dec	bh
  2507 0000BF4B 75E7                <1> 	jnz	short sysvideo_10
  2508 0000BF4D E9CEF6FFFF          <1> 	jmp	sysret
  2509                              <1> 	
  2510                              <1> sysvideo_11:
  2511                              <1> 	; system to user video/display page window transfer (mode 0)
  2512 0000BF52 87FE                <1> 	xchg	edi, esi
  2513                              <1> sysvideo_12:
  2514                              <1> 	; esi = beginning address of the window
  2515                              <1> 	; edi =	user buffer	
  2516 0000BF54 E8F7190000          <1> 	call	transfer_to_user_buffer ; fast transfer
  2517 0000BF59 0F82C1F6FFFF        <1> 	jc	sysret
  2518 0000BF5F 010D[88300100]      <1> 	add	[u.r0], ecx
  2519 0000BF65 01D6                <1> 	add	esi, edx ; next row
  2520 0000BF67 01CF                <1> 	add	edi, ecx
  2521 0000BF69 FECF                <1> 	dec	bh
  2522 0000BF6B 75E7                <1> 	jnz	short sysvideo_12
  2523 0000BF6D E9AEF6FFFF          <1> 	jmp	sysret
  2524                              <1> 
  2525                              <1> sysvideo_13:
  2526 0000BF72 80FF01              <1> 	cmp	bh, 1
  2527 0000BF75 0F871F030000        <1>         ja      sysvideo_38
  2528                              <1> 	; BH = 1 = CGA Graphics (0B8000h) data transfers
  2529                              <1> 
  2530 0000BF7B 20DB                <1> 	and	bl, bl
  2531 0000BF7D 751A                <1> 	jnz	short sysvideo_14
  2532                              <1> 
  2533                              <1> 	; BL =	0 = Fill color (color in CL] (32K)
  2534                              <1> 
  2535 0000BF7F 88C8                <1> 	mov	al, cl
  2536 0000BF81 B900800000          <1> 	mov	ecx, 32768
  2537 0000BF86 66890D[88300100]    <1> 	mov	[u.r0], cx
  2538 0000BF8D BF00800B00          <1> 	mov	edi, 0B8000h
  2539 0000BF92 F3AB                <1> 	rep	stosd
  2540 0000BF94 E987F6FFFF          <1> 	jmp	sysret
  2541                              <1> 
  2542                              <1> sysvideo_14:
  2543 0000BF99 80FB01              <1> 	cmp	bl, 1
  2544 0000BF9C 7723                <1> 	ja	short sysvideo_16
  2545                              <1> 
  2546 0000BF9E 89CE                <1> 	mov	esi, ecx ; user buffer
  2547                              <1> 	; BL = 1 = user to system video/display page transfer
  2548                              <1> sysvideo_15:	
  2549 0000BFA0 BF00800B00          <1> 	mov	edi, 0B8000h
  2550                              <1> 	; edi = video page address
  2551 0000BFA5 B900800000          <1> 	mov	ecx, 32768
  2552 0000BFAA E8EB190000          <1> 	call	transfer_from_user_buffer ; fast transfer
  2553 0000BFAF 0F826BF6FFFF        <1> 	jc	sysret ; [u.r0] = 0
  2554 0000BFB5 66890D[88300100]    <1> 	mov	[u.r0], cx		
  2555 0000BFBC E95FF6FFFF          <1> 	jmp	sysret
  2556                              <1> 
  2557                              <1> sysvideo_16:
  2558 0000BFC1 80FB02              <1> 	cmp	bl, 2	
  2559 0000BFC4 7723                <1> 	ja	short sysvideo_18
  2560                              <1> 
  2561 0000BFC6 89CF                <1> 	mov	edi, ecx ; user buffer
  2562                              <1> 	; BL = 2 = system to user video/display page transfer
  2563                              <1> sysvideo_17:	
  2564 0000BFC8 BE00800B00          <1> 	mov	esi, 0B8000h
  2565 0000BFCD B900800000          <1> 	mov	ecx, 32768
  2566 0000BFD2 E879190000          <1> 	call	transfer_to_user_buffer ; fast transfer
  2567 0000BFD7 0F8243F6FFFF        <1> 	jc	sysret ; [u.r0] = 0
  2568 0000BFDD 66890D[88300100]    <1> 	mov	[u.r0], cx
  2569 0000BFE4 E937F6FFFF          <1> 	jmp	sysret 	
  2570                              <1> 
  2571                              <1> sysvideo_18:
  2572 0000BFE9 80FB03              <1> 	cmp	bl, 3
  2573 0000BFEC 777E                <1> 	ja	short sysvideo_23
  2574                              <1> 
  2575                              <1> 	; BL = 3 = NOT bits in window (ECX, EDX)
  2576                              <1> 
  2577 0000BFEE BF00800B00          <1> 	mov	edi, 0B8000h
  2578 0000BFF3 89FE                <1> 	mov	esi, edi
  2579                              <1> 	
  2580 0000BFF5 39CA                <1> 	cmp	edx, ecx ; bottom-right > top-left ?
  2581 0000BFF7 7716                <1> 	ja	short sysvideo_20 ; window
  2582                              <1> 	; full screen (update)
  2583 0000BFF9 B900800000          <1> 	mov	ecx, 32768
  2584 0000BFFE 66890D[88300100]    <1> 	mov	[u.r0], cx
  2585                              <1> sysvideo_19:
  2586 0000C005 F616                <1> 	not	byte [esi] ; NOT operation
  2587 0000C007 46                  <1> 	inc	esi
  2588 0000C008 E2FB                <1> 	loop	sysvideo_19
  2589 0000C00A E911F6FFFF          <1> 	jmp	sysret
  2590                              <1> sysvideo_20:
  2591 0000C00F 0FB7C2              <1> 	movzx	eax, dx ; bottom right column
  2592 0000C012 6629C8              <1> 	sub	ax, cx  ; - top left column
  2593 0000C015 0F8205F6FFFF        <1>         jb      sysret ; invalid
  2594 0000C01B 6640                <1> 	inc	ax ; same column no == 1 column	 
  2595 0000C01D 50                  <1> 	push	eax ; byte count per window row
  2596 0000C01E 52                  <1> 	push	edx
  2597 0000C01F BB40010000          <1> 	mov	ebx, 320 ; screen width
  2598 0000C024 89C8                <1> 	mov	eax, ecx
  2599 0000C026 C1E810              <1> 	shr	eax, 16  ; top row
  2600 0000C029 F7E3                <1> 	mul	ebx
  2601 0000C02B 6689CA              <1> 	mov	dx, cx ; top left column
  2602 0000C02E 01D0                <1> 	add	eax, edx
  2603 0000C030 01C6                <1> 	add	esi, eax ; start address 
  2604 0000C032 59                  <1> 	pop	ecx ; edx
  2605 0000C033 89C8                <1> 	mov	eax, ecx
  2606 0000C035 C1E810              <1> 	shr	eax, 16 ; bottom row
  2607 0000C038 F7E3                <1> 	mul	ebx
  2608 0000C03A 6689CA              <1> 	mov	dx, cx ; bottom right column
  2609 0000C03D 01D0                <1> 	add	eax, edx
  2610 0000C03F 01C7                <1> 	add	edi, eax ; stop address (included)
  2611 0000C041 5A                  <1> 	pop	edx ; byte count per window row
  2612 0000C042 81FFFFFF0B00        <1> 	cmp	edi, 0BFFFFh
  2613 0000C048 0F87D2F5FFFF        <1> 	ja	sysret	
  2614 0000C04E 56                  <1> 	push	esi
  2615 0000C04F 4E                  <1> 	dec	esi
  2616                              <1> sysvideo_21:
  2617 0000C050 89D1                <1> 	mov	ecx, edx
  2618                              <1> sysvideo_22:
  2619 0000C052 46                  <1> 	inc	esi
  2620 0000C053 F616                <1> 	not	byte [esi]
  2621 0000C055 E2FB                <1> 	loop	sysvideo_22
  2622 0000C057 01DE                <1> 	add	esi, ebx ; bytes per screen row
  2623                              <1> 	;
  2624 0000C059 39FE                <1> 	cmp	esi, edi ; stop address (included in loop)
  2625 0000C05B 76F3                <1> 	jna	short sysvideo_21
  2626 0000C05D 5E                  <1> 	pop	esi
  2627 0000C05E 29F7                <1> 	sub	edi, esi
  2628 0000C060 66893D[88300100]    <1> 	mov	[u.r0], di
  2629 0000C067 E9B4F5FFFF          <1> 	jmp	sysret
  2630                              <1> 
  2631                              <1> sysvideo_23:
  2632 0000C06C 80FB04              <1> 	cmp	bl, 4
  2633 0000C06F 0F87A7000000        <1>         ja      sysvideo_26
  2634                              <1> 
  2635                              <1> 	; BL = 4 = window copy (system to system)
  2636                              <1> 
  2637 0000C075 B800800B00          <1> 	mov	eax, 0B8000h
  2638 0000C07A 39C6                <1> 	cmp	esi, eax
  2639 0000C07C 0F829EF5FFFF        <1> 	jb	sysret
  2640 0000C082 39C7                <1> 	cmp	edi, eax
  2641 0000C084 0F8296F5FFFF        <1> 	jb	sysret
  2642 0000C08A 6605FF7F            <1> 	add	ax, 7FFFh ; 32767
  2643 0000C08E 39C6                <1> 	cmp	esi, eax
  2644 0000C090 0F878AF5FFFF        <1> 	ja	sysret
  2645 0000C096 39C7                <1> 	cmp	edi, eax
  2646 0000C098 0F8782F5FFFF        <1> 	ja	sysret
  2647                              <1> 	
  2648 0000C09E 39CA                <1> 	cmp	edx, ecx ; bottom-right > top-left ?
  2649 0000C0A0 7714                <1> 	ja	short sysvideo_24 ; window
  2650                              <1> 	; full screen copy
  2651 0000C0A2 89C1                <1> 	mov	ecx, eax
  2652 0000C0A4 29F9                <1> 	sub	ecx, edi
  2653 0000C0A6 6641                <1> 	inc	cx
  2654 0000C0A8 66890D[88300100]    <1> 	mov	[u.r0], cx
  2655 0000C0AF F3A4                <1> 	rep	movsb
  2656 0000C0B1 E96AF5FFFF          <1> 	jmp	sysret
  2657                              <1> sysvideo_24:
  2658 0000C0B6 0FB7C2              <1> 	movzx	eax, dx ; bottom right column
  2659 0000C0B9 6629C8              <1> 	sub	ax, cx  ; - top left column
  2660 0000C0BC 0F825EF5FFFF        <1>         jb      sysret ; invalid
  2661 0000C0C2 6640                <1> 	inc	ax ; same column no == 1 column	 
  2662 0000C0C4 50                  <1> 	push	eax ; byte count per window row
  2663                              <1> 	;
  2664 0000C0C5 52                  <1> 	push	edx
  2665 0000C0C6 BB40010000          <1> 	mov	ebx, 320 ; screen width
  2666 0000C0CB 89C8                <1> 	mov	eax, ecx
  2667 0000C0CD C1E810              <1> 	shr	eax, 16	; top row
  2668 0000C0D0 F7E3                <1> 	mul	ebx
  2669 0000C0D2 6689CA              <1> 	mov	dx, cx ; top left column
  2670 0000C0D5 01D0                <1> 	add	eax, edx
  2671 0000C0D7 01C7                <1> 	add	edi, eax ; start address 
  2672 0000C0D9 01C6                <1> 	add	esi, eax
  2673 0000C0DB 59                  <1> 	pop	ecx ; edx
  2674 0000C0DC 89C8                <1> 	mov	eax, ecx
  2675 0000C0DE C1E810              <1> 	shr	eax, 16 ; bottom row
  2676 0000C0E1 F7E3                <1> 	mul	ebx
  2677 0000C0E3 6689CA              <1> 	mov	dx, cx ; bottom right column
  2678 0000C0E6 01D0                <1> 	add	eax, edx
  2679 0000C0E8 5A                  <1> 	pop	edx ; byte count per window row
  2680 0000C0E9 0500800B00          <1> 	add	eax, 0B8000h
  2681 0000C0EE 3DFFFF0B00          <1> 	cmp	eax, 0BFFFFh
  2682 0000C0F3 0F8727F5FFFF        <1> 	ja	sysret
  2683 0000C0F9 57                  <1> 	push	edi ; start address 
  2684 0000C0FA 50                  <1> 	push	eax ; stop address (included)
  2685                              <1> sysvideo_25:
  2686 0000C0FB 89D1                <1> 	mov	ecx, edx
  2687 0000C0FD F3A4                <1> 	rep	movsb
  2688 0000C0FF 4F                  <1> 	dec	edi
  2689 0000C100 4E                  <1> 	dec	esi
  2690 0000C101 01DF                <1> 	add	edi, ebx ; bytes per screen row
  2691 0000C103 01DE                <1> 	add	esi, ebx
  2692                              <1> 	;
  2693 0000C105 3B3C24              <1> 	cmp	edi, [esp] ; stop addr(included in loop)
  2694 0000C108 76F1                <1> 	jna	short sysvideo_25
  2695 0000C10A 5B                  <1> 	pop	ebx ; stop address
  2696 0000C10B 5F                  <1> 	pop	edi ; start address
  2697 0000C10C 29FB                <1> 	sub	ebx, edi
  2698 0000C10E 6643                <1> 	inc	bx
  2699 0000C110 66891D[88300100]    <1> 	mov	[u.r0], bx	
  2700 0000C117 E904F5FFFF          <1> 	jmp	sysret
  2701                              <1> 
  2702                              <1> sysvideo_26:
  2703 0000C11C 80FB05              <1> 	cmp	bl, 5
  2704 0000C11F 0F8795000000        <1>         ja      sysvideo_29
  2705                              <1> 
  2706                              <1> 	; BL = 5 = window copy (user to system)
  2707                              <1> 
  2708 0000C125 B800800B00          <1> 	mov	eax, 0B8000h
  2709 0000C12A 39C7                <1> 	cmp	edi, eax
  2710 0000C12C 0F82EEF4FFFF        <1> 	jb	sysret
  2711 0000C132 6605FF7F            <1> 	add	ax, 7FFFh ; 32767
  2712 0000C136 39C7                <1> 	cmp	edi, eax
  2713 0000C138 0F87E2F4FFFF        <1> 	ja	sysret
  2714                              <1> 
  2715                              <1> 	; esi = user buffer (in user's memory space)
  2716 0000C13E 39CA                <1> 	cmp	edx, ecx ; bottom-right > top-left ?
  2717 0000C140 0F865AFEFFFF        <1>         jna     sysvideo_15 ; full screen copy
  2718                              <1> 
  2719 0000C146 0FB7C2              <1> 	movzx	eax, dx ; bottom right column
  2720 0000C149 6629C8              <1> 	sub	ax, cx  ; - top left column
  2721 0000C14C 0F82CEF4FFFF        <1>         jb      sysret ; invalid
  2722 0000C152 6640                <1> 	inc	ax ; same column no == 1 column	 
  2723 0000C154 50                  <1> 	push	eax ; byte count per window row
  2724                              <1> 
  2725 0000C155 52                  <1> 	push	edx
  2726 0000C156 BB40010000          <1> 	mov	ebx, 320 ; screen width
  2727 0000C15B 89C8                <1> 	mov	eax, ecx
  2728 0000C15D C1E810              <1> 	shr	eax, 16	; top row
  2729 0000C160 F7E3                <1> 	mul	ebx
  2730 0000C162 6689CA              <1> 	mov	dx, cx ; top left column
  2731 0000C165 01D0                <1> 	add	eax, edx
  2732 0000C167 01C7                <1> 	add	edi, eax ; start address 
  2733 0000C169 59                  <1> 	pop	ecx ; edx
  2734 0000C16A 89C8                <1> 	mov	eax, ecx
  2735 0000C16C C1E810              <1> 	shr	eax, 16 ; bottom row
  2736 0000C16F F7E3                <1> 	mul	ebx
  2737 0000C171 6689CA              <1> 	mov	dx, cx ; bottom right column
  2738 0000C174 01D0                <1> 	add	eax, edx
  2739 0000C176 5A                  <1> 	pop	edx ; byte count per window row
  2740 0000C177 0500800B00          <1> 	add	eax, 0B8000h
  2741 0000C17C 3DFFFF0B00          <1> 	cmp	eax, 0BFFFFh
  2742 0000C181 0F8799F4FFFF        <1> 	ja	sysret
  2743 0000C187 57                  <1> 	push	edi ; start address 
  2744 0000C188 50                  <1> 	push	eax ; stop address (included)
  2745                              <1> sysvideo_27:
  2746 0000C189 89D1                <1> 	mov	ecx, edx ; byte count
  2747                              <1> 	; user to system video/display page window transfer
  2748                              <1> 	; esi =	user buffer
  2749 0000C18B E80A180000          <1> 	call	transfer_from_user_buffer ; fast transfer
  2750 0000C190 7221                <1> 	jc	short sysvideo_28
  2751 0000C192 010D[88300100]      <1> 	add	[u.r0], ecx
  2752 0000C198 01DF                <1> 	add	edi, ebx ; next row
  2753 0000C19A 01CE                <1> 	add	esi, ecx
  2754 0000C19C 3B3C24              <1> 	cmp	edi, [esp] ; stop addr(included in loop)
  2755 0000C19F 76E8                <1> 	jna	short sysvideo_27
  2756 0000C1A1 5B                  <1> 	pop	ebx ; stop address
  2757 0000C1A2 5F                  <1> 	pop	edi ; start address
  2758 0000C1A3 29FB                <1> 	sub	ebx, edi
  2759 0000C1A5 6643                <1> 	inc	bx
  2760 0000C1A7 66891D[88300100]    <1> 	mov	[u.r0], bx	
  2761 0000C1AE E96DF4FFFF          <1> 	jmp	sysret
  2762                              <1> sysvideo_28:
  2763 0000C1B3 58                  <1> 	pop	eax
  2764 0000C1B4 5A                  <1> 	pop	edx
  2765 0000C1B5 E966F4FFFF          <1> 	jmp	sysret
  2766                              <1> 
  2767                              <1> sysvideo_29:
  2768 0000C1BA 80FB06              <1> 	cmp	bl, 6
  2769 0000C1BD 0F8797000000        <1>         ja      sysvideo_32
  2770                              <1> 
  2771                              <1> 	; BL = 6 = window copy (system to user)
  2772                              <1> 
  2773 0000C1C3 89F7                <1> 	mov	edi, esi ; user buffer
  2774                              <1> 
  2775 0000C1C5 B800800B00          <1> 	mov	eax, 0B8000h
  2776 0000C1CA 39C6                <1> 	cmp	esi, eax
  2777 0000C1CC 0F824EF4FFFF        <1> 	jb	sysret
  2778 0000C1D2 6605FF7F            <1> 	add	ax, 7FFFh ; 32767
  2779 0000C1D6 39C6                <1> 	cmp	esi, eax
  2780 0000C1D8 0F8742F4FFFF        <1> 	ja	sysret
  2781                              <1> 
  2782                              <1> 	; edi = user buffer (in user's memory space)
  2783 0000C1DE 39CA                <1> 	cmp	edx, ecx ; bottom-right > top-left ?
  2784 0000C1E0 0F86E2FDFFFF        <1>         jna     sysvideo_17 ; full screen copy
  2785                              <1> 
  2786 0000C1E6 0FB7C2              <1> 	movzx	eax, dx ; bottom right column
  2787 0000C1E9 6629C8              <1> 	sub	ax, cx  ; - top left column
  2788 0000C1EC 0F822EF4FFFF        <1>         jb      sysret ; invalid
  2789 0000C1F2 6640                <1> 	inc	ax ; same column no == 1 column	 
  2790 0000C1F4 50                  <1> 	push	eax ; byte count per window row
  2791                              <1> 
  2792 0000C1F5 52                  <1> 	push	edx
  2793 0000C1F6 BB40010000          <1> 	mov	ebx, 320 ; screen width
  2794 0000C1FB 89C8                <1> 	mov	eax, ecx
  2795 0000C1FD C1E810              <1> 	shr	eax, 16	; top row
  2796 0000C200 F7E3                <1> 	mul	ebx
  2797 0000C202 6689CA              <1> 	mov	dx, cx ; top left column
  2798 0000C205 01D0                <1> 	add	eax, edx
  2799 0000C207 01C6                <1> 	add	esi, eax ; start address 
  2800 0000C209 59                  <1> 	pop	ecx ; edx
  2801 0000C20A 89C8                <1> 	mov	eax, ecx
  2802 0000C20C C1E810              <1> 	shr	eax, 16 ; bottom row
  2803 0000C20F F7E3                <1> 	mul	ebx
  2804 0000C211 6689CA              <1> 	mov	dx, cx ; bottom right column
  2805 0000C214 01D0                <1> 	add	eax, edx
  2806 0000C216 5A                  <1> 	pop	edx ; byte count per window row
  2807 0000C217 0500800B00          <1> 	add	eax, 0B8000h
  2808 0000C21C 3DFFFF0B00          <1> 	cmp	eax, 0BFFFFh
  2809 0000C221 0F87F9F3FFFF        <1> 	ja	sysret
  2810 0000C227 56                  <1> 	push	esi ; start address 
  2811 0000C228 50                  <1> 	push	eax ; stop address (included)
  2812                              <1> sysvideo_30:
  2813 0000C229 89D1                <1> 	mov	ecx, edx ; byte count
  2814                              <1> 	; user to system video/display page window transfer
  2815                              <1> 	; esi =	user buffer
  2816 0000C22B E820170000          <1> 	call	transfer_to_user_buffer ; fast transfer
  2817 0000C230 7221                <1> 	jc	short sysvideo_31
  2818 0000C232 010D[88300100]      <1> 	add	[u.r0], ecx
  2819 0000C238 01DF                <1> 	add	edi, ebx ; next row
  2820 0000C23A 01CE                <1> 	add	esi, ecx
  2821 0000C23C 3B3C24              <1> 	cmp	edi, [esp] ; stop addr(included in loop)
  2822 0000C23F 76E8                <1> 	jna	short sysvideo_30
  2823 0000C241 5B                  <1> 	pop	ebx ; stop address
  2824 0000C242 5F                  <1> 	pop	edi ; start address
  2825 0000C243 29FB                <1> 	sub	ebx, edi
  2826 0000C245 6643                <1> 	inc	bx
  2827 0000C247 66891D[88300100]    <1> 	mov	[u.r0], bx	
  2828 0000C24E E9CDF3FFFF          <1> 	jmp	sysret
  2829                              <1> sysvideo_31:
  2830 0000C253 58                  <1> 	pop	eax
  2831 0000C254 5A                  <1> 	pop	edx
  2832 0000C255 E9C6F3FFFF          <1> 	jmp	sysret
  2833                              <1> 
  2834                              <1> sysvideo_32:
  2835 0000C25A 80FB07              <1> 	cmp	bl, 7
  2836 0000C25D 770F                <1> 	ja	short sysvideo_34
  2837                              <1> 
  2838                              <1> 	; BL = 7 = AND display page bytes with CL
  2839                              <1> 
  2840 0000C25F BE00800B00          <1> 	mov	esi, 0B8000h
  2841 0000C264 B900800000          <1> 	mov	ecx, 32768
  2842                              <1> sysvideo_33:
  2843 0000C269 200E                <1> 	and	byte [esi], cl
  2844 0000C26B 46                  <1> 	inc	esi
  2845 0000C26C E2FB                <1> 	loop	sysvideo_33
  2846                              <1> 
  2847                              <1> sysvideo_34:
  2848 0000C26E 80FB08              <1> 	cmp	bl, 8
  2849 0000C271 770F                <1> 	ja	short sysvideo_36
  2850                              <1> 
  2851                              <1> 	; BL = 8 = OR display page bytes with CL
  2852                              <1> 
  2853 0000C273 BE00800B00          <1> 	mov	esi, 0B8000h
  2854 0000C278 B900800000          <1> 	mov	ecx, 32768
  2855                              <1> sysvideo_35:
  2856 0000C27D 080E                <1> 	or	byte [esi], cl
  2857 0000C27F 46                  <1> 	inc	esi
  2858 0000C280 E2FB                <1> 	loop	sysvideo_35	
  2859                              <1> 
  2860                              <1> sysvideo_36:
  2861 0000C282 80FB09              <1> 	cmp	bl, 9
  2862 0000C285 0F8795F3FFFF        <1>         ja      sysret ; nothing to do
  2863                              <1> 
  2864                              <1> 	; BL = 9 = XOR display page bytes with CL
  2865                              <1> 
  2866 0000C28B BE00800B00          <1> 	mov	esi, 0B8000h
  2867 0000C290 B900800000          <1> 	mov	ecx, 32768
  2868                              <1> sysvideo_37:
  2869 0000C295 300E                <1> 	xor	byte [esi], cl
  2870 0000C297 46                  <1> 	inc	esi
  2871 0000C298 E2FB                <1> 	loop	sysvideo_37
  2872                              <1> 
  2873                              <1> sysvideo_38:
  2874 0000C29A 80FF02              <1> 	cmp	bh, 2
  2875 0000C29D 0F8733030000        <1>         ja      sysvideo_64
  2876                              <1> 	; BH = 2 = VGA Graphics (0A0000h) data transfers
  2877                              <1> 
  2878 0000C2A3 88DC                <1> 	mov	ah, bl
  2879 0000C2A5 80E30F              <1> 	and	bl, 0Fh	
  2880 0000C2A8 C0EC04              <1> 	shr	ah, 4
  2881 0000C2AB C1E310              <1> 	shl	ebx, 16
  2882 0000C2AE 66BB4001            <1> 	mov	bx, 320 ; 320*200, 320*240
  2883 0000C2B2 20E4                <1> 	and	ah, ah
  2884 0000C2B4 7413                <1> 	jz	short sysvideo_39
  2885 0000C2B6 66D1E3              <1> 	shl	bx, 1 ; 640*200, 640 * 400, 640*480
  2886 0000C2B9 80FC02              <1> 	cmp	ah, 2
  2887 0000C2BC 720B                <1> 	jb	short sysvideo_39 		
  2888 0000C2BE 0F875CF3FFFF        <1> 	ja	sysret ; invalid
  2889                              <1> 	; 800*600
  2890 0000C2C4 6681C3A000          <1> 	add	bx, 160 ; 800
  2891                              <1> sysvideo_39:
  2892 0000C2C9 C1CB10              <1> 	ror	ebx, 16
  2893                              <1> 		
  2894 0000C2CC 20DB                <1>  	and	bl, bl
  2895 0000C2CE 7519                <1> 	jnz	short sysvideo_40
  2896                              <1> 
  2897                              <1> 	; BL =	0 = Fill color (color in CL] (64K)
  2898                              <1> 
  2899 0000C2D0 88C8                <1> 	mov	al, cl
  2900 0000C2D2 B900000100          <1> 	mov	ecx, 65536
  2901 0000C2D7 890D[88300100]      <1> 	mov	[u.r0], ecx
  2902 0000C2DD BF00000A00          <1> 	mov	edi, 0A0000h
  2903 0000C2E2 F3AB                <1> 	rep	stosd
  2904 0000C2E4 E937F3FFFF          <1> 	jmp	sysret
  2905                              <1> 
  2906                              <1> sysvideo_40:
  2907 0000C2E9 80FB01              <1> 	cmp	bl, 1
  2908 0000C2EC 7722                <1> 	ja	short sysvideo_42
  2909                              <1> 
  2910 0000C2EE 89CE                <1> 	mov	esi, ecx ; user buffer
  2911                              <1> 	; BL = 1 = user to system video/display page transfer
  2912                              <1> sysvideo_41:	
  2913 0000C2F0 BF00000A00          <1> 	mov	edi, 0A0000h
  2914                              <1> 	; edi = video page address
  2915 0000C2F5 B900000100          <1> 	mov	ecx, 65536
  2916 0000C2FA E89B160000          <1> 	call	transfer_from_user_buffer ; fast transfer
  2917 0000C2FF 0F821BF3FFFF        <1> 	jc	sysret ; [u.r0] = 0
  2918 0000C305 890D[88300100]      <1> 	mov	[u.r0], ecx		
  2919 0000C30B E910F3FFFF          <1> 	jmp	sysret
  2920                              <1> 
  2921                              <1> sysvideo_42:
  2922 0000C310 80FB02              <1> 	cmp	bl, 2	
  2923 0000C313 7722                <1> 	ja	short sysvideo_44
  2924                              <1> 
  2925 0000C315 89CF                <1> 	mov	edi, ecx ; user buffer
  2926                              <1> 	; BL = 2 = system to user video/display page transfer
  2927                              <1> sysvideo_43:	
  2928 0000C317 BE00000A00          <1> 	mov	esi, 0A0000h
  2929 0000C31C B900000100          <1> 	mov	ecx, 65536
  2930 0000C321 E82A160000          <1> 	call	transfer_to_user_buffer ; fast transfer
  2931 0000C326 0F82F4F2FFFF        <1> 	jc	sysret ; [u.r0] = 0
  2932 0000C32C 890D[88300100]      <1> 	mov	[u.r0], ecx
  2933 0000C332 E9E9F2FFFF          <1> 	jmp	sysret 	
  2934                              <1> 
  2935                              <1> sysvideo_44:
  2936 0000C337 80FB03              <1> 	cmp	bl, 3
  2937 0000C33A 777A                <1> 	ja	short sysvideo_49
  2938                              <1> 
  2939                              <1> 	; BL = 3 = NOT bits in window (ECX, EDX)
  2940                              <1> 
  2941 0000C33C BF00000A00          <1> 	mov	edi, 0A0000h
  2942 0000C341 89FE                <1> 	mov	esi, edi
  2943                              <1> 	
  2944 0000C343 39CA                <1> 	cmp	edx, ecx ; bottom-right > top-left ?
  2945 0000C345 770B                <1> 	ja	short sysvideo_45 ; window
  2946                              <1> 	; full screen (update)
  2947 0000C347 B900000100          <1> 	mov	ecx, 65536
  2948 0000C34C 890D[88300100]      <1> 	mov	[u.r0], ecx
  2949                              <1> sysvideo_45:
  2950 0000C352 F616                <1> 	not	byte [esi] ; NOT operation
  2951 0000C354 46                  <1> 	inc	esi
  2952 0000C355 E2FB                <1> 	loop	sysvideo_45
  2953 0000C357 E9C4F2FFFF          <1> 	jmp	sysret
  2954                              <1> sysvideo_46:
  2955 0000C35C 0FB7C2              <1> 	movzx	eax, dx ; bottom right column
  2956 0000C35F 6629C8              <1> 	sub	ax, cx  ; - top left column
  2957 0000C362 0F82B8F2FFFF        <1>         jb      sysret ; invalid
  2958 0000C368 6640                <1> 	inc	ax ; same column no == 1 column	 
  2959 0000C36A 50                  <1> 	push	eax ; byte count per window row
  2960 0000C36B 52                  <1> 	push	edx
  2961 0000C36C C1EB10              <1> 	shr	ebx, 16 ; 320,640,800 : screen width
  2962 0000C36F 89C8                <1> 	mov	eax, ecx
  2963 0000C371 C1E810              <1> 	shr	eax, 16  ; top row
  2964 0000C374 F7E3                <1> 	mul	ebx
  2965 0000C376 6689CA              <1> 	mov	dx, cx ; top left column
  2966 0000C379 01D0                <1> 	add	eax, edx
  2967 0000C37B 01C6                <1> 	add	esi, eax ; start address 
  2968 0000C37D 59                  <1> 	pop	ecx ; edx
  2969 0000C37E 89C8                <1> 	mov	eax, ecx
  2970 0000C380 C1E810              <1> 	shr	eax, 16 ; bottom row
  2971 0000C383 F7E3                <1> 	mul	ebx
  2972 0000C385 6689CA              <1> 	mov	dx, cx ; bottom right column
  2973 0000C388 01D0                <1> 	add	eax, edx
  2974 0000C38A 01C7                <1> 	add	edi, eax ; stop address (included)
  2975 0000C38C 5A                  <1> 	pop	edx ; byte count per window row
  2976 0000C38D 81FFFFFF0A00        <1> 	cmp	edi, 0AFFFFh
  2977 0000C393 0F8787F2FFFF        <1> 	ja	sysret	
  2978 0000C399 56                  <1> 	push	esi
  2979 0000C39A 4E                  <1> 	dec	esi
  2980                              <1> sysvideo_47:
  2981 0000C39B 89D1                <1> 	mov	ecx, edx
  2982                              <1> sysvideo_48:
  2983 0000C39D 46                  <1> 	inc	esi
  2984 0000C39E F616                <1> 	not	byte [esi]
  2985 0000C3A0 E2FB                <1> 	loop	sysvideo_48
  2986 0000C3A2 01DE                <1> 	add	esi, ebx ; bytes per screen row
  2987                              <1> 	;
  2988 0000C3A4 39FE                <1> 	cmp	esi, edi ; stop address (included in loop)
  2989 0000C3A6 76F3                <1> 	jna	short sysvideo_47
  2990 0000C3A8 5E                  <1> 	pop	esi
  2991 0000C3A9 29F7                <1> 	sub	edi, esi
  2992 0000C3AB 893D[88300100]      <1> 	mov	[u.r0], edi
  2993 0000C3B1 E96AF2FFFF          <1> 	jmp	sysret
  2994                              <1> 
  2995                              <1> sysvideo_49:
  2996 0000C3B6 80FB04              <1> 	cmp	bl, 4
  2997 0000C3B9 0F87A1000000        <1>         ja      sysvideo_52
  2998                              <1> 
  2999                              <1> 	; BL = 4 = window copy (system to system)
  3000                              <1> 
  3001 0000C3BF B800000A00          <1> 	mov	eax, 0A0000h
  3002 0000C3C4 39C6                <1> 	cmp	esi, eax
  3003 0000C3C6 0F8254F2FFFF        <1> 	jb	sysret
  3004 0000C3CC 39C7                <1> 	cmp	edi, eax
  3005 0000C3CE 0F824CF2FFFF        <1> 	jb	sysret
  3006 0000C3D4 6683C0FF            <1> 	add	ax, 0FFFFh ; 65535
  3007 0000C3D8 39C6                <1> 	cmp	esi, eax
  3008 0000C3DA 0F8740F2FFFF        <1> 	ja	sysret
  3009 0000C3E0 39C7                <1> 	cmp	edi, eax
  3010 0000C3E2 0F8738F2FFFF        <1> 	ja	sysret
  3011                              <1> 	
  3012 0000C3E8 39CA                <1> 	cmp	edx, ecx ; bottom-right > top-left ?
  3013 0000C3EA 7712                <1> 	ja	short sysvideo_50 ; window
  3014                              <1> 	; full screen copy
  3015 0000C3EC 89C1                <1> 	mov	ecx, eax
  3016 0000C3EE 29F9                <1> 	sub	ecx, edi
  3017 0000C3F0 41                  <1> 	inc	ecx
  3018 0000C3F1 890D[88300100]      <1> 	mov	[u.r0], ecx
  3019 0000C3F7 F3A4                <1> 	rep	movsb
  3020 0000C3F9 E922F2FFFF          <1> 	jmp	sysret
  3021                              <1> sysvideo_50:
  3022 0000C3FE 0FB7C2              <1> 	movzx	eax, dx ; bottom right column
  3023 0000C401 6629C8              <1> 	sub	ax, cx  ; - top left column
  3024 0000C404 0F8216F2FFFF        <1>         jb      sysret ; invalid
  3025 0000C40A 6640                <1> 	inc	ax ; same column no == 1 column	 
  3026 0000C40C 50                  <1> 	push	eax ; byte count per window row
  3027                              <1> 	;
  3028 0000C40D 52                  <1> 	push	edx
  3029 0000C40E C1EB10              <1> 	shr	ebx, 16 ; 320,640,800 : screen width
  3030 0000C411 89C8                <1> 	mov	eax, ecx
  3031 0000C413 C1E810              <1> 	shr	eax, 16	; top row
  3032 0000C416 F7E3                <1> 	mul	ebx
  3033 0000C418 6689CA              <1> 	mov	dx, cx ; top left column
  3034 0000C41B 01D0                <1> 	add	eax, edx
  3035 0000C41D 01C7                <1> 	add	edi, eax ; start address 
  3036 0000C41F 01C6                <1> 	add	esi, eax
  3037 0000C421 59                  <1> 	pop	ecx ; edx
  3038 0000C422 89C8                <1> 	mov	eax, ecx
  3039 0000C424 C1E810              <1> 	shr	eax, 16 ; bottom row
  3040 0000C427 F7E3                <1> 	mul	ebx
  3041 0000C429 6689CA              <1> 	mov	dx, cx ; bottom right column
  3042 0000C42C 01D0                <1> 	add	eax, edx
  3043 0000C42E 5A                  <1> 	pop	edx ; byte count per window row
  3044 0000C42F 0500000A00          <1> 	add	eax, 0A0000h
  3045 0000C434 3DFFFF0A00          <1> 	cmp	eax, 0AFFFFh
  3046 0000C439 0F87E1F1FFFF        <1> 	ja	sysret
  3047 0000C43F 57                  <1> 	push	edi ; start address 
  3048 0000C440 50                  <1> 	push	eax ; stop address (included)
  3049                              <1> sysvideo_51:
  3050 0000C441 89D1                <1> 	mov	ecx, edx
  3051 0000C443 F3A4                <1> 	rep	movsb
  3052 0000C445 4F                  <1> 	dec	edi
  3053 0000C446 4E                  <1> 	dec	esi
  3054 0000C447 01DF                <1> 	add	edi, ebx ; bytes per screen row
  3055 0000C449 01DE                <1> 	add	esi, ebx
  3056                              <1> 	;
  3057 0000C44B 3B3C24              <1> 	cmp	edi, [esp] ; stop addr(included in loop)
  3058 0000C44E 76F1                <1> 	jna	short sysvideo_51
  3059 0000C450 5B                  <1> 	pop	ebx ; stop address
  3060 0000C451 5F                  <1> 	pop	edi ; start address
  3061 0000C452 29FB                <1> 	sub	ebx, edi
  3062 0000C454 43                  <1> 	inc	ebx
  3063 0000C455 891D[88300100]      <1> 	mov	[u.r0], ebx	
  3064 0000C45B E9C0F1FFFF          <1> 	jmp	sysret
  3065                              <1> 
  3066                              <1> sysvideo_52:
  3067 0000C460 80FB05              <1> 	cmp	bl, 5
  3068 0000C463 0F8791000000        <1>         ja      sysvideo_55
  3069                              <1> 
  3070                              <1> 	; BL = 5 = window copy (user to system)
  3071                              <1> 
  3072 0000C469 B800000A00          <1> 	mov	eax, 0A0000h
  3073 0000C46E 39C7                <1> 	cmp	edi, eax
  3074 0000C470 0F82AAF1FFFF        <1> 	jb	sysret
  3075 0000C476 6683C0FF            <1> 	add	ax, 0FFFFh ; 65535
  3076 0000C47A 39C7                <1> 	cmp	edi, eax
  3077 0000C47C 0F879EF1FFFF        <1> 	ja	sysret
  3078                              <1> 
  3079                              <1> 	; esi = user buffer (in user's memory space)
  3080 0000C482 39CA                <1> 	cmp	edx, ecx ; bottom-right > top-left ?
  3081 0000C484 0F8666FEFFFF        <1>         jna     sysvideo_41 ; full screen copy
  3082                              <1> 
  3083 0000C48A 0FB7C2              <1> 	movzx	eax, dx ; bottom right column
  3084 0000C48D 6629C8              <1> 	sub	ax, cx  ; - top left column
  3085 0000C490 0F828AF1FFFF        <1>         jb      sysret ; invalid
  3086 0000C496 6640                <1> 	inc	ax ; same column no == 1 column	 
  3087 0000C498 50                  <1> 	push	eax ; byte count per window row
  3088                              <1> 
  3089 0000C499 52                  <1> 	push	edx
  3090 0000C49A C1EB10              <1> 	shr	ebx, 16 ; 320,640,800 : screen width
  3091 0000C49D 89C8                <1> 	mov	eax, ecx
  3092 0000C49F C1E810              <1> 	shr	eax, 16	; top row
  3093 0000C4A2 F7E3                <1> 	mul	ebx
  3094 0000C4A4 6689CA              <1> 	mov	dx, cx ; top left column
  3095 0000C4A7 01D0                <1> 	add	eax, edx
  3096 0000C4A9 01C7                <1> 	add	edi, eax ; start address 
  3097 0000C4AB 59                  <1> 	pop	ecx ; edx
  3098 0000C4AC 89C8                <1> 	mov	eax, ecx
  3099 0000C4AE C1E810              <1> 	shr	eax, 16 ; bottom row
  3100 0000C4B1 F7E3                <1> 	mul	ebx
  3101 0000C4B3 6689CA              <1> 	mov	dx, cx ; bottom right column
  3102 0000C4B6 01D0                <1> 	add	eax, edx
  3103 0000C4B8 5A                  <1> 	pop	edx ; byte count per window row
  3104 0000C4B9 0500000A00          <1> 	add	eax, 0A0000h
  3105 0000C4BE 3DFFFF0A00          <1> 	cmp	eax, 0AFFFFh
  3106 0000C4C3 0F8757F1FFFF        <1> 	ja	sysret
  3107 0000C4C9 57                  <1> 	push	edi ; start address 
  3108 0000C4CA 50                  <1> 	push	eax ; stop address (included)
  3109                              <1> sysvideo_53:
  3110 0000C4CB 89D1                <1> 	mov	ecx, edx ; byte count
  3111                              <1> 	; user to system video/display page window transfer
  3112                              <1> 	; esi =	user buffer
  3113 0000C4CD E8C8140000          <1> 	call	transfer_from_user_buffer ; fast transfer
  3114 0000C4D2 721F                <1> 	jc	short sysvideo_54
  3115 0000C4D4 010D[88300100]      <1> 	add	[u.r0], ecx
  3116 0000C4DA 01DF                <1> 	add	edi, ebx ; next row
  3117 0000C4DC 01CE                <1> 	add	esi, ecx
  3118 0000C4DE 3B3C24              <1> 	cmp	edi, [esp] ; stop addr(included in loop)
  3119 0000C4E1 76E8                <1> 	jna	short sysvideo_53
  3120 0000C4E3 5B                  <1> 	pop	ebx ; stop address
  3121 0000C4E4 5F                  <1> 	pop	edi ; start address
  3122 0000C4E5 29FB                <1> 	sub	ebx, edi
  3123 0000C4E7 43                  <1> 	inc	ebx
  3124 0000C4E8 891D[88300100]      <1> 	mov	[u.r0], ebx	
  3125 0000C4EE E92DF1FFFF          <1> 	jmp	sysret
  3126                              <1> sysvideo_54:
  3127 0000C4F3 58                  <1> 	pop	eax
  3128 0000C4F4 5A                  <1> 	pop	edx
  3129 0000C4F5 E926F1FFFF          <1> 	jmp	sysret
  3130                              <1> 
  3131                              <1> sysvideo_55:
  3132 0000C4FA 80FB06              <1> 	cmp	bl, 6
  3133 0000C4FD 0F8793000000        <1>         ja      sysvideo_58
  3134                              <1> 
  3135                              <1> 	; BL = 6 = window copy (system to user)
  3136                              <1> 
  3137 0000C503 89F7                <1> 	mov	edi, esi ; user buffer
  3138                              <1> 
  3139 0000C505 B800000A00          <1> 	mov	eax, 0A0000h
  3140 0000C50A 39C6                <1> 	cmp	esi, eax
  3141 0000C50C 0F820EF1FFFF        <1> 	jb	sysret
  3142 0000C512 6683C0FF            <1> 	add	ax, 0FFFFh ; 65535
  3143 0000C516 39C6                <1> 	cmp	esi, eax
  3144 0000C518 0F8702F1FFFF        <1> 	ja	sysret
  3145                              <1> 
  3146                              <1> 	; edi = user buffer (in user's memory space)
  3147 0000C51E 39CA                <1> 	cmp	edx, ecx ; bottom-right > top-left ?
  3148 0000C520 0F86A2FAFFFF        <1>         jna     sysvideo_17 ; full screen copy
  3149                              <1> 
  3150 0000C526 0FB7C2              <1> 	movzx	eax, dx ; bottom right column
  3151 0000C529 6629C8              <1> 	sub	ax, cx  ; - top left column
  3152 0000C52C 0F82EEF0FFFF        <1>         jb      sysret ; invalid
  3153 0000C532 6640                <1> 	inc	ax ; same column no == 1 column	 
  3154 0000C534 50                  <1> 	push	eax ; byte count per window row
  3155                              <1> 
  3156 0000C535 52                  <1> 	push	edx
  3157 0000C536 C1EB10              <1> 	shr	ebx, 16 ; 320, 640,800 ; screen width
  3158 0000C539 89C8                <1> 	mov	eax, ecx
  3159 0000C53B C1E810              <1> 	shr	eax, 16	; top row
  3160 0000C53E F7E3                <1> 	mul	ebx
  3161 0000C540 6689CA              <1> 	mov	dx, cx ; top left column
  3162 0000C543 01D0                <1> 	add	eax, edx
  3163 0000C545 01C6                <1> 	add	esi, eax ; start address 
  3164 0000C547 59                  <1> 	pop	ecx ; edx
  3165 0000C548 89C8                <1> 	mov	eax, ecx
  3166 0000C54A C1E810              <1> 	shr	eax, 16 ; bottom row
  3167 0000C54D F7E3                <1> 	mul	ebx
  3168 0000C54F 6689CA              <1> 	mov	dx, cx ; bottom right column
  3169 0000C552 01D0                <1> 	add	eax, edx
  3170 0000C554 5A                  <1> 	pop	edx ; byte count per window row
  3171 0000C555 0500000A00          <1> 	add	eax, 0A0000h
  3172 0000C55A 3DFFFF0A00          <1> 	cmp	eax, 0AFFFFh
  3173 0000C55F 0F87BBF0FFFF        <1> 	ja	sysret
  3174 0000C565 56                  <1> 	push	esi ; start address 
  3175 0000C566 50                  <1> 	push	eax ; stop address (included)
  3176                              <1> sysvideo_56:
  3177 0000C567 89D1                <1> 	mov	ecx, edx ; byte count
  3178                              <1> 	; user to system video/display page window transfer
  3179                              <1> 	; esi =	user buffer
  3180 0000C569 E8E2130000          <1> 	call	transfer_to_user_buffer ; fast transfer
  3181 0000C56E 721F                <1> 	jc	short sysvideo_57
  3182 0000C570 010D[88300100]      <1> 	add	[u.r0], ecx
  3183 0000C576 01DF                <1> 	add	edi, ebx ; next row
  3184 0000C578 01CE                <1> 	add	esi, ecx
  3185 0000C57A 3B3C24              <1> 	cmp	edi, [esp] ; stop addr(included in loop)
  3186 0000C57D 76E8                <1> 	jna	short sysvideo_56
  3187 0000C57F 5B                  <1> 	pop	ebx ; stop address
  3188 0000C580 5F                  <1> 	pop	edi ; start address
  3189 0000C581 29FB                <1> 	sub	ebx, edi
  3190 0000C583 43                  <1> 	inc	ebx
  3191 0000C584 891D[88300100]      <1> 	mov	[u.r0], ebx	
  3192 0000C58A E991F0FFFF          <1> 	jmp	sysret
  3193                              <1> sysvideo_57:
  3194 0000C58F 58                  <1> 	pop	eax
  3195 0000C590 5A                  <1> 	pop	edx
  3196 0000C591 E98AF0FFFF          <1> 	jmp	sysret
  3197                              <1> 
  3198                              <1> sysvideo_58:
  3199 0000C596 80FB07              <1> 	cmp	bl, 7
  3200 0000C599 770F                <1> 	ja	short sysvideo_60
  3201                              <1> 
  3202                              <1> 	; BL = 7 = AND display page bytes with CL
  3203                              <1> 
  3204 0000C59B BE00000A00          <1> 	mov	esi, 0A0000h
  3205 0000C5A0 B900000100          <1> 	mov	ecx, 65536
  3206                              <1> sysvideo_59:
  3207 0000C5A5 200E                <1> 	and	byte [esi], cl
  3208 0000C5A7 46                  <1> 	inc	esi
  3209 0000C5A8 E2FB                <1> 	loop	sysvideo_59
  3210                              <1> 
  3211                              <1> sysvideo_60:
  3212 0000C5AA 80FB08              <1> 	cmp	bl, 8
  3213 0000C5AD 770F                <1> 	ja	short sysvideo_62
  3214                              <1> 
  3215                              <1> 	; BL = 8 = OR display page bytes with CL
  3216                              <1> 
  3217 0000C5AF BE00000A00          <1> 	mov	esi, 0A0000h
  3218 0000C5B4 B900000100          <1> 	mov	ecx, 65536
  3219                              <1> sysvideo_61:
  3220 0000C5B9 080E                <1> 	or	byte [esi], cl
  3221 0000C5BB 46                  <1> 	inc	esi
  3222 0000C5BC E2FB                <1> 	loop	sysvideo_61	
  3223                              <1> 
  3224                              <1> sysvideo_62:
  3225 0000C5BE 80FB09              <1> 	cmp	bl, 9
  3226 0000C5C1 0F8759F0FFFF        <1>         ja      sysret ; nothing to do
  3227                              <1> 
  3228                              <1> 	; BL = 9 = XOR display page bytes with CL
  3229                              <1> 
  3230 0000C5C7 BE00000A00          <1> 	mov	esi, 0A0000h
  3231 0000C5CC B900000100          <1> 	mov	ecx, 65536
  3232                              <1> sysvideo_63:
  3233 0000C5D1 300E                <1> 	xor	byte [esi], cl
  3234 0000C5D3 46                  <1> 	inc	esi
  3235 0000C5D4 E2FB                <1> 	loop	sysvideo_63
  3236                              <1> 
  3237                              <1> sysvideo_64:
  3238 0000C5D6 80FF03              <1> 	cmp	bh, 3
  3239 0000C5D9 7460                <1> 	je	short sysvideo_68
  3240 0000C5DB 80FF04              <1> 	cmp	bh, 4
  3241 0000C5DE 771F                <1> 	ja	short sysvideo_65
  3242                              <1> 	
  3243                              <1> 	; BH = 4
  3244                              <1> 	; Direct User Access for CGA video memory.
  3245                              <1> 	; Setup user's page tables for direct access to 0B8000h.
  3246                              <1> 	;
  3247                              <1> 	; Permission checks are not implemented yet !
  3248                              <1> 	; (11/07/2016)
  3249                              <1> 
  3250 0000C5E0 B800800B00          <1> 	mov	eax, 0B8000h
  3251 0000C5E5 B908000000          <1> 	mov	ecx, 8 ; 8 pages (8*4K=32K)
  3252 0000C5EA E8B58AFFFF          <1> 	call	direct_memory_access	
  3253 0000C5EF 0F822BF0FFFF        <1> 	jc	sysret
  3254                              <1> 	; eax = 0B8000h if there is not an error
  3255 0000C5F5 A3[88300100]        <1> 	mov	[u.r0], eax
  3256 0000C5FA E921F0FFFF          <1> 	jmp	sysret
  3257                              <1> 
  3258                              <1> sysvideo_65:
  3259 0000C5FF 80FF05              <1> 	cmp	bh, 5
  3260 0000C602 771F                <1> 	ja	short sysvideo_66
  3261                              <1> 
  3262                              <1> 	; BH = 5
  3263                              <1> 	; Direct User Access for VGA video memory.
  3264                              <1> 	; Setup user's page tables for direct access to 0A0000h.
  3265                              <1> 	;
  3266                              <1> 	; Permission checks are not implemented yet !
  3267                              <1> 	; (11/07/2016)
  3268                              <1> 
  3269 0000C604 B800000A00          <1> 	mov	eax, 0A0000h
  3270 0000C609 B910000000          <1> 	mov	ecx, 16 ; 16 pages (16*4K=64K)
  3271 0000C60E E8918AFFFF          <1> 	call	direct_memory_access	
  3272 0000C613 0F8207F0FFFF        <1> 	jc	sysret
  3273                              <1> 	; eax = 0A0000h if there is not an error
  3274 0000C619 A3[88300100]        <1> 	mov	[u.r0], eax
  3275 0000C61E E9FDEFFFFF          <1> 	jmp	sysret
  3276                              <1> 
  3277                              <1> sysvideo_66:
  3278 0000C623 80FF06              <1> 	cmp	bh, 6
  3279 0000C626 7705                <1> 	ja	short sysvideo_67
  3280                              <1> 	; BH = 6
  3281                              <1> 	; Direct User Access for (Super VGA) Linear Frame Buffer.
  3282                              <1> 	; Setup user's page tables for direct access to LFB.
  3283                              <1> 	;
  3284                              <1> 	; Not implemented yet !
  3285                              <1> 	; (11/07/2016)
  3286 0000C628 E9F3EFFFFF          <1> 	jmp	sysret
  3287                              <1> 
  3288                              <1> sysvideo_67:
  3289 0000C62D 80FF07              <1> 	cmp	bh, 7
  3290 0000C630 0F87EAEFFFFF        <1> 	ja	sysret ; invalid !
  3291                              <1> 
  3292                              <1> 	; BH = 7
  3293                              <1> 	; Get (Super/Extended VGA) Linear Frame Buffer info.
  3294                              <1> 	;
  3295                              <1> 	; Not implemented yet !
  3296                              <1> 	; (11/07/2016)
  3297 0000C636 E9E5EFFFFF          <1> 	jmp	sysret
  3298                              <1> 
  3299                              <1> sysvideo_68:
  3300                              <1> 	; BH = 3
  3301                              <1> 	; Super VGA, LINEAR FRAME BUFFER data transfers
  3302                              <1> 	; Not implemented for yet ! (11/07/2016)
  3303 0000C63B E9E0EFFFFF          <1> 	jmp	sysret
  3304                              <1> 
  3305                              <1> sysaudio: ; AUDIO FUNCTIONS
  3306                              <1> 	; 16/05/2016 - TRDOS 386 (TRDOS v2.0)
  3307                              <1> 	;
  3308                              <1> 	; Inputs:
  3309                              <1> 	;	BH = 0 -> Beep (PC Speaker)
  3310                              <1> 	;	     BL = Duration Counter (1 for 1/64 second)
  3311                              <1> 	;	     CX = Frequency Divisor (1193180/Frequency)
  3312                              <1> 	;		 (1331 for 886 Hz)			
  3313                              <1> 	;
  3314                              <1> 	; Outputs:
  3315                              <1> 	;	none
  3316                              <1> 	;
  3317 0000C640 20FF                <1> 	and	bh, bh
  3318 0000C642 0F85D8EFFFFF        <1> 	jnz	sysret
  3319 0000C648 E8BE55FFFF          <1> 	call	beep
  3320 0000C64D E9CEEFFFFF          <1> 	jmp	sysret
  3321                              <1>  
  3322                              <1> syslink:
  3323                              <1> 	; 23/06/2015 (Retro UNIX 386 v1 - Beginning)
  3324                              <1> 	; 19/06/2013 (Retro UNIX 8086 v1)
  3325                              <1> 	;
  3326                              <1> 	; 'syslink' is given two arguments, name 1 and name 2.
  3327                              <1> 	; name 1 is a file that already exists. name 2 is the name
  3328                              <1> 	; given to the entry that will go in the current directory.
  3329                              <1> 	; name2 will then be a link to the name 1 file. The i-number
  3330                              <1> 	; in the name 2 entry of current directory is the same
  3331                              <1> 	; i-number for the name 1 file.
  3332                              <1> 	;
  3333                              <1> 	; Calling sequence:
  3334                              <1> 	;	syslink; name 1; name 2
  3335                              <1> 	; Arguments:
  3336                              <1> 	;	name 1 - file name to which link will be created.
  3337                              <1> 	;	name 2 - name of entry in current directory that
  3338                              <1> 	;		 links to name 1.
  3339                              <1> 	; Inputs: -
  3340                              <1> 	; Outputs: -
  3341                              <1> 	; ...............................................................
  3342                              <1> 	;	
  3343                              <1> 	; Retro UNIX 8086 v1 modification: 
  3344                              <1> 	;       'syslink' system call has two arguments; so,
  3345                              <1> 	;	* 1st argument, name 1 is pointed to by BX register
  3346                              <1> 	;	* 2nd argument, name 2 is pointed to by CX register
  3347                              <1> 	;
  3348                              <1> 		; / name1, name2
  3349                              <1> 		;jsr r0,arg2 / u.namep has 1st arg u.off has 2nd
  3350 0000C652 891D[A0300100]      <1> 	mov	[u.namep], ebx
  3351 0000C658 51                  <1> 	push	ecx
  3352 0000C659 E86C040000          <1> 	call	namei
  3353                              <1> 		; jsr r0,namei / find the i-number associated with
  3354                              <1> 			     ; / the 1st path name
  3355                              <1>      	;;and	ax, ax
  3356                              <1> 	;;jz	error ; File not found
  3357                              <1> 	;jc	error 
  3358                              <1> 		; br error9 / cannot be found
  3359 0000C65E 730F                <1> 	jnc	short syslink0
  3360                              <1> 	;pop 	ecx
  3361                              <1> 	; 'file not found !' error
  3362 0000C660 C705[DD300100]0C00- <1> 	mov	dword [u.error], ERR_FILE_NOT_FOUND ; 12
  3362 0000C668 0000                <1>
  3363 0000C66A E991EFFFFF          <1> 	jmp	error
  3364                              <1> syslink0:
  3365 0000C66F E862130000          <1> 	call	iget
  3366                              <1> 		; jsr r0,iget / get the i-node into core
  3367 0000C674 8F05[A0300100]      <1> 	pop	dword [u.namep] ; ecx
  3368                              <1> 		; mov (sp)+,u.namep / u.namep points to 2nd name
  3369 0000C67A 6650                <1> 	push	ax
  3370                              <1> 		; mov r1,-(sp) / put i-number of name1 on the stack
  3371                              <1> 			    ; / (a link to this file is to be created)
  3372 0000C67C 66FF35[6A300100]    <1> 	push	word [cdev]
  3373                              <1> 		; mov cdev,-(sp) / put i-nodes device on the stack
  3374 0000C683 E855000000          <1> 	call	isdir
  3375                              <1> 		; jsr r0,isdir / is it a directory
  3376 0000C688 E83D040000          <1> 	call	namei
  3377                              <1> 		; jsr r0,namei / no, get i-number of name2
  3378                              <1> 	;jnc	error
  3379                              <1> 		; br .+4   / not found 
  3380                              <1> 			 ; / so r1 = i-number of current directory
  3381                              <1> 			 ; / ii = i-number of current directory
  3382                              <1> 		; br error9 / file already exists., error
  3383 0000C68D 720F                <1> 	jc	short syslink1
  3384                              <1> 	; pop ax
  3385                              <1> 	; pop ax
  3386                              <1> 	; 'file exists !' error
  3387 0000C68F C705[DD300100]0E00- <1> 	mov	dword [u.error], ERR_FILE_EXISTS ; 14
  3387 0000C697 0000                <1>
  3388 0000C699 E962EFFFFF          <1> 	jmp	error
  3389                              <1> syslink1:
  3390 0000C69E 6659                <1> 	pop	cx
  3391                              <1> 	;cmp	cx, [cdev]
  3392 0000C6A0 3A0D[6A300100]      <1> 	cmp	cl, [cdev]
  3393                              <1> 	;jne	error
  3394                              <1> 		; cmp (sp)+,cdev / u.dirp now points to 
  3395                              <1> 			       ; / end of current directory
  3396                              <1> 	        ; bne error9
  3397 0000C6A6 740F                <1> 	je	short syslink2
  3398                              <1> 	; 'not same drive !' error
  3399 0000C6A8 C705[DD300100]1500- <1> 	mov	dword [u.error],  ERR_DRV_NOT_SAME ; 21
  3399 0000C6B0 0000                <1>
  3400 0000C6B2 E949EFFFFF          <1> 	jmp	error
  3401                              <1> syslink2:
  3402 0000C6B7 6658                <1> 	pop	ax
  3403 0000C6B9 6650                <1> 	push	ax
  3404 0000C6BB 66A3[BA300100]      <1> 	mov	[u.dirbuf], ax
  3405                              <1> 		; mov (sp),u.dirbuf / i-number of name1 into u.dirbuf
  3406 0000C6C1 E8A8000000          <1> 	call	mkdir
  3407                              <1> 		; jsr r0,mkdir / make directory entry for name2 
  3408                              <1> 		 	     ; / in current directory
  3409 0000C6C6 6658                <1> 	pop	ax
  3410                              <1> 		; mov (sp)+,r1 / r1 has i-number of name1
  3411 0000C6C8 E809130000          <1> 	call	iget
  3412                              <1> 		; jsr r0,iget / get i-node into core
  3413 0000C6CD FE05[4E2D0100]      <1> 	inc	byte [i.nlks]
  3414                              <1> 		; incb i.nlks / add 1 to its number of links
  3415 0000C6D3 E805130000          <1> 	call	setimod
  3416                              <1> 		; jsr r0,setimod / set the i-node modified flag
  3417 0000C6D8 E943EFFFFF          <1> 	jmp	sysret
  3418                              <1> 
  3419                              <1> isdir:
  3420                              <1> 	; 22/06/2015 (Retro UNIX 386 v1 - Beginning)
  3421                              <1> 	; 04/05/2013 - 02/08/2013 (Retro UNIX 8086 v1)
  3422                              <1> 	;
  3423                              <1> 	; 'isdir' check to see if the i-node whose i-number is in r1
  3424                              <1> 	;  is a directory. If it is, an error occurs, because 'isdir'
  3425                              <1> 	;  called by syslink and sysunlink to make sure directories
  3426                              <1> 	;  are not linked. If the user is the super user (u.uid=0),
  3427                              <1> 	; 'isdir' does not bother checking. The current i-node
  3428                              <1> 	;  is not disturbed.			
  3429                              <1> 	;		
  3430                              <1> 	; INPUTS ->
  3431                              <1> 	;    r1 - contains the i-number whose i-node is being checked.
  3432                              <1> 	;    u.uid - user id
  3433                              <1> 	; OUTPUTS ->
  3434                              <1> 	;    r1 - contains current i-number upon exit
  3435                              <1> 	;    	 (current i-node back in core) 
  3436                              <1> 	;	
  3437                              <1> 	; ((AX = R1))
  3438                              <1> 	;
  3439                              <1>         ; ((Modified registers: eAX, eDX, eBX, eCX, eSI, eDI, eBP))  
  3440                              <1> 	;
  3441                              <1> 
  3442                              <1> 	; / if the i-node whose i-number is in r1 is a directory 
  3443                              <1> 	; / there is an error unless super user made the call
  3444                              <1> 	
  3445 0000C6DD 803D[D4300100]00    <1> 	cmp	byte [u.uid], 0 
  3446                              <1> 		; tstb u.uid / super user
  3447 0000C6E4 762D                <1> 	jna	short isdir1
  3448                              <1> 		; beq 1f / yes, don't care
  3449 0000C6E6 66FF35[0D310100]    <1> 	push	word [ii]
  3450                              <1> 		; mov ii,-(sp) / put current i-number on stack
  3451 0000C6ED E8E4120000          <1> 	call	iget
  3452                              <1> 		; jsr r0,iget / get i-node into core (i-number in r1)
  3453 0000C6F2 66F705[4C2D0100]00- <1> 	test 	word [i.flgs], 4000h ; Bit 14 : Directory flag
  3453 0000C6FA 40                  <1>
  3454                              <1> 		; bit $40000,i.flgs / is it a directory
  3455                              <1> 	;jnz	error
  3456                              <1> 		; bne error9 / yes, error
  3457 0000C6FB 740F                <1> 	jz	short isdir0
  3458 0000C6FD C705[DD300100]0B00- <1> 	mov 	dword [u.error], ERR_NOT_FILE  ; 11 ; ERR_DIR_ACCESS 
  3458 0000C705 0000                <1>
  3459                              <1> 				; 'permission denied !' error
  3460                              <1> 	; pop	ax
  3461 0000C707 E9F4EEFFFF          <1> 	jmp	error	
  3462                              <1> isdir0:	
  3463 0000C70C 6658                <1> 	pop	ax
  3464                              <1> 		; mov (sp)+,r1 / no, put current i-number in r1 (ii)
  3465 0000C70E E8C3120000          <1> 	call	iget
  3466                              <1> 		; jsr r0,iget / get it back in
  3467                              <1> isdir1: ; 1:
  3468 0000C713 C3                  <1> 	retn
  3469                              <1> 		; rts r0
  3470                              <1> 
  3471                              <1> sysunlink:
  3472                              <1> 	; 04/12/2015 (14 byte file names)
  3473                              <1> 	; 23/06/2015 (Retro UNIX 386 v1 - Beginning)
  3474                              <1> 	; 19/06/2013 (Retro UNIX 8086 v1)
  3475                              <1> 	;
  3476                              <1> 	; 'sysunlink' removes the entry for the file pointed to by
  3477                              <1> 	; name from its directory. If this entry was the last link
  3478                              <1> 	; to the file, the contents of the file are freed and the
  3479                              <1> 	; file is destroyed. If, however, the file was open in any
  3480                              <1> 	; process, the actual destruction is delayed until it is 
  3481                              <1> 	; closed, even though the directory entry has disappeared.
  3482                              <1> 	; 
  3483                              <1> 	; The error bit (e-bit) is set to indicate that the file	
  3484                              <1> 	; does not exist or that its directory can not be written.
  3485                              <1> 	; Write permission is not required on the file itself.
  3486                              <1> 	; It is also illegal to unlink a directory (except for
  3487                              <1> 	; the superuser).
  3488                              <1> 	;
  3489                              <1> 	; Calling sequence:
  3490                              <1> 	;	sysunlink; name
  3491                              <1> 	; Arguments:
  3492                              <1> 	;	name - name of directory entry to be removed 
  3493                              <1> 	; Inputs: -
  3494                              <1> 	; Outputs: -
  3495                              <1> 	; ...............................................................
  3496                              <1> 	;				
  3497                              <1> 	; Retro UNIX 8086 v1 modification:
  3498                              <1> 	;	 The user/application program puts address of the name
  3499                              <1> 	;        in BX register as 'sysunlink' system call argument.
  3500                              <1> 
  3501                              <1> 	; / name - remove link name
  3502 0000C714 891D[A0300100]      <1> 	mov	[u.namep], ebx
  3503                              <1> 		;jsr r0,arg; u.namep / u.namep points to name
  3504 0000C71A E8AB030000          <1> 	call	namei
  3505                              <1> 		; jsr r0,namei / find the i-number associated 
  3506                              <1> 			     ; / with the path name
  3507                              <1> 	;jc	error
  3508                              <1> 		; br error9 / not found
  3509 0000C71F 730F                <1> 	jnc	short sysunlink1
  3510                              <1> 	; 'file not found !' error
  3511 0000C721 C705[DD300100]0C00- <1> 	mov	dword [u.error], ERR_FILE_NOT_FOUND ; 12
  3511 0000C729 0000                <1>
  3512 0000C72B E9D0EEFFFF          <1> 	jmp	error
  3513                              <1> sysunlink1:
  3514 0000C730 6650                <1> 	push	ax
  3515                              <1> 		; mov r1,-(sp) / put its i-number on the stack
  3516 0000C732 E8A6FFFFFF          <1> 	call	isdir
  3517                              <1> 		; jsr r0,isdir / is it a directory
  3518 0000C737 6631C0              <1> 	xor 	ax, ax
  3519 0000C73A 66A3[BA300100]      <1> 	mov	[u.dirbuf], ax ; 0
  3520                              <1> 		; clr u.dirbuf / no, clear the location that will
  3521                              <1> 			   ; / get written into the i-number portion
  3522                              <1> 			 ; / of the entry
  3523 0000C740 832D[A4300100]10    <1> 	sub	dword [u.off], 16 ; 04/12/2015 (10 -> 16) 
  3524                              <1> 		; sub $10.,u.off / move u.off back 1 directory entry
  3525 0000C747 E86E000000          <1> 	call	wdir
  3526                              <1> 		; jsr r0,wdir / free the directory entry
  3527 0000C74C 6658                <1> 	pop	ax
  3528                              <1> 		; mov (sp)+,r1 / get i-number back
  3529 0000C74E E883120000          <1> 	call	iget
  3530                              <1> 		; jsr r0,iget / get i-node
  3531 0000C753 E885120000          <1> 	call	setimod
  3532                              <1> 		; jsr r0,setimod / set modified flag
  3533 0000C758 FE0D[4E2D0100]      <1> 	dec	byte [i.nlks]
  3534                              <1> 		; decb i.nlks / decrement the number of links
  3535 0000C75E 0F85BCEEFFFF        <1> 	jnz	sysret
  3536                              <1> 		; bgt sysret9 / if this was not the last link
  3537                              <1> 			    ; / to file return
  3538                              <1> 	; AX = r1 = i-number
  3539 0000C764 E886070000          <1> 	call	anyi
  3540                              <1> 		; jsr r0,anyi / if it was, see if anyone has it open.
  3541                              <1> 			 ; / Then free contents of file and destroy it.
  3542 0000C769 E9B2EEFFFF          <1> 	jmp	sysret
  3543                              <1> 		; br sysret9
  3544                              <1> 
  3545                              <1> mkdir:
  3546                              <1> 	; 04/12/2015 (14 byte directory names)
  3547                              <1> 	; 12/10/2015
  3548                              <1> 	; 17/06/2015 (Retro UNIX 386 v1 - Beginning)
  3549                              <1> 	; 29/04/2013 - 01/08/2013 (Retro UNIX 8086 v1)
  3550                              <1> 	;
  3551                              <1> 	; 'mkdir' makes a directory entry from the name pointed to
  3552                              <1> 	; by u.namep into the current directory.
  3553                              <1> 	;
  3554                              <1> 	; INPUTS ->
  3555                              <1> 	;    u.namep - points to a file name 
  3556                              <1> 	;	           that is about to be a directory entry.
  3557                              <1> 	;    ii - current directory's i-number.	
  3558                              <1> 	; OUTPUTS ->
  3559                              <1> 	;    u.dirbuf+2 - u.dirbuf+10 - contains file name. 
  3560                              <1> 	;    u.off - points to entry to be filled 
  3561                              <1> 	;	     in the current directory		
  3562                              <1> 	;    u.base - points to start of u.dirbuf.
  3563                              <1> 	;    r1 - contains i-number of current directory 
  3564                              <1> 	;	
  3565                              <1> 	; ((AX = R1)) output
  3566                              <1> 	;
  3567                              <1> 	;    (Retro UNIX Prototype : 11/11/2012, UNIXCOPY.ASM)
  3568                              <1>         ;    ((Modified registers: eAX, eDX, eBX, eCX, eSI, eDI, eBP))  
  3569                              <1> 	;
  3570                              <1> 
  3571                              <1> 	; 17/06/2015 - 32 bit modifications (Retro UNIX 386 v1)
  3572 0000C76E 31C0                <1> 	xor 	eax, eax
  3573 0000C770 BF[BC300100]        <1> 	mov     edi, u.dirbuf+2
  3574 0000C775 89FE                <1> 	mov	esi, edi
  3575 0000C777 AB                  <1> 	stosd
  3576 0000C778 AB                  <1> 	stosd
  3577                              <1> 	; 04/12/2015 (14 byte directory names)
  3578 0000C779 AB                  <1> 	stosd
  3579 0000C77A 66AB                <1> 	stosw
  3580                              <1> 		; jsr r0,copyz; u.dirbuf+2; u.dirbuf+10. / clear this
  3581 0000C77C 89F7                <1> 	mov	edi, esi ; offset to u.dirbuf
  3582                              <1> 	; 12/10/2015 ([u.namep] -> ebp)
  3583                              <1> 	;mov 	ebp, [u.namep]
  3584 0000C77E E88C040000          <1> 	call	trans_addr_nmbp ; convert virtual address to physical
  3585                              <1> 		; esi = physical address (page start + offset)
  3586                              <1> 		; ecx = byte count in the page (1 - 4096)
  3587                              <1> 	; edi = offset to u.dirbuf (edi is not modified in trans_addr_nm)
  3588                              <1> 		; mov u.namep,r2 / r2 points to name of directory entry
  3589                              <1> 		; mov $u.dirbuf+2,r3 / r3 points to u.dirbuf+2
  3590                              <1> mkdir_1: ; 1: 
  3591 0000C783 45                  <1> 	inc	ebp ; 12/10/2015
  3592                              <1> 	;
  3593                              <1> 	; / put characters in the directory name in u.dirbuf+2 - u.dirbuf+10
  3594                              <1> 	 ; 01/08/2013
  3595 0000C784 AC                  <1> 	lodsb
  3596                              <1> 		; movb (r2)+,r1 / move character in name to r1
  3597 0000C785 20C0                <1> 	and 	al, al
  3598 0000C787 7427                <1> 	jz 	short mkdir_3 	  
  3599                              <1> 		; beq 1f / if null, done
  3600 0000C789 3C2F                <1> 	cmp	al, '/'
  3601                              <1> 		; cmp r1,$'/ / is it a "/"?
  3602 0000C78B 7414                <1> 	je	short mkdir_err
  3603                              <1> 	;je	error
  3604                              <1> 		; beq error9 / yes, error
  3605                              <1> 	; 12/10/2015
  3606 0000C78D 6649                <1> 	dec	cx
  3607 0000C78F 7505                <1> 	jnz	short mkdir_2
  3608                              <1> 	; 12/10/2015 ([u.namep] -> ebp)
  3609 0000C791 E87F040000          <1> 	call	trans_addr_nm ; convert virtual address to physical
  3610                              <1> 		; esi = physical address (page start + offset)
  3611                              <1> 		; ecx = byte count in the page
  3612                              <1> 	; edi = offset to u.dirbuf (edi is not modified in trans_addr_nm)
  3613                              <1> mkdir_2:
  3614 0000C796 81FF[CA300100]      <1> 	cmp     edi, u.dirbuf+16 ; ; 04/12/2015 (10 -> 16) 
  3615                              <1> 		; cmp r3,$u.dirbuf+10. / have we reached the last slot for
  3616                              <1> 				     ; / a char?
  3617 0000C79C 74E5                <1> 	je	short mkdir_1
  3618                              <1> 		; beq 1b / yes, go back
  3619 0000C79E AA                  <1> 	stosb
  3620                              <1> 		; movb r1,(r3)+ / no, put the char in the u.dirbuf
  3621 0000C79F EBE2                <1> 	jmp 	short mkdir_1
  3622                              <1> 		; br 1b / get next char
  3623                              <1> mkdir_err:
  3624                              <1> 	; 17/06/2015
  3625 0000C7A1 C705[DD300100]1300- <1> 	mov	dword [u.error], ERR_NOT_DIR ; 'not a valid directory !'
  3625 0000C7A9 0000                <1>
  3626 0000C7AB E950EEFFFF          <1> 	jmp	error
  3627                              <1> 
  3628                              <1> mkdir_3: ; 1:
  3629 0000C7B0 A1[9C300100]        <1> 	mov	eax, [u.dirp]
  3630 0000C7B5 A3[A4300100]        <1> 	mov	[u.off], eax
  3631                              <1> 		; mov u.dirp,u.off / pointer to empty current directory
  3632                              <1> 				 ; / slot to u.off
  3633                              <1> wdir: ; 29/04/2013
  3634 0000C7BA C705[A8300100]-     <1>         mov     dword [u.base], u.dirbuf
  3634 0000C7C0 [BA300100]          <1>
  3635                              <1> 		; mov $u.dirbuf,u.base / u.base points to created file name
  3636 0000C7C4 C705[AC300100]1000- <1>         mov     dword [u.count], 16 ; 04/12/2015 (10 -> 16) 
  3636 0000C7CC 0000                <1>
  3637                              <1> 		; mov $10.,u.count / u.count = 10
  3638 0000C7CE 66A1[0D310100]      <1> 	mov	ax, [ii] 
  3639                              <1> 		; mov ii,r1 / r1 has i-number of current directory
  3640 0000C7D4 B201                <1> 	mov	dl, 1 ; owner flag mask ; RETRO UNIX 8086 v1 modification !
  3641 0000C7D6 E806120000          <1> 	call 	access
  3642                              <1> 		; jsr r0,access; 1 / get i-node and set its file up 
  3643                              <1> 				 ; / for writing
  3644                              <1> 	; AX = i-number of current directory
  3645                              <1> 	; 01/08/2013
  3646 0000C7DB FE05[EF300100]      <1> 	inc     byte [u.kcall] ; the caller is 'mkdir' sign	
  3647 0000C7E1 E8F3110000          <1> 	call	writei
  3648                              <1> 		; jsr r0,writei / write into directory
  3649 0000C7E6 C3                  <1> 	retn	
  3650                              <1> 		; rts r0
  3651                              <1> 
  3652                              <1> sysexec:
  3653                              <1> 	; 24/04/2016 - TRDOS 386 (TRDOS v2.0)
  3654                              <1> 	; 23/06/2015 - 23/10/2015 (Retro UNIX 386 v1)
  3655                              <1> 	; 03/06/2013 - 06/12/2013 (Retro UNIX 8086 v1)
  3656                              <1> 	;
  3657                              <1> 	; 'sysexec' initiates execution of a file whose path name if
  3658                              <1> 	; pointed to by 'name' in the sysexec call. 
  3659                              <1> 	; 'sysexec' performs the following operations:
  3660                              <1> 	;    1. obtains i-number of file to be executed via 'namei'.
  3661                              <1> 	;    2. obtains i-node of file to be exceuted via 'iget'.
  3662                              <1> 	;    3. sets trap vectors to system routines.
  3663                              <1> 	;    4. loads arguments to be passed to executing file into
  3664                              <1> 	;	highest locations of user's core
  3665                              <1> 	;    5. puts pointers to arguments in locations immediately
  3666                              <1> 	;	following arguments.
  3667                              <1> 	;    6.	saves number of arguments in next location.
  3668                              <1> 	;    7. intializes user's stack area so that all registers
  3669                              <1> 	;	will be zeroed and the PS is cleared and the PC set
  3670                              <1> 	;	to core when 'sysret' restores registers 
  3671                              <1> 	;	and does an rti.
  3672                              <1> 	;    8. inializes u.r0 and u.sp
  3673                              <1> 	;    9. zeros user's core down to u.r0
  3674                              <1> 	;   10.	reads executable file from storage device into core
  3675                              <1> 	;	starting at location 'core'.
  3676                              <1> 	;   11.	sets u.break to point to end of user's code with
  3677                              <1> 	;	data area appended.
  3678                              <1> 	;   12.	calls 'sysret' which returns control at location
  3679                              <1> 	;	'core' via 'rti' instruction. 		  		
  3680                              <1> 	;
  3681                              <1> 	; Calling sequence:
  3682                              <1> 	;	sysexec; namep; argp
  3683                              <1> 	; Arguments:
  3684                              <1> 	;	namep - points to pathname of file to be executed
  3685                              <1> 	;	argp  - address of table of argument pointers
  3686                              <1> 	;	argp1... argpn - table of argument pointers
  3687                              <1> 	;	argp1:<...0> ... argpn:<...0> - argument strings
  3688                              <1> 	; Inputs: (arguments)
  3689                              <1> 	; Outputs: -	
  3690                              <1> 	; ...............................................................
  3691                              <1> 	;
  3692                              <1> 	; Retro UNIX 386 v1 modification: 
  3693                              <1> 	;	User application runs in it's own virtual space 
  3694                              <1> 	;	which is izolated from kernel memory (and other
  3695                              <1> 	;	memory pages) via 80386	paging in ring 3 
  3696                              <1> 	;	privilige mode. Virtual start address is always 0.
  3697                              <1> 	;	User's core memory starts at linear address 400000h
  3698                              <1> 	;	(the end of the 1st 4MB).
  3699                              <1> 	;
  3700                              <1> 	; Retro UNIX 8086 v1 modification: 
  3701                              <1> 	;	user/application segment and system/kernel segment
  3702                              <1> 	;	are different and sysenter/sysret/sysrele routines
  3703                              <1> 	;	are different (user's registers are saved to 
  3704                              <1> 	;	and then restored from system's stack.)
  3705                              <1> 	;
  3706                              <1> 	;	NOTE: Retro UNIX 8086 v1 'arg2' routine gets these
  3707                              <1> 	;	      arguments which were in these registers;
  3708                              <1> 	;	      but, it returns by putting the 1st argument
  3709                              <1> 	;	      in 'u.namep' and the 2nd argument
  3710                              <1> 	;	      on top of stack. (1st argument is offset of the
  3711                              <1> 	;	      file/path name in the user's program segment.)		 	
  3712                              <1> 	
  3713                              <1> 	;call	arg2
  3714                              <1> 	; * name - 'u.namep' points to address of file/path name
  3715                              <1> 	;          in the user's program segment ('u.segmnt')
  3716                              <1> 	;          with offset in BX register (as sysopen argument 1).
  3717                              <1> 	; * argp - sysexec argument 2 is in CX register 
  3718                              <1> 	;          which is on top of stack.
  3719                              <1> 	;
  3720                              <1> 		; jsr r0,arg2 / arg0 in u.namep,arg1 on top of stack
  3721                              <1> 
  3722                              <1> 	; 23/06/2015 (32 bit modifications)
  3723                              <1> 
  3724 0000C7E7 891D[A0300100]      <1> 	mov	[u.namep], ebx ; argument 1
  3725                              <1>         ; 18/10/2015
  3726 0000C7ED 890D[08310100]      <1> 	mov     [argv], ecx  ; * ; argument 2
  3727 0000C7F3 E8D2020000          <1> 	call	namei
  3728                              <1> 		; jsr r0,namei / namei returns i-number of file 
  3729                              <1> 			     ; / named in sysexec call in r1
  3730                              <1> 	;jc	error
  3731                              <1> 		; br error9
  3732 0000C7F8 731E                <1> 	jnc	short sysexec_0
  3733                              <1> 	;
  3734                              <1> 	; 'file not found !' error
  3735 0000C7FA C705[DD300100]0C00- <1> 	mov	dword [u.error], ERR_FILE_NOT_FOUND
  3735 0000C802 0000                <1>
  3736 0000C804 E9F7EDFFFF          <1> 	jmp	error 
  3737                              <1> sysexec_not_exf:
  3738                              <1> 	; 'not executable file !' error
  3739 0000C809 C705[DD300100]1600- <1> 	mov	dword [u.error], ERR_NOT_EXECUTABLE
  3739 0000C811 0000                <1>
  3740 0000C813 E9E8EDFFFF          <1> 	jmp	error 
  3741                              <1> sysexec_0:
  3742 0000C818 E8B9110000          <1> 	call	iget
  3743                              <1> 		; jsr r0,iget / get i-node for file to be executed
  3744 0000C81D 66F705[4C2D0100]10- <1>         test    word [i.flgs], 10h
  3744 0000C825 00                  <1>
  3745                              <1> 		; bit $20,i.flgs / is file executable
  3746 0000C826 74E1                <1> 	jz	short sysexec_not_exf
  3747                              <1> 	;jz	error
  3748                              <1> 		; beq error9
  3749                              <1> 	;;
  3750 0000C828 E8AD110000          <1> 	call	iopen
  3751                              <1> 		; jsr r0,iopen / gets i-node for file with i-number
  3752                              <1> 			     ; / given in r1 (opens file)
  3753                              <1> 	; AX = i-number of the file
  3754 0000C82D 66F705[4C2D0100]20- <1> 	test	word [i.flgs], 20h
  3754 0000C835 00                  <1>
  3755                              <1> 		; bit $40,i.flgs / test user id on execution bit
  3756 0000C836 7415                <1> 	jz	short sysexec_1
  3757                              <1> 		; beq 1f
  3758 0000C838 803D[D4300100]00    <1> 	cmp 	byte [u.uid], 0 ; 02/08/2013
  3759                              <1> 		; tstb u.uid / test user id
  3760 0000C83F 760C                <1> 	jna	short sysexec_1
  3761                              <1> 		; beq 1f / super user
  3762 0000C841 8A0D[4F2D0100]      <1> 	mov	cl, [i.uid]
  3763 0000C847 880D[D4300100]      <1> 	mov	[u.uid], cl ; 02/08/2013
  3764                              <1> 		; movb i.uid,u.uid / put user id of owner of file
  3765                              <1> 				 ; / as process user id
  3766                              <1> sysexec_1:
  3767                              <1> 	; 18/10/2215
  3768                              <1> 	; 10/10/2015
  3769                              <1> 	; 24/07/2015
  3770                              <1> 	; 21/07/2015
  3771                              <1> 	; 25/06/2015
  3772                              <1> 	; 24/06/2015
  3773                              <1>         ; Moving arguments to the end of [u.upage]
  3774                              <1> 	; (by regarding page borders in user's memory space)
  3775                              <1> 	;
  3776                              <1> 	; 10/10/2015
  3777                              <1> 	; 21/07/2015
  3778 0000C84D 89E5                <1> 	mov	ebp, esp ; (**)
  3779                              <1> 	; 18/10/2015
  3780 0000C84F 89EF                <1> 	mov 	edi, ebp
  3781 0000C851 B900010000          <1> 	mov 	ecx, MAX_ARG_LEN ; 256
  3782                              <1> 	;sub	edi, MAX_ARG_LEN ; 256
  3783 0000C856 29CF                <1> 	sub	edi, ecx
  3784 0000C858 89FC                <1> 	mov	esp, edi
  3785 0000C85A 31C0                <1> 	xor	eax, eax
  3786 0000C85C A3[B0300100]        <1> 	mov 	[u.nread], eax ; 0
  3787 0000C861 49                  <1> 	dec	ecx ; 256 - 1
  3788 0000C862 890D[AC300100]      <1> 	mov 	[u.count], ecx ; MAX_ARG_LEN - 1 ; 255
  3789                              <1> 	;mov 	dword [u.count], MAX_ARG_LEN - 1 ; 255
  3790                              <1> sysexec_2:
  3791 0000C868 8B35[08310100]      <1> 	mov	esi, [argv] ; 18/10/2015 
  3792 0000C86E E866000000          <1> 	call	get_argp
  3793 0000C873 B904000000          <1> 	mov	ecx, 4 ; mov ecx, 4
  3794                              <1> sysexec_3:
  3795 0000C878 21C0                <1> 	and	eax, eax
  3796 0000C87A 0F84C4090000        <1>         jz      sysexec_6
  3797                              <1> 	; 18/10/2015
  3798 0000C880 010D[08310100]      <1> 	add	[argv], ecx ; 4
  3799 0000C886 66FF05[06310100]    <1> 	inc	word [argc]
  3800                              <1> 	;
  3801 0000C88D A3[A8300100]        <1> 	mov	[u.base], eax
  3802                              <1>  	; 23/10/2015
  3803 0000C892 66C705[ED300100]00- <1> 	mov	word [u.pcount], 0
  3803 0000C89A 00                  <1>
  3804                              <1> sysexec_4:
  3805 0000C89B E850100000          <1> 	call	cpass ; get a character from user's core memory
  3806 0000C8A0 750E                <1>         jnz      short sysexec_5
  3807                              <1> 		; (max. 255 chars + null)
  3808                              <1> 	; 18/10/2015
  3809 0000C8A2 28C0                <1> 	sub 	al, al
  3810 0000C8A4 AA                  <1> 	stosb
  3811 0000C8A5 FF05[B0300100]      <1> 	inc	dword [u.nread]
  3812 0000C8AB E994090000          <1> 	jmp	sysexec_6 ; 24/04/2016
  3813                              <1> sysexec_5:
  3814 0000C8B0 AA                  <1> 	stosb
  3815 0000C8B1 20C0                <1> 	and 	al, al
  3816 0000C8B3 75E6                <1> 	jnz	short sysexec_4
  3817 0000C8B5 B904000000          <1> 	mov	ecx, 4
  3818 0000C8BA 390D[04310100]      <1> 	cmp	[ncount], ecx ; 4
  3819 0000C8C0 72A6                <1> 	jb	short sysexec_2
  3820 0000C8C2 8B35[00310100]      <1> 	mov	esi, [nbase]
  3821 0000C8C8 010D[00310100]      <1> 	add	[nbase], ecx ; 4	
  3822 0000C8CE 66290D[04310100]    <1> 	sub	[ncount], cx 
  3823 0000C8D5 8B06                <1> 	mov	eax, [esi]
  3824 0000C8D7 EB9F                <1> 	jmp	short sysexec_3
  3825                              <1> 
  3826                              <1> get_argp:
  3827                              <1> 	; 18/10/2015 (nbase, ncount)
  3828                              <1> 	; 21/07/2015
  3829                              <1> 	; 24/06/2015 (Retro UNIX 386 v1)
  3830                              <1> 	; Get (virtual) address of argument from user's core memory
  3831                              <1> 	;
  3832                              <1> 	; INPUT:
  3833                              <1> 	;	esi = virtual address of argument pointer
  3834                              <1> 	; OUTPUT:
  3835                              <1> 	;	eax = virtual address of argument
  3836                              <1> 	;
  3837                              <1> 	; Modified registers: EAX, EBX, ECX, EDX, ESI 
  3838                              <1> 	;
  3839 0000C8D9 833D[E5300100]00    <1>  	cmp     dword [u.ppgdir], 0 ; /etc/init ?
  3840                              <1> 				    ; (the caller is kernel)
  3841 0000C8E0 7667                <1>         jna     short get_argpk 
  3842                              <1> 	;
  3843 0000C8E2 89F3                <1>      	mov	ebx, esi
  3844 0000C8E4 E8F183FFFF          <1> 	call	get_physical_addr ; get physical address
  3845 0000C8E9 0F8289000000        <1>         jc      get_argp_err
  3846 0000C8EF A3[00310100]        <1> 	mov 	[nbase], eax ; physical address	
  3847 0000C8F4 66890D[04310100]    <1> 	mov	[ncount], cx ; remain byte count in page (1-4096)
  3848 0000C8FB B804000000          <1> 	mov	eax, 4 ; 21/07/2015
  3849 0000C900 6639C1              <1> 	cmp	cx, ax ; 4
  3850 0000C903 735D                <1> 	jnb	short get_argp2
  3851 0000C905 89F3                <1> 	mov	ebx, esi
  3852 0000C907 01CB                <1> 	add	ebx, ecx
  3853 0000C909 E8CC83FFFF          <1> 	call	get_physical_addr ; get physical address
  3854 0000C90E 7268                <1> 	jc	short get_argp_err
  3855                              <1> 	;push	esi
  3856 0000C910 89C6                <1> 	mov	esi, eax
  3857 0000C912 66870D[04310100]    <1> 	xchg	cx, [ncount]
  3858 0000C919 8735[00310100]      <1> 	xchg	esi, [nbase]
  3859 0000C91F B504                <1> 	mov	ch, 4
  3860 0000C921 28CD                <1> 	sub	ch, cl
  3861                              <1> get_argp0:
  3862 0000C923 AC                  <1> 	lodsb
  3863 0000C924 6650                <1> 	push	ax
  3864 0000C926 FEC9                <1> 	dec	cl
  3865 0000C928 75F9                <1>         jnz     short get_argp0
  3866 0000C92A 8B35[00310100]      <1> 	mov	esi, [nbase]
  3867                              <1> 	; 21/07/2015
  3868 0000C930 0FB6C5              <1> 	movzx	eax, ch
  3869 0000C933 0105[00310100]      <1> 	add	[nbase], eax
  3870 0000C939 662905[04310100]    <1> 	sub	[ncount], ax
  3871                              <1> get_argp1:
  3872 0000C940 AC                  <1> 	lodsb
  3873 0000C941 FECD                <1> 	dec	ch
  3874 0000C943 743D                <1>         jz      short get_argp3
  3875 0000C945 6650                <1>         push	ax
  3876 0000C947 EBF7                <1> 	jmp     short get_argp1
  3877                              <1> get_argpk:
  3878                              <1> 	; Argument is in kernel's memory space
  3879 0000C949 66C705[04310100]00- <1> 	mov	word [ncount], PAGE_SIZE ; 4096
  3879 0000C951 10                  <1>
  3880 0000C952 8935[00310100]      <1> 	mov	[nbase], esi
  3881 0000C958 8305[00310100]04    <1> 	add	dword [nbase], 4
  3882 0000C95F 8B06                <1> 	mov	eax, [esi] ; virtual addr. = physcal addr.
  3883 0000C961 C3                  <1> 	retn
  3884                              <1> get_argp2:
  3885                              <1> 	; 21/07/2015
  3886                              <1> 	;mov	eax, 4
  3887 0000C962 8B15[00310100]      <1> 	mov 	edx, [nbase] ; 18/10/2015
  3888 0000C968 0105[00310100]      <1> 	add	[nbase], eax
  3889 0000C96E 662905[04310100]    <1> 	sub	[ncount], ax
  3890                              <1> 	;
  3891 0000C975 8B02                <1> 	mov	eax, [edx]
  3892 0000C977 C3                  <1> 	retn
  3893                              <1> get_argp_err:
  3894 0000C978 A3[DD300100]        <1> 	mov	[u.error], eax
  3895 0000C97D E97EECFFFF          <1> 	jmp	error
  3896                              <1> get_argp3:
  3897 0000C982 B103                <1> 	mov	cl, 3
  3898                              <1> get_argp4:
  3899 0000C984 C1E008              <1> 	shl	eax, 8
  3900 0000C987 665A                <1> 	pop	dx
  3901 0000C989 88D0                <1> 	mov 	al, dl
  3902 0000C98B E2F7                <1>         loop    get_argp4
  3903                              <1> 	;pop	esi
  3904 0000C98D C3                  <1> 	retn	
  3905                              <1> 
  3906                              <1> sysfstat: 
  3907                              <1> 	; 23/06/2015 (Retro UNIX 386 v1 - Beginning)
  3908                              <1> 	; 19/06/2013 (Retro UNIX 8086 v1)
  3909                              <1> 	;
  3910                              <1> 	; 'sysfstat' is identical to 'sysstat' except that it operates
  3911                              <1> 	; on open files instead of files given by name. It puts the
  3912                              <1> 	; buffer address on the stack, gets the i-number and
  3913                              <1> 	; checks to see if the file is open for reading or writing.
  3914                              <1> 	; If the file is open for writing (i-number is negative)
  3915                              <1> 	; the i-number is set positive and a branch into 'sysstat'
  3916                              <1> 	; is made.	
  3917                              <1> 	;
  3918                              <1> 	; Calling sequence:
  3919                              <1> 	;	sysfstat; buf
  3920                              <1> 	; Arguments:
  3921                              <1> 	;	buf - buffer address
  3922                              <1> 	;
  3923                              <1> 	; Inputs: *u.r0 - file descriptor
  3924                              <1> 	; Outputs: buffer is loaded with file information
  3925                              <1> 	; ...............................................................
  3926                              <1> 	;				
  3927                              <1> 	; Retro UNIX 8086 v1 modification:
  3928                              <1> 	;       'sysfstat' system call has two arguments; so,
  3929                              <1> 	;	* 1st argument, file descriptor is in BX register
  3930                              <1> 	;	* 2nd argument, buf is pointed to by CX register
  3931                              <1> 
  3932                              <1> 	; / set status of open file
  3933                              <1> 		; jsr r0,arg; u.off / put buffer address in u.off
  3934 0000C98E 51                  <1> 	push	ecx
  3935                              <1> 		; mov u.off,-(sp) / put buffer address on the stack
  3936                              <1> 		; mov *u.r0,r1 / put file descriptor in r1
  3937                              <1> 		; jsr r0,getf / get the files i-number
  3938                              <1> 	; BX = file descriptor (file number)
  3939 0000C98F E8FF000000          <1> 	call	getf1
  3940 0000C994 6621C0              <1> 	and	ax, ax ; i-number of the file
  3941                              <1> 		; tst	r1 / is it 0?
  3942                              <1> 	;jz	error
  3943                              <1> 		; beq error3 / yes, error
  3944 0000C997 750F                <1> 	jnz	short sysfstat1
  3945 0000C999 C705[DD300100]0A00- <1> 	mov	dword [u.error], ERR_FILE_NOT_OPEN  ; 'file not open !'
  3945 0000C9A1 0000                <1>
  3946 0000C9A3 E958ECFFFF          <1> 	jmp	error
  3947                              <1> sysfstat1:
  3948 0000C9A8 80FC80              <1> 	cmp	ah, 80h
  3949 0000C9AB 7223                <1>         jb      short sysstat1
  3950                              <1> 		; bgt 1f / if i-number is negative (open for writing)
  3951 0000C9AD 66F7D8              <1> 	neg	ax
  3952                              <1> 		; neg r1 / make it positive, then branch
  3953 0000C9B0 EB1E                <1> 	jmp	short sysstat1
  3954                              <1> 		; br 1f / to 1f
  3955                              <1> sysstat:
  3956                              <1> 	; 18/10/2015
  3957                              <1> 	; 07/10/2015
  3958                              <1> 	; 02/09/2015
  3959                              <1> 	; 23/06/2015 (Retro UNIX 386 v1 - Beginning)
  3960                              <1> 	; 19/06/2013 (Retro UNIX 8086 v1)
  3961                              <1> 	;
  3962                              <1> 	; 'sysstat' gets the status of a file. Its arguments are the
  3963                              <1> 	; name of the file and buffer address. The buffer is 34 bytes
  3964                              <1> 	; long and information about the file placed in it.	
  3965                              <1> 	; sysstat calls 'namei' to get the i-number of the file.
  3966                              <1> 	; Then 'iget' is called to get i-node in core. The buffer
  3967                              <1> 	; is then loaded and the results are given in the UNIX
  3968                              <1> 	; Programmers Manual sysstat (II).	
  3969                              <1> 	;
  3970                              <1> 	; Calling sequence:
  3971                              <1> 	;	sysstat; name; buf
  3972                              <1> 	; Arguments:
  3973                              <1> 	;	name - points to the name of the file
  3974                              <1> 	;	buf - address of a 34 bytes buffer
  3975                              <1> 	; Inputs: -
  3976                              <1> 	; Outputs: buffer is loaded with file information
  3977                              <1> 	; ...............................................................
  3978                              <1> 	;				
  3979                              <1> 	; Retro UNIX 8086 v1 modification: 
  3980                              <1> 	;       'sysstat' system call has two arguments; so,
  3981                              <1> 	;	Retro UNIX 8086 v1 argument transfer method 2 is used
  3982                              <1> 	;	to get sysstat system call arguments from the user;
  3983                              <1> 	;	* 1st argument, name is pointed to by BX register
  3984                              <1> 	;	* 2nd argument, buf is pointed to by CX register
  3985                              <1> 	;
  3986                              <1> 	;	NOTE: Retro UNIX 8086 v1 'arg2' routine gets these
  3987                              <1> 	;	      arguments which were in these registers;
  3988                              <1> 	;	      but, it returns by putting the 1st argument
  3989                              <1> 	;	      in 'u.namep' and the 2nd argument
  3990                              <1> 	;	      on top of stack. (1st argument is offset of the
  3991                              <1> 	;	      file/path name in the user's program segment.)		 	
  3992                              <1> 	
  3993                              <1> 	; / ; name of file; buffer - get files status
  3994                              <1> 		; jsr r0,arg2 / get the 2 arguments
  3995 0000C9B2 891D[A0300100]      <1> 	mov	[u.namep], ebx
  3996 0000C9B8 51                  <1> 	push	ecx
  3997 0000C9B9 E80C010000          <1> 	call	namei
  3998                              <1> 		; jsr r0,namei / get the i-number for the file
  3999                              <1> 	;jc	error
  4000                              <1> 		; br error3 / no such file, error
  4001 0000C9BE 7310                <1> 	jnc	short sysstat1
  4002                              <1> 	; pop 	ecx
  4003                              <1> sysstat_err0:
  4004                              <1> 	; 'file not found !' error
  4005 0000C9C0 C705[DD300100]0C00- <1> 	mov	dword [u.error], ERR_FILE_NOT_FOUND ; 12
  4005 0000C9C8 0000                <1>
  4006 0000C9CA E931ECFFFF          <1> 	jmp	error
  4007                              <1> 
  4008 0000C9CF 00                  <1> statx: db 0
  4009                              <1> 
  4010                              <1> sysstat1: ; 1:
  4011 0000C9D0 E801100000          <1> 	call	iget
  4012                              <1> 		; jsr r0,iget / get the i-node into core
  4013                              <1> 	; 07/10/2015 (ax = [ii], inode number)
  4014                              <1> 	; 02/09/2015
  4015 0000C9D5 8F05[A8300100]      <1> 	pop	dword [u.base]
  4016                              <1> 		; mov (sp)+,r3 / move u.off to r3 (points to buffer)
  4017 0000C9DB E858000000          <1> 	call	sysstat_gpa ; get physical address
  4018 0000C9E0 730A                <1> 	jnc 	short sysstat2
  4019                              <1> sysstat_err1:
  4020 0000C9E2 A3[DD300100]        <1> 	mov	dword [u.error], eax ; error code
  4021 0000C9E7 E914ECFFFF          <1> 	jmp	error
  4022                              <1> sysstat2:
  4023 0000C9EC A0[0D310100]        <1> 	mov 	al, [ii] ; 07/10/2015 (result of 'iget' call, above)
  4024 0000C9F1 AA                  <1> 	stosb
  4025 0000C9F2 FF05[A8300100]      <1> 	inc 	dword [u.base]
  4026 0000C9F8 6649                <1> 	dec 	cx
  4027 0000C9FA 7505                <1> 	jnz	short sysstat3
  4028 0000C9FC E837000000          <1> 	call	sysstat_gpa
  4029                              <1> 	;jc	short sysstat_err1
  4030                              <1> sysstat3:
  4031 0000CA01 A0[0E310100]        <1> 	mov 	al, [ii+1] ; 07/10/2015 (result of 'iget' call, above)
  4032 0000CA06 AA                  <1> 	stosb
  4033                              <1> 		; mov r1,(r3)+ / put i-number in 1st word of buffer
  4034 0000CA07 FF05[A8300100]      <1> 	inc 	dword [u.base]
  4035                              <1> 	;dec 	word [u.pcount]
  4036 0000CA0D 6649                <1> 	dec	cx
  4037 0000CA0F 7505                <1> 	jnz	short sysstat4
  4038 0000CA11 E822000000          <1> 	call	sysstat_gpa
  4039                              <1> 	;jc	short sysstat_err1	
  4040                              <1> sysstat4:
  4041 0000CA16 BE[4C2D0100]        <1> 	mov	esi, inode
  4042                              <1> 		; mov $inode,r2 / r2 points to i-node
  4043                              <1> sysstat5: ; 1:
  4044 0000CA1B A4                  <1> 	movsb
  4045                              <1> 		; mov (r2)+,(r3)+ / move rest of i-node to buffer
  4046 0000CA1C FF05[A8300100]      <1> 	inc 	dword [u.base]
  4047                              <1> 	;dec 	word [u.pcount]
  4048 0000CA22 6649                <1> 	dec	cx
  4049 0000CA24 7505                <1> 	jnz	short sysstat6
  4050 0000CA26 E80D000000          <1> 	call	sysstat_gpa
  4051                              <1> 	;jc	short sysstat_err1
  4052                              <1> sysstat6:		
  4053 0000CA2B 81FE[6C2D0100]      <1> 	cmp	esi, inode + 32
  4054                              <1> 		; cmp r2,$inode+32 / done?
  4055 0000CA31 75E8                <1> 	jne	short sysstat5
  4056                              <1> 		; bne 1b / no, go back
  4057 0000CA33 E9E8EBFFFF          <1> 	jmp	sysret
  4058                              <1> 		; br sysret3 / return through sysret
  4059                              <1> 	;
  4060                              <1> sysstat_gpa: ; get physical address of file status buffer
  4061                              <1> 	; 02/09/2015
  4062 0000CA38 8B1D[A8300100]      <1> 	mov 	ebx, [u.base]
  4063                              <1> 	; 07/10/2015
  4064 0000CA3E E89782FFFF          <1> 	call	get_physical_addr ; get physical address
  4065                              <1> 	;jc	short sysstat_gpa1
  4066 0000CA43 729D                <1> 	jc	short sysstat_err1
  4067                              <1> 	; 18/10/2015
  4068 0000CA45 89C7                <1> 	mov	edi, eax ; physical address
  4069                              <1> 	;mov	[u.pcount], cx ; remain bytes in page
  4070                              <1> ;sysstat_gpa1:
  4071 0000CA47 C3                  <1> 	retn
  4072                              <1> 
  4073                              <1> fclose:
  4074                              <1> 	; 18/06/2015 (Retro UNIX 386 v1 - Beginning)
  4075                              <1> 	;            (32 bit offset pointer modification)
  4076                              <1> 	; 19/04/2013 - 12/01/2014 (Retro UNIX 8086 v1)
  4077                              <1> 	;
  4078                              <1> 	; Given the file descriptor (index to the u.fp list)
  4079                              <1> 	; 'fclose' first gets the i-number of the file via 'getf'.
  4080                              <1> 	; If i-node is active (i-number > 0) the entry in 
  4081                              <1> 	; u.fp list is cleared. If all the processes that opened
  4082                              <1> 	; that file close it, then fsp etry is freed and the file
  4083                              <1> 	; is closed. If not a return is taken. 
  4084                              <1> 	; If the file has been deleted while open, 'anyi' is called
  4085                              <1> 	; to see anyone else has it open, i.e., see if it is appears
  4086                              <1> 	; in another entry in the fsp table. Upon return from 'anyi'
  4087                              <1> 	; a check is made to see if the file is special.	
  4088                              <1> 	;
  4089                              <1> 	; INPUTS ->
  4090                              <1> 	;    r1 - contains the file descriptor (value=0,1,2...)
  4091                              <1> 	;    u.fp - list of entries in the fsp table
  4092                              <1> 	;    fsp - table of entries (4 words/entry) of open files.	 
  4093                              <1> 	; OUTPUTS ->
  4094                              <1> 	;    r1 - contains the same file descriptor
  4095                              <1> 	;    r2 - contains i-number
  4096                              <1> 	;
  4097                              <1> 	; ((AX = R1))
  4098                              <1> 	; ((Modified registers: eDX, eBX, eCX, eSI, eDI, eBP))
  4099                              <1> 	;
  4100                              <1> 	; Retro UNIX 8086 v1 modification : CF = 1
  4101                              <1> 	;              if i-number of the file is 0. (error)  	
  4102                              <1> 	;
  4103 0000CA48 0FB7D0              <1> 	movzx	edx, ax ; **
  4104 0000CA4B 6650                <1> 	push	ax ; ***
  4105                              <1> 		; mov r1,-(sp) / put r1 on the stack (it contains 
  4106                              <1> 			     ; / the index to u.fp list)
  4107 0000CA4D E83F000000          <1> 	call	getf
  4108                              <1> 		; jsr r0,getf / r1 contains i-number, 
  4109                              <1> 			    ; / cdev has device =, u.fofp 
  4110                              <1> 			    ; / points to 3rd word of fsp entry
  4111 0000CA52 6683F801            <1> 	cmp	ax, 1 ; r1
  4112                              <1> 		; tst r1 / is i-number 0?
  4113 0000CA56 7236                <1> 	jb	short fclose_2
  4114                              <1> 		; beq 1f / yes, i-node not active so return
  4115                              <1> 		; tst (r0)+ / no, jump over error return
  4116 0000CA58 89D3                <1> 	mov	ebx, edx ; **
  4117 0000CA5A 6689C2              <1> 	mov 	dx, ax ; *
  4118                              <1> 		; mov r1,r2 / move i-number to r2 ;*
  4119                              <1> 		; mov (sp),r1 / restore value of r1 from the stack
  4120                              <1> 			    ; / which is index to u.fp ; **
  4121 0000CA5D C683[8E300100]00    <1> 	mov	byte [ebx+u.fp], 0
  4122                              <1> 		; clrb u.fp(r1) / clear that entry in the u.fp list
  4123 0000CA64 8B1D[98300100]      <1> 	mov	ebx, [u.fofp]
  4124                              <1> 		; mov u.fofp,r1 / r1 points to 3rd word in fsp entry
  4125                              <1> fclose_0:
  4126 0000CA6A FE4B04              <1> 	dec	byte [ebx+4] ; 18/06/2015
  4127                              <1> 		; decb 2(r1) / decrement the number of processes 
  4128                              <1> 			   ; / that have opened the file
  4129 0000CA6D 791F                <1> 	jns	short fclose_2 ; jump if not negative (jump if bit 7 is 0)	 
  4130                              <1> 		; bge 1f / if all processes haven't closed the file, return
  4131                              <1> 	;
  4132 0000CA6F 6652                <1> 	push	dx ;*
  4133                              <1> 		; mov r2,-(sp) / put r2 on the stack (i-number)
  4134 0000CA71 6631C0              <1> 	xor	ax, ax ; 0
  4135 0000CA74 668943FC            <1> 	mov	[ebx-4], ax ; 0
  4136                              <1> 		; clr -4(r1) / clear 1st word of fsp entry
  4137 0000CA78 8A4305              <1> 	mov	al, [ebx+5] ; 18/06/2015
  4138                              <1> 		; tstb	3(r1) / has this file been deleted
  4139 0000CA7B 20C0                <1> 	and	al, al
  4140 0000CA7D 7408                <1> 	jz	short fclose_1
  4141                              <1> 		; beq 2f / no, branch
  4142 0000CA7F 6689D0              <1> 	mov	ax, dx ; *
  4143                              <1> 		; mov r2,r1 / yes, put i-number back into r1
  4144                              <1> 	; AX = inode number
  4145 0000CA82 E868040000          <1> 	call	anyi
  4146                              <1> 		; jsr r0,anyi / free all blocks related to i-number
  4147                              <1> 			    ; / check if file appears in fsp again
  4148                              <1> fclose_1: ; 2:
  4149 0000CA87 6658                <1> 	pop	ax ; *
  4150                              <1> 		; mov (sp)+,r1 / put i-number back into r1
  4151 0000CA89 E84D0F0000          <1> 	call	iclose ; close if it is special file 
  4152                              <1> 		; jsr r0,iclose / check to see if its a special file
  4153                              <1> fclose_2: ; 1:
  4154 0000CA8E 6658                <1> 	pop	ax ; ***
  4155                              <1> 		; mov (sp)+,r1 / put index to u.fp back into r1
  4156 0000CA90 C3                  <1> 	retn
  4157                              <1> 		; rts r0
  4158                              <1> 
  4159                              <1> getf:	; / get the device number and the i-number of an open file
  4160                              <1> 	; 13/05/2015
  4161                              <1> 	; 11/05/2015 (Retro UNIX 386 v1 - Beginning)
  4162                              <1> 	; 19/04/2013 - 18/11/2013 (Retro UNIX 8086 v1)
  4163                              <1> 	;
  4164 0000CA91 89C3                <1> 	mov	ebx, eax
  4165                              <1> getf1: ;; Calling point from 'rw1' (23/05/2013)
  4166 0000CA93 83FB0A              <1> 	cmp	ebx, 10
  4167                              <1> 		; cmp r1,$10. / user limited to 10 open files
  4168 0000CA96 730A                <1>         jnb	short getf2 ; 13/05/2015
  4169                              <1> 	;jnb     error
  4170                              <1> 		; bhis error3 / u.fp is table of users open files, 
  4171                              <1> 			    ; / index in fsp table
  4172 0000CA98 8A9B[8E300100]      <1> 	mov	bl, [ebx+u.fp]
  4173                              <1> 		; movb	u.fp(r1),r1 / r1 contains number of entry 
  4174                              <1> 		                  ; / in fsp table
  4175 0000CA9E 08DB                <1> 	or	bl, bl
  4176 0000CAA0 7503                <1> 	jnz	short getf3
  4177                              <1> 	;jz	short getf4
  4178                              <1> 		; beq 1f / if its zero return
  4179                              <1> getf2:
  4180                              <1> 	; 'File not open !' error (ax=0)
  4181 0000CAA2 29C0                <1> 	sub	eax, eax
  4182 0000CAA4 C3                  <1> 	retn
  4183                              <1> getf3:	
  4184                              <1> 	; Retro UNIX 386 v1 modification ! (11/05/2015)
  4185                              <1> 	;
  4186                              <1> 	; 'fsp' table (10 bytes/entry)
  4187                              <1> 	; bit 15				   bit 0
  4188                              <1> 	; ---|-------------------------------------------
  4189                              <1> 	; r/w|		i-number of open file
  4190                              <1> 	; ---|-------------------------------------------
  4191                              <1> 	;		   device number
  4192                              <1> 	; -----------------------------------------------
  4193                              <1> 	; offset pointer, r/w pointer to file (bit 0-15)
  4194                              <1> 	; -----------------------------------------------
  4195                              <1> 	; offset pointer, r/w pointer to file (bit 16-31)
  4196                              <1> 	; ----------------------|------------------------
  4197                              <1> 	;  flag that says file 	| number of processes
  4198                              <1> 	;   has been deleted	| that have file open 
  4199                              <1> 	; ----------------------|------------------------
  4200                              <1> 	;
  4201 0000CAA5 B80A000000          <1> 	mov	eax, 10
  4202 0000CAAA F6E3                <1> 	mul	bl
  4203 0000CAAC BB[562E0100]        <1> 	mov	ebx, fsp - 6 ; the 3rd word in the fsp entry
  4204 0000CAB1 01C3                <1> 	add	ebx, eax
  4205                              <1> 		; asl r1
  4206                              <1> 		; asl r1 / multiply by 8 to get index into 
  4207                              <1> 		       ; / fsp table entry
  4208                              <1> 		; asl r1
  4209                              <1> 		; add $fsp-4,r1 / r1 is pointing at the 3rd word 
  4210                              <1> 			      ; / in the fsp entry
  4211 0000CAB3 891D[98300100]      <1> 	mov	[u.fofp], ebx
  4212                              <1> 		; mov r1,u.fofp / save address of 3rd word 
  4213                              <1> 			      ; / in fsp entry in u.fofp
  4214 0000CAB9 4B                  <1> 	dec	ebx
  4215 0000CABA 4B                  <1> 	dec	ebx
  4216 0000CABB 668B03              <1> 	mov	ax, [ebx]
  4217                              <1> 	;mov	[cdev], al ; ;;Retro UNIX 8086 v1 ! 
  4218 0000CABE 66A3[6A300100]      <1> 	mov	[cdev], ax ; ;;in fact (!) 
  4219                              <1> 			     ;;dev number is in 1 byte
  4220                              <1> 		; mov -(r1),cdev / remove the device number  cdev
  4221 0000CAC4 4B                  <1> 	dec	ebx
  4222 0000CAC5 4B                  <1> 	dec	ebx
  4223 0000CAC6 668B03              <1> 	mov	ax, [ebx]
  4224                              <1> 		; mov -(r1),r1 / and the i-number  r1
  4225                              <1> getf4:	; 1:
  4226 0000CAC9 C3                  <1> 	retn
  4227                              <1> 		; rts r0
  4228                              <1> 
  4229                              <1> namei:
  4230                              <1> 	; 04/12/2015 (14 byte file names)
  4231                              <1> 	; 18/10/2015 (nbase, ncount)
  4232                              <1> 	; 12/10/2015
  4233                              <1> 	; 21/08/2015
  4234                              <1> 	; 18/07/2015
  4235                              <1> 	; 02/07/2015
  4236                              <1> 	; 17/06/2015
  4237                              <1> 	; 16/06/2015 (Retro UNIX 386 v1 - Beginning)
  4238                              <1> 	; 24/04/2013 - 31/07/2013 (Retro UNIX 8086 v1)
  4239                              <1> 	;
  4240                              <1> 	; 'namei' takes a file path name and returns i-number of
  4241                              <1> 	; the file in the current directory or the root directory
  4242                              <1> 	; (if the first character of the pathname is '/').	
  4243                              <1> 	;
  4244                              <1> 	; INPUTS ->
  4245                              <1> 	;    u.namep - points to a file path name
  4246                              <1> 	;    u.cdir - i-number of users directory
  4247                              <1> 	;    u.cdev - device number on which user directory resides	
  4248                              <1> 	; OUTPUTS ->
  4249                              <1> 	;    r1 - i-number of file
  4250                              <1> 	;    cdev
  4251                              <1> 	;    u.dirbuf - points to directory entry where a match 
  4252                              <1> 	;               occurs in the search for file path name.
  4253                              <1> 	;	        If no match u.dirb points to the end of 
  4254                              <1> 	;               the directory and r1 = i-number of the current
  4255                              <1> 	;	        directory.	
  4256                              <1> 	; ((AX = R1))
  4257                              <1> 	;
  4258                              <1> 	; (Retro UNIX Prototype : 07/10/2012 - 05/01/2013, UNIXCOPY.ASM)
  4259                              <1>         ; ((Modified registers: eDX, eBX, eCX, eSI, eDI, eBP))  
  4260                              <1> 	;
  4261                              <1> 
  4262 0000CACA 66A1[8C300100]      <1> 	mov	ax, [u.cdir]
  4263                              <1> 		; mov u.cdir,r1 / put the i-number of current directory
  4264                              <1> 			      ; / in r1
  4265 0000CAD0 668B15[D2300100]    <1> 	mov	dx, [u.cdrv]
  4266 0000CAD7 668915[6A300100]    <1> 	mov	[cdev], dx 	    ; NOTE: Retro UNIX 8086 v1 
  4267                              <1> 				    ; device/drive number is in 1 byte, 
  4268                              <1> 				    ; not in 1 word!
  4269                              <1> 		; mov u.cdev,cdev / device number for users directory 
  4270                              <1> 				; / into cdev
  4271                              <1> 	; 12/10/2015
  4272                              <1> 	; 16/06/2015 - 32 bit modifications (Retro UNIX 386 v1)
  4273                              <1>       	 ; convert virtual (pathname) addr to physical address
  4274 0000CADE E82C010000          <1> 	call    trans_addr_nmbp ; 12/10/2015
  4275                              <1> 		; esi = physical address of [u.namep]
  4276                              <1> 		; ecx = byte count in the page
  4277 0000CAE3 803E2F              <1> 	cmp	byte [esi], '/'
  4278                              <1> 		; cmpb *u.namep,$'/ / is first char in file name a /
  4279 0000CAE6 751E                <1> 	jne	short namei_1
  4280                              <1> 		; bne 1f
  4281 0000CAE8 FF05[A0300100]      <1> 	inc	dword [u.namep]
  4282                              <1> 		; inc u.namep / go to next char
  4283 0000CAEE 6649                <1> 	dec	cx ; remain byte count in the page
  4284 0000CAF0 7506                <1> 	jnz	short namei_0
  4285                              <1> 	; 12/10/2015
  4286 0000CAF2 E818010000          <1> 	call	trans_addr_nmbp ; convert virtual address to physical
  4287                              <1> 		; esi = physical address (page start + offset)
  4288                              <1> 		; ecx = byte count in the page
  4289 0000CAF7 4E                  <1> 	dec	esi
  4290                              <1> namei_0:
  4291 0000CAF8 46                  <1> 	inc 	esi  ; go to next char
  4292 0000CAF9 66A1[74300100]      <1> 	mov	ax, [rootdir] ; 09/07/2013
  4293                              <1> 		; mov rootdir,r1 / put i-number of rootdirectory in r1
  4294 0000CAFF C605[6A300100]00    <1> 	mov	byte [cdev], 0
  4295                              <1> 		; clr cdev / clear device number
  4296                              <1> namei_1: ; 1:
  4297 0000CB06 F606FF              <1> 	test	byte [esi], 0FFh
  4298 0000CB09 74BE                <1> 	jz	short getf4
  4299                              <1> 	;jz      nig
  4300                              <1> 		; tstb *u.namep / is the character in file name a nul
  4301                              <1> 		; beq nig / yes, end of file name reached; 
  4302                              <1> 			; / branch to "nig"
  4303                              <1> namei_2: ; 1:
  4304                              <1> 	; 18/10/2015
  4305 0000CB0B 8935[00310100]      <1> 	mov 	[nbase], esi
  4306 0000CB11 66890D[04310100]    <1> 	mov 	[ncount], cx
  4307                              <1> 	;
  4308                              <1> 	;mov	dx, 2
  4309 0000CB18 B202                <1> 	mov	dl, 2 ; user flag (read, non-owner)
  4310 0000CB1A E8C20E0000          <1> 	call	access
  4311                              <1> 		; jsr r0,access; 2 / get i-node with i-number r1
  4312                              <1> 	; 'access' will not return here if user has not "r" permission !
  4313 0000CB1F 66F705[4C2D0100]00- <1> 	test 	word [i.flgs], 4000h
  4313 0000CB27 40                  <1>
  4314                              <1> 		; bit $40000,i.flgs / directory i-node?
  4315 0000CB28 746A                <1>         jz      short namei_err
  4316                              <1> 		; beq error3 / no, got an error
  4317                              <1> 	; 16/06/2015 - 32 bit modifications (Retro UNIX 386 v1)
  4318 0000CB2A 31C0                <1> 	xor	eax, eax
  4319 0000CB2C A3[A4300100]        <1> 	mov	[u.off], eax ; 0
  4320 0000CB31 66A1[11310100]      <1> 	mov	ax, [i.size]
  4321 0000CB37 A3[9C300100]        <1> 	mov	[u.dirp], eax
  4322                              <1> 		; mov i.size,u.dirp / put size of directory in u.dirp
  4323                              <1> 		; clr u.off / u.off is file offset used by user
  4324 0000CB3C C705[98300100]-     <1> 	mov	dword [u.fofp], u.off
  4324 0000CB42 [A4300100]          <1>
  4325                              <1> 		; mov $u.off,u.fofp / u.fofp is a pointer to 
  4326                              <1> 				  ; / the offset portion of fsp entry
  4327                              <1> namei_3: ; 2:
  4328 0000CB46 C705[A8300100]-     <1> 	mov	dword [u.base], u.dirbuf
  4328 0000CB4C [BA300100]          <1>
  4329                              <1> 		; mov $u.dirbuf,u.base / u.dirbuf holds a file name 
  4330                              <1> 				    ; / copied from a directory
  4331 0000CB50 C705[AC300100]1000- <1> 	mov 	dword [u.count], 16 ; 04/12/2015 (10 -> 16) 	
  4331 0000CB58 0000                <1>
  4332                              <1>  		; mov $10.,u.count / u.count is byte count 
  4333                              <1> 				 ; / for reads and writes
  4334 0000CB5A 66A1[0D310100]      <1> 	mov 	ax, [ii]
  4335                              <1> 	; 31/07/2013 ('namei_r') - 16/06/2015 ('u.kcall')
  4336 0000CB60 FE05[EF300100]      <1>  	inc     byte [u.kcall] ; the caller is 'namei' sign	
  4337 0000CB66 E815090000          <1>     	call	readi
  4338                              <1> 		; jsr r0,readi / read 10. bytes of file 
  4339                              <1> 		      ; with i-number (r1); i.e. read a directory entry
  4340 0000CB6B 8B0D[B0300100]      <1> 	mov 	ecx, [u.nread]
  4341 0000CB71 09C9                <1> 	or 	ecx, ecx
  4342                              <1> 		; tst u.nread
  4343 0000CB73 741B                <1> 	jz	short nib
  4344                              <1> 		; ble nib / gives error return
  4345                              <1> 	;
  4346 0000CB75 668B1D[BA300100]    <1> 	mov 	bx, [u.dirbuf]
  4347 0000CB7C 6621DB              <1> 	and 	bx, bx       
  4348                              <1> 		; tst u.dirbuf /
  4349 0000CB7F 7522                <1> 	jnz	short namei_4
  4350                              <1> 		; bne 3f / branch when active directory entry 
  4351                              <1> 		       ; / (i-node word in entry non zero)
  4352 0000CB81 A1[A4300100]        <1> 	mov	eax, [u.off]
  4353 0000CB86 83E810              <1> 	sub	eax, 16 ; 04/12/2015 (10 -> 16) 
  4354 0000CB89 A3[9C300100]        <1> 	mov	[u.dirp], eax
  4355                              <1> 		; mov u.off,u.dirp
  4356                              <1> 		; sub $10.,u.dirp
  4357 0000CB8E EBB6                <1> 	jmp	short namei_3
  4358                              <1> 		; br 2b
  4359                              <1> 
  4360                              <1> 	; 18/07/2013
  4361                              <1> nib: 
  4362 0000CB90 31C0                <1> 	xor	eax, eax  ; xor ax, ax ; ax = 0 -> file not found 
  4363 0000CB92 F9                  <1> 	stc
  4364                              <1> nig:
  4365 0000CB93 C3                  <1> 	retn
  4366                              <1> 
  4367                              <1> namei_err:
  4368                              <1> 	; 16/06/2015
  4369 0000CB94 C705[DD300100]1300- <1> 	mov	dword [u.error], ERR_NOT_DIR ; 'not a directory !' error
  4369 0000CB9C 0000                <1>
  4370 0000CB9E E95DEAFFFF          <1> 	jmp	error
  4371                              <1> 
  4372                              <1> namei_4: ; 3:
  4373                              <1> 	; 18/10/2015
  4374                              <1> 	; 12/10/2015
  4375                              <1> 	; 21/08/2015
  4376                              <1> 	; 18/07/2015
  4377 0000CBA3 8B2D[A0300100]      <1> 	mov	ebp, [u.namep]
  4378                              <1> 		; mov u.namep,r2 / u.namep points into a file name string
  4379 0000CBA9 BF[BC300100]        <1> 	mov 	edi, u.dirbuf + 2
  4380                              <1> 		; mov $u.dirbuf+2,r3 / points to file name of directory entry
  4381                              <1> 	; 18/10/2015
  4382 0000CBAE 8B35[00310100]      <1> 	mov	esi, [nbase]	
  4383 0000CBB4 668B0D[04310100]    <1> 	mov	cx, [ncount]
  4384                              <1> 	;
  4385 0000CBBB 6621C9              <1> 	and	cx, cx
  4386 0000CBBE 7505                <1> 	jnz	short namei_5	
  4387                              <1> 	;
  4388 0000CBC0 E850000000          <1> 	call	trans_addr_nm ; convert virtual address to physical
  4389                              <1> 		; esi = physical address (page start + offset)
  4390                              <1> 		; ecx = byte count in the page
  4391                              <1> namei_5: ; 3:
  4392 0000CBC5 45                  <1> 	inc	ebp ; 18/07/2015
  4393 0000CBC6 AC                  <1> 	lodsb   ; mov al, [esi] ; inc esi (al = r4)
  4394                              <1> 		; movb (r2)+,r4 / move a character from u.namep string into r4
  4395 0000CBC7 08C0                <1> 	or 	al, al
  4396 0000CBC9 741D                <1> 	jz 	short namei_7
  4397                              <1> 		; beq 3f / if char is nul, then the last char in string
  4398                              <1> 			; / has been moved
  4399 0000CBCB 3C2F                <1> 	cmp	al, '/'
  4400                              <1> 		; cmp r4,$'/ / is char a </>
  4401 0000CBCD 7419                <1> 	je 	short namei_7
  4402                              <1> 		; beq 3f	
  4403                              <1> 	; 12/10/2015
  4404 0000CBCF 6649                <1> 	dec	cx ; remain byte count in the page
  4405 0000CBD1 7505                <1> 	jnz	short namei_6
  4406 0000CBD3 E83D000000          <1> 	call	trans_addr_nm ; convert virtual address to physical
  4407                              <1> 		; esi = physical address (page start + offset)
  4408                              <1> 		; ecx = byte count in the page
  4409                              <1> namei_6:
  4410 0000CBD8 81FF[CA300100]      <1>         cmp     edi, u.dirbuf + 16 ; 04/12/2015 (10 -> 16) 
  4411                              <1> 		; cmp r3,$u.dirbuf+10. / have I checked
  4412                              <1> 				     ; / all 8 bytes of file name
  4413 0000CBDE 74E5                <1> 	je	short namei_5
  4414                              <1> 		; beq 3b
  4415 0000CBE0 AE                  <1> 	scasb	
  4416                              <1> 		; cmpb (r3)+,r4 / compare char in u.namep string to file name 
  4417                              <1> 			      ; / char read from directory
  4418 0000CBE1 74E2                <1> 	je 	short namei_5
  4419                              <1> 		; beq 3b / branch if chars match
  4420                              <1> 
  4421 0000CBE3 E95EFFFFFF          <1>         jmp    namei_3 ; 2b
  4422                              <1> 		; br 2b / file names do not match go to next directory entry
  4423                              <1> namei_7: ; 3:
  4424 0000CBE8 81FF[CA300100]      <1> 	cmp	edi, u.dirbuf + 16 ; 04/12/2015 (10 -> 16) 
  4425                              <1> 		; cmp r3,$u.dirbuf+10. / if equal all 8 bytes were matched
  4426 0000CBEE 740A                <1> 	je	short namei_8
  4427                              <1> 		; beq 3f
  4428 0000CBF0 8A27                <1> 	mov 	ah, [edi]
  4429                              <1> 	;inc 	edi 
  4430 0000CBF2 20E4                <1> 	and 	ah, ah
  4431                              <1> 		; tstb (r3)+ /
  4432 0000CBF4 0F854CFFFFFF        <1>         jnz     namei_3
  4433                              <1> 		; bne 2b
  4434                              <1> namei_8: ; 3
  4435 0000CBFA 892D[A0300100]      <1> 	mov	[u.namep], ebp ; 18/07/2015
  4436                              <1> 		; mov r2,u.namep / u.namep points to char 
  4437                              <1> 			       ; / following a / or nul
  4438                              <1> 	;mov	bx, [u.dirbuf]
  4439                              <1> 		; mov u.dirbuf,r1 / move i-node number in directory 
  4440                              <1> 				; / entry to r1
  4441 0000CC00 20C0                <1> 	and 	al, al
  4442                              <1> 		; tst r4 / if r4 = 0 the end of file name reached,
  4443                              <1> 		      ;  / if r4 = </> then go to next directory
  4444                              <1> 	; mov	ax, bx
  4445 0000CC02 66A1[BA300100]      <1> 	mov 	ax, [u.dirbuf] ; 17/06/2015
  4446 0000CC08 0F85FDFEFFFF        <1>         jnz     namei_2 
  4447                              <1> 		; bne 1b
  4448                              <1> 	; AX = i-number of the file
  4449                              <1> ;;nig:
  4450 0000CC0E C3                  <1> 	retn
  4451                              <1> 		; tst (r0)+ / gives non-error return
  4452                              <1> ;;nib:
  4453                              <1> ;;	xor	ax, ax ; Retro UNIX 8086 v1 modification !
  4454                              <1> 		       ; ax = 0 -> file not found 
  4455                              <1> ;;	stc	; 27/05/2013
  4456                              <1> ;;	retn
  4457                              <1> 		; rts r0
  4458                              <1> 
  4459                              <1> trans_addr_nmbp:
  4460                              <1> 	; 18/10/2015
  4461                              <1> 	; 12/10/2015
  4462 0000CC0F 8B2D[A0300100]      <1> 	mov 	ebp, [u.namep]
  4463                              <1> trans_addr_nm: 
  4464                              <1> 	; Convert virtual (pathname) address to physical address
  4465                              <1> 	; (Retro UNIX 386 v1 feature only !)
  4466                              <1> 	; 18/10/2015
  4467                              <1> 	; 12/10/2015 (u.pnbase & u.pncount has been removed from code)
  4468                              <1> 	; 02/07/2015
  4469                              <1> 	; 17/06/2015
  4470                              <1> 	; 16/06/2015
  4471                              <1> 	;
  4472                              <1> 	; INPUTS: 
  4473                              <1> 	;	ebp = pathname address (virtual) ; [u.namep]
  4474                              <1> 	;	[u.pgdir] = user's page directory
  4475                              <1> 	; OUTPUT:
  4476                              <1> 	;       esi = physical address of the pathname
  4477                              <1> 	;	ecx = remain byte count in the page
  4478                              <1> 	;
  4479                              <1> 	; (Modified registers: EAX, EBX, ECX, EDX, ESI)
  4480                              <1> 	;
  4481 0000CC15 833D[E5300100]00    <1>         cmp     dword [u.ppgdir], 0  ; /etc/init ? (sysexec)
  4482 0000CC1C 7618                <1> 	jna	short trans_addr_nmk ; the caller is os kernel;
  4483                              <1> 				     ; it is already physical address
  4484 0000CC1E 50                  <1>    	push	eax	
  4485 0000CC1F 89EB                <1> 	mov	ebx, ebp ; [u.namep] ; pathname address (virtual)
  4486 0000CC21 E8B480FFFF          <1>        	call	get_physical_addr ; get physical address
  4487 0000CC26 7204                <1> 	jc	short tr_addr_nm_err
  4488                              <1> 	; 18/10/2015
  4489                              <1> 	; eax = physical address 
  4490                              <1> 	; cx = remain byte count in page (1-4096) 
  4491                              <1> 		; 12/10/2015 (cx = [u.pncount])
  4492 0000CC28 89C6                <1> 	mov	esi, eax ; 12/10/2015 (esi=[u.pnbase])
  4493 0000CC2A 58                  <1> 	pop	eax 
  4494 0000CC2B C3                  <1> 	retn
  4495                              <1> 
  4496                              <1> tr_addr_nm_err:
  4497 0000CC2C A3[DD300100]        <1> 	mov	[u.error], eax
  4498                              <1> 	;pop 	eax
  4499 0000CC31 E9CAE9FFFF          <1> 	jmp	error
  4500                              <1> 
  4501                              <1> trans_addr_nmk:
  4502                              <1> 	; 12/10/2015
  4503                              <1> 	; 02/07/2015
  4504 0000CC36 8B35[A0300100]      <1> 	mov	esi, [u.namep]  ; [u.pnbase]
  4505 0000CC3C 66B90010            <1> 	mov	cx, PAGE_SIZE ; 4096 ; [u.pncount]
  4506 0000CC40 C3                  <1> 	retn
  4507                              <1> 
  4508                              <1> syschdir:
  4509                              <1> 	; / makes the directory specified in the argument
  4510                              <1> 	; / the current directory
  4511                              <1> 	;
  4512                              <1> 	; 23/06/2015 (Retro UNIX 386 v1 - Beginning)
  4513                              <1> 	; 19/06/2013 (Retro UNIX 8086 v1)
  4514                              <1> 	;
  4515                              <1> 	; 'syschdir' makes the directory specified in its argument
  4516                              <1> 	; the current working directory.
  4517                              <1> 	;
  4518                              <1> 	; Calling sequence:
  4519                              <1> 	;	syschdir; name
  4520                              <1> 	; Arguments:
  4521                              <1> 	;	name - address of the path name of a directory
  4522                              <1> 	;	       terminated by nul byte.	
  4523                              <1> 	; Inputs: -
  4524                              <1> 	; Outputs: -
  4525                              <1> 	; ...............................................................
  4526                              <1> 	;				
  4527                              <1> 	; Retro UNIX 8086 v1 modification:
  4528                              <1> 	;	 The user/application program puts address of 
  4529                              <1> 	;	 the path name in BX register as 'syschdir' 
  4530                              <1> 	; 	 system call argument.
  4531                              <1> 
  4532 0000CC41 891D[A0300100]      <1> 	mov	[u.namep], ebx
  4533                              <1> 		;jsr r0,arg; u.namep / u.namep points to path name
  4534 0000CC47 E87EFEFFFF          <1> 	call	namei
  4535                              <1> 		; jsr r0,namei / find its i-number
  4536                              <1> 	;jc	error
  4537                              <1> 		; br error3
  4538 0000CC4C 730F                <1> 	jnc	short syschdir0
  4539                              <1> 	; 'directory not found !' error
  4540 0000CC4E C705[DD300100]0C00- <1> 	mov	dword [u.error], ERR_DIR_NOT_FOUND ; 12
  4540 0000CC56 0000                <1>
  4541 0000CC58 E9A3E9FFFF          <1> 	jmp	error
  4542                              <1> syschdir0:
  4543 0000CC5D E87F0D0000          <1> 	call	access
  4544                              <1> 		; jsr r0,access; 2 / get i-node into core
  4545 0000CC62 66F705[4C2D0100]00- <1> 	test	word [i.flgs], 4000h
  4545 0000CC6A 40                  <1>
  4546                              <1> 		; bit $40000,i.flgs / is it a directory?
  4547                              <1> 	;jz	error 
  4548                              <1> 		; beq error3 / no error
  4549 0000CC6B 750F                <1> 	jnz	short syschdir1
  4550 0000CC6D C705[DD300100]1300- <1> 	mov	dword [u.error], ERR_NOT_DIR ; 'not a valid directory !'
  4550 0000CC75 0000                <1>
  4551 0000CC77 E984E9FFFF          <1> 	jmp	error
  4552                              <1> syschdir1:
  4553 0000CC7C 66A3[8C300100]      <1> 	mov	[u.cdir], ax
  4554                              <1> 		; mov r1,u.cdir / move i-number to users 
  4555                              <1> 			      ; / current directory
  4556 0000CC82 66A1[6A300100]      <1> 	mov	ax, [cdev]
  4557 0000CC88 66A3[D2300100]      <1> 	mov	[u.cdrv], ax
  4558                              <1> 		; mov cdev,u.cdev / move its device to users 
  4559                              <1> 			        ; / current device
  4560 0000CC8E E98DE9FFFF          <1> 	jmp	sysret
  4561                              <1> 		; br sysret3
  4562                              <1> 	
  4563                              <1> syschmod: ; < change mode of file >
  4564                              <1> 	; 23/06/2015 (Retro UNIX 386 v1 - Beginning)
  4565                              <1> 	; 20/06/2013 - 07/07/2013 (Retro UNIX 8086 v1)
  4566                              <1> 	;
  4567                              <1> 	; 'syschmod' changes mode of the file whose name is given as
  4568                              <1> 	; null terminated string pointed to by 'name' has it's mode 
  4569                              <1> 	; changed to 'mode'.
  4570                              <1> 	;
  4571                              <1> 	; Calling sequence:
  4572                              <1> 	;	syschmod; name; mode
  4573                              <1> 	; Arguments:
  4574                              <1> 	;	name - address of the file name
  4575                              <1> 	;	       terminated by null byte.
  4576                              <1> 	;	mode - (new) mode/flags < attributes >
  4577                              <1> 	;	
  4578                              <1> 	; Inputs: -
  4579                              <1> 	; Outputs: -
  4580                              <1> 	; ...............................................................
  4581                              <1> 	;				
  4582                              <1> 	; Retro UNIX 8086 v1 modification: 
  4583                              <1> 	;       'syschmod' system call has two arguments; so,
  4584                              <1> 	;	* 1st argument, name is pointed to by BX register
  4585                              <1> 	;	* 2nd argument, mode is in CX register
  4586                              <1> 	;
  4587                              <1> 	; Mode bits (Flags):
  4588                              <1> 	;	bit 0 - write permission for non-owner (1)
  4589                              <1> 	;	bit 1 - read permission for non-owner (2)
  4590                              <1> 	;	bit 2 - write permission for owner (4)
  4591                              <1> 	;	bit 3 - read permission for owner (8)
  4592                              <1> 	;	bit 4 - executable flag (16) 	
  4593                              <1> 	;	bit 5 - set user ID on execution flag (32) 
  4594                              <1> 	;	bit 6,7,8,9,10,11 are not used (undefined)
  4595                              <1> 	;	bit 12 - large file flag (4096)
  4596                              <1> 	;	bit 13 - file has modified flag (always on) (8192)
  4597                              <1> 	;	bit 14 - directory flag (16384)
  4598                              <1> 	;	bit 15 - 'i-node is allocated' flag (32768)
  4599                              <1> 
  4600                              <1> 	; / name; mode
  4601 0000CC93 E814000000          <1> 	call	isown
  4602                              <1> 		;jsr r0,isown / get the i-node and check user status
  4603 0000CC98 66F705[4C2D0100]00- <1> 	test	word [i.flgs], 4000h
  4603 0000CCA0 40                  <1>
  4604                              <1> 		; bit	$40000,i.flgs / directory?
  4605 0000CCA1 7402                <1> 	jz	short syschmod1
  4606                              <1> 		; beq 2f / no
  4607                              <1> 	; AL = (new) mode
  4608 0000CCA3 24CF                <1> 	and	al, 0CFh ; 11001111b (clears bit 4 & 5)
  4609                              <1> 		; bic $60,r2 / su & ex / yes, clear set user id and 
  4610                              <1> 			   ; / executable modes
  4611                              <1> syschmod1: ; 2:
  4612 0000CCA5 A2[4C2D0100]        <1> 	mov	[i.flgs], al	
  4613                              <1> 		; movb r2,i.flgs / move remaining mode to i.flgs
  4614 0000CCAA EB42                <1> 	jmp	short isown1
  4615                              <1> 		; br 1f
  4616                              <1> 
  4617                              <1> isown:
  4618                              <1> 	; 22/06/2015 (Retro UNIX 386 v1 - Beginning)
  4619                              <1> 	; 04/05/2013 - 07/07/2013 (Retro UNIX 8086 v1)
  4620                              <1> 	;
  4621                              <1> 	; 'isown' is given a file name (the 1st argument).
  4622                              <1> 	;  It find the i-number of that file via 'namei' 
  4623                              <1> 	;  then gets the i-node into core via 'iget'.
  4624                              <1> 	;  It then tests to see if the user is super user. 
  4625                              <1> 	;  If not, it cheks to see if the user is owner of 
  4626                              <1> 	;  the file. If he is not an error occurs.
  4627                              <1> 	;  If user is the owner 'setimod' is called to indicate
  4628                              <1> 	;  the inode has been modificed and the 2nd argument of
  4629                              <1> 	;  the call is put in r2.
  4630                              <1> 	;
  4631                              <1> 	; INPUTS ->
  4632                              <1> 	;    arguments of syschmod and syschown calls
  4633                              <1> 	; OUTPUTS ->
  4634                              <1> 	;    u.uid - id of user
  4635                              <1> 	;    imod - set to a 1
  4636                              <1> 	;    r2 - contains second argument of the system call				 	
  4637                              <1> 	;
  4638                              <1> 	;   ((AX=R2) output as 2nd argument)
  4639                              <1> 	;
  4640                              <1>         ; ((Modified registers: eAX, eDX, eBX, eCX, eSI, eDI, eBP))  
  4641                              <1> 	;
  4642                              <1> 		; jsr r0,arg2 / u.namep points to file name
  4643                              <1> 	;; ! 2nd argument on top of stack !
  4644                              <1> 	;; 22/06/2015 - 32 bit modifications
  4645                              <1> 	;; 07/07/2013
  4646 0000CCAC 891D[A0300100]      <1> 	mov	[u.namep], ebx ;; 1st argument
  4647 0000CCB2 51                  <1> 	push 	ecx ;; 2nd argument
  4648                              <1> 	;;
  4649 0000CCB3 E812FEFFFF          <1> 	call	namei
  4650                              <1> 		; jsr r0,namei / get its i-number
  4651                              <1>        ; Retro UNIX 8086 v1 modification !
  4652                              <1>        ; ax = 0 -> file not found 
  4653                              <1> 	;and	ax, ax
  4654                              <1> 	;jz	error
  4655                              <1> 	;jc	error ; 27/05/2013
  4656                              <1> 		; br error3
  4657 0000CCB8 730F                <1> 	jnc	short isown0
  4658                              <1> 	; 'file not found !' error
  4659 0000CCBA C705[DD300100]0C00- <1> 	mov	dword [u.error], ERR_FILE_NOT_FOUND ; 12
  4659 0000CCC2 0000                <1>
  4660 0000CCC4 E937E9FFFF          <1> 	jmp	error
  4661                              <1> isown0:
  4662 0000CCC9 E8080D0000          <1> 	call	iget
  4663                              <1> 		; jsr r0,iget / get i-node into core
  4664 0000CCCE A0[D4300100]        <1> 	mov	al, [u.uid] ; 02/08/2013
  4665 0000CCD3 08C0                <1> 	or	al, al
  4666                              <1> 		; tstb u.uid / super user?
  4667 0000CCD5 7417                <1> 	jz	short isown1
  4668                              <1> 		; beq 1f / yes, branch
  4669 0000CCD7 3A05[4F2D0100]      <1> 	cmp	al, [i.uid]
  4670                              <1> 		; cmpb i.uid,u.uid / no, is this the owner of
  4671                              <1> 				 ; / the file
  4672                              <1> 	;jne	error
  4673                              <1> 		; beq 1f / yes
  4674                              <1> 		; jmp error3 / no, error
  4675 0000CCDD 740F                <1> 	je	short isown1
  4676                              <1> 
  4677 0000CCDF C705[DD300100]0B00- <1> 	mov	dword [u.error], ERR_NOT_OWNER  ; 11
  4677 0000CCE7 0000                <1>
  4678                              <1> 			;  'permission denied !' error
  4679 0000CCE9 E912E9FFFF          <1> 	jmp	error
  4680                              <1> isown1: ; 1:
  4681 0000CCEE E8EA0C0000          <1> 	call	setimod
  4682                              <1> 		; jsr r0,setimod / indicates 
  4683                              <1> 		;	       ; / i-node has been modified
  4684 0000CCF3 58                  <1> 	pop	eax ; 2nd argument
  4685                              <1> 		; mov (sp)+,r2 / mode is put in r2 
  4686                              <1> 		       ; / (u.off put on stack with 2nd arg)
  4687 0000CCF4 C3                  <1> 	retn
  4688                              <1> 		; rts r0
  4689                              <1> 
  4690                              <1> ;;arg:  ; < get system call arguments >
  4691                              <1> 	; 'arg' extracts an argument for a routine whose call is 
  4692                              <1> 	; of form:
  4693                              <1> 	;	sys 'routine' ; arg1
  4694                              <1> 	;		or
  4695                              <1> 	;	sys 'routine' ; arg1 ; arg2
  4696                              <1> 	;		or
  4697                              <1> 	;	sys 'routine' ; arg1;...;arg10 (sys exec) 
  4698                              <1> 	;	
  4699                              <1> 	; INPUTS ->
  4700                              <1> 	;    u.sp+18 - contains a pointer to one of arg1..argn
  4701                              <1> 	;	This pointers's value is actually the value of
  4702                              <1> 	;	update pc at the the trap to sysent (unkni) is
  4703                              <1> 	;	made to process the sys instruction
  4704                              <1> 	;    r0 - contains the return address for the routine
  4705                              <1> 	;	that called arg. The data in the word pointer 
  4706                              <1> 	;	to by the return address is used as address
  4707                              <1> 	;	in which the extracted argument is stored   		
  4708                              <1> 	;    	
  4709                              <1> 	; OUTPUTS ->
  4710                              <1> 	;    'address' - contains the extracted argument 
  4711                              <1> 	;    u.sp+18 - is incremented by 2 
  4712                              <1> 	;    r1 - contains the extracted argument
  4713                              <1> 	;    r0 - points to the next instruction to be
  4714                              <1> 	;	 executed in the calling routine.
  4715                              <1> 	;
  4716                              <1>   
  4717                              <1> 	; mov u.sp,r1
  4718                              <1> 	; mov *18.(r1),*(r0)+ / put argument of system call
  4719                              <1> 			; / into argument of arg2
  4720                              <1> 	; add $2,18.(r1) / point pc on stack 
  4721                              <1> 			      ; / to next system argument
  4722                              <1> 	; rts r0
  4723                              <1> 
  4724                              <1> ;;arg2: ; < get system calls arguments - with file name pointer>
  4725                              <1> 	; 'arg2' takes first argument in system call
  4726                              <1> 	;  (pointer to name of the file) and puts it in location
  4727                              <1> 	;  u.namep; takes second argument and puts it in u.off
  4728                              <1> 	;  and on top of the stack
  4729                              <1> 	;	
  4730                              <1> 	; INPUTS ->
  4731                              <1> 	;    u.sp, r0
  4732                              <1> 	;    	
  4733                              <1> 	; OUTPUTS ->
  4734                              <1> 	;    u.namep
  4735                              <1> 	;    u.off 
  4736                              <1> 	;    u.off pushed on stack
  4737                              <1> 	;    r1
  4738                              <1> 	;
  4739                              <1> 
  4740                              <1> 	; jsr	r0,arg; u.namep / u.namep contains value of
  4741                              <1> 				; / first arg in sys call
  4742                              <1> 	; jsr r0,arg; u.off / u.off contains value of 
  4743                              <1> 				; / second arg in sys call
  4744                              <1> 	; mov r0,r1 / r0 points to calling routine
  4745                              <1> 	; mov (sp),r0 / put operation code back in r0
  4746                              <1> 	; mov u.off,(sp) / put pointer to second argument 
  4747                              <1> 			; / on stack
  4748                              <1> 	; jmp (r1) / return to calling routine
  4749                              <1> 
  4750                              <1> syschown: ; < change owner of file >
  4751                              <1> 	; 23/06/2015 (Retro UNIX 386 v1 - Beginning)
  4752                              <1> 	; 20/06/2013 - 02/08/2013 (Retro UNIX 8086 v1)
  4753                              <1> 	;
  4754                              <1> 	; 'syschown' changes the owner of the file whose name is given
  4755                              <1> 	; as null terminated string pointed to by 'name' has it's owner
  4756                              <1> 	; changed to 'owner'
  4757                              <1> 	;
  4758                              <1> 	; Calling sequence:
  4759                              <1> 	;	syschown; name; owner
  4760                              <1> 	; Arguments:
  4761                              <1> 	;	name - address of the file name
  4762                              <1> 	;	       terminated by null byte.
  4763                              <1> 	;	owner - (new) owner (number/ID)
  4764                              <1> 	;	
  4765                              <1> 	; Inputs: -
  4766                              <1> 	; Outputs: -
  4767                              <1> 	; ...............................................................
  4768                              <1> 	;				
  4769                              <1> 	; Retro UNIX 8086 v1 modification: 
  4770                              <1> 	;       'syschown' system call has two arguments; so,
  4771                              <1> 	;	* 1st argument, name is pointed to by BX register
  4772                              <1> 	;	* 2nd argument, owner number is in CX register
  4773                              <1> 	;
  4774                              <1> 	; / name; owner
  4775 0000CCF5 E8B2FFFFFF          <1> 	call	isown
  4776                              <1> 		; jsr r0,isown / get the i-node and check user status
  4777 0000CCFA 803D[D4300100]00    <1> 	cmp 	byte [u.uid], 0 ; 02/08/2013 
  4778                              <1> 		; tstb u.uid / super user
  4779 0000CD01 7418                <1> 	jz	short syschown1
  4780                              <1> 		; beq 2f / yes, 2f
  4781 0000CD03 F605[4C2D0100]20    <1>         test    byte [i.flgs], 20h ; 32
  4782                              <1> 		; bit $40,i.flgs / no, set userid on execution?
  4783                              <1> 	;jnz	error
  4784                              <1> 		; bne 3f / yes error, could create Trojan Horses
  4785 0000CD0A 740F                <1> 	jz	short syschown1
  4786                              <1> 	; 'permission denied !'
  4787 0000CD0C C705[DD300100]0B00- <1> 	mov	dword [u.error], ERR_FILE_ACCESS  ; 11
  4787 0000CD14 0000                <1>
  4788 0000CD16 E9E5E8FFFF          <1> 	jmp	error
  4789                              <1> syschown1: ; 2:
  4790                              <1> 	; AL = owner (number/ID)
  4791 0000CD1B A2[4F2D0100]        <1> 	mov	[i.uid], al ; 23/06/2015
  4792                              <1> 		;  movb	r2,i.uid / no, put the new owners id 
  4793                              <1> 			       ; / in the i-node
  4794 0000CD20 E9FBE8FFFF          <1> 	jmp	sysret
  4795                              <1> 	; 1: 
  4796                              <1> 		; jmp sysret4
  4797                              <1> 	; 3:
  4798                              <1> 		; jmp	error
  4799                              <1> 
  4800                              <1> systime: ; / get time of year
  4801                              <1> 	; 23/06/2015 (Retro UNIX 386 v1 - Beginning)
  4802                              <1> 	; 20/06/2013 (Retro UNIX 8086 v1)
  4803                              <1> 	;
  4804                              <1> 	; 20/06/2013
  4805                              <1> 	; 'systime' gets the time of the year.
  4806                              <1> 	; The present time is put on the stack.
  4807                              <1> 	;
  4808                              <1> 	; Calling sequence:
  4809                              <1> 	;	systime
  4810                              <1> 	; Arguments: -
  4811                              <1> 	;	
  4812                              <1> 	; Inputs: -
  4813                              <1> 	; Outputs: sp+2, sp+4 - present time
  4814                              <1> 	; ...............................................................
  4815                              <1> 	;	
  4816                              <1> 	; Retro UNIX 8086 v1 modification: 
  4817                              <1> 	;       'systime' system call will return to the user
  4818                              <1> 	;	with unix time (epoch) in DX:AX register pair
  4819                              <1> 	;
  4820                              <1> 	; 	!! Major modification on original Unix v1 'systime' 
  4821                              <1> 	;	system call for PC compatibility !!		 	
  4822                              <1> 
  4823 0000CD25 E8B90C0000          <1> 	call 	epoch
  4824 0000CD2A A3[88300100]        <1> 	mov 	[u.r0], eax
  4825                              <1> 		; mov s.time,4(sp)
  4826                              <1> 		; mov s.time+2,2(sp) / put the present time 
  4827                              <1> 				   ; / on the stack
  4828                              <1> 		; br sysret4
  4829 0000CD2F E9ECE8FFFF          <1> 	jmp	sysret 
  4830                              <1> 
  4831                              <1> sysstime: ; / set time
  4832                              <1> 	; 23/06/2015 (Retro UNIX 386 v1 - Beginning)
  4833                              <1> 	; 20/06/2013 - 02/08/2013 (Retro UNIX 8086 v1)
  4834                              <1> 	;
  4835                              <1> 	; 'sysstime' sets the time. Only super user can use this call.
  4836                              <1> 	;
  4837                              <1> 	; Calling sequence:
  4838                              <1> 	;	sysstime
  4839                              <1> 	; Arguments: -
  4840                              <1> 	;	
  4841                              <1> 	; Inputs: sp+2, sp+4 - time system is to be set to.
  4842                              <1> 	; Outputs: -
  4843                              <1> 	; ...............................................................
  4844                              <1> 	;	
  4845                              <1> 	; Retro UNIX 8086 v1 modification: 
  4846                              <1> 	;	the user calls 'sysstime' with unix (epoch) time
  4847                              <1> 	;	(to be set) is in CX:BX register pair as two arguments.
  4848                              <1> 	; 
  4849                              <1> 	;	Retro UNIX 8086 v1 argument transfer method 2 is used
  4850                              <1> 	;	to get sysstime system call arguments from the user;
  4851                              <1> 	;	* 1st argument, lowword of unix time is in BX register
  4852                              <1> 	;	* 2nd argument, highword of unix time is in CX register		 	
  4853                              <1> 	;
  4854                              <1> 	; 	!! Major modification on original Unix v1 'sysstime' 
  4855                              <1> 	;	system call for PC compatibility !!	
  4856                              <1> 
  4857 0000CD34 803D[D4300100]00    <1> 	cmp	byte [u.uid], 0
  4858                              <1> 		; tstb u.uid / is user the super user
  4859                              <1> 	;ja	error
  4860                              <1> 		; bne error4 / no, error
  4861 0000CD3B 760F                <1> 	jna	short systime1
  4862                              <1> 	; 'permission denied !'
  4863 0000CD3D C705[DD300100]0B00- <1> 	mov	dword [u.error], ERR_NOT_SUPERUSER  ; 11 
  4863 0000CD45 0000                <1>
  4864 0000CD47 E9B4E8FFFF          <1> 	jmp	error
  4865                              <1> systime1:
  4866                              <1> 	; 23/06/2015 (Retro UNIX 386 v1 - 32 bit version)
  4867                              <1> 	; EBX = unix (epoch) time (from user)
  4868 0000CD4C 89D8                <1> 	mov	eax, ebx
  4869 0000CD4E E8910C0000          <1> 	call 	set_date_time
  4870                              <1> 		; mov 4(sp),s.time
  4871                              <1> 		; mov 2(sp),s.time+2 / set the system time
  4872 0000CD53 E9C8E8FFFF          <1> 	jmp	sysret
  4873                              <1> 		; br sysret4
  4874                              <1> 
  4875                              <1> sysbreak:
  4876                              <1> 	; 18/10/2015
  4877                              <1> 	; 07/10/2015
  4878                              <1> 	; 23/06/2015 (Retro UNIX 386 v1 - Beginning)
  4879                              <1> 	; 20/06/2013 - 24/03/2014 (Retro UNIX 8086 v1)
  4880                              <1> 	;
  4881                              <1> 	; 'sysbreak' sets the programs break points. 
  4882                              <1> 	; It checks the current break point (u.break) to see if it is
  4883                              <1> 	; between "core" and the stack (sp). If it is, it is made an
  4884                              <1> 	; even address (if it was odd) and the area between u.break
  4885                              <1> 	; and the stack is cleared. The new breakpoint is then put
  4886                              <1> 	; in u.break and control is passed to 'sysret'.
  4887                              <1> 	;
  4888                              <1> 	; Calling sequence:
  4889                              <1> 	;	sysbreak; addr
  4890                              <1> 	; Arguments: -
  4891                              <1> 	;	
  4892                              <1> 	; Inputs: u.break - current breakpoint
  4893                              <1> 	; Outputs: u.break - new breakpoint 
  4894                              <1> 	;	area between old u.break and the stack (sp) is cleared.
  4895                              <1> 	; ...............................................................
  4896                              <1> 	;	
  4897                              <1> 	; Retro UNIX 8086 v1 modification:
  4898                              <1> 	;	The user/application program puts breakpoint address
  4899                              <1> 	;       in BX register as 'sysbreak' system call argument.
  4900                              <1> 	; 	(argument transfer method 1)
  4901                              <1> 	;
  4902                              <1> 	;  NOTE: Beginning of core is 0 in Retro UNIX 8086 v1 !
  4903                              <1> 	; 	((!'sysbreak' is not needed in Retro UNIX 8086 v1!))
  4904                              <1> 	;  NOTE:
  4905                              <1> 	; 	'sysbreak' clears extended part (beyond of previous
  4906                              <1> 	;	'u.break' address) of user's memory for original unix's
  4907                              <1> 	;	'bss' compatibility with Retro UNIX 8086 v1 (19/11/2013)
  4908                              <1> 
  4909                              <1> 		; mov u.break,r1 / move users break point to r1
  4910                              <1> 		; cmp r1,$core / is it the same or lower than core?
  4911                              <1> 		; blos 1f / yes, 1f
  4912                              <1> 	; 23/06/2015
  4913 0000CD58 8B2D[B4300100]      <1> 	mov	ebp, [u.break] ; virtual address (offset)
  4914                              <1> 	;and	ebp, ebp
  4915                              <1> 	;jz	short sysbreak_3 
  4916                              <1> 	; Retro UNIX 386 v1 NOTE: u.break points to virtual address !!!
  4917                              <1> 	; (Even break point address is not needed for Retro UNIX 386 v1)
  4918 0000CD5E 8B15[80300100]      <1> 	mov	edx, [u.sp] ; kernel stack at the beginning of sys call
  4919 0000CD64 83C20C              <1> 	add	edx, 12 ; EIP -4-> CS -4-> EFLAGS -4-> ESP (user) 
  4920                              <1> 	; 07/10/2015
  4921 0000CD67 891D[B4300100]      <1> 	mov	[u.break], ebx ; virtual address !!!
  4922                              <1> 	;
  4923 0000CD6D 3B1A                <1> 	cmp	ebx, [edx] ; compare new break point with 
  4924                              <1> 			   ; with top of user's stack (virtual!)
  4925 0000CD6F 7327                <1> 	jnb	short sysbreak_3
  4926                              <1> 		; cmp r1,sp / is it the same or higher 
  4927                              <1> 			  ; / than the stack?
  4928                              <1> 		; bhis 1f / yes, 1f
  4929 0000CD71 89DE                <1> 	mov	esi, ebx
  4930 0000CD73 29EE                <1> 	sub	esi, ebp ; new break point - old break point
  4931 0000CD75 7621                <1> 	jna	short sysbreak_3 
  4932                              <1> 	;push	ebx
  4933                              <1> sysbreak_1:
  4934 0000CD77 89EB                <1> 	mov	ebx, ebp  
  4935 0000CD79 E85C7FFFFF          <1> 	call	get_physical_addr ; get physical address
  4936 0000CD7E 0F82A8FEFFFF        <1> 	jc	tr_addr_nm_err
  4937                              <1> 	; 18/10/2015
  4938 0000CD84 89C7                <1> 	mov	edi, eax 
  4939 0000CD86 29C0                <1> 	sub	eax, eax ; 0
  4940                              <1> 		 ; ECX = remain byte count in page (1-4096)
  4941 0000CD88 39CE                <1> 	cmp	esi, ecx
  4942 0000CD8A 7302                <1> 	jnb	short sysbreak_2
  4943 0000CD8C 89F1                <1> 	mov	ecx, esi
  4944                              <1> sysbreak_2:
  4945 0000CD8E 29CE                <1> 	sub	esi, ecx
  4946 0000CD90 01CD                <1> 	add	ebp, ecx
  4947 0000CD92 F3AA                <1> 	rep 	stosb
  4948 0000CD94 09F6                <1> 	or	esi, esi
  4949 0000CD96 75DF                <1> 	jnz	short sysbreak_1
  4950                              <1> 	;
  4951                              <1> 		; bit $1,r1 / is it an odd address
  4952                              <1> 		; beq 2f / no, its even
  4953                              <1> 		; clrb (r1)+ / yes, make it even
  4954                              <1> 	; 2: / clear area between the break point and the stack
  4955                              <1> 		; cmp r1,sp / is it higher or same than the stack
  4956                              <1> 		; bhis 1f / yes, quit
  4957                              <1> 		; clr (r1)+ / clear word
  4958                              <1> 		; br 2b / go back
  4959                              <1> 	;pop	ebx
  4960                              <1> sysbreak_3: ; 1:
  4961                              <1> 	;mov	[u.break], ebx ; virtual address !!!
  4962                              <1> 		; jsr r0,arg; u.break / put the "address" 
  4963                              <1> 			; / in u.break (set new break point)
  4964                              <1> 		; br sysret4 / br sysret
  4965 0000CD98 E983E8FFFF          <1> 	jmp	sysret
  4966                              <1> 
  4967                              <1> 
  4968                              <1> maknod: 
  4969                              <1> 	; 22/06/2015 (Retro UNIX 386 v1 - Beginning)
  4970                              <1> 	; 02/05/2013 - 02/08/2013 (Retro UNIX 8086 v1)
  4971                              <1> 	;
  4972                              <1> 	; 'maknod' creates an i-node and makes a directory entry
  4973                              <1> 	; for this i-node in the current directory.
  4974                              <1> 	;
  4975                              <1> 	; INPUTS ->
  4976                              <1> 	;    r1 - contains mode
  4977                              <1> 	;    ii - current directory's i-number	
  4978                              <1> 	;    	
  4979                              <1> 	; OUTPUTS ->
  4980                              <1> 	;    u.dirbuf - contains i-number of free i-node 
  4981                              <1> 	;    i.flgs - flags in new i-node 
  4982                              <1> 	;    i.uid - filled with u.uid
  4983                              <1> 	;    i.nlks - 1 is put in the number of links
  4984                              <1> 	;    i.ctim - creation time				
  4985                              <1> 	;    i.ctim+2 - modification time
  4986                              <1> 	;    imod - set via call to setimod
  4987                              <1> 	;	
  4988                              <1> 	; ((AX = R1)) input
  4989                              <1> 	;
  4990                              <1> 	; (Retro UNIX Prototype : 
  4991                              <1> 	;	30/10/2012 - 01/03/2013, UNIXCOPY.ASM)
  4992                              <1>         ; ((Modified registers: eAX, eDX, eBX, eCX, eSI, eDI, eBP))  
  4993                              <1> 
  4994                              <1> 	; / r1 contains the mode
  4995 0000CD9D 80CC80              <1> 	or 	ah, 80h  ; 10000000b
  4996                              <1> 		; bis	$100000,r1 / allocate flag set
  4997 0000CDA0 6650                <1> 	push	ax
  4998                              <1> 		; mov r1,-(sp) / put mode on stack
  4999                              <1> 	; 31/07/2013
  5000 0000CDA2 66A1[0D310100]      <1> 	mov	ax, [ii] ; move current i-number to AX/r1
  5001                              <1> 		; mov ii,r1 / move current i-number to r1
  5002 0000CDA8 B201                <1> 	mov	dl, 1 ; owner flag mask
  5003 0000CDAA E8320C0000          <1> 	call	access	
  5004                              <1> 		; jsr r0,access; 1 / get its i-node into core
  5005 0000CDAF 6650                <1> 	push	ax
  5006                              <1> 		; mov r1,-(sp) / put i-number on stack
  5007 0000CDB1 66B82800            <1> 	mov	ax, 40
  5008                              <1> 		; mov $40.,r1 / r1 = 40
  5009                              <1> maknod1: ; 1: / scan for a free i-node (next 4 instructions)
  5010 0000CDB5 6640                <1> 	inc	ax
  5011                              <1> 		; inc r1 / r1 = r1 + 1
  5012 0000CDB7 E8290C0000          <1> 	call	imap
  5013                              <1> 		; jsr r0,imap / get byte address and bit position in 
  5014                              <1> 			    ; /	inode map in r2 & m
  5015                              <1>           ; DX (MQ) has a 1 in the calculated bit position
  5016                              <1>           ; eBX (R2) has byte address of the byte with allocation bit
  5017                              <1> 	; 22/06/2015 - NOTE for next Retro UNIX version: 
  5018                              <1> 	;	       Inode count must be checked here
  5019                              <1> 	; (Original UNIX v1 did not check inode count here !?) 	
  5020 0000CDBC 8413                <1> 	test	[ebx], dl
  5021                              <1> 		; bitb mq,(r2) / is the i-node active
  5022 0000CDBE 75F5                <1> 	jnz	short maknod1
  5023                              <1> 		; bne 1b / yes, try the next one
  5024 0000CDC0 0813                <1> 	or	[ebx], dl
  5025                              <1> 		; bisb mq,(r2) / no, make it active 
  5026                              <1> 			     ; / (put a 1 in the bit map)
  5027 0000CDC2 E80F0C0000          <1> 	call	iget
  5028                              <1> 		; jsr r0,iget / get i-node into core
  5029 0000CDC7 66F705[4C2D0100]00- <1> 	test	word [i.flgs], 8000h 
  5029 0000CDCF 80                  <1>
  5030                              <1> 		; tst i.flgs / is i-node already allocated
  5031 0000CDD0 75E3                <1> 	jnz	short maknod1	
  5032                              <1> 		; blt 1b / yes, look for another one
  5033 0000CDD2 66A3[BA300100]      <1> 	mov	[u.dirbuf], ax
  5034                              <1> 		; mov r1,u.dirbuf / no, put i-number in u.dirbuf
  5035 0000CDD8 6658                <1> 	pop	ax
  5036                              <1> 		; mov (sp)+,r1 / get current i-number back
  5037 0000CDDA E8F70B0000          <1> 	call	iget
  5038                              <1> 		; jsr r0,iget / get i-node in core
  5039 0000CDDF E88AF9FFFF          <1> 	call	mkdir
  5040                              <1> 		; jsr r0,mkdir / make a directory entry 
  5041                              <1> 			     ; / in current directory
  5042 0000CDE4 66A1[BA300100]      <1> 	mov	ax, [u.dirbuf]
  5043                              <1> 		; mov u.dirbuf,r1 / r1 = new inode number
  5044 0000CDEA E8E70B0000          <1> 	call	iget
  5045                              <1> 		; jsr r0,iget / get it into core
  5046                              <1> 		; jsr r0,copyz; inode; inode+32. / 0 it out
  5047 0000CDEF B908000000          <1> 	mov	ecx, 8 
  5048 0000CDF4 31C0                <1> 	xor	eax, eax ; 0
  5049 0000CDF6 BF[4C2D0100]        <1> 	mov	edi, inode 
  5050 0000CDFB F3AB                <1> 	rep	stosd
  5051                              <1> 	;
  5052 0000CDFD 668F05[4C2D0100]    <1> 	pop	word [i.flgs]
  5053                              <1> 		; mov (sp)+,i.flgs / fill flags
  5054 0000CE04 8A0D[D4300100]      <1> 	mov 	cl, [u.uid] ; 02/08/2013
  5055 0000CE0A 880D[4F2D0100]      <1> 	mov 	[i.uid], cl
  5056                              <1> 		; movb u.uid,i.uid / user id	
  5057 0000CE10 C605[4E2D0100]01    <1> 	mov     byte [i.nlks], 1
  5058                              <1> 		; movb $1,i.nlks / 1 link
  5059                              <1> 	;call	epoch ; Retro UNIX 8086 v1 modification !
  5060                              <1> 	;mov	eax, [s.time]
  5061                              <1> 	;mov 	[i.ctim], eax
  5062                              <1> 	 	; mov s.time,i.ctim / time created
  5063                              <1> 	 	; mov s.time+2,i.ctim+2 / time modified
  5064                              <1> 	; Retro UNIX 8086 v1 modification !
  5065                              <1> 	; i.ctime=0, i.ctime+2=0 and
  5066                              <1>         ; 'setimod' will set ctime of file via 'epoch'
  5067 0000CE17 E8C10B0000          <1> 	call setimod
  5068                              <1> 		; jsr r0,setimod / set modified flag
  5069 0000CE1C C3                  <1> 	retn
  5070                              <1> 		; rts r0 / return
  5071                              <1> 
  5072                              <1> sysseek: ; / moves read write pointer in an fsp entry
  5073                              <1> 	; 22/06/2015 (Retro UNIX 386 v1 - Beginning)
  5074                              <1> 	; 07/07/2013 - 05/08/2013 (Retro UNIX 8086 v1)
  5075                              <1> 	;
  5076                              <1> 	; 'sysseek' changes the r/w pointer of (3rd word of in an
  5077                              <1> 	; fsp entry) of an open file whose file descriptor is in u.r0.
  5078                              <1> 	; The file descriptor refers to a file open for reading or
  5079                              <1> 	; writing. The read (or write) pointer is set as follows:
  5080                              <1> 	;	* if 'ptrname' is 0, the pointer is set to offset.
  5081                              <1> 	;	* if 'ptrname' is 1, the pointer is set to its
  5082                              <1> 	;	  current location plus offset.
  5083                              <1> 	;	* if 'ptrname' is 2, the pointer is set to the
  5084                              <1> 	;	  size of file plus offset.
  5085                              <1> 	; The error bit (e-bit) is set for an undefined descriptor.
  5086                              <1> 	;
  5087                              <1> 	; Calling sequence:
  5088                              <1> 	;	sysseek; offset; ptrname
  5089                              <1> 	; Arguments:
  5090                              <1> 	;	offset - number of bytes desired to move 
  5091                              <1> 	;		 the r/w pointer
  5092                              <1> 	;	ptrname - a switch indicated above
  5093                              <1> 	;
  5094                              <1> 	; Inputs: r0 - file descriptor 
  5095                              <1> 	; Outputs: -
  5096                              <1> 	; ...............................................................
  5097                              <1> 	;	
  5098                              <1> 	; Retro UNIX 8086 v1 modification: 
  5099                              <1> 	;       'sysseek' system call has three arguments; so,
  5100                              <1> 	;	* 1st argument, file descriptor is in BX (BL) register
  5101                              <1> 	;	* 2nd argument, offset is in CX register
  5102                              <1> 	;	* 3rd argument, ptrname/switch is in DX (DL) register	
  5103                              <1> 	;	
  5104                              <1> 
  5105 0000CE1D E823000000          <1> 	call	seektell
  5106                              <1> 	; AX = u.count
  5107                              <1> 	; BX = *u.fofp
  5108                              <1> 		; jsr r0,seektell / get proper value in u.count
  5109                              <1> 		; add u.base,u.count / add u.base to it
  5110 0000CE22 0305[A8300100]      <1> 	add	eax, [u.base] ; add offset (u.base) to base
  5111 0000CE28 8903                <1> 	mov	[ebx], eax
  5112                              <1> 		; mov u.count,*u.fofp / put result into r/w pointer
  5113 0000CE2A E9F1E7FFFF          <1> 	jmp	sysret
  5114                              <1> 		; br sysret4
  5115                              <1> 
  5116                              <1> systell: ; / get the r/w pointer
  5117                              <1> 	; 22/06/2015 (Retro UNIX 386 v1 - Beginning)
  5118                              <1> 	; 07/07/2013 - 05/08/2013 (Retro UNIX 8086 v1)
  5119                              <1> 	;
  5120                              <1> 	; Retro UNIX 8086 v1 modification:
  5121                              <1> 	; ! 'systell' does not work in original UNIX v1,
  5122                              <1> 	; 	    it returns with error !
  5123                              <1> 	; Inputs: r0 - file descriptor 
  5124                              <1> 	; Outputs: r0 - file r/w pointer
  5125                              <1> 
  5126                              <1> 	;xor	ecx, ecx ; 0
  5127 0000CE2F BA01000000          <1> 	mov	edx, 1 ; 05/08/2013
  5128                              <1> 	;call 	seektell
  5129 0000CE34 E812000000          <1> 	call 	seektell0 ; 05/08/2013
  5130                              <1> 	;mov	ebx, [u.fofp]
  5131 0000CE39 8B03                <1> 	mov	eax, [ebx]
  5132 0000CE3B A3[88300100]        <1> 	mov	[u.r0], eax
  5133 0000CE40 E9DBE7FFFF          <1> 	jmp	sysret
  5134                              <1> 
  5135                              <1> ; Original unix v1 'systell' system call:
  5136                              <1> 		; jsr r0,seektell
  5137                              <1> 		; br error4
  5138                              <1> 
  5139                              <1> seektell:
  5140                              <1> 	; 03/01/2016
  5141                              <1> 	; 22/06/2015 (Retro UNIX 386 v1 - Beginning)
  5142                              <1> 	; 07/07/2013 - 05/08/2013 (Retro UNIX 8086 v1)
  5143                              <1> 	;
  5144                              <1> 	; 'seektell' puts the arguments from sysseek and systell
  5145                              <1> 	; call in u.base and u.count. It then gets the i-number of
  5146                              <1> 	; the file from the file descriptor in u.r0 and by calling
  5147                              <1> 	; getf. The i-node is brought into core and then u.count
  5148                              <1> 	; is checked to see it is a 0, 1, or 2.
  5149                              <1> 	; If it is 0 - u.count stays the same
  5150                              <1> 	;          1 - u.count = offset (u.fofp)
  5151                              <1> 	;	   2 - u.count = i.size (size of file)
  5152                              <1> 	; 	 		
  5153                              <1> 	; !! Retro UNIX 8086 v1 modification:
  5154                              <1> 	;	Argument 1, file descriptor is in BX;
  5155                              <1> 	;	Argument 2, offset is in CX;
  5156                              <1> 	;	Argument 3, ptrname/switch is in DX register.	
  5157                              <1> 	;
  5158                              <1> 	; mov 	ax, 3 ; Argument transfer method 3 (three arguments)	
  5159                              <1> 	; call 	arg
  5160                              <1> 	;
  5161                              <1> 	; ((Return -> ax = base for offset (position= base+offset))
  5162                              <1> 	;
  5163 0000CE45 890D[A8300100]      <1> 	mov 	[u.base], ecx ; offset
  5164                              <1> 		; jsr r0,arg; u.base / puts offset in u.base
  5165                              <1> seektell0:
  5166 0000CE4B 8915[AC300100]      <1> 	mov 	[u.count], edx
  5167                              <1> 		; jsr r0,arg; u.count / put ptr name in u.count
  5168                              <1> 	; mov	ax, bx
  5169                              <1> 		; mov *u.r0,r1 / file descriptor in r1 
  5170                              <1> 			     ; / (index in u.fp list)
  5171                              <1> 	; call	getf
  5172                              <1> 		; jsr r0,getf / u.fofp points to 3rd word in fsp entry
  5173                              <1> 	; BX = file descriptor (file number)
  5174 0000CE51 E83DFCFFFF          <1> 	call	getf1
  5175 0000CE56 6609C0              <1> 	or	ax, ax ; i-number of the file
  5176                              <1> 		; mov r1,-(sp) / r1 has i-number of file, 
  5177                              <1> 		             ; / put it on the stack
  5178                              <1> 	;jz	error
  5179                              <1> 		; beq error4 / if i-number is 0, not active so error
  5180 0000CE59 750F                <1> 	jnz	short seektell1
  5181 0000CE5B C705[DD300100]0A00- <1> 	mov	dword [u.error], ERR_FILE_NOT_OPEN  ; 'file not open !'
  5181 0000CE63 0000                <1>
  5182 0000CE65 E996E7FFFF          <1> 	jmp	error
  5183                              <1> seektell1:
  5184                              <1> 	;push	eax
  5185 0000CE6A 80FC80              <1> 	cmp	ah, 80h
  5186 0000CE6D 7203                <1> 	jb	short seektell2
  5187                              <1> 		; bgt .+4 / if its positive jump
  5188 0000CE6F 66F7D8              <1> 	neg	ax
  5189                              <1> 		; neg r1 / if not make it positive
  5190                              <1> seektell2:
  5191 0000CE72 E85F0B0000          <1> 	call	iget
  5192                              <1> 		; jsr r0,iget / get its i-node into core
  5193 0000CE77 8B1D[98300100]      <1>         mov     ebx, [u.fofp] ; 05/08/2013
  5194 0000CE7D 803D[AC300100]01    <1> 	cmp	byte [u.count], 1
  5195                              <1> 		; cmp u.count,$1 / is ptr name =1
  5196 0000CE84 7705                <1> 	ja	short seektell3
  5197                              <1> 		; blt 2f / no its zero
  5198 0000CE86 740A                <1> 	je	short seektell_4
  5199                              <1> 		; beq 1f / yes its 1
  5200 0000CE88 31C0                <1> 	xor	eax, eax
  5201                              <1> 	;jmp	short seektell_5
  5202 0000CE8A C3                  <1> 	retn
  5203                              <1> seektell3:
  5204                              <1> 	; 03/01/2016
  5205                              <1> 	;movzx	eax, word [i.size]
  5206 0000CE8B 66A1[11310100]      <1>         mov   	ax, [i.size]
  5207                              <1>                 ; mov i.size,u.count /  put number of bytes 
  5208                              <1>                                    ; / in file in u.count
  5209                              <1> 	;jmp	short seektell_5
  5210                              <1> 		; br 2f
  5211 0000CE91 C3                  <1> 	retn
  5212                              <1> seektell_4: ; 1: / ptrname =1
  5213                              <1> 	;mov	ebx, [u.fofp]
  5214 0000CE92 8B03                <1> 	mov	eax, [ebx]
  5215                              <1> 		; mov *u.fofp,u.count / put offset in u.count
  5216                              <1> ;seektell_5: ; 2: / ptrname =0
  5217                              <1> 	;mov	[u.count], eax
  5218                              <1> 	;pop	eax 
  5219                              <1> 		; mov (sp)+,r1 / i-number on stack  r1
  5220 0000CE94 C3                  <1> 	retn
  5221                              <1> 		; rts r0
  5222                              <1> 
  5223                              <1> sysintr: ; / set interrupt handling
  5224                              <1> 	; 22/06/2015 (Retro UNIX 386 v1 - Beginning)
  5225                              <1> 	; 07/07/2013 (Retro UNIX 8086 v1)
  5226                              <1> 	;
  5227                              <1> 	; 'sysintr' sets the interrupt handling value. It puts
  5228                              <1> 	; argument of its call in u.intr then branches into 'sysquit'
  5229                              <1> 	; routine. u.tty is checked if to see if a control tty exists.
  5230                              <1> 	; If one does the interrupt character in the tty buffer is
  5231                              <1> 	; cleared and 'sysret'is called. If one does not exits
  5232                              <1> 	; 'sysret' is just called.	
  5233                              <1> 	;
  5234                              <1> 	; Calling sequence:
  5235                              <1> 	;	sysintr; arg
  5236                              <1> 	; Argument:
  5237                              <1> 	;	arg - if 0, interrupts (ASCII DELETE) are ignored.
  5238                              <1> 	;	    - if 1, intterupts cause their normal result
  5239                              <1> 	;		 i.e force an exit.
  5240                              <1> 	;	    - if arg is a location within the program,
  5241                              <1> 	;		control is passed to that location when
  5242                              <1> 	;		an interrupt occurs.	
  5243                              <1> 	; Inputs: -
  5244                              <1> 	; Outputs: -
  5245                              <1> 	; ...............................................................
  5246                              <1> 	;	
  5247                              <1> 	; Retro UNIX 8086 v1 modification: 
  5248                              <1> 	;       'sysintr' system call sets u.intr to value of BX
  5249                              <1> 	;	then branches into sysquit.
  5250                              <1> 	;
  5251 0000CE95 66891D[CC300100]    <1> 	mov	[u.intr], bx
  5252                              <1> 		; jsr r0,arg; u.intr / put the argument in u.intr
  5253                              <1> 		; br 1f / go into quit routine
  5254 0000CE9C E97FE7FFFF          <1> 	jmp	sysret
  5255                              <1> 
  5256                              <1> sysquit:
  5257                              <1> 	; 22/06/2015 (Retro UNIX 386 v1 - Beginning)
  5258                              <1> 	; 07/07/2013 (Retro UNIX 8086 v1)
  5259                              <1> 	;
  5260                              <1> 	; 'sysquit' turns off the quit signal. it puts the argument of
  5261                              <1> 	; the call in u.quit. u.tty is checked if to see if a control 
  5262                              <1> 	; tty exists. If one does the interrupt character in the tty
  5263                              <1> 	; buffer is cleared and 'sysret'is called. If one does not exits
  5264                              <1> 	; 'sysret' is just called.	
  5265                              <1> 	;
  5266                              <1> 	; Calling sequence:
  5267                              <1> 	;	sysquit; arg
  5268                              <1> 	; Argument:
  5269                              <1> 	;	arg - if 0, this call diables quit signals from the
  5270                              <1> 	;		typewriter (ASCII FS)
  5271                              <1> 	;	    - if 1, quits are re-enabled and cause execution to
  5272                              <1> 	;		cease and a core image to be produced.
  5273                              <1> 	;		 i.e force an exit.
  5274                              <1> 	;	    - if arg is an addres in the program,
  5275                              <1> 	;		a quit causes control to sent to that
  5276                              <1> 	;		location.	
  5277                              <1> 	; Inputs: -
  5278                              <1> 	; Outputs: -
  5279                              <1> 	; ...............................................................
  5280                              <1> 	;	
  5281                              <1> 	; Retro UNIX 8086 v1 modification: 
  5282                              <1> 	;       'sysquit' system call sets u.quit to value of BX
  5283                              <1> 	;	then branches into 'sysret'.
  5284                              <1> 	;
  5285 0000CEA1 66891D[CE300100]    <1> 	mov	[u.quit], bx
  5286 0000CEA8 E973E7FFFF          <1> 	jmp	sysret
  5287                              <1> 		; jsr r0,arg; u.quit / put argument in u.quit
  5288                              <1> 	;1:
  5289                              <1> 		; mov u.ttyp,r1 / move pointer to control tty buffer
  5290                              <1> 			      ; / to r1
  5291                              <1> 		; beq sysret4 / return to user
  5292                              <1> 		; clrb 6(r1) / clear the interrupt character 
  5293                              <1> 			   ; / in the tty buffer
  5294                              <1> 		; br sysret4 / return to user
  5295                              <1> 
  5296                              <1> syssetuid: ; / set process id
  5297                              <1> 	; 22/06/2015 (Retro UNIX 386 v1 - Beginning)
  5298                              <1> 	; 07/07/2013 - 02/08/2013 (Retro UNIX 8086 v1)
  5299                              <1> 	;
  5300                              <1> 	; 'syssetuid' sets the user id (u.uid) of the current process
  5301                              <1> 	; to the process id in (u.r0). Both the effective user and 
  5302                              <1> 	; u.uid and the real user u.ruid are set to this. 
  5303                              <1> 	; Only the super user can make this call.	
  5304                              <1> 	;
  5305                              <1> 	; Calling sequence:
  5306                              <1> 	;	syssetuid
  5307                              <1> 	; Arguments: -
  5308                              <1> 	;
  5309                              <1> 	; Inputs: (u.r0) - contains the process id.
  5310                              <1> 	; Outputs: -
  5311                              <1> 	; ...............................................................
  5312                              <1> 	;	
  5313                              <1> 	; Retro UNIX 8086 v1 modification: 
  5314                              <1> 	;       BL contains the (new) user ID of the current process
  5315                              <1> 
  5316                              <1> 		; movb *u.r0,r1 / move process id (number) to r1
  5317 0000CEAD 3A1D[D5300100]      <1> 	cmp	bl, [u.ruid] 
  5318                              <1> 		; cmpb r1,u.ruid / is it equal to the real user 
  5319                              <1> 			       ; / id number
  5320 0000CEB3 741E                <1> 	je	short setuid1
  5321                              <1> 		; beq 1f / yes
  5322 0000CEB5 803D[D4300100]00    <1> 	cmp	byte [u.uid], 0 ; 02/08/2013
  5323                              <1> 		; tstb u.uid / no, is current user the super user?
  5324                              <1> 	;ja	error
  5325                              <1> 		; bne error4 / no, error
  5326 0000CEBC 760F                <1> 	jna	short setuid0
  5327 0000CEBE C705[DD300100]0B00- <1> 	mov	dword [u.error], ERR_NOT_SUPERUSER  ; 11
  5327 0000CEC6 0000                <1>
  5328                              <1> 				;  'permission denied !' error
  5329 0000CEC8 E933E7FFFF          <1> 	jmp	error
  5330                              <1> setuid0:
  5331 0000CECD 881D[D5300100]      <1> 	mov	[u.ruid], bl
  5332                              <1> setuid1: ; 1:
  5333 0000CED3 881D[D4300100]      <1> 	mov	[u.uid], bl ; 02/08/2013
  5334                              <1> 		; movb r1,u.uid / put process id in u.uid
  5335                              <1> 		; movb r1,u.ruid / put process id in u.ruid
  5336 0000CED9 E942E7FFFF          <1> 	jmp	sysret
  5337                              <1> 		; br sysret4 / system return
  5338                              <1> 
  5339                              <1> sysgetuid: ; < get user id >
  5340                              <1> 	; 22/06/2015 (Retro UNIX 386 v1 - Beginning)
  5341                              <1> 	; 07/07/2013 (Retro UNIX 8086 v1)
  5342                              <1> 	;
  5343                              <1> 	; 'sysgetuid' returns the real user ID of the current process.
  5344                              <1> 	; The real user ID identifies the person who is logged in,
  5345                              <1> 	; in contradistinction to the effective user ID, which
  5346                              <1> 	; determines his access permission at each moment. It is thus
  5347                              <1> 	; useful to programs which operate using the 'set user ID'
  5348                              <1> 	; mode, to find out who invoked them.	
  5349                              <1> 	;
  5350                              <1> 	; Calling sequence:
  5351                              <1> 	;	syssetuid
  5352                              <1> 	; Arguments: -
  5353                              <1> 	;
  5354                              <1> 	; Inputs: -
  5355                              <1> 	; Outputs: (u.r0) - contains the real user's id.
  5356                              <1> 	; ...............................................................
  5357                              <1> 	;	
  5358                              <1> 	; Retro UNIX 8086 v1 modification: 
  5359                              <1> 	;       AL contains the real user ID at return.
  5360                              <1> 	;
  5361 0000CEDE 0FB605[D5300100]    <1> 	movzx 	eax, byte [u.ruid]
  5362 0000CEE5 A3[88300100]        <1> 	mov	[u.r0], eax
  5363                              <1> 		; movb	u.ruid,*u.r0 / move the real user id to (u.r0)
  5364 0000CEEA E931E7FFFF          <1> 	jmp	sysret
  5365                              <1> 		; br sysret4 / systerm return, sysret
  5366                              <1> 
  5367                              <1> anyi: 
  5368                              <1> 	; 22/06/2015 (Retro UNIX 386 v1 - Beginning)
  5369                              <1> 	; 25/04/2013 (Retro UNIX 8086 v1)
  5370                              <1> 	;
  5371                              <1> 	; 'anyi' is called if a file deleted while open.
  5372                              <1> 	; "anyi" checks to see if someone else has opened this file.
  5373                              <1> 	;
  5374                              <1> 	; INPUTS ->
  5375                              <1> 	;    r1 - contains an i-number
  5376                              <1> 	;    fsp - start of table containing open files
  5377                              <1> 	;
  5378                              <1> 	; OUTPUTS ->
  5379                              <1> 	;    "deleted" flag set in fsp entry of another occurrence of
  5380                              <1> 	;	   this file and r2 points 1st word of this fsp entry.
  5381                              <1> 	;    if file not found - bit in i-node map is cleared
  5382                              <1> 	;    			 (i-node is freed)
  5383                              <1> 	;               all blocks related to i-node are freed
  5384                              <1> 	;	        all flags in i-node are cleared
  5385                              <1> 	; ((AX = R1)) input
  5386                              <1> 	;
  5387                              <1> 	;    (Retro UNIX Prototype : 02/12/2012, UNIXCOPY.ASM)
  5388                              <1>         ;    ((Modified registers: eDX, eCX, eBX, eSI, eDI, eBP))  
  5389                              <1> 	;
  5390                              <1> 		; / r1 contains an i-number
  5391 0000CEEF BB[5C2E0100]        <1> 	mov	ebx, fsp
  5392                              <1> 		; mov $fsp,r2 / move start of fsp table to r2
  5393                              <1> anyi_1: ; 1:
  5394 0000CEF4 663B03              <1> 	cmp	ax, [ebx]
  5395                              <1> 		; cmp r1,(r2) / do i-numbers match?
  5396 0000CEF7 7433                <1> 	je	short anyi_3
  5397                              <1> 		; beq 1f / yes, 1f
  5398 0000CEF9 66F7D8              <1> 	neg	ax
  5399                              <1> 		; neg r1 / no complement r1
  5400 0000CEFC 663B03              <1> 	cmp	ax, [ebx]
  5401                              <1> 		; cmp r1,(r2) / do they match now?
  5402 0000CEFF 742B                <1> 	je	short anyi_3
  5403                              <1> 		; beq 1f / yes, transfer
  5404                              <1> 		; / i-numbers do not match
  5405 0000CF01 83C30A              <1> 	add	ebx, 10 ; fsp table size is 10 bytes
  5406                              <1> 			; in Retro UNIX 386 v1 (22/06/2015)
  5407                              <1> 		; add $8,r2 / no, bump to next entry in fsp table
  5408 0000CF04 81FB[50300100]      <1> 	cmp	ebx, fsp + (nfiles*10) ; 22/06/2015 
  5409                              <1> 		; cmp r2,$fsp+[nfiles*8] 
  5410                              <1> 				; / are we at last entry in the table
  5411 0000CF0A 72E8                <1> 	jb	short anyi_1
  5412                              <1> 		; blt 1b / no, check next entries i-number
  5413                              <1> 	;cmp	ax, 32768
  5414 0000CF0C 80FC80              <1> 	cmp	ah, 80h ; negative number check
  5415                              <1> 		; tst r1 / yes, no match
  5416                              <1> 		; bge .+4
  5417 0000CF0F 7203                <1> 	jb	short anyi_2
  5418 0000CF11 66F7D8              <1> 	neg	ax
  5419                              <1> 		; neg r1 / make i-number positive
  5420                              <1> anyi_2:	
  5421 0000CF14 E8CC0A0000          <1> 	call	imap
  5422                              <1> 		; jsr r0,imap / get address of allocation bit 
  5423                              <1> 			    ; / in the i-map in r2
  5424                              <1> 	;; DL/DX (MQ) has a 1 in the calculated bit position
  5425                              <1>         ;; eBX (R2) has address of the byte with allocation bit
  5426                              <1>  	; not	dx
  5427 0000CF19 F6D2                <1> 	not 	dl ;; 0 at calculated bit position, other bits are 1
  5428                              <1>         ;and	[ebx], dx
  5429 0000CF1B 2013                <1> 	and 	[ebx], dl 
  5430                              <1> 		; bicb mq,(r2) / clear bit for i-node in the imap
  5431 0000CF1D E8BA0A0000          <1> 	call	itrunc
  5432                              <1> 		; jsr r0,itrunc / free all blocks related to i-node
  5433 0000CF22 66C705[4C2D0100]00- <1>  	mov 	word [i.flgs], 0
  5433 0000CF2A 00                  <1>
  5434                              <1> 		; clr i.flgs / clear all flags in the i-node
  5435 0000CF2B C3                  <1> 	retn
  5436                              <1> 		;rts	r0 / return
  5437                              <1> anyi_3: ; 1: / i-numbers match
  5438 0000CF2C FE4309              <1> 	inc 	byte [ebx+9] ; 22/06/2015
  5439                              <1> 		;incb 7(r2) / increment upper byte of the 4th word
  5440                              <1> 		   ; / in that fsp entry (deleted flag of fsp entry)
  5441 0000CF2F C3                  <1> 	retn
  5442                              <1> 		; rts r0
  5443                              <1> 
  5444                              <1> ; Retro UNIX 386 v1 Kernel (v0.2) - u7.s
  5445                              <1> ; Last Modification: 14/11/2015
  5446                              <1> 
  5447                              <1> sysmount: ; / mount file system; args special; name
  5448                              <1> 	; 14/11/2015
  5449                              <1> 	; 24/10/2015
  5450                              <1> 	; 13/10/2015
  5451                              <1> 	; 10/07/2015
  5452                              <1> 	; 16/05/2015 (Retro UNIX 386 v1 - Beginning)
  5453                              <1> 	; 09/07/2013 - 04/11/2013 (Retro UNIX 8086 v1)
  5454                              <1> 	;
  5455                              <1> 	; 'sysmount' anounces to the system that a removable 
  5456                              <1> 	; file system has been mounted on a special file.
  5457                              <1> 	; The device number of the special file is obtained via
  5458                              <1> 	; a call to 'getspl'. It is put in the I/O queue entry for
  5459                              <1> 	; dismountable file system (sb1) and the I/O queue entry is
  5460                              <1> 	; set up to read (bit 10 is set). 'ppoke' is then called to
  5461                              <1> 	; to read file system into core, i.e. the first block on the
  5462                              <1> 	; mountable file system is read in. This block is super block
  5463                              <1> 	; for the file system. This call is super user restricted.	
  5464                              <1> 	;
  5465                              <1> 	; Calling sequence:
  5466                              <1> 	;	sysmount; special; name
  5467                              <1> 	; Arguments:
  5468                              <1> 	;	special - pointer to name of special file (device)
  5469                              <1> 	;	name -  pointer to name of the root directory of the
  5470                              <1> 	;		newly mounted file system. 'name' should 
  5471                              <1> 	;		always be a directory.
  5472                              <1> 	; Inputs: - 
  5473                              <1> 	; Outputs: -
  5474                              <1> 	; ...............................................................
  5475                              <1> 	;				
  5476                              <1> 	; Retro UNIX 8086 v1 modification: 
  5477                              <1> 	;       'sysmount' system call has two arguments; so,
  5478                              <1> 	;	* 1st argument, special is pointed to by BX register
  5479                              <1> 	;	* 2nd argument, name is in CX register
  5480                              <1> 	;
  5481                              <1> 	;	NOTE: Device numbers, names and related procedures are 
  5482                              <1> 	;	       already modified for IBM PC compatibility and 
  5483                              <1> 	;	       Retro UNIX 8086 v1 device configuration.	
  5484                              <1> 	
  5485                              <1> 	;call	arg2
  5486                              <1> 		; jsr r0,arg2 / get arguments special and name
  5487 0000CF30 891D[A0300100]      <1> 	mov	[u.namep], ebx
  5488 0000CF36 51                  <1> 	push	ecx ; directory name
  5489 0000CF37 66833D[70300100]00  <1> 	cmp	word [mnti], 0
  5490                              <1> 		; tst mnti / is the i-number of the cross device file
  5491                              <1> 			 ; / zero?
  5492                              <1> 	;ja	error
  5493                              <1>         	; bne errora / no, error
  5494 0000CF3F 0F87E9000000        <1> 	ja	sysmnt_err0
  5495                              <1> 	;
  5496 0000CF45 E8CC000000          <1> 	call	getspl
  5497                              <1> 		; jsr r0,getspl / get special files device number in r1
  5498                              <1> 	; 13/10/2015
  5499 0000CF4A 0FB7D8              <1> 	movzx	ebx, ax ; ; Retro UNIX 8086 v1 device number (0 to 5)
  5500 0000CF4D F683[44ED0000]80    <1>         test    byte [ebx+drv.status], 80h ; 24/10/2015 
  5501 0000CF54 750F                <1> 	jnz	short sysmnt_1
  5502                              <1> sysmnt_err1:
  5503 0000CF56 C705[DD300100]0F00- <1>         mov     dword [u.error], ERR_DRV_NOT_RDY ; drive not ready !
  5503 0000CF5E 0000                <1>
  5504 0000CF60 E99BE6FFFF          <1> 	jmp	error
  5505                              <1> sysmnt_1:
  5506 0000CF65 8F05[A0300100]      <1> 	pop	dword [u.namep]
  5507                              <1>         	; mov (sp)+,u.namep / put the name of file to be placed
  5508                              <1> 				  ; / on the device
  5509                              <1> 	; 14/11/2015
  5510 0000CF6B 53                  <1> 	push	ebx ; 13/10/2015
  5511                              <1> 		; mov r1,-(sp) / save the device number
  5512                              <1>         ;
  5513 0000CF6C E859FBFFFF          <1> 	call	namei
  5514                              <1> 	;or	ax, ax ; Retro UNIX 8086 v1 modification !
  5515                              <1> 		       ; ax = 0 -> file not found 	
  5516                              <1> 	;jz	error
  5517                              <1> 	;jc	error
  5518                              <1> 		; jsr r0,namei / get the i-number of the file
  5519                              <1>                	; br errora
  5520 0000CF71 730F                <1> 	jnc	short sysmnt_2
  5521                              <1> sysmnt_err2:
  5522 0000CF73 C705[DD300100]0C00- <1>         mov     dword [u.error], ERR_FILE_NOT_FOUND ; drive not ready !
  5522 0000CF7B 0000                <1>
  5523 0000CF7D E97EE6FFFF          <1> 	jmp	error
  5524                              <1> sysmnt_2:	
  5525 0000CF82 66A3[70300100]      <1> 	mov	[mnti], ax
  5526                              <1>         	; mov r1,mnti / put it in mnti
  5527                              <1> ;	mov	ebx, sb1 ; super block buffer (of mounted disk)
  5528                              <1> sysmnt_3: ;1:
  5529                              <1>         ;cmp	byte [ebx+1], 0
  5530                              <1> 		; tstb sb1+1 / is 15th bit of I/O queue entry for
  5531                              <1> 			   ; / dismountable device set?
  5532                              <1>         ;jna	short sysmnt_4		
  5533                              <1> 		; bne 1b / (inhibit bit) yes, skip writing
  5534                              <1> 	;call	idle 	; (wait for hardware interrupt)
  5535                              <1> 	;jmp	short sysmnt_3
  5536                              <1> sysmnt_4:   
  5537 0000CF88 58                  <1> 	pop	eax ; Retro UNIX 8086 v1 device number/ID (0 to 5)     
  5538 0000CF89 A2[6D300100]        <1> 	mov	[mdev], al
  5539                              <1> 		; mov  (sp),mntd / no, put the device number in mntd
  5540 0000CF8E 8803                <1> 	mov	[ebx], al
  5541                              <1>         	; movb (sp),sb1 / put the device number in the lower byte
  5542                              <1> 			      ; / of the I/O queue entry
  5543                              <1> 	;mov	byte [cdev], 1 ; mounted device/drive
  5544                              <1>         	; mov (sp)+,cdev / put device number in cdev
  5545 0000CF90 66810B0004          <1>         or	word [ebx], 400h ; Bit 10, 'read' flag/bit
  5546                              <1> 		; bis $2000,sb1 / set the read bit
  5547                              <1> 	; Retro UNIX 386 v1 modification : 
  5548                              <1> 	;	32 bit block number at buffer header offset 4
  5549 0000CF95 C7430401000000      <1> 	mov	dword [ebx+4], 1 ; physical block number = 1
  5550 0000CF9C E8450A0000          <1> 	call 	diskio
  5551 0000CFA1 731C                <1> 	jnc	short sysmnt_5
  5552 0000CFA3 31C0                <1> 	xor 	eax, eax
  5553 0000CFA5 66A3[70300100]      <1> 	mov	[mnti], ax ; 0
  5554 0000CFAB A2[6D300100]        <1> 	mov	[mdev], al ; 0
  5555                              <1> 	;mov	[cdev], al ; 0
  5556                              <1> sysmnt_invd:
  5557                              <1> 	; 14/11/2015
  5558 0000CFB0 FEC8                <1> 	dec 	al
  5559 0000CFB2 8903                <1> 	mov	[ebx], eax ; 000000FFh
  5560 0000CFB4 FEC0                <1> 	inc	al
  5561 0000CFB6 48                  <1> 	dec	eax
  5562 0000CFB7 894304              <1> 	mov	[ebx+4], eax ; 0FFFFFFFFh
  5563 0000CFBA E941E6FFFF          <1> 	jmp	error
  5564                              <1> sysmnt_5:
  5565                              <1> 	; 14/11/2015 (Retro UNIX 386 v1 modification)
  5566                              <1> 	; (Following check is needed to prevent mounting an
  5567                              <1> 	; in valid valid file system (in valid super block).
  5568                              <1> 	; 
  5569 0000CFBF 0FB603              <1> 	movzx	eax, byte [ebx] ; device number
  5570 0000CFC2 C0E002              <1> 	shl	al, 2 ; 4*index
  5571 0000CFC5 8B88[28ED0000]      <1> 	mov	ecx, [eax+drv.size] ; volume (fs) size
  5572 0000CFCB C1E103              <1> 	shl 	ecx, 3
  5573 0000CFCE 0FB715[413B0100]    <1> 	movzx	edx, word [sb1+4] ; the 1st data word
  5574 0000CFD5 39D1                <1> 	cmp	ecx, edx ; compare free map bits and volume size
  5575                              <1> 			 ; (in sectors), if they are not equal
  5576                              <1> 			 ; the disk to be mounted is an...	
  5577 0000CFD7 75D7                <1> 	jne	short sysmnt_invd ; invalid disk !
  5578                              <1> 			 ; (which has not got a valid super block)
  5579                              <1> 	;
  5580 0000CFD9 C6430100            <1> 	mov	byte [ebx+1], 0
  5581                              <1> 	       	; jsr r0,ppoke / read in entire file system
  5582                              <1> ;sysmnt_6: ;1:
  5583                              <1> 	;;cmp	byte [sb1+1], 0
  5584                              <1> 		; tstb   sb1+1 / done reading?
  5585                              <1>    	;;jna	sysret
  5586                              <1> 	;;call	idle ; (wait for hardware interrupt)
  5587                              <1> 	;;jmp	short sysmnt_6
  5588                              <1> 		;bne 1b / no, wait
  5589                              <1>         	;br sysreta / yes
  5590 0000CFDD E93EE6FFFF          <1> 	jmp	sysret
  5591                              <1> 
  5592                              <1> sysumount: ; / special dismount file system
  5593                              <1> 	; 16/05/2015 (Retro UNIX 386 v1 - Beginning)
  5594                              <1> 	; 09/07/2013 - 04/11/2013 (Retro UNIX 8086 v1)
  5595                              <1> 	;
  5596                              <1> 	; 04/11/2013
  5597                              <1> 	; 09/07/2013
  5598                              <1> 	; 'sysumount' anounces to the system that the special file, 
  5599                              <1> 	; indicated as an argument is no longer contain a removable
  5600                              <1> 	; file system. 'getspl' gets the device number of the special
  5601                              <1> 	; file. If no file system was mounted on that device an error
  5602                              <1> 	; occurs. 'mntd' and 'mnti' are cleared and control is passed
  5603                              <1> 	; to 'sysret'.
  5604                              <1> 	;
  5605                              <1> 	; Calling sequence:
  5606                              <1> 	;	sysmount; special
  5607                              <1> 	; Arguments:
  5608                              <1> 	;	special - special file to dismount (device)
  5609                              <1> 	;
  5610                              <1> 	; Inputs: - 
  5611                              <1> 	; Outputs: -
  5612                              <1> 	; ...............................................................
  5613                              <1> 	;				
  5614                              <1> 	; Retro UNIX 8086 v1 modification: 
  5615                              <1> 	;       'sysumount' system call has one argument; so,
  5616                              <1> 	;	* Single argument, special is pointed to by BX register
  5617                              <1> 	;
  5618                              <1> 	
  5619                              <1> 	;mov 	ax, 1 ; one/single argument, put argument in BX	
  5620                              <1> 	;call	arg
  5621                              <1> 		; jsr r0,arg; u.namep / point u.namep to special
  5622 0000CFE2 891D[A0300100]      <1>         mov	[u.namep], ebx
  5623 0000CFE8 E829000000          <1> 	call	getspl
  5624                              <1> 		; jsr r0,getspl / get the device number in r1
  5625 0000CFED 3A05[6D300100]      <1> 	cmp	al, [mdev]
  5626                              <1> 		; cmp r1,mntd / is it equal to the last device mounted?
  5627 0000CFF3 7539                <1> 	jne	short sysmnt_err0 ; 'permission denied !' error
  5628                              <1> 	;jne	error
  5629                              <1>         	; bne errora / no error
  5630 0000CFF5 30C0                <1> 	xor	al, al ; ah = 0
  5631                              <1> sysumnt_0: ;1:
  5632 0000CFF7 3805[3E3B0100]      <1>      	cmp 	[sb1+1], al ; 0
  5633                              <1> 		; tstb sb1+1 / yes, is the device still doing I/O 
  5634                              <1> 			   ; / (inhibit bit set)?
  5635 0000CFFD 7607                <1> 	jna	short sysumnt_1		
  5636                              <1> 		; bne 1b / yes, wait
  5637 0000CFFF E8E3090000          <1> 	call	idle ; (wait for hardware interrupt)
  5638 0000D004 EBF1                <1> 	jmp	short sysumnt_0
  5639                              <1> sysumnt_1:        
  5640 0000D006 A2[6D300100]        <1> 	mov	[mdev], al
  5641                              <1> 	     	; clr mntd / no, clear these
  5642 0000D00B 66A3[70300100]      <1>    	mov	[mnti], ax
  5643                              <1>         	; clr mnti
  5644 0000D011 E90AE6FFFF          <1>         jmp	sysret
  5645                              <1> 		; br sysreta / return
  5646                              <1> 
  5647                              <1> getspl: ; / get device number from a special file name
  5648 0000D016 E8AFFAFFFF          <1> 	call	namei
  5649                              <1> 	;or	ax, ax ; Retro UNIX 8086 v1 modification !
  5650                              <1> 		       ; ax = 0 -> file not found 	
  5651 0000D01B 0F8252FFFFFF        <1>         jc      sysmnt_err2 ; 'file not found !' error
  5652                              <1> 	;jz	error
  5653                              <1> 	;jc	error
  5654                              <1> 		; jsr r0,namei / get the i-number of the special file
  5655                              <1>                 ; br errora / no such file
  5656 0000D021 6683E803            <1>         sub	ax, 3 ; Retro UNIX 8086 v1 modification !
  5657                              <1> 		      ;	i-number-3, 0 = fd0, 5 = hd3 
  5658                              <1> 		; sub $4,r1 / i-number-4 rk=1,tap=2+n
  5659 0000D025 7207                <1>         jc	short sysmnt_err0 ; 'permission denied !' error
  5660                              <1> 	;jc	error
  5661                              <1> 		; ble errora / less than 0?  yes, error
  5662 0000D027 6683F805            <1>         cmp	ax, 5 ;
  5663                              <1> 		; cmp  r1,$9. / greater than 9  tap 7
  5664 0000D02B 7701                <1> 	ja	short sysmnt_err0 ; 'permission denied !' error
  5665                              <1> 	;ja	error
  5666                              <1>         	; bgt errora / yes, error
  5667                              <1>         ; AX = Retro UNIX 8086 v1 Device Number (0 to 5)
  5668                              <1> iopen_retn:
  5669 0000D02D C3                  <1> 	retn
  5670                              <1> 		; rts    r0 / return with device number in r1
  5671                              <1> sysmnt_err0:
  5672 0000D02E C705[DD300100]0B00- <1> 	mov	dword [u.error], ERR_FILE_ACCESS ; permission denied !
  5672 0000D036 0000                <1>
  5673 0000D038 E9C3E5FFFF          <1> 	jmp	error
  5674                              <1> 
  5675                              <1> ; Retro UNIX 386 v1 Kernel (v0.2) - SYS9.INC
  5676                              <1> ; Last Modification: 09/12/2015
  5677                              <1> 
  5678                              <1> syssleep:
  5679                              <1> 	; 29/06/2015 - (Retro UNIX 386 v1)
  5680                              <1> 	; 11/06/2014 - (Retro UNIX 8086 v1)
  5681                              <1> 	;
  5682                              <1> 	; Retro UNIX 8086 v1 feature only
  5683                              <1> 	; (INPUT -> none)
  5684                              <1> 	;
  5685 0000D03D 0FB61D[D7300100]    <1> 	movzx	ebx, byte [u.uno] ; process number
  5686 0000D044 8AA3[CB2D0100]      <1> 	mov	ah, [ebx+p.ttyc-1] ; current/console tty
  5687 0000D04A E899090000          <1> 	call	sleep
  5688 0000D04F E9CCE5FFFF          <1> 	jmp	sysret
  5689                              <1> 
  5690                              <1> _vp_clr:
  5691                              <1> 	; Reset/Clear Video Page
  5692                              <1> 	;
  5693                              <1> 	; 30/06/2015 - (Retro UNIX 386 v1)
  5694                              <1> 	; 21/05/2013 - 30/10/2013(Retro UNIX 8086 v1) (U0.ASM)
  5695                              <1> 	;
  5696                              <1> 	; Retro UNIX 8086 v1 feature only !
  5697                              <1> 	;
  5698                              <1> 	; INPUTS -> 
  5699                              <1> 	;   BH = video page number	 
  5700                              <1> 	;
  5701                              <1> 	; OUTPUT ->
  5702                              <1> 	;   none
  5703                              <1> 	; ((Modified registers: eAX, BH, eCX, eDX, eSI, eDI))
  5704                              <1> 	;
  5705                              <1> 	; 04/12/2013
  5706 0000D054 28C0                <1> 	sub	al, al
  5707                              <1> 	; al = 0 (clear video page)
  5708                              <1> 	; bh = video page ; 13/05/2016
  5709 0000D056 B407                <1> 	mov	ah, 07h
  5710                              <1> 	; ah = 7 (attribute/color)
  5711 0000D058 6631C9              <1> 	xor 	cx, cx ; 0, left upper column (cl) & row (cl)
  5712 0000D05B 66BA4F18            <1> 	mov	dx, 184Fh ; right lower column & row (dl=24, dh=79)
  5713 0000D05F E81048FFFF          <1> 	call	_scroll_up
  5714                              <1> 	; bh = video page
  5715 0000D064 6631D2              <1> 	xor	dx, dx ; 0 (cursor position) 
  5716 0000D067 E9464BFFFF          <1> 	jmp 	_set_cpos
  5717                              <1> 
  5718                              <1> sysmsg:
  5719                              <1> 	; 13/05/2016
  5720                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
  5721                              <1> 	; 01/07/2015 - 11/11/2015 (Retro UNIX 386 v1)
  5722                              <1> 	; Print user-application message on user's console tty
  5723                              <1> 	;
  5724                              <1> 	; Input -> EBX = Message address
  5725                              <1> 	;	   ECX = Message length (max. 255)
  5726                              <1> 	;	   DL = Color (IBM PC Rombios color attributes)
  5727                              <1> 	;
  5728 0000D06C 81F9FF000000        <1> 	cmp	ecx, MAX_MSG_LEN ; 255
  5729 0000D072 0F87A8E5FFFF        <1> 	ja	sysret ; nothing to do with big message size
  5730 0000D078 08C9                <1> 	or	cl, cl
  5731 0000D07A 0F84A0E5FFFF        <1> 	jz	sysret
  5732 0000D080 20D2                <1> 	and	dl, dl
  5733 0000D082 7502                <1> 	jnz	short sysmsg0
  5734 0000D084 B207                <1> 	mov	dl, 07h ; default color
  5735                              <1> 		; (black background, light gray character) 
  5736                              <1> sysmsg0:
  5737 0000D086 891D[A8300100]      <1> 	mov	[u.base], ebx
  5738 0000D08C 8815[D71F0100]      <1> 	mov	[ccolor], dl ; color attributes
  5739 0000D092 89E5                <1> 	mov	ebp, esp
  5740 0000D094 31DB                <1> 	xor	ebx, ebx ; 0
  5741 0000D096 891D[B0300100]      <1> 	mov	[u.nread], ebx ; 0
  5742                              <1> 	;
  5743 0000D09C 381D[EF300100]      <1> 	cmp	[u.kcall], bl ; 0
  5744 0000D0A2 7769                <1> 	ja	short sysmsgk ; Temporary (01/07/2015)
  5745                              <1> 	;
  5746 0000D0A4 890D[AC300100]      <1> 	mov	[u.count], ecx
  5747 0000D0AA 41                  <1> 	inc	ecx ; + 00h ; ASCIIZ
  5748 0000D0AB 29CC                <1> 	sub	esp, ecx
  5749 0000D0AD 89E7                <1> 	mov	edi, esp
  5750 0000D0AF 89E6                <1> 	mov	esi, esp
  5751 0000D0B1 66891D[ED300100]    <1> 	mov	[u.pcount], bx ; reset page (phy. addr.) counter
  5752                              <1> 	; 11/11/2015
  5753 0000D0B8 8A25[B8300100]      <1> 	mov 	ah, [u.ttyp] ; recent open tty
  5754                              <1> 	; 0 = none
  5755 0000D0BE FECC                <1> 	dec	ah
  5756 0000D0C0 790C                <1> 	jns	short sysmsg1 
  5757 0000D0C2 8A1D[D7300100]      <1> 	mov	bl, [u.uno] ; process number	
  5758 0000D0C8 8AA3[CB2D0100]      <1> 	mov	ah, [ebx+p.ttyc-1] ; user's (process's) console tty
  5759                              <1> sysmsg1:
  5760 0000D0CE 8825[DC300100]      <1> 	mov	[u.ttyn], ah
  5761                              <1> sysmsg2:
  5762 0000D0D4 E817080000          <1> 	call	cpass
  5763 0000D0D9 7416                <1> 	jz	short sysmsg5
  5764 0000D0DB AA                  <1> 	stosb
  5765 0000D0DC 20C0                <1> 	and	al, al
  5766 0000D0DE 75F4                <1> 	jnz	short sysmsg2
  5767                              <1> sysmsg3:
  5768 0000D0E0 80FC07              <1> 	cmp	ah, 7 ; tty number
  5769 0000D0E3 7711                <1> 	ja	short sysmsg6 ; serial port
  5770 0000D0E5 E83E000000          <1> 	call	print_cmsg
  5771                              <1> sysmsg4:
  5772 0000D0EA 89EC                <1> 	mov	esp, ebp	
  5773 0000D0EC E92FE5FFFF          <1> 	jmp	sysret
  5774                              <1> sysmsg5:
  5775 0000D0F1 C60700              <1> 	mov	byte [edi], 0
  5776 0000D0F4 EBEA                <1> 	jmp	short sysmsg3
  5777                              <1> sysmsg6:
  5778 0000D0F6 8A06                <1> 	mov	al, [esi]
  5779 0000D0F8 E8E3080000          <1> 	call	sndc
  5780 0000D0FD 72EB                <1> 	jc	short sysmsg4
  5781 0000D0FF 803E00              <1> 	cmp	byte [esi], 0  ; 0 is stop character
  5782 0000D102 76E6                <1> 	jna	short sysmsg4
  5783 0000D104 46                  <1> 	inc 	esi
  5784 0000D105 8A25[DC300100]      <1> 	mov	ah, [u.ttyn]
  5785 0000D10B EBE9                <1> 	jmp	short sysmsg6
  5786                              <1> 
  5787                              <1> sysmsgk: ; Temporary (01/07/2015)
  5788                              <1> 	; The message has been sent by Kernel (ASCIIZ string)
  5789                              <1> 	; (ECX -character count- will not be considered)
  5790 0000D10D 8B35[A8300100]      <1> 	mov	esi, [u.base]
  5791 0000D113 8A25[D61F0100]      <1> 	mov	ah, [ptty] ; present/current screen (video page)
  5792 0000D119 8825[DC300100]      <1> 	mov	[u.ttyn], ah
  5793 0000D11F C605[EF300100]00    <1> 	mov	byte [u.kcall], 0
  5794 0000D126 EBB8                <1> 	jmp	short sysmsg3
  5795                              <1> 	
  5796                              <1> print_cmsg: 
  5797                              <1> 	; 13/05/2016 - TRDOS 386 (TRDOS v2.0)
  5798                              <1> 	; 01/07/2015 (Retro UNIX 386 v1)
  5799                              <1> 	;
  5800                              <1> 	; print message (on user's console tty) 
  5801                              <1> 	;	with requested color
  5802                              <1> 	;
  5803                              <1> 	; INPUTS:
  5804                              <1> 	;	esi = message address
  5805                              <1> 	;	[u.ttyn] = tty number (0 to 7)
  5806                              <1> 	;	[ccolor] = color attributes (IBM PC BIOS colors)
  5807                              <1> 	
  5808 0000D128 8A3D[DC300100]      <1> 	mov	bh, [u.ttyn]
  5809                              <1> 	;mov	bh, ah
  5810                              <1> 
  5811 0000D12E AC                  <1> 	lodsb
  5812                              <1> pcmsg1:
  5813 0000D12F 56                  <1> 	push 	esi
  5814 0000D130 8A1D[D71F0100]      <1> 	mov	bl, [ccolor]
  5815                              <1> 	;mov	bh, [u.ttyn]
  5816 0000D136 E8E149FFFF          <1> 	call 	_write_tty
  5817 0000D13B 5E                  <1> 	pop	esi
  5818 0000D13C AC                  <1> 	lodsb
  5819 0000D13D 20C0                <1> 	and 	al, al  ; 0
  5820 0000D13F 75EE                <1> 	jnz 	short pcmsg1
  5821 0000D141 C3                  <1> 	retn
  5822                              <1> 
  5823                              <1> sysgeterr:
  5824                              <1> 	; 09/12/2015
  5825                              <1> 	; 21/09/2015 - (Retro UNIX 386 v1 feature only!)
  5826                              <1> 	; Get last error number or page fault count
  5827                              <1> 	; (for debugging)
  5828                              <1> 	;
  5829                              <1> 	; Input -> EBX = return type
  5830                              <1> 	;	   0 = last error code (which is in 'u.error')	
  5831                              <1> 	;	   FFFFFFFFh = page fault count for running process
  5832                              <1> 	;	   FFFFFFFEh = total page fault count
  5833                              <1> 	;	   1 .. FFFFFFFDh = undefined 
  5834                              <1> 	;
  5835                              <1> 	; Output -> EAX = last error number or page fault count
  5836                              <1> 	;	   (depending on EBX input)
  5837                              <1> 	; 	
  5838 0000D142 21DB                <1> 	and 	ebx, ebx
  5839 0000D144 750B                <1> 	jnz	short glerr_2
  5840                              <1> glerr_0:
  5841 0000D146 A1[DD300100]        <1> 	mov	eax, [u.error]
  5842                              <1> glerr_1:
  5843 0000D14B A3[88300100]        <1> 	mov	[u.r0], eax
  5844 0000D150 C3                  <1>  	retn
  5845                              <1> glerr_2:
  5846 0000D151 43                  <1> 	inc	ebx ; FFFFFFFFh -> 0, FFFFFFFEh -> FFFFFFFFh
  5847 0000D152 74FD                <1> 	jz	short glerr_2 ; page fault count for process
  5848 0000D154 43                  <1> 	inc	ebx ; FFFFFFFFh -> 0	
  5849 0000D155 75EF                <1> 	jnz	short glerr_0
  5850 0000D157 A1[6C3E0100]        <1> 	mov	eax, [PF_Count] ; total page fault count
  5851 0000D15C EBED                <1>         jmp     short glerr_1
  5852                              <1> glerr_3:
  5853 0000D15E A1[F1300100]        <1> 	mov 	eax, [u.pfcount]
  5854 0000D163 EBE6                <1> 	jmp	short glerr_1
  5855                              <1> 
  5856                              <1> load_and_run_file:
  5857                              <1> 	; 06/06/2016
  5858                              <1> 	; 06/05/2016
  5859                              <1> 	; 03/05/2016
  5860                              <1> 	; 02/05/2016
  5861                              <1> 	; 24/04/2016
  5862                              <1> 	; 23/04/2016 (TRDOS 386 = TRDOS v2.0)
  5863                              <1> 	; 23/10/2015 (Retro UNIX 386 v1, 'sysexec')
  5864                              <1> 	; 23/06/2015 (Retro UNIX 386 v1 - Beginning)
  5865                              <1> 	; 03/06/2013 - 06/12/2013 (Retro UNIX 8086 v1)
  5866                              <1> 	; EAX = First Cluster number
  5867                              <1> 	; EDX = File Size
  5868                              <1> 	; ESI = Argument list address
  5869                              <1> 	; [argc] = argument count
  5870                              <1> 	; [u.nread] = argument list length
  5871                              <1> 	; [esp] = return address to the caller (*)
  5872                              <1> 	;
  5873 0000D165 8935[08310100]      <1> 	mov	[argv], esi
  5874 0000D16B 8915[11310100]      <1> 	mov	[i.size], edx
  5875 0000D171 A3[0D310100]        <1> 	mov	[ii], eax
  5876                              <1> 
  5877                              <1> 	; 06/05/2016
  5878                              <1> 	; Set 'sysexit' return order to MainProg
  5879                              <1> 	;
  5880 0000D176 58                  <1> 	pop	eax ; * 'loc_load_and_run_file_8:' address
  5881 0000D177 8B25[441F0100]      <1> 	mov	esp, [tss.esp0]
  5882                              <1> 	;
  5883                              <1> 	; 'loc_load_run_file_8' address has 
  5884                              <1> 	; 'jmp loc_file_rw_restore_retn' instruction
  5885                              <1> 	; 'loc_file_rw_restore_retn:' will return to
  5886                              <1> 	; [mainprog_return_addr] 
  5887                              <1> 	; just after 'call command_interpreter'
  5888                              <1> 	;
  5889 0000D17D 68[10550000]        <1> 	push	_end_of_mainprog ; we must not return to here !
  5890 0000D182 FF35[1C2D0100]      <1> 	push	dword [mainprog_return_addr]
  5891 0000D188 89E5                <1> 	mov	ebp, esp ; **
  5892                              <1> 	;	
  5893 0000D18A 9C                  <1> 	pushfd  ; EFLAGS      ; IRETD
  5894 0000D18B 6A08                <1> 	push	KCODE ; cs    ; IRETD
  5895 0000D18D 50                  <1> 	push	eax ; * (eip) ; IRETD
  5896 0000D18E 8925[80300100]      <1> 	mov	[u.sp], esp
  5897 0000D194 1E                  <1> 	push	ds
  5898 0000D195 06                  <1> 	push	es
  5899 0000D196 0FA0                <1> 	push	fs
  5900 0000D198 0FA8                <1> 	push	gs	
  5901 0000D19A 60                  <1> 	pushad
  5902 0000D19B 68[20B60000]        <1> 	push	sysret
  5903 0000D1A0 8925[84300100]      <1> 	mov	[u.usp], esp
  5904                              <1> 	;
  5905 0000D1A6 E858060000          <1> 	call	wswap ; Save MainProg (process 1) 'u' structure
  5906                              <1> 		      ; and registers for return (from program)	
  5907 0000D1AB 89EC                <1> 	mov	esp, ebp ; **
  5908 0000D1AD 50                  <1> 	push	eax  ; * 'loc_load_and_run_file_8:' address
  5909                              <1> 	;
  5910                              <1> 	;;; 02/05/2016
  5911                              <1> 	;;; Create a new process (parent: MainProg)	
  5912 0000D1AE 31F6                <1> 	xor 	esi, esi
  5913                              <1> cnpm_1: ; search p.stat table for unused process number
  5914 0000D1B0 46                  <1> 	inc	esi
  5915 0000D1B1 80BE[FB2D0100]00    <1> 	cmp	byte [esi+p.stat-1], 0 ; SFREE
  5916                              <1> 				; is process active, unused, dead
  5917 0000D1B8 760B                <1> 	jna	short cnpm_2	; it's unused so branch
  5918 0000D1BA 6683FE10            <1> 	cmp	si, nproc 	; all processes checked
  5919 0000D1BE 72F0                <1> 	jb	short cnpm_1    ; no, branch back
  5920 0000D1C0 E9C183FFFF          <1> 	jmp	panic 
  5921                              <1> cnpm_2:
  5922 0000D1C5 A1[E1300100]        <1> 	mov	eax, [u.pgdir] ; page directory of MainProg
  5923 0000D1CA A3[E5300100]        <1> 	mov	[u.ppgdir], eax ; parent's page directory
  5924 0000D1CF E8EE73FFFF          <1> 	call	allocate_page
  5925 0000D1D4 0F82AC83FFFF        <1> 	jc	panic
  5926                              <1> 	; EAX = UPAGE (user structure page) address
  5927 0000D1DA A3[D8300100]        <1> 	mov	[u.upage], eax ; memory page for 'user' struct (child)
  5928 0000D1DF 89F7                <1> 	mov	edi, esi
  5929 0000D1E1 66C1E702            <1> 	shl	di, 2
  5930 0000D1E5 8987[082E0100]      <1> 	mov	[edi+p.upage-4], eax ; memory page for 'user' struct
  5931 0000D1EB E84C74FFFF          <1> 	call	clear_page ; 03/05/2016
  5932                              <1> 	;movzx	eax, byte [p.ttyc] ; console tty (for MainProg)
  5933 0000D1F0 6629C0              <1> 	sub	ax, ax ; 0
  5934 0000D1F3 668986[CB2D0100]    <1> 	mov     [esi+p.ttyc-1], ax ; al - set child's console tty
  5935                              <1> 				   ; ah - reset child's wait channel	
  5936 0000D1FA 89F0                <1> 	mov	eax, esi
  5937 0000D1FC A2[D7300100]        <1> 	mov	[u.uno], al ; child process number
  5938 0000D201 FE86[FB2D0100]      <1>         inc     byte [esi+p.stat-1] ; 1, SRUN
  5939 0000D207 66D1E6              <1> 	shl	si, 1 ; multiply si by 2 to get index into p.pid table
  5940 0000D20A 66FF05[72300100]    <1> 	inc	word [mpid] ; increment m.pid; get a new process name
  5941 0000D211 66A1[72300100]      <1> 	mov	ax, [mpid]
  5942 0000D217 668986[6A2D0100]    <1> 	mov	[esi+p.pid-2], ax ; put new process name 
  5943                              <1> 				  ; in child process' name slot
  5944                              <1> 	;mov	ax, [p.pid]  ; get process name of MainProg
  5945 0000D21E 66B80100            <1> 	mov	ax, 1
  5946 0000D222 668986[8A2D0100]    <1> 	mov	[esi+p.ppid-2], ax ; put parent process name 
  5947                              <1> 			           ; in parent process slot for child
  5948 0000D229 6648                <1> 	dec	ax ; 0
  5949 0000D22B 66A3[B8300100]      <1> 	mov 	[u.ttyp], ax ; 0
  5950                              <1> 	;;;
  5951 0000D231 A1[0D310100]        <1> 	mov 	eax,  [ii]
  5952                              <1> 	; Retro UNIX 386 v1, 'sysexec' (u2.s)
  5953 0000D236 E89F070000          <1> 	call	iopen
  5954                              <1> 	; 06/06/2016
  5955 0000D23B C605[CB300100]01    <1> 	mov	byte [u.pri], 1 ; normal priority
  5956                              <1> 	;
  5957 0000D242 EB0A                <1> 	jmp	short sysexec_7 ; 02/05/2016
  5958                              <1> 
  5959                              <1> sysexec_6:
  5960                              <1> 	;;02/05/2016
  5961                              <1> 	; 23/04/2016
  5962                              <1> 	; 18/10/2015 ('sysexec_6')
  5963                              <1> 	; 23/06/2015
  5964                              <1> 	;;mov	eax, [u.pgdir] ; parent's page directory
  5965                              <1> 	;;cmp 	eax, [k_page_dir] ; TRDOS MainProg ? 
  5966                              <1> 	;;je	short sysexec_7
  5967 0000D244 A1[E1300100]        <1> 	mov	eax, [u.pgdir] ; physical address of page directory
  5968 0000D249 E8AD74FFFF          <1> 	call	deallocate_page_dir
  5969                              <1> sysexec_7:
  5970 0000D24E E8DD73FFFF          <1> 	call	make_page_dir
  5971 0000D253 0F822D83FFFF        <1> 	jc	panic  ; allocation error 
  5972                              <1> 		       ; after a deallocation would be nonsence !?
  5973                              <1> 	; 24/07/2015
  5974                              <1> 	; map kernel pages (1st 4MB) to PDE 0
  5975                              <1> 	;     of the user's page directory
  5976                              <1> 	;     (It is needed for interrupts!)
  5977                              <1> 	; 18/10/2015
  5978 0000D259 8B15[A81F0100]      <1> 	mov	edx, [k_page_dir] ; Kernel's page directory
  5979 0000D25F 8B02                <1> 	mov	eax, [edx] ; physical address of
  5980                              <1> 			   ; kernel's first page table (1st 4 MB)
  5981                              <1> 			   ; (PDE 0 of kernel's page directory)
  5982 0000D261 8B15[E1300100]      <1> 	mov 	edx, [u.pgdir]
  5983 0000D267 8902                <1> 	mov	[edx], eax ; PDE 0 (1st 4MB)
  5984                              <1> 	;
  5985                              <1> 	; 20/07/2015
  5986 0000D269 BB00004000          <1> 	mov	ebx, CORE ; start address = 0 (virtual) + CORE
  5987                              <1> 	; 18/10/2015
  5988 0000D26E BE[F8300100]        <1> 	mov	esi, pcore ; physical start address
  5989                              <1> sysexec_8:	
  5990 0000D273 B907000000          <1> 	mov	ecx, PDE_A_USER + PDE_A_WRITE + PDE_A_PRESENT
  5991 0000D278 E8D173FFFF          <1> 	call	make_page_table
  5992 0000D27D 0F820383FFFF        <1> 	jc	panic
  5993                              <1> 	;mov	ecx, PTE_A_USER + PTE_A_WRITE + PTE_A_PRESENT
  5994 0000D283 E8D473FFFF          <1> 	call	make_page ; make new page, clear and set the pte 
  5995 0000D288 0F82F882FFFF        <1> 	jc	panic
  5996                              <1> 	;
  5997 0000D28E 8906                <1> 	mov	[esi], eax ; 24/06/2015
  5998                              <1> 	; ebx = virtual address (24/07/2015)
  5999 0000D290 E86F79FFFF          <1> 	call 	add_to_swap_queue
  6000                              <1> 	; 18/10/2015
  6001 0000D295 81FE[FC300100]      <1> 	cmp	esi, ecore ; user's stack (last) page ?
  6002 0000D29B 740C                <1> 	je	short sysexec_9 ; yes
  6003 0000D29D BE[FC300100]        <1> 	mov	esi, ecore  ; physical address of the last page 
  6004                              <1> 	; 20/07/2015
  6005 0000D2A2 BB00F0FFFF          <1> 	mov	ebx, (ECORE - PAGE_SIZE) + CORE
  6006                              <1> 	; ebx = virtual end address + segment base address - 4K
  6007 0000D2A7 EBCA                <1>         jmp     short sysexec_8
  6008                              <1> sysexec_9:
  6009                              <1> 	; 24/04/2016
  6010                              <1> 	; 18/10/2015
  6011                              <1> 	; 26/08/2015
  6012                              <1> 	; 25/06/2015
  6013                              <1> 	; move arguments from kernel stack to [ecore]
  6014                              <1> 	; (argument list/line will be copied from kernel stack
  6015                              <1> 	; frame to the last (stack) page of user's core memory)
  6016                              <1> 	; 18/10/2015
  6017 0000D2A9 8B3D[FC300100]      <1> 	mov	edi, [ecore]
  6018 0000D2AF 81C700100000        <1> 	add	edi, PAGE_SIZE
  6019 0000D2B5 0FB705[06310100]    <1> 	movzx	eax, word [argc]
  6020 0000D2BC 09C0                <1> 	or	eax, eax
  6021 0000D2BE 7509                <1> 	jnz	short sysexec_10
  6022 0000D2C0 89FB                <1> 	mov 	ebx, edi
  6023 0000D2C2 83EB04              <1> 	sub	ebx, 4 
  6024 0000D2C5 8903                <1> 	mov	[ebx], eax ; 0
  6025 0000D2C7 EB44                <1> 	jmp 	short sysexec_13
  6026                              <1> sysexec_10:
  6027 0000D2C9 8B0D[B0300100]      <1> 	mov	ecx, [u.nread]
  6028                              <1> 	;mov	esi, TextBuffer
  6029 0000D2CF 8B35[08310100]      <1> 	mov	esi, [argv] ; 24/04/2016 (TRDOS 386  = TRDOS v2.0)
  6030 0000D2D5 29CF                <1> 	sub	edi, ecx ; page end address - argument list length
  6031 0000D2D7 89C2                <1> 	mov	edx, eax
  6032 0000D2D9 FEC2                <1> 	inc	dl ; argument count + 1 for argc value  
  6033 0000D2DB C0E202              <1> 	shl 	dl, 2  ; 4 * (argument count + 1)
  6034 0000D2DE 89FB                <1> 	mov	ebx, edi
  6035 0000D2E0 80E3FC              <1> 	and	bl, 0FCh ; 32 bit (dword) alignment
  6036 0000D2E3 29D3                <1> 	sub 	ebx, edx
  6037 0000D2E5 89FA                <1> 	mov	edx, edi
  6038 0000D2E7 F3A4                <1> 	rep	movsb
  6039 0000D2E9 89D6                <1> 	mov 	esi, edx
  6040 0000D2EB 89DF                <1> 	mov 	edi, ebx
  6041 0000D2ED BA00F0BFFF          <1> 	mov	edx, ECORE - PAGE_SIZE ; virtual addr. of the last page
  6042 0000D2F2 2B15[FC300100]      <1> 	sub 	edx, [ecore] ; difference (virtual - physical) 
  6043 0000D2F8 AB                  <1> 	stosd	; eax = argument count	
  6044                              <1> sysexec_11:
  6045 0000D2F9 89F0                <1> 	mov	eax, esi
  6046 0000D2FB 01D0                <1> 	add	eax, edx
  6047 0000D2FD AB                  <1> 	stosd  ; eax = virtual address
  6048 0000D2FE FE0D[06310100]      <1> 	dec	byte [argc]
  6049 0000D304 7407                <1> 	jz	short sysexec_13
  6050                              <1> sysexec_12:
  6051 0000D306 AC                  <1> 	lodsb
  6052 0000D307 20C0                <1> 	and	al, al
  6053 0000D309 75FB                <1> 	jnz	short sysexec_12
  6054 0000D30B EBEC                <1> 	jmp	short sysexec_11
  6055                              <1> sysexec_13:
  6056                              <1> 	; 24/04/2016 - TRDOS 386 (TRDOS v2.0)
  6057                              <1> 	; 23/06/2015 - 19/10/2015 (Retro UNIX 386 v1, 'sysexec_13')
  6058                              <1> 	;
  6059                              <1> 	; moving arguments to [ecore] is OK here..
  6060                              <1> 	;
  6061                              <1> 	; ebx = beginning addres of argument list pointers
  6062                              <1> 		;	in user's stack
  6063 0000D30D 2B1D[FC300100]      <1> 	sub 	ebx, [ecore]
  6064 0000D313 81C300F0BFFF        <1> 	add     ebx, (ECORE - PAGE_SIZE)
  6065                              <1> 			; end of core - 4096 (last page)
  6066                              <1> 			; (virtual address)
  6067 0000D319 891D[08310100]      <1> 	mov	[argv], ebx
  6068 0000D31F 891D[B4300100]      <1> 	mov	[u.break], ebx ; available user memory
  6069                              <1> 	;
  6070 0000D325 29C0                <1> 	sub	eax, eax
  6071 0000D327 C705[AC300100]2000- <1> 	mov	dword [u.count], 32 ; Executable file header size
  6071 0000D32F 0000                <1>
  6072 0000D331 C705[98300100]-     <1> 	mov	dword [u.fofp], u.off
  6072 0000D337 [A4300100]          <1>
  6073 0000D33B A3[A4300100]        <1> 	mov	[u.off], eax ; 0
  6074 0000D340 A3[A8300100]        <1> 	mov	[u.base], eax ; 0, start of user's core (virtual)
  6075 0000D345 A1[0D310100]        <1> 	mov	eax, [ii] ; Fist Cluster of the Program (PRG) file
  6076                              <1> 	; EAX = First cluster of the executable file
  6077 0000D34A E831010000          <1> 	call	readi
  6078                              <1> 
  6079 0000D34F 8B0D[B4300100]      <1> 	mov	ecx, [u.break] ; top of user's stack (physical addr.)
  6080 0000D355 890D[AC300100]      <1> 	mov	[u.count], ecx ; save for overrun check
  6081                              <1> 	;
  6082 0000D35B 8B0D[B0300100]      <1> 	mov	ecx, [u.nread]
  6083 0000D361 890D[B4300100]      <1> 	mov	[u.break], ecx ; virtual address (offset from start)
  6084 0000D367 80F920              <1> 	cmp	cl, 32
  6085 0000D36A 7540                <1>         jne     short sysexec_15
  6086                              <1> 	;:
  6087                              <1> 	; Retro UNIX 386 v1 (32 bit) executable file header format
  6088 0000D36C 8B35[F8300100]      <1> 	mov	esi, [pcore] ; start address of user's core memory 
  6089                              <1> 		             ; (phys. start addr. of the exec. file)
  6090 0000D372 AD                  <1> 	lodsd
  6091 0000D373 663DEB1E            <1> 	cmp	ax, 1EEBh ; EBH, 1Eh -> jump to +32
  6092 0000D377 7533                <1> 	jne	short sysexec_15
  6093 0000D379 AD                  <1> 	lodsd
  6094 0000D37A 89C1                <1> 	mov	ecx, eax ; text (code) section size
  6095 0000D37C AD                  <1> 	lodsd
  6096 0000D37D 01C1                <1> 	add	ecx, eax ; + data section size (initialized data)
  6097 0000D37F 89CB                <1> 	mov	ebx, ecx
  6098 0000D381 AD                  <1> 	lodsd	
  6099 0000D382 01C3                <1> 	add	ebx, eax ; + bss section size (for overrun checking)
  6100 0000D384 3B1D[AC300100]      <1> 	cmp	ebx, [u.count]
  6101 0000D38A 7711                <1> 	ja	short sysexec_14  ; program overruns stack !
  6102                              <1> 	;
  6103                              <1> 	; add bss section size to [u.break]
  6104 0000D38C 0105[B4300100]      <1> 	add 	[u.break], eax
  6105                              <1> 	;
  6106 0000D392 83E920              <1> 	sub	ecx, 32  ; header size (already loaded)
  6107                              <1> 	;cmp	ecx, [u.count]
  6108                              <1> 	;jnb	short sysexec_16
  6109 0000D395 890D[AC300100]      <1> 	mov	[u.count], ecx ; required read count
  6110 0000D39B EB29                <1> 	jmp	short sysexec_16
  6111                              <1> sysexec_14:
  6112                              <1> 	; insufficient (out of) memory
  6113 0000D39D C705[DD300100]0100- <1> 	mov	dword [u.error], ERR_MINOR_IM ; 1
  6113 0000D3A5 0000                <1>
  6114 0000D3A7 E954E2FFFF          <1> 	jmp	error
  6115                              <1> sysexec_15:
  6116 0000D3AC 8B15[11310100]      <1>         mov	edx, [i.size] ; file size
  6117 0000D3B2 29CA                <1> 	sub	edx, ecx ; file size - loaded bytes
  6118 0000D3B4 7626                <1> 	jna	short sysexec_17 ; no need to next read
  6119 0000D3B6 01D1                <1> 	add	ecx, edx ; [i.size]
  6120 0000D3B8 3B0D[AC300100]      <1> 	cmp	ecx, [u.count] ; overrun check (!)
  6121 0000D3BE 77DD                <1> 	ja	short sysexec_14
  6122 0000D3C0 8915[AC300100]      <1> 	mov	[u.count], edx
  6123                              <1> sysexec_16:
  6124 0000D3C6 A1[0D310100]        <1> 	mov	eax, [ii] ; first cluster
  6125 0000D3CB E8B0000000          <1> 	call	readi
  6126 0000D3D0 8B0D[B0300100]      <1> 	mov	ecx, [u.nread]
  6127 0000D3D6 010D[B4300100]      <1> 	add	[u.break], ecx
  6128                              <1> sysexec_17:
  6129 0000D3DC A1[0D310100]        <1> 	mov	eax, [ii] ; first cluster
  6130 0000D3E1 E8F5050000          <1> 	call	iclose
  6131 0000D3E6 31C0                <1> 	xor     eax, eax
  6132 0000D3E8 FEC0                <1> 	inc	al
  6133 0000D3EA 66A3[CC300100]      <1> 	mov	[u.intr], ax ; 1 (interrupt/time-out is enabled)
  6134 0000D3F0 66A3[CE300100]      <1> 	mov	[u.quit], ax ; 1 ('crtl+brk' signal is enabled) 
  6135 0000D3F6 833D[E5300100]00    <1>         cmp	dword [u.ppgdir], 0  ; is the caller MainProg (kernel) ?
  6136 0000D3FD 770C                <1> 	ja	short sysexec_18 ; no, the caller is user process
  6137                              <1> 	; If the caller is kernel (MainProg), 'sysexec' will come here
  6138 0000D3FF 8B15[A81F0100]      <1> 	mov	edx, [k_page_dir] ; kernel's page directory
  6139 0000D405 8915[E5300100]      <1> 	mov	[u.ppgdir], edx ; next time 'sysexec' must not come here 
  6140                              <1> sysexec_18:
  6141                              <1> 	; 02/05/2016
  6142                              <1> 	; 24/04/2016 (TRDOS 386 = TRDOS v2.0)
  6143                              <1> 	; 18/10/2015 (Retro UNIX 386 v1)
  6144                              <1> 	; 05/08/2015
  6145                              <1> 	; 29/07/2015
  6146 0000D40B 8B2D[08310100]      <1> 	mov	ebp, [argv] ; user's stack pointer must point to argument
  6147                              <1> 			    ; list pointers (argument count)
  6148 0000D411 FA                  <1> 	cli
  6149 0000D412 8B25[441F0100]      <1>         mov     esp, [tss.esp0]  ; ring 0 (kernel) stack pointer
  6150                              <1> 	;mov   	esp, [u.sp] ; Restore Kernel stack
  6151                              <1> 			    ; for this process	 
  6152                              <1> 	;add	esp, 20 ; --> EIP, CS, EFLAGS, ESP, SS
  6153                              <1> 	;xor	eax, eax ; 0
  6154 0000D418 FEC8                <1> 	dec	al ; eax = 0
  6155 0000D41A 66BA2300            <1> 	mov	dx, UDATA
  6156 0000D41E 6652                <1> 	push	dx  ; user's stack segment
  6157 0000D420 55                  <1> 	push	ebp ; user's stack pointer
  6158                              <1> 		    ; (points to number of arguments)
  6159 0000D421 FB                  <1> 	sti
  6160 0000D422 9C                  <1> 	pushfd	; EFLAGS
  6161                              <1> 		; Set IF for enabling interrupts in user mode	
  6162                              <1> 	;or	dword [esp], 200h 
  6163                              <1> 	;
  6164                              <1> 	;mov	bx, UCODE
  6165                              <1> 	;push	bx ; user's code segment
  6166 0000D423 6A1B                <1> 	push	UCODE
  6167                              <1> 	;push	0
  6168 0000D425 50                  <1> 	push	eax ; EIP (=0) - start address -	
  6169 0000D426 8925[80300100]      <1> 	mov	[u.sp], esp ; 29/07/2015
  6170                              <1> 	; 05/08/2015
  6171                              <1> 	; Remedy of a General Protection Fault during 'iretd' is here !
  6172                              <1> 	; ('push dx' would cause to general protection fault, 
  6173                              <1> 	; after 'pop ds' etc.)
  6174                              <1> 	;
  6175                              <1> 	;; push dx ; ds (UDATA)
  6176                              <1> 	;; push dx ; es (UDATA)
  6177                              <1> 	;; push dx ; fs (UDATA)
  6178                              <1> 	;; push dx ; gs (UDATA)
  6179                              <1> 	;
  6180                              <1> 	; This is a trick to prevent general protection fault
  6181                              <1> 	; during 'iretd' intruction at the end of 'sysrele' (in u1.s):
  6182 0000D42C 8EC2                <1> 	mov 	es, dx ; UDATA
  6183 0000D42E 06                  <1> 	push 	es ; ds (UDATA)
  6184 0000D42F 06                  <1> 	push 	es ; es (UDATA)
  6185 0000D430 06                  <1> 	push 	es ; fs (UDATA)
  6186 0000D431 06                  <1> 	push	es ; gs (UDATA)
  6187 0000D432 66BA1000            <1> 	mov	dx, KDATA
  6188 0000D436 8EC2                <1> 	mov	es, dx
  6189                              <1> 	;
  6190                              <1> 	;; pushad simulation
  6191 0000D438 89E5                <1> 	mov	ebp, esp ; esp before pushad
  6192 0000D43A 50                  <1> 	push	eax ; eax (0)
  6193 0000D43B 50                  <1> 	push	eax ; ecx (0)
  6194 0000D43C 50                  <1> 	push	eax ; edx (0)
  6195 0000D43D 50                  <1> 	push	eax ; ebx (0)
  6196 0000D43E 55                  <1> 	push	ebp ; esp before pushad
  6197 0000D43F 50                  <1> 	push	eax ; ebp (0)
  6198 0000D440 50                  <1> 	push	eax ; esi (0)		
  6199 0000D441 50                  <1> 	push	eax ; edi (0)	
  6200                              <1> 	;
  6201 0000D442 A3[88300100]        <1> 	mov	[u.r0], eax ; eax = 0
  6202 0000D447 8925[84300100]      <1> 	mov	[u.usp], esp
  6203                              <1> 
  6204                              <1> 	; 02/05/2016
  6205 0000D44D FE05[7F300100]      <1> 	inc	byte [sysflg] ; 0FFh -> 0
  6206 0000D453 0FB61D[D7300100]    <1> 	movzx	ebx, byte [u.uno]	
  6207 0000D45A 6683BB[8A2D0100]01  <1> 	cmp	word [ebx+p.ppid-2], 1 ; MainProg
  6208 0000D462 0F87BBE1FFFF        <1> 	ja	sysret0 ; 03/05/2016
  6209 0000D468 68[20B60000]        <1> 	push	sysret ; * 
  6210 0000D46D 8925[84300100]      <1> 	mov	[u.usp], esp
  6211 0000D473 E88B030000          <1> 	call	wswap ; save child process 'u' structure and
  6212                              <1> 		      ; registers
  6213 0000D478 8305[84300100]04    <1> 	add	dword [u.usp], 4 ; 03/05/2016 
  6214                              <1> sysexec_19: ; 02/05/2016
  6215 0000D47F C3                  <1> 	retn ; * 'sysret' ; byte [sysflg] -> 0FFh
  6216                              <1> 
  6217                              <1> readi:
  6218                              <1> 	; 01/05/2016
  6219                              <1> 	; 25/04/2016 - TRDOS 386 (TRDOS v2.0)
  6220                              <1> 	; 20/05/2015 - Retro UNIX 386 v1
  6221                              <1> 	; 11/03/2013 - 31/07/2013 (Retro UNIX 8086 v1)
  6222                              <1> 	;
  6223                              <1> 	; Reads from a file whose the first cluster number in EAX
  6224                              <1> 	; 
  6225                              <1> 	; INPUTS ->
  6226                              <1> 	;    EAX - First cluster number of the file
  6227                              <1> 	;    u.count - byte count user desires
  6228                              <1> 	;    u.base - points to user buffer
  6229                              <1> 	;    u.fofp - points to dword with current file offset
  6230                              <1> 	;    i.size - file size
  6231                              <1> 	; OUTPUTS ->
  6232                              <1> 	;    u.count - cleared
  6233                              <1> 	;    u.nread - accumulates total bytes passed back
  6234                              <1> 	;
  6235                              <1> 	; ((EAX)) input/output
  6236                              <1> 	; (Retro UNIX Prototype : 01/03/2013 - 14/12/2012, UNIXCOPY.ASM)
  6237                              <1>         ; ((Modified registers: edx, ebx, ecx, esi, esi, ebp))  
  6238                              <1> 
  6239 0000D480 31D2                <1> 	xor	edx, edx ; 0
  6240 0000D482 8915[B0300100]      <1> 	mov 	[u.nread], edx ; 0
  6241 0000D488 668915[ED300100]    <1> 	mov	[u.pcount], dx ; 19/05/2015
  6242 0000D48F 3915[AC300100]      <1> 	cmp 	[u.count], edx ; 0
  6243 0000D495 7701                <1> 	ja 	short readi_1
  6244 0000D497 C3                  <1> 	retn
  6245                              <1> readi_1:
  6246                              <1> dskr:
  6247                              <1> 	; 01/05/2016
  6248                              <1> 	; 25/04/2016 - TRDOS 386 (TRDOS v2.0)
  6249                              <1> 	; 24/05/2015 - 12/10/2015 (Retro UNIX 386 v1)
  6250                              <1> 	; 26/04/2013 - 03/08/2013 (Retro UNIX 8086 v1)
  6251                              <1> dskr_0:
  6252 0000D498 8B15[11310100]      <1>         mov	edx, [i.size]
  6253 0000D49E 8B1D[98300100]      <1> 	mov	ebx, [u.fofp]
  6254 0000D4A4 2B13                <1> 	sub	edx, [ebx]
  6255 0000D4A6 7647                <1> 	jna	short dskr_4
  6256                              <1> 	;
  6257 0000D4A8 50                  <1> 	push	eax ; 01/05/2016
  6258 0000D4A9 3B15[AC300100]      <1> 	cmp     edx, [u.count] 
  6259 0000D4AF 7306                <1> 	jnb	short dskr_1
  6260 0000D4B1 8915[AC300100]      <1> 	mov	[u.count], edx
  6261                              <1> dskr_1:
  6262                              <1> 	; EAX = First Cluster
  6263                              <1> 	; [Current_Drv] = Physical drive number 
  6264 0000D4B7 E83B000000          <1> 	call	mget_r
  6265                              <1> 	; NOTE: in 'mget_r', relevant sector will be read in buffer
  6266                              <1> 	; if it not already in buffer !
  6267 0000D4BC BB[1D310100]        <1> 	mov	ebx, readi_buffer
  6268 0000D4C1 803D[EF300100]00    <1> 	cmp	byte [u.kcall], 0 ; the caller is 'namei' sign (=1)
  6269 0000D4C8 770F                <1> 	ja	short dskr_3	  ; zf=0 -> the caller is 'namei'
  6270 0000D4CA 66833D[ED300100]00  <1> 	cmp	word [u.pcount], 0
  6271 0000D4D2 7705                <1> 	ja	short dskr_3
  6272                              <1> dskr_2:
  6273                              <1> 	; [u.base] = virtual address to transfer (as destination address)
  6274 0000D4D4 E89A010000          <1> 	call	trans_addr_w ; translate virtual address to physical (w)
  6275                              <1> dskr_3:
  6276                              <1> 	; EBX (r5) = system (I/O) buffer address -physical-
  6277 0000D4D9 E8F3010000          <1> 	call	sioreg
  6278 0000D4DE 87F7                <1> 	xchg	esi, edi
  6279                              <1> 	; EDI = file (user data) offset
  6280                              <1> 	; ESI = sector (I/O) buffer offset
  6281                              <1> 	; ECX = byte count
  6282 0000D4E0 F3A4                <1> 	rep	movsb
  6283                              <1> 	; eax = remain bytes in buffer
  6284                              <1>         ;       (check if remain bytes in the buffer > [u.pcount])
  6285 0000D4E2 09C0                <1> 	or	eax, eax
  6286 0000D4E4 75EE                <1> 	jnz	short dskr_2 ; (page end before system buffer end!)		
  6287 0000D4E6 58                  <1> 	pop	eax  ; (first cluster number)
  6288 0000D4E7 390D[AC300100]      <1> 	cmp	[u.count], ecx ; 0
  6289 0000D4ED 77A9                <1> 	ja	short dskr_0
  6290                              <1> dskr_4:
  6291 0000D4EF C605[EF300100]00    <1> 	mov	byte [u.kcall], 0
  6292 0000D4F6 C3                  <1> 	retn
  6293                              <1> 
  6294                              <1> mget_r:
  6295                              <1> 	; 29/04/2016
  6296                              <1> 	; 25/04/2016 - TRDOS 386 (TRDOS v2.0)
  6297                              <1> 	; 03/06/2015 (Retro UNIX 386 v1, 'mget', u.5s)
  6298                              <1> 	; 22/03/2013 - 31/07/2013 (Retro UNIX 8086 v1)
  6299                              <1> 	;
  6300                              <1> 	; Get existing or (allocate) a new disk block for file
  6301                              <1> 	; 
  6302                              <1> 	; INPUTS ->
  6303                              <1> 	;    u.fofp = file offset pointer
  6304                              <1> 	;    EAX = First Cluster
  6305                              <1> 	;    (u.off = file offset)
  6306                              <1> 	; OUTPUTS ->
  6307                              <1> 	;    EAX = logical sector number
  6308                              <1> 	;    ESI = Logical Dos Drive Description Table address	
  6309                              <1> 	;
  6310                              <1> 	; Modified registers: EDX, EBX, ECX, ESI, EDI, EBP  
  6311                              <1> 
  6312 0000D4F7 8B35[98300100]      <1> 	mov     esi, [u.fofp]
  6313 0000D4FD 8B1E                <1> 	mov	ebx, [esi] ; u.off
  6314                              <1> 
  6315 0000D4FF 29C9                <1> 	sub	ecx, ecx
  6316 0000D501 8A2D[6E200100]      <1> 	mov	ch, [Current_Drv]
  6317                              <1> 
  6318 0000D507 BE00010900          <1> 	mov	esi, Logical_DOSDisks
  6319 0000D50C 01CE                <1> 	add	esi, ecx
  6320                              <1> 
  6321 0000D50E 380D[DC2C0100]      <1> 	cmp	[readi.valid], cl ; 0
  6322 0000D514 764B                <1> 	jna	short mget_r_0
  6323                              <1> 	
  6324 0000D516 3A2D[DD2C0100]      <1> 	cmp	ch, [readi.drv]
  6325 0000D51C 7543                <1> 	jne	short mget_r_0
  6326                              <1> 
  6327 0000D51E 3B05[F02C0100]      <1> 	cmp	eax, [readi.fclust]
  6328 0000D524 7567                <1> 	jne	short mget_r_3
  6329                              <1> 	
  6330 0000D526 668B0D[E42C0100]    <1> 	mov	cx, [readi.bpc]
  6331 0000D52D 41                  <1> 	inc	ecx ; <= 65536
  6332 0000D52E 29D2                <1> 	sub	edx, edx
  6333 0000D530 F7F1                <1> 	div	ecx
  6334                              <1> 
  6335 0000D532 8B3D[EC2C0100]      <1> 	mov	edi, [readi.c_index] ; cluster index
  6336                              <1> 
  6337 0000D538 39F8                <1> 	cmp	eax, edi
  6338 0000D53A 0F858B000000        <1>         jne     mget_r_5  ; (*)
  6339                              <1> 
  6340                              <1> 	; edx = byte offset in cluster (<= 65535)
  6341 0000D540 668915[E62C0100]    <1> 	mov	[readi.offset], dx
  6342 0000D547 66C1EA09            <1> 	shr	dx, 9 ; / 512
  6343 0000D54B 8815[DF2C0100]      <1> 	mov	[readi.s_index], dl ; sector index in cluster (0 to spc -1)
  6344                              <1> 	
  6345 0000D551 A1[E82C0100]        <1> 	mov	eax, [readi.cluster]
  6346 0000D556 8B15[F42C0100]      <1> 	mov	edx, [readi.fs_index]
  6347 0000D55C E9AF000000          <1>         jmp     mget_r_8
  6348                              <1> 	
  6349                              <1> mget_r_0:
  6350 0000D561 882D[DD2C0100]      <1> 	mov	[readi.drv], ch ; physical drive number
  6351 0000D567 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
  6352 0000D56B 7707                <1> 	ja	short  mget_r_1
  6353 0000D56D 8A4E12              <1> 	mov	cl, [esi+LD_FS_BytesPerSec+1]
  6354 0000D570 D0E9                <1> 	shr	cl, 1 ;  ; 1 for 512 bytes, 4 for 2048 bytes
  6355 0000D572 EB03                <1> 	jmp	short mget_r_2	
  6356                              <1> mget_r_1:
  6357 0000D574 8A4E13              <1> 	mov	cl, [esi+LD_BPB+BPB_SecPerClust]
  6358                              <1> mget_r_2:
  6359 0000D577 880D[DE2C0100]      <1> 	mov	[readi.spc], cl  ; sectors per cluster
  6360                              <1> 	; NOTE: readi bytes per sector value is always 512 ! 
  6361 0000D57D 66C1E109            <1> 	shl	cx, 9 ; * 512
  6362 0000D581 6649                <1> 	dec	cx ; bytes per cluster - 1
  6363 0000D583 66890D[E42C0100]    <1> 	mov	[readi.bpc], cx
  6364 0000D58A 6629C9              <1> 	sub	cx, cx
  6365                              <1> mget_r_3:
  6366 0000D58D A3[F02C0100]        <1> 	mov	[readi.fclust], eax ; first cluster (or FDT address)
  6367 0000D592 880D[DC2C0100]      <1> 	mov	[readi.valid], cl ; 0 
  6368 0000D598 880D[DF2C0100]      <1> 	mov	[readi.s_index], cl ; 0
  6369 0000D59E 66890D[E62C0100]    <1> 	mov	[readi.offset], cx ; 0
  6370 0000D5A5 890D[EC2C0100]      <1> 	mov	[readi.c_index], ecx ; 0
  6371 0000D5AB 890D[E82C0100]      <1> 	mov	[readi.cluster], ecx ; 0
  6372 0000D5B1 890D[E02C0100]      <1> 	mov	[readi.sector], ecx ; 0
  6373                              <1> mget_r_4:	
  6374 0000D5B7 89D8                <1> 	mov	eax, ebx ; file offset
  6375 0000D5B9 668B0D[E42C0100]    <1> 	mov	cx, [readi.bpc]
  6376 0000D5C0 41                  <1> 	inc	ecx ; <= 65536
  6377 0000D5C1 29D2                <1> 	sub	edx, edx
  6378 0000D5C3 F7F1                <1> 	div	ecx
  6379 0000D5C5 8B3D[EC2C0100]      <1> 	mov	edi, [readi.c_index] ; previous cluster index
  6380                              <1> mget_r_5:
  6381 0000D5CB A3[EC2C0100]        <1> 	mov	[readi.c_index], eax ; cluster index
  6382                              <1> 	; edx = byte offset in cluster (<= 65535)
  6383 0000D5D0 668915[E62C0100]    <1> 	mov	[readi.offset], dx
  6384 0000D5D7 66C1EA09            <1> 	shr	dx, 9 ; / 512
  6385 0000D5DB 8815[DF2C0100]      <1> 	mov	[readi.s_index], dl ; sector index in cluster (0 to spc -1)
  6386                              <1> 
  6387 0000D5E1 89C1                <1> 	mov	ecx, eax ; current cluster index
  6388 0000D5E3 A1[F02C0100]        <1> 	mov	eax, [readi.fclust]
  6389 0000D5E8 09C9                <1> 	or	ecx, ecx ; cluster index
  6390 0000D5EA 741F                <1> 	jz	short mget_r_7
  6391                              <1> 
  6392 0000D5EC 39CF                <1> 	cmp	edi, ecx
  6393 0000D5EE 7710                <1> 	ja	short mget_r_6 ; old cluster index is higher
  6394 0000D5F0 8B15[E82C0100]      <1> 	mov	edx, [readi.cluster]
  6395 0000D5F6 21D2                <1> 	and	edx, edx
  6396 0000D5F8 7406                <1> 	jz	short mget_r_6
  6397                              <1> 	; valid 'readi' parameters (*)
  6398 0000D5FA 89D0                <1> 	mov	eax, edx
  6399 0000D5FC 29F9                <1> 	sub	ecx, edi
  6400 0000D5FE 7410                <1> 	jz	short mget_r_8
  6401                              <1> mget_r_6:
  6402                              <1> 	; EAX = Beginning cluster
  6403                              <1> 	; EDX = Sector index in disk/file section
  6404                              <1> 	;	(Only for SINGLIX file system!)
  6405                              <1> 	; ECX = Cluster sequence number after the beginning cluster
  6406                              <1> 	; ESI = Logical DOS Drive Description Table address
  6407 0000D600 E8C9DEFFFF          <1> 	call	get_cluster_by_index
  6408 0000D605 0F82F5DFFFFF        <1> 	jc	error
  6409                              <1> 	; EAX = Cluster number		
  6410                              <1> mget_r_7:
  6411 0000D60B A3[E82C0100]        <1> 	mov	[readi.cluster], eax ; FDT number for Singlix File System
  6412                              <1> mget_r_8:
  6413 0000D610 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
  6414 0000D614 764E                <1> 	jna	short  mget_r_13
  6415                              <1> 
  6416 0000D616 83E802              <1> 	sub	eax, 2
  6417 0000D619 0FB615[DE2C0100]    <1> 	movzx	edx, byte [readi.spc]
  6418 0000D620 F7E2                <1> 	mul	edx
  6419                              <1> 
  6420 0000D622 034668              <1> 	add	eax, [esi+LD_DATABegin]
  6421 0000D625 8A15[DF2C0100]      <1> 	mov	dl, [readi.s_index]
  6422 0000D62B 01D0                <1> 	add	eax, edx
  6423                              <1> msget_r_9:
  6424                              <1> 	; eax = logical sector number
  6425 0000D62D 803D[DC2C0100]00    <1> 	cmp	byte [readi.valid], 0
  6426 0000D634 7608                <1> 	jna	short mget_r_10
  6427 0000D636 3B05[E02C0100]      <1> 	cmp	eax, [readi.sector]
  6428 0000D63C 7425                <1> 	je	short mget_r_12 ; sector is already in 'readi' buffer
  6429                              <1> mget_r_10:
  6430 0000D63E A3[E02C0100]        <1> 	mov	[readi.sector], eax
  6431 0000D643 BB[1D310100]        <1> 	mov	ebx, readi_buffer ; buffer address
  6432 0000D648 B901000000          <1> 	mov	ecx, 1
  6433                              <1> 	; 29/04/2016
  6434                              <1> 	;xor	dl, dl
  6435                              <1> 
  6436                              <1> 	; EAX = Logical sector number
  6437                              <1> 	; ECX = Sector count
  6438                              <1> 	; EBX = Buffer address
  6439                              <1> 	; (EDX = 0)
  6440                              <1> 	; ESI = Logical DOS drive description table address	
  6441                              <1> 
  6442 0000D64D E8A6030000          <1> 	call	disk_read
  6443 0000D652 730A                <1> 	jnc	short mget_r_11
  6444                              <1> 
  6445 0000D654 B815000000          <1> 	mov	eax, 15h ; Drive not ready or read error !
  6446 0000D659 E9A2DFFFFF          <1> 	jmp	error
  6447                              <1> mget_r_11:
  6448 0000D65E A1[E02C0100]        <1> 	mov	eax, [readi.sector]
  6449                              <1> mget_r_12:
  6450 0000D663 C3                  <1> 	retn
  6451                              <1> mget_r_13:
  6452                              <1> 	; EAX = FDT number
  6453                              <1> 	; EDX = Sector index from FDT sector (0,1,2,3,4...)
  6454 0000D664 40                  <1> 	inc	eax ; the first data sector in FS disk section	
  6455 0000D665 8915[F42C0100]      <1> 	mov	[readi.fs_index], edx
  6456 0000D66B 01D0                <1> 	add	eax, edx
  6457 0000D66D EBBE                <1> 	jmp	short msget_r_9
  6458                              <1> 
  6459                              <1> trans_addr_r:
  6460                              <1> 	; 02/05/2016 - TRDOS 386 (TRDOS v2.0)
  6461                              <1> 	; Translate virtual address to physical address 
  6462                              <1> 	; for reading from user's memory space
  6463                              <1> 	; 04/06/2015 - 18/10/2015 (Retro UNIX 386 v1)
  6464                              <1> 
  6465 0000D66F 31D2                <1> 	xor	edx, edx ; 0 (read access sign)
  6466 0000D671 EB04                <1> 	jmp 	short trans_addr_rw
  6467                              <1> 
  6468                              <1> trans_addr_w:
  6469                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
  6470                              <1> 	; Translate virtual address to physical address 
  6471                              <1> 	; for writing to user's memory space
  6472                              <1> 	; 04/06/2015 - 18/10/2015 (Retro UNIX 386 v1)
  6473                              <1> 	
  6474 0000D673 29D2                <1> 	sub	edx, edx
  6475 0000D675 FEC2                <1> 	inc	dl ; 1 (write access sign)
  6476                              <1> trans_addr_rw:
  6477 0000D677 50                  <1> 	push	eax
  6478 0000D678 53                  <1> 	push	ebx
  6479 0000D679 52                  <1> 	push 	edx ; r/w sign (in DL)
  6480                              <1> 	;
  6481 0000D67A 8B1D[A8300100]      <1> 	mov	ebx, [u.base]
  6482 0000D680 E85576FFFF          <1> 	call	get_physical_addr ; get physical address
  6483 0000D685 730A                <1> 	jnc	short passc_0
  6484 0000D687 A3[DD300100]        <1> 	mov	[u.error], eax
  6485                              <1> 	;pop	edx
  6486                              <1> 	;pop 	ebx
  6487                              <1> 	;pop	eax
  6488 0000D68C E96FDFFFFF          <1> 	jmp	error
  6489                              <1> passc_0:
  6490 0000D691 F6C202              <1> 	test	dl, PTE_A_WRITE ; writable page
  6491 0000D694 5A                  <1> 	pop	edx
  6492 0000D695 751C                <1> 	jnz	short passc_1
  6493                              <1> 	
  6494 0000D697 20D2                <1> 	and 	dl, dl
  6495 0000D699 7418                <1> 	jz	short passc_1
  6496                              <1> 	; read only (duplicated) page -must be copied to a new page-
  6497                              <1> 	; EBX = linear address
  6498 0000D69B 51                  <1> 	push 	ecx
  6499 0000D69C E8CF72FFFF          <1> 	call 	copy_page
  6500 0000D6A1 59                  <1> 	pop	ecx
  6501 0000D6A2 721E                <1> 	jc	short passc_2
  6502 0000D6A4 50                  <1> 	push	eax ; physical address of the new/allocated page
  6503 0000D6A5 E85A75FFFF          <1> 	call	add_to_swap_queue	
  6504 0000D6AA 58                  <1> 	pop	eax
  6505 0000D6AB 81E3FF0F0000        <1> 	and 	ebx, PAGE_OFF ; 0FFFh
  6506                              <1> 	;mov 	ecx, PAGE_SIZE
  6507                              <1> 	;sub	ecx, ebx 
  6508 0000D6B1 01D8                <1> 	add	eax, ebx  
  6509                              <1> passc_1: 
  6510 0000D6B3 A3[E9300100]        <1> 	mov 	[u.pbase], eax ; physical address	
  6511 0000D6B8 66890D[ED300100]    <1> 	mov	[u.pcount], cx ; remain byte count in page (1-4096)
  6512 0000D6BF 5B                  <1> 	pop	ebx
  6513 0000D6C0 58                  <1> 	pop	eax
  6514 0000D6C1 C3                  <1> 	retn
  6515                              <1> passc_2:
  6516 0000D6C2 C705[DD300100]0100- <1> 	mov	dword [u.error], ERR_MINOR_IM ; "Insufficient memory !" error
  6516 0000D6CA 0000                <1>
  6517                              <1> 	;pop 	ebx
  6518                              <1> 	;pop	eax
  6519 0000D6CC E92FDFFFFF          <1> 	jmp	error
  6520                              <1> 
  6521                              <1> sioreg: 
  6522                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
  6523                              <1> 	; 19/05/2015 - 25/07/2015 (Retro UNIX 386 v1)
  6524                              <1> 	; 12/03/2013 - 22/07/2013 (Retro UNIX 8086 v1)
  6525                              <1> 	; INPUTS -> 
  6526                              <1> 	;     EBX = system buffer (data) address (r5)
  6527                              <1> 	;     [u.fofp] = pointer to file offset pointer
  6528                              <1> 	;     [u.base] = virtual address of the user buffer
  6529                              <1> 	;     [u.pbase] = physical address of the user buffer
  6530                              <1> 	;     [u.count] = byte count
  6531                              <1> 	;     [u.pcount] = byte count within page frame 			
  6532                              <1> 	; OUTPUTS -> 
  6533                              <1> 	;     ESI = user data offset (r1)
  6534                              <1> 	;     EDI = system (I/O) buffer offset (r2)
  6535                              <1> 	;     ECX = byte count (r3)
  6536                              <1> 	;     EAX = remain bytes after byte count within page frame
  6537                              <1> 	;	(If EAX > 0, transfer will continue from the next page)
  6538                              <1>         ;
  6539                              <1> 	; ((Modified registers:  EDX))
  6540                              <1>  
  6541 0000D6D1 8B35[98300100]      <1>         mov     esi, [u.fofp]
  6542 0000D6D7 8B3E                <1>         mov     edi, [esi]
  6543 0000D6D9 89F9                <1> 	mov	ecx, edi
  6544 0000D6DB 81C900FEFFFF        <1> 	or	ecx, 0FFFFFE00h
  6545 0000D6E1 81E7FF010000        <1> 	and	edi, 1FFh
  6546 0000D6E7 01DF                <1> 	add	edi, ebx ; EBX = system buffer (data) address
  6547 0000D6E9 F7D9                <1> 	neg	ecx
  6548 0000D6EB 3B0D[AC300100]      <1> 	cmp	ecx, [u.count]
  6549 0000D6F1 7606                <1> 	jna	short sioreg_0
  6550 0000D6F3 8B0D[AC300100]      <1> 	mov	ecx, [u.count]
  6551                              <1> sioreg_0:
  6552 0000D6F9 803D[EF300100]00    <1> 	cmp	byte [u.kcall], 0 
  6553 0000D700 7613                <1> 	jna	short sioreg_1
  6554                              <1> 	 ; the caller is 'mkdir' or 'namei'
  6555 0000D702 A1[A8300100]        <1> 	mov	eax, [u.base]
  6556 0000D707 A3[E9300100]        <1> 	mov 	[u.pbase], eax ; physical address = virtual address
  6557 0000D70C 66890D[ED300100]    <1> 	mov	word [u.pcount], cx ; remain bytes in buffer (1 sector)
  6558 0000D713 EB0B                <1> 	jmp	short sioreg_2
  6559                              <1> sioreg_1:
  6560 0000D715 0FB715[ED300100]    <1> 	movzx	edx, word [u.pcount]
  6561 0000D71C 39D1                <1> 	cmp	ecx, edx	
  6562 0000D71E 772A                <1> 	ja	short sioreg_4 ; transfer count > [u.pcount]
  6563                              <1> sioreg_2: ; 2:
  6564 0000D720 31C0                <1> 	xor 	eax, eax
  6565                              <1> sioreg_3:
  6566 0000D722 010D[B0300100]      <1> 	add 	[u.nread], ecx
  6567 0000D728 290D[AC300100]      <1> 	sub 	[u.count], ecx
  6568 0000D72E 010D[A8300100]      <1> 	add 	[u.base], ecx
  6569 0000D734 010E                <1>         add 	[esi], ecx 
  6570 0000D736 8B35[E9300100]      <1> 	mov	esi, [u.pbase]
  6571 0000D73C 66290D[ED300100]    <1> 	sub	[u.pcount], cx
  6572 0000D743 010D[E9300100]      <1> 	add	[u.pbase], ecx
  6573 0000D749 C3                  <1>         retn
  6574                              <1> sioreg_4:
  6575                              <1> 	; transfer count > [u.pcount] 
  6576                              <1> 	; (ecx > edx)
  6577 0000D74A 89C8                <1> 	mov	eax, ecx
  6578 0000D74C 29D0                <1> 	sub	eax, edx ; remain bytes for 1 sector (block) transfer 
  6579 0000D74E 89D1                <1> 	mov	ecx, edx ; current transfer count = [u.pcount]
  6580 0000D750 EBD0                <1> 	jmp	short sioreg_3
  6581                              <1> 
  6582                              <1> tswitch: ; Retro UNIX 386 v1
  6583                              <1> tswap:
  6584                              <1> 	; 21/05/2016 - TRDOS 386 (TRDOS v2.0)
  6585                              <1> 	; 10/05/2015 - 01/09/2015 (Retro UNIX 386 v1)
  6586                              <1> 	; 14/04/2013 - 14/02/2014 (Retro UNIX 8086 v1)
  6587                              <1> 	; time out swap, called when a user times out.
  6588                              <1> 	; the user is put on the low priority queue.
  6589                              <1> 	; This is done by making a link from the last user
  6590                              <1> 	; on the low priority queue to him via a call to 'putlu'.
  6591                              <1> 	; then he is swapped out.
  6592                              <1> 
  6593                              <1> 	; TRDOS 386 (TRDOS v2.0) modification ->  ** 21/05/2016 **
  6594                              <1> 	;     * when a high priority (event) process will be stopped
  6595                              <1> 	;	(swapped out, swithched out/off), 'tswap/tswitch' will
  6596                              <1> 	;	not add it to a run queue. 
  6597                              <1> 	;	/// What for: Process may be already in a run queue, 
  6598                              <1> 	;	it is unspeficied state because process might be started
  6599                              <1> 	;	by a timer event which does not regard previous priority
  6600                              <1> 	;	level and run queue of the process (for fast executing!).
  6601                              <1> 	;	After the 'run for event', process will be sequenced
  6602                              <1> 	;	to run by it's actual run queue. ///
  6603                              <1> 	;
  6604                              <1> 	; Retro UNIX 386 v1 modification ->
  6605                              <1> 	;       swap (software task switch) is performed by changing
  6606                              <1> 	;	user's page directory (u.pgdir) instead of segment change
  6607                              <1> 	;	as in Retro UNIX 8086 v1.
  6608                              <1> 	;
  6609                              <1> 	; RETRO UNIX 8086 v1 modification ->
  6610                              <1> 	;       'swap to disk' is replaced with 'change running segment'
  6611                              <1> 	;	according to 8086 cpu (x86 real mode) architecture.
  6612                              <1> 	;	pdp-11 was using 64KB uniform memory while IBM PC
  6613                              <1> 	;	compatibles was using 1MB segmented memory 
  6614                              <1> 	;	in 8086/8088 times.
  6615                              <1> 	;
  6616                              <1> 	; INPUTS ->
  6617                              <1> 	;    u.uno - users process number
  6618                              <1> 	;    runq+4 - lowest priority queue
  6619                              <1> 	; OUTPUTS ->
  6620                              <1> 	;    r0 - users process number
  6621                              <1> 	;    r2 - lowest priority queue address
  6622                              <1> 	;
  6623                              <1> 	; ((AX = R0, BX = R2)) output
  6624                              <1> 	; ((Modified registers: EDX, EBX, ECX, ESI, EDI))  	
  6625                              <1> 	;
  6626                              <1> 
  6627                              <1> 	NOTE:
  6628                              <1> 	;* [u.pri] priority level is specified by run queue which is process 
  6629                              <1> 	;  comes to run from.
  6630                              <1> 	;* Initial [u.pri] is 1 ('normal/regular') for programs 
  6631                              <1> 	;  (which are launched by MainProg or 'sysexec'), it is changed
  6632                              <1> 	;  to 2 ('high') by timer event, if program uses 'systimer' system call.
  6633                              <1> 	;* Program (Process) also can change it's running priority 
  6634                              <1> 	;  from 1 to 0 or up to 2 by using 'syspri' system call; but,
  6635                              <1> 	;  if program selects priority level 2 (high) for running, next time 
  6636                              <1> 	;  it is reduced to 1 (normal/regular) because 'syspri' adds this
  6637                              <1> 	;  program to 'run for normal' queue while running duration is a bit
  6638                              <1> 	;  protected from swap/switch out immediate, behalf of other high 
  6639                              <1> 	;  priority process in sequence. Program (with high priority) will not 
  6640                              <1> 	;  be swapped/switched out (by timer event) before it's time quantum 
  6641                              <1> 	;  will be elapsed, but, this will be temporary if program is not using 
  6642                              <1> 	;  timer event function.	  			 	
  6643                              <1> 
  6644                              <1> 	;For example:
  6645                              <1> 	;If a process frequently gets a timer event, it runs at high priority
  6646                              <1> 	;level but when it returns from running it returns to actual run queue,
  6647                              <1> 	;not to 'run for event' queue again.
  6648                              <1> 	;'tswap' will not change the sequence at return/stop(swap out) stage.
  6649                              <1> 	;But if priority level not high (=2, 'run for event'), 'tswap/tswitch'
  6650                              <1> 	;will add the stopping process to relevant run queue according to
  6651                              <1> 	;[u.pri] priority level.
  6652                              <1> 
  6653                              <1> 	; 21/05/2016
  6654 0000D752 803D[CB300100]02    <1> 	cmp	byte [u.pri], 2	; high priority (run for event) ?
  6655 0000D759 731A                <1> 	jnb	short swap      ; yes, do not add process to the run queue   
  6656                              <1> 	
  6657 0000D75B BB[78300100]        <1> 	mov	ebx, runq+2 	; 'runq_normal' ; normal/regular priority
  6658 0000D760 803D[CB300100]00    <1> 	cmp	byte [u.pri], 0
  6659 0000D767 7702                <1> 	ja	short tswap_1	; normal priority
  6660                              <1> 
  6661 0000D769 43                  <1> 	inc	ebx
  6662 0000D76A 43                  <1> 	inc	ebx		; runq+4, 'runq_background', low priority
  6663                              <1> tswap_1:
  6664 0000D76B A0[D7300100]        <1> 	mov 	al, [u.uno]
  6665                              <1> 	       	; movb u.uno,r1 / move users process number to r1
  6666                              <1> 		; mov  $runq+4,r2 
  6667                              <1> 			; / move lowest priority queue address to r2
  6668                              <1>       	; ebx = run queue
  6669 0000D770 E8F0000000          <1> 	call 	putlu
  6670                              <1> 		; jsr r0,putlu / create link from last user on Q to 
  6671                              <1> 		             ; / u.uno's user
  6672                              <1> 
  6673                              <1> switch: ; Retro UNIX 386 v1
  6674                              <1> swap:
  6675                              <1> 	; 21/05/2016
  6676                              <1> 	; 20/05/2016
  6677                              <1> 	; 02/05/2016
  6678                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
  6679                              <1> 	; 10/05/2015 - 02/09/2015 (Retro UNIX 386 v1)
  6680                              <1> 	; 14/04/2013 - 08/03/2014 (Retro UNIX 8086 v1)
  6681                              <1> 	;
  6682                              <1> 	; 'swap' is routine that controls the swapping of processes
  6683                              <1> 	; in and out of core.
  6684                              <1> 	;
  6685                              <1> 	; TRDOS 386 (TRDOS v2.0) modification ->  ** 20/05/2016 **
  6686                              <1> 	;     * 3 different priority level is applied 
  6687                              <1> 	;	(just as original unix v1)
  6688                              <1> 	;	1) high priority (event) run queue, 'runq_event'
  6689                              <1> 	;	2) normal priority (regular) run queue, 'runq_normal'
  6690                              <1> 	;	3) low priority (background) run queue, 'runq_backgroud'
  6691                              <1> 	;	'swap' code will run a process which has max. priority
  6692                              <1>         ;       (for earliest event at first)
  6693                              <1> 	;
  6694                              <1> 	; Retro UNIX 386 v1 modification ->
  6695                              <1> 	;       swap (software task switch) is performed by changing
  6696                              <1> 	;	user's page directory (u.pgdir) instead of segment change
  6697                              <1> 	;	as in Retro UNIX 8086 v1.
  6698                              <1> 	;
  6699                              <1> 	; RETRO UNIX 8086 v1 modification ->
  6700                              <1> 	;       'swap to disk' is replaced with 'change running segment'
  6701                              <1> 	;	according to 8086 cpu (x86 real mode) architecture.
  6702                              <1> 	;	pdp-11 was using 64KB uniform memory while IBM PC
  6703                              <1> 	;	compatibles was using 1MB segmented memory 
  6704                              <1> 	;	in 8086/8088 times.
  6705                              <1> 	;
  6706                              <1> 	; INPUTS ->
  6707                              <1> 	;    runq table - contains processes to run.
  6708                              <1> 	;    p.link - contains next process in line to be run.
  6709                              <1> 	;    u.uno - process number of process in core	
  6710                              <1> 	;    s.stack - swap stack used as an internal stack for swapping.	
  6711                              <1> 	; OUTPUTS ->
  6712                              <1> 	;    (original unix v1 -> present process to its disk block)
  6713                              <1> 	;    (original unix v1 -> new process into core -> 
  6714                              <1> 	;	   Retro Unix 8086 v1 -> segment registers changed 
  6715                              <1> 	;	   for new process)
  6716                              <1> 	;    u.quant = 3 (Time quantum for a process)
  6717                              <1> 	; 	((INT 1Ch count down speed -> 18.2 times per second)	 	
  6718                              <1> 	;    RETRO UNIX 8086 v1 will use INT 1Ch (18.2 times per second)
  6719                              <1> 	;	 for now, it will swap the process if there is not
  6720                              <1> 	;	 a keyboard event (keystroke) (Int 15h, function 4Fh)
  6721                              <1> 	;	 or will count down from 3 to 0 even if there is a
  6722                              <1> 	;        keyboard event locking due to repetitive key strokes.
  6723                              <1> 	;	 u.quant will be reset to 3 for RETRO UNIX 8086 v1.
  6724                              <1> 	;
  6725                              <1> 	; ((Modified registers: EAX, EDX, EBX, ECX, ESI, EDI))  	
  6726                              <1> 
  6727                              <1> 	;NOTE:
  6728                              <1> 	;High priority queue is the first for selecting a process to run.
  6729                              <1> 	;If there is not a process in high priority level run queue,
  6730                              <1> 	;a process in normal priority run queue will be selected
  6731                              <1> 	;or a proces in low priority run queue will be selected if normal
  6732                              <1> 	;priority level run queue is empty.
  6733                              <1> 	
  6734                              <1> 	; 21/05/2016 -(3 priority levels, 3 run queues)
  6735 0000D775 BE[76300100]        <1> 	mov	esi, runq ; 'runq_event' ; high priority, 'run for event'
  6736 0000D77A C605[2C2D0100]03    <1> 	mov	byte [priority], 3 ; high priority + 1
  6737                              <1> swap_0: ; 1: / search runq table for highest priority process
  6738 0000D781 66AD                <1> 	lodsw  ; mov ax, [esi], add esi+2
  6739 0000D783 31DB                <1> 	xor	ebx, ebx ; 02/05/2016
  6740 0000D785 6621C0              <1> 	and 	ax, ax ; are there any processes to run in this Q entry
  6741 0000D788 750E                <1> 	jnz	short swap_2 
  6742                              <1> 	; 21/05/2026
  6743                              <1> 	; runq_normal = runq+2, runq_background = runq+4
  6744 0000D78A FE0D[2C2D0100]      <1> 	dec	byte [priority] ; 3 -> 3, 2 -> 1, 1-> 0
  6745 0000D790 75EF                <1> 	jnz	short swap_0	
  6746                              <1> 	;cmp	esi, runq+6  ; if zero compare address to end of table
  6747                              <1> 	;jb	short swap_0 ; if not at end, go back
  6748                              <1> swap_1:
  6749                              <1> 	; 02/05/2016
  6750                              <1> 	; 29/04/2016 (TRDOS 386 = TRDOS v2.0)
  6751                              <1> 	; No user process to run...
  6752                              <1> 	; Run the kernel process... MainProg: Internal Command Interpreter  
  6753 0000D792 FEC0                <1> 	inc	al ; mov al, 1  ; process number of MainProg
  6754 0000D794 FEC3                <1> 	inc	bl ; mov bl, al ; 1
  6755 0000D796 EB1E                <1> 	jmp	short swap_4
  6756                              <1> swap_2:
  6757                              <1> 	; 21/05/2016
  6758 0000D798 FE0D[2C2D0100]      <1> 	dec	byte [priority] ; priority level of present user/process
  6759                              <1> 			        ; 0, 1, 2	   
  6760 0000D79E 4E                  <1> 	dec	esi
  6761 0000D79F 4E                  <1>         dec     esi
  6762                              <1> 	;
  6763 0000D7A0 88C3                <1> 	mov	bl, al
  6764 0000D7A2 38E0                <1> 	cmp	al, ah ; is there only 1 process in the queue to be run
  6765 0000D7A4 740A                <1> 	je	short swap_3 ; yes
  6766 0000D7A6 8AA3[EB2D0100]      <1> 	mov	ah, [ebx+p.link-1] 
  6767 0000D7AC 8826                <1>        	mov	[esi], ah ; move next process in line into run queue
  6768 0000D7AE EB06                <1> 	jmp	short swap_4
  6769                              <1> swap_3: 
  6770 0000D7B0 6631D2              <1> 	xor	dx, dx
  6771 0000D7B3 668916              <1> 	mov	[esi], dx ; zero the entry; no processes on the Q
  6772                              <1> swap_4: 
  6773 0000D7B6 8A25[D7300100]      <1> 	mov 	ah, [u.uno]
  6774 0000D7BC 38C4                <1> 	cmp	ah, al ;is this process the same as the process in core?
  6775 0000D7BE 743B                <1>        	je	short swap_8 ; yes, don't have to swap
  6776 0000D7C0 08E4                <1> 	or	ah, ah  ; is the process # = 0
  6777 0000D7C2 740D                <1>        	jz	short swap_6 ; 'sysexit'
  6778 0000D7C4 8925[84300100]      <1> 	mov	[u.usp], esp ; return  address for 'syswait' & 'sleep'
  6779 0000D7CA E834000000          <1> 	call	wswap   ; write out core to disk
  6780 0000D7CF EB1C                <1> 	jmp 	short swap_7
  6781                              <1> swap_6:
  6782                              <1> 	; Deallocate memory pages belong to the process
  6783                              <1> 	; which is being terminated.
  6784                              <1> 	; (Retro UNIX 386 v1 modification !)
  6785                              <1> 	;
  6786 0000D7D1 53                  <1> 	push	ebx
  6787 0000D7D2 A1[E1300100]        <1> 	mov 	eax, [u.pgdir]  ; page directory of the process
  6788 0000D7D7 8B1D[E5300100]      <1> 	mov	ebx, [u.ppgdir] ; page directory of the parent process
  6789 0000D7DD E8196FFFFF          <1> 	call	deallocate_page_dir
  6790 0000D7E2 A1[D8300100]        <1> 	mov	eax, [u.upage] ; 'user' structure page of the process
  6791 0000D7E7 E8B46FFFFF          <1> 	call	deallocate_page
  6792 0000D7EC 5B                  <1> 	pop	ebx
  6793                              <1> swap_7: 
  6794 0000D7ED C0E302              <1> 	shl	bl, 2 ; * 4 
  6795 0000D7F0 8B83[082E0100]      <1> 	mov	eax, [ebx+p.upage-4] ; the 'u' page of the new process
  6796 0000D7F6 E831000000          <1> 	call	rswap ; read new process into core
  6797                              <1> swap_8: 
  6798                              <1> 	; Retro UNIX  8086 v1 modification !
  6799 0000D7FB C605[CA300100]04    <1> 	mov	byte [u.quant], time_count 
  6800 0000D802 C3                  <1> 	retn
  6801                              <1> 
  6802                              <1> wswap:  ; < swap out, swap to disk >
  6803                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
  6804                              <1> 	; 09/05/2015 (Retro UNIX 386 v1)
  6805                              <1> 	; 26/05/2013 - 08/03/2014 (Retro UNIX 8086 v1)
  6806                              <1> 	; 'wswap' writes out the process that is in core onto its 
  6807                              <1> 	; appropriate disk area.
  6808                              <1> 	;
  6809                              <1> 	; Retro UNIX 386 v1 modification ->
  6810                              <1> 	;       User (u) structure content and the user's register content
  6811                              <1> 	;	will be copied to the process's/user's UPAGE (a page for
  6812                              <1> 	;	saving 'u' structure and user registers for task switching).
  6813                              <1> 	;	u.usp - points to kernel stack address which contains
  6814                              <1> 	;		user's registers while entering system call.  
  6815                              <1> 	;	u.sp  - points to kernel stack address 
  6816                              <1> 	;		to return from system call -for IRET-.
  6817                              <1> 	;	[u.usp]+32+16 = [u.sp] 
  6818                              <1> 	;	[u.usp] -> edi, esi, ebp, esp (= [u.usp]+32), ebx, 
  6819                              <1> 	;		edx, ecx, eax, gs, fs, es, ds, -> [u.sp].
  6820                              <1> 	;
  6821                              <1> 	; Retro UNIX 8086 v1 modification ->
  6822                              <1> 	;       'swap to disk' is replaced with 'change running segment'
  6823                              <1> 	;	according to 8086 cpu (x86 real mode) architecture.
  6824                              <1> 	;	pdp-11 was using 64KB uniform memory while IBM PC
  6825                              <1> 	;	compatibles was using 1MB segmented memory 
  6826                              <1> 	;	in 8086/8088 times.
  6827                              <1> 	;
  6828                              <1> 	; INPUTS ->
  6829                              <1> 	;    u.break - points to end of program
  6830                              <1> 	;    u.usp - stack pointer at the moment of swap
  6831                              <1> 	;    core - beginning of process program		
  6832                              <1> 	;    ecore - end of core 	
  6833                              <1> 	;    user - start of user parameter area		
  6834                              <1> 	;    u.uno - user process number	
  6835                              <1> 	;    p.dska - holds block number of process	
  6836                              <1> 	; OUTPUTS ->
  6837                              <1> 	;    swp I/O queue
  6838                              <1> 	;    p.break - negative word count of process 
  6839                              <1> 	;    r1 - process disk address	
  6840                              <1> 	;    r2 - negative word count
  6841                              <1> 	;
  6842                              <1> 	; RETRO UNIX 8086 v1 input/output:
  6843                              <1> 	;
  6844                              <1> 	; INPUTS ->
  6845                              <1> 	;    u.uno - process number (to be swapped out)
  6846                              <1> 	; OUTPUTS ->
  6847                              <1> 	;    none
  6848                              <1> 	;
  6849                              <1> 	;   ((Modified registers: ECX, ESI, EDI))  
  6850                              <1> 	;
  6851 0000D803 8B3D[D8300100]      <1> 	mov	edi, [u.upage] ; process's user (u) structure page addr
  6852 0000D809 B91E000000          <1> 	mov	ecx, (U_SIZE + 3) / 4
  6853 0000D80E BE[80300100]        <1> 	mov	esi, user ; active user (u) structure	
  6854 0000D813 F3A5                <1> 	rep	movsd
  6855                              <1> 	;
  6856 0000D815 8B35[84300100]      <1> 	mov	esi, [u.usp] ; esp (system stack pointer, 
  6857                              <1> 			     ;      points to user registers)
  6858 0000D81B 8B0D[80300100]      <1> 	mov	ecx, [u.sp]  ; return address from the system call
  6859                              <1> 			     ; (for IRET)
  6860                              <1> 			     ; [u.sp] -> EIP (user)
  6861                              <1> 			     ; [u.sp+4]-> CS (user)
  6862                              <1> 			     ; [u.sp+8] -> EFLAGS (user)
  6863                              <1> 			     ; [u.sp+12] -> ESP (user)
  6864                              <1> 			     ; [u.sp+16] -> SS (user)	
  6865 0000D821 29F1                <1> 	sub	ecx, esi     ; required space for user registers
  6866 0000D823 83C114              <1> 	add	ecx, 20	     ; +5 dwords to return from system call
  6867                              <1> 			     ; (for IRET) 	
  6868 0000D826 C1E902              <1> 	shr	ecx, 2	     		
  6869 0000D829 F3A5                <1> 	rep	movsd
  6870 0000D82B C3                  <1> 	retn
  6871                              <1> 
  6872                              <1> rswap:  ; < swap in, swap from disk >
  6873                              <1> 	; 21/05/2016
  6874                              <1> 	; 03/05/2016
  6875                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
  6876                              <1> 	; 09/05/2015 - 15/09/2015 (Retro UNIX 386 v1)
  6877                              <1> 	; 26/05/2013 - 08/03/2014 (Retro UNIX 8086 v1)
  6878                              <1> 	; 'rswap' reads a process whose number is in r1, 
  6879                              <1> 	; from disk into core.
  6880                              <1> 	;
  6881                              <1> 	; Retro UNIX 386 v1 modification ->
  6882                              <1> 	;       User (u) structure content and the user's register content
  6883                              <1> 	;	will be restored from process's/user's UPAGE (a page for
  6884                              <1> 	;	saving 'u' structure and user registers for task switching).
  6885                              <1> 	;	u.usp - points to kernel stack address which contains
  6886                              <1> 	;		user's registers while entering system call.  
  6887                              <1> 	;	u.sp  - points to kernel stack address 
  6888                              <1> 	;		to return from system call -for IRET-.
  6889                              <1> 	;	[u.usp]+32+16 = [u.sp] 
  6890                              <1> 	;	[u.usp] -> edi, esi, ebp, esp (= [u.usp]+32), ebx, 
  6891                              <1> 	;		edx, ecx, eax, gs, fs, es, ds, -> [u.sp].
  6892                              <1> 	;
  6893                              <1> 	; RETRO UNIX 8086 v1 modification ->
  6894                              <1> 	;       'swap to disk' is replaced with 'change running segment'
  6895                              <1> 	;	according to 8086 cpu (x86 real mode) architecture.
  6896                              <1> 	;	pdp-11 was using 64KB uniform memory while IBM PC
  6897                              <1> 	;	compatibles was using 1MB segmented memory 
  6898                              <1> 	;	in 8086/8088 times.
  6899                              <1> 	;
  6900                              <1> 	; INPUTS ->
  6901                              <1> 	;    r1 - process number of process to be read in
  6902                              <1> 	;    p.break - negative of word count of process 
  6903                              <1> 	;    p.dska - disk address of the process		
  6904                              <1> 	;    u.emt - determines handling of emt's 	
  6905                              <1> 	;    u.ilgins - determines handling of illegal instructions		
  6906                              <1> 	; OUTPUTS ->
  6907                              <1> 	;    8 = (u.ilgins)
  6908                              <1> 	;    24 = (u.emt)
  6909                              <1> 	;    swp - bit 10 is set to indicate read 
  6910                              <1> 	;		(bit 15=0 when reading is done)	
  6911                              <1> 	;    swp+2 - disk block address
  6912                              <1> 	;    swp+4 - negative word count 	
  6913                              <1> 	;      ((swp+6 - address of user structure)) 
  6914                              <1> 	;
  6915                              <1> 	; RETRO UNIX 8086 v1 input/output:
  6916                              <1> 	;
  6917                              <1> 	; INPUTS ->
  6918                              <1> 	;    AL	- new process number (to be swapped in)	 
  6919                              <1> 	; OUTPUTS ->
  6920                              <1> 	;    none
  6921                              <1> 	;
  6922                              <1> 	;   ((Modified registers: EAX, ECX, ESI, EDI, ESP)) 
  6923                              <1> 	;
  6924                              <1> 	; Retro UNIX 386 v1 - modification ! 14/05/2015
  6925 0000D82C 89C6                <1> 	mov	esi, eax  ; process's user (u) structure page addr
  6926 0000D82E B91E000000          <1> 	mov	ecx, (U_SIZE + 3) / 4
  6927 0000D833 BF[80300100]        <1> 	mov	edi, user ; active user (u) structure	
  6928 0000D838 F3A5                <1> 	rep	movsd
  6929 0000D83A 58                  <1> 	pop	eax	; 'rswap' return address
  6930                              <1> 	; 
  6931                              <1> 	;; 21/05/2016
  6932 0000D83B 8A0D[2C2D0100]      <1> 	mov	cl, [priority]
  6933 0000D841 880D[CB300100]      <1> 	mov	[u.pri], cl  ; running priority level 
  6934                              <1> 			     ; (specifies run queue which is 
  6935                              <1> 			     ; process comes from)
  6936                              <1> 	;cli
  6937 0000D847 8B3D[84300100]      <1> 	mov	edi, [u.usp] ; esp (system stack pointer, 
  6938                              <1> 			     ;     points to user registers)
  6939 0000D84D 8B0D[80300100]      <1> 	mov	ecx, [u.sp]  ; return address from the system call
  6940                              <1> 			     ; (for IRET)
  6941                              <1> 			     ; [u.sp] -> EIP (user)
  6942                              <1> 			     ; [u.sp+4]-> CS (user)
  6943                              <1> 			     ; [u.sp+8] -> EFLAGS (user)
  6944                              <1> 			     ; [u.sp+12] -> ESP (user)
  6945                              <1> 			     ; [u.sp+16] -> SS (user)		
  6946 0000D853 29F9                <1> 	sub	ecx, edi     ; required space for user registers
  6947 0000D855 83C114              <1> 	add	ecx, 20	     ; +5 dwords to return from system call
  6948                              <1> 			     ; (for IRET) 	
  6949 0000D858 C1E902              <1> 	shr	ecx, 2	       		
  6950 0000D85B F3A5                <1> 	rep	movsd
  6951 0000D85D 8B25[84300100]      <1> 	mov	esp, [u.usp] ; 15/09/2015
  6952                              <1> 	;sti
  6953 0000D863 50                  <1> 	push	eax	; 'rswap' return address
  6954 0000D864 C3                  <1> 	retn
  6955                              <1> 
  6956                              <1> putlu: 
  6957                              <1> 	; 20/05/2016
  6958                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
  6959                              <1> 	; 10/05/2015 - 12/09/2015 (Retro UNIX 386 v1)
  6960                              <1> 	; 15/04/2013 - 23/02/2014 (Retro UNIX 8086 v1)
  6961                              <1> 	; 'putlu' is called with a process number in r1 and a pointer
  6962                              <1> 	; to lowest priority Q (runq+4) in r2. A link is created from
  6963                              <1> 	; the last process on the queue to process in r1 by putting
  6964                              <1> 	; the process number in r1 into the last process's link.
  6965                              <1> 	;
  6966                              <1> 	; INPUTS ->
  6967                              <1> 	;    r1 - user process number
  6968                              <1> 	;    r2 - points to lowest priority queue 
  6969                              <1> 	;    p.dska - disk address of the process		
  6970                              <1> 	;    u.emt - determines handling of emt's 	
  6971                              <1> 	;    u.ilgins - determines handling of illegal instructions		
  6972                              <1> 	; OUTPUTS ->
  6973                              <1> 	;    r3 - process number of last process on the queue upon
  6974                              <1> 	;	  entering putlu
  6975                              <1> 	;    p.link-1 + r3 - process number in r1
  6976                              <1> 	;    r2 - points to lowest priority queue
  6977                              <1> 	;
  6978                              <1> 	; ((Modified registers: EDX, EBX)) 
  6979                              <1> 	;
  6980                              <1> 	; / r1 = user process no.; r2 points to lowest priority queue
  6981                              <1> 
  6982                              <1> 	; EBX = r2
  6983                              <1> 	; EAX = r1 (AL=r1b)
  6984                              <1> 
  6985                              <1> 	; 20/05/2016
  6986                              <1> 	; AL = process number (1 to 16) // Retro UNIX 8086, 386 v1 // 
  6987                              <1> 	;     (max. 16 processes available for current kernel version) 
  6988                              <1> 	; EBX = run queue address ; 20/05/2016 (TRDOS 386)
  6989                              <1> 		; which is one of following addresses:
  6990                              <1> 		;  1) 'runq_event' high priority run queue	 	
  6991                              <1> 		;  2) 'runq_normal' normal/regular priority run queue
  6992                              <1> 		;  3) 'runq_background' low priority run queue
  6993                              <1> 
  6994                              <1> 	;mov	ebx, runq
  6995 0000D865 0FB613              <1> 	movzx  	edx, byte [ebx]
  6996 0000D868 43                  <1> 	inc	ebx
  6997 0000D869 20D2                <1> 	and	dl, dl
  6998                              <1> 		; tstb (r2)+ / is queue empty?
  6999 0000D86B 740A                <1>        	jz	short putlu_1
  7000                              <1> 		; beq 1f / yes, branch
  7001 0000D86D 8A13                <1> 	mov 	dl, [ebx] ; 12/09/2015
  7002                              <1> 		; movb (r2),r3 / no, save the "last user" process number
  7003                              <1> 			     ; / in r3
  7004 0000D86F 8882[EB2D0100]      <1>        	mov	[edx+p.link-1], al
  7005                              <1> 		; movb r1,p.link-1(r3) / put pointer to user on 
  7006                              <1> 			     ; / "last users" link
  7007 0000D875 EB03                <1> 	jmp	short putlu_2
  7008                              <1> 		; br 2f /
  7009                              <1> putlu_1: ; 1:
  7010 0000D877 8843FF              <1> 	mov	[ebx-1], al
  7011                              <1>        		; movb r1,-1(r2) / user is only user; 
  7012                              <1> 			    ; / put process no. at beginning and at end
  7013                              <1> putlu_2: ; 2: 
  7014 0000D87A 8803                <1> 	mov	[ebx], al
  7015                              <1>        		; movb r1,(r2) / user process in r1 is now the last entry
  7016                              <1> 			     ; / on the queue
  7017 0000D87C 88C2                <1> 	mov	dl, al
  7018 0000D87E 88B2[EB2D0100]      <1>         mov     [edx+p.link-1], dh ; 0
  7019                              <1> 		; dec r2 / restore r2
  7020 0000D884 C3                  <1>         retn
  7021                              <1> 		; rts r0
  7022                              <1> sysver:
  7023                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
  7024 0000D885 C705[88300100]0002- <1> 	mov	dword [u.r0], 200h ; AH = major version, AL = minor version 
  7024 0000D88D 0000                <1>
  7025 0000D88F E98CDDFFFF          <1> 	jmp	sysret
  7026                              <1> 
  7027                              <1> sysreserved1:
  7028                              <1> 	; 19/05/2016 - TRDOS 386 (TRDOS v2.0)
  7029                              <1> 	; // name and contect will be changed later //
  7030 0000D894 C705[88300100]E007- <1> 	mov	dword [u.r0], 2016
  7030 0000D89C 0000                <1>
  7031 0000D89E E97DDDFFFF          <1> 	jmp	sysret
  7032                              <1> 
  7033                              <1> syspri: ; change running priority (of the process)
  7034                              <1> 	; 21/05/2016
  7035                              <1> 	; 20/05/2026 - TRDOS 386 (TRDOS v2.0)
  7036                              <1> 	; INPUT ->
  7037                              <1> 	;	BL = priority level
  7038                              <1> 	;	   0 = low running priority (running on background)
  7039                              <1> 	;	   1 = normal/regular priority (running as regular)
  7040                              <1> 	;	   2 = high/event priority (running for event)
  7041                              <1> 	;	   >2 = invalid, it will accepted as 2 (event)
  7042                              <1> 	;	   0FFh = get/return current running priority only	
  7043                              <1> 	; OUTPUT -> 	
  7044                              <1> 	;	* if current [u.pri] < 2
  7045                              <1> 	;	  if BL input < 0FFh ->
  7046                              <1> 	;	     [u.pri] is updated as in BL input (0,1,2)
  7047                              <1> 	;	  if BL input = 0FFh -> AL = [u.pri] (current)
  7048                              <1> 	;	      
  7049                              <1> 	;	* if current [u.pri] = 2
  7050                              <1> 	;	  if BL input < 0FFh -> cf = 1 & AL = 2
  7051                              <1> 	;	  if BL input = 0FFh -> cf = 0 & AL = 2  
  7052                              <1> 	;	
  7053                              <1> 	;	NOTE: 	
  7054                              <1> 	;	If [u.pri] = 2, it can not be changed to 1 or 0;
  7055                              <1> 	;	because, run queue of the running process is unspecified
  7056                              <1> 	;	at this	stage. Process might be started by a timer event
  7057                              <1> 	;	or priority might be changed to high by previous
  7058                              <1> 	;	'syspri' system	call. In both cases, the process is in
  7059                              <1> 	;	'runq_normal' or 'runq_background' queue.
  7060                              <1> 	;	As result of this fact, when the [u.quant] time quantum
  7061                              <1> 	;	of the process is elapsed or 'sysrele' system call is
  7062                              <1> 	;	instructed by the process, 'tswap' ('tswitch') procedure
  7063                              <1> 	;	will be called (to 'swap' or 'switch' out the procedure)
  7064                              <1> 	;	and it will not call 'putlu' to add the (stopping)
  7065                              <1> 	;	process to relevant run queue when [u.pri] = 2.
  7066                              <1> 	;	(Otherwise, it would be possible to add process to
  7067                              <1> 	;	a run queue while it is already in a run queue, wrongly.)
  7068                              <1>   	;
  7069                              <1> 	;	If [u.pri]< 2, 'tswap/tswitch' procedure will call 
  7070                              <1> 	;	'putlu' to add process to relevant run queue
  7071                              <1> 	;	according to [u.pri] value. ('runq_normal' for 1, 
  7072                              <1> 	;	'runq_background' for 0).
  7073                              <1> 	;
  7074                              <1> 	;	If BL input >= 2 and < 0FFh while [u.pri] < 2,
  7075                              <1> 	;	process will be added to 'runq_normal' queue and
  7076                              <1> 	;	[u.pri] will be set to 2. (in 'syspri' system call)
  7077                              <1> 	;
  7078                              <1> 
  7079 0000D8A3 29C0                <1> 	sub	eax, eax ; 0
  7080 0000D8A5 A3[DD300100]        <1> 	mov	[u.error], eax
  7081                              <1> 
  7082 0000D8AA A0[CB300100]        <1> 	mov	al, [u.pri]
  7083 0000D8AF A3[88300100]        <1> 	mov	[u.r0], eax
  7084                              <1> 
  7085 0000D8B4 FEC3                <1> 	inc	bl
  7086 0000D8B6 0F8464DDFFFF        <1> 	jz	sysret ; 0FFh -> 0, get priority level
  7087                              <1> 	
  7088 0000D8BC 3C02                <1> 	cmp	al, 2
  7089 0000D8BE 0F833CDDFFFF        <1> 	jnb	error ; CF = 1 & AL = 2 (& last error = 0)
  7090                              <1> 
  7091 0000D8C4 FECB                <1> 	dec	bl
  7092 0000D8C6 80FB02              <1> 	cmp	bl, 2
  7093 0000D8C9 7602                <1> 	jna	short syspri_1
  7094 0000D8CB B302                <1> 	mov	bl, 2
  7095                              <1> syspri_1:
  7096 0000D8CD 881D[CB300100]      <1> 	mov	[u.pri], bl
  7097 0000D8D3 80FB02              <1> 	cmp	bl, 2
  7098 0000D8D6 0F8244DDFFFF        <1>         jb      sysret
  7099                              <1> 
  7100                              <1> 	; here...
  7101                              <1> 	; Priority of current process has been changed to high
  7102                              <1> 	; ('run for event') but current process will be added to
  7103                              <1> 	; 'run as normal' queue. ('run for event' high priority
  7104                              <1> 	; queue is under control of timer -& RTC- interrupt only!) 
  7105                              <1> 	;
  7106                              <1> 	; (Otherwise, process can fall into black hole!
  7107                              <1> 	; e.g. if it is not in waiting list and it has not got 
  7108                              <1> 	; a timer event and it is not in a run queue!
  7109                              <1> 	; Because, when [u.pri] is 2, 'tswap/tswitch' will not 
  7110                              <1> 	; add the stopping process to a run queue.)
  7111                              <1> 
  7112 0000D8DC A0[D7300100]        <1> 	mov	al, [u.uno]
  7113 0000D8E1 BB[78300100]        <1> 	mov	ebx, runq_normal ; normal priority !
  7114                              <1> 				 ; [u.pri] is set to high
  7115                              <1> 				 ; but 'runq_event' queue is set
  7116                              <1> 				 ; only by the kernel's timer
  7117                              <1> 				 ; event function (timer interrupt). 
  7118 0000D8E6 E87AFFFFFF          <1> 	call	putlu
  7119 0000D8EB E930DDFFFF          <1> 	jmp	sysret
  7120                              <1> 
  7121                              <1> cpass: ; / get next character from user area of core and put it in AL (r1)
  7122                              <1> 	; 02/05/2016 - TRDOS 386 (TRDOS v2.0)
  7123                              <1> 	; 19/05/2015 - 18/10/2015 (Retro UNIX 386 v1)
  7124                              <1> 	; 14/08/2013 - 20/09/2013 (Retro UNIX 8086 v1)
  7125                              <1> 	; INPUTS -> 
  7126                              <1> 	;     [u.base] = virtual address in user area
  7127                              <1> 	;     [u.count] = byte count (max.)
  7128                              <1> 	;     [u.pcount] = byte count in page (0 = reset)		
  7129                              <1> 	; OUTPUTS -> 
  7130                              <1> 	;     AL = the character which is pointed by [u.base]
  7131                              <1> 	;     zf = 1 -> transfer count has been completed	
  7132                              <1>         ;
  7133                              <1> 	; ((Modified registers:  EAX, EDX, ECX))
  7134                              <1> 	;
  7135 0000D8F0 833D[AC300100]00    <1> 	cmp 	dword [u.count], 0  ; have all the characters been transferred
  7136                              <1> 			    	    ; i.e., u.count, # of chars. left
  7137 0000D8F7 763F                <1> 	jna	short cpass_3	    ; to be transferred = 0?) yes, branch
  7138 0000D8F9 FF0D[AC300100]      <1> 	dec	dword [u.count]	    ; no, decrement u.count
  7139                              <1>         ; 19/05/2015 
  7140                              <1> 	;(Retro UNIX 386 v1 - translation from user's virtual address
  7141                              <1> 	;		      to physical address
  7142 0000D8FF 66833D[ED300100]00  <1> 	cmp	word [u.pcount], 0 ; byte count in page = 0 (initial value)
  7143                              <1> 			     ; 1-4095 --> use previous physical base address
  7144                              <1> 			     ; in [u.pbase]
  7145 0000D907 770E                <1> 	ja	short cpass_1
  7146 0000D909 833D[E5300100]00    <1> 	cmp     dword [u.ppgdir], 0  ; is the caller os kernel
  7147 0000D910 7427                <1>         je      short cpass_k       ; (sysexec, '/etc/init') ?  (MainProg)
  7148 0000D912 E858FDFFFF          <1> 	call	trans_addr_r
  7149                              <1> cpass_1:
  7150 0000D917 66FF0D[ED300100]    <1> 	dec	word [u.pcount]
  7151                              <1> cpass_2: 
  7152 0000D91E 8B15[E9300100]      <1> 	mov	edx, [u.pbase]
  7153 0000D924 8A02                <1> 	mov	al, [edx]	; take the character pointed to 
  7154                              <1> 				; by u.base and put it in r1
  7155 0000D926 FF05[B0300100]      <1> 	inc	dword [u.nread] ; increment no. of bytes transferred
  7156 0000D92C FF05[A8300100]      <1> 	inc	dword [u.base]  ; increment the buffer address to point to the
  7157                              <1> 			        ; next byte
  7158 0000D932 FF05[E9300100]      <1> 	inc	dword [u.pbase]
  7159                              <1> cpass_3:
  7160 0000D938 C3                  <1> 	retn
  7161                              <1> cpass_k:
  7162                              <1> 	; 02/07/2015
  7163                              <1> 	; The caller is os kernel 
  7164                              <1> 	; (get sysexec arguments from kernel's memory space)
  7165 0000D939 8B1D[A8300100]      <1> 	mov	ebx, [u.base]
  7166 0000D93F 66C705[ED300100]00- <1>         mov     word [u.pcount], PAGE_SIZE ; 4096
  7166 0000D947 10                  <1>
  7167 0000D948 891D[E9300100]      <1> 	mov	[u.pbase], ebx
  7168 0000D94E EBCE                <1> 	jmp	short cpass_2
  7169                              <1> 
  7170                              <1> transfer_to_user_buffer: ; fast transfer
  7171                              <1> 	; 27/05/2016
  7172                              <1> 	; 16/05/2016 - TRDOS 386 (TRDOS v2.0)
  7173                              <1> 	;
  7174                              <1> 	; INPUT ->
  7175                              <1> 	;	ESI = source address in system space
  7176                              <1> 	;	EDI = user's buffer address
  7177                              <1> 	;	ECX = transfer (byte) count
  7178                              <1> 	;	[u.pgdir] = user's page directory
  7179                              <1> 	; OUTPUT ->
  7180                              <1> 	;	ecx = actual transfer count
  7181                              <1> 	;	cf = 1 -> error
  7182                              <1> 	;	[u.count] = remain byte count
  7183                              <1> 	;
  7184                              <1> 	; Modified registers: eax, ecx
  7185                              <1> 	;
  7186                              <1> 
  7187 0000D950 21C9                <1> 	and	ecx, ecx
  7188 0000D952 743B                <1> 	jz	short ttub_4
  7189                              <1> 
  7190 0000D954 890D[AC300100]      <1> 	mov	[u.count], ecx
  7191                              <1> 	
  7192 0000D95A 57                  <1> 	push	edi
  7193 0000D95B 56                  <1> 	push	esi
  7194 0000D95C 53                  <1> 	push	ebx
  7195 0000D95D 52                  <1> 	push	edx
  7196 0000D95E 51                  <1> 	push	ecx
  7197                              <1> 
  7198 0000D95F 89FB                <1> 	mov	ebx, edi
  7199 0000D961 81C300004000        <1> 	add	ebx, CORE ; 27/05/2016
  7200                              <1> ttub_1:
  7201                              <1> 	; ebx = virtual (linear) address
  7202                              <1> 	; [u.pgdir] = user's page directory
  7203 0000D967 E87473FFFF          <1>        	call	get_physical_addr_x ; get physical address
  7204 0000D96C 7222                <1> 	jc	short ttub_5
  7205                              <1> 	; eax = physical address 
  7206                              <1> 	; ecx = remain byte count in page (1-4096)
  7207 0000D96E 89C7                <1> 	mov	edi, eax
  7208 0000D970 A1[AC300100]        <1> 	mov	eax, [u.count]
  7209 0000D975 39C1                <1> 	cmp	ecx, eax
  7210 0000D977 7602                <1> 	jna	short ttub_2
  7211 0000D979 89C1                <1> 	mov	ecx, eax
  7212                              <1> ttub_2:	
  7213 0000D97B 29C8                <1> 	sub	eax, ecx
  7214 0000D97D 01CB                <1> 	add	ebx, ecx
  7215 0000D97F F3A4                <1> 	rep	movsb
  7216 0000D981 A3[AC300100]        <1> 	mov	[u.count], eax
  7217 0000D986 09C0                <1> 	or	eax, eax
  7218 0000D988 75DD                <1> 	jnz	short ttub_1
  7219                              <1> ttub_retn:
  7220                              <1> tfub_retn:
  7221 0000D98A 59                  <1> 	pop	ecx ; transfer count = actual transfer count
  7222                              <1> ttub_3:
  7223 0000D98B 5A                  <1> 	pop	edx
  7224 0000D98C 5B                  <1> 	pop	ebx
  7225 0000D98D 5E                  <1> 	pop	esi
  7226 0000D98E 5F                  <1> 	pop	edi
  7227                              <1> ttub_4:
  7228 0000D98F C3                  <1> 	retn
  7229                              <1> ttub_5:
  7230 0000D990 59                  <1> 	pop	ecx
  7231 0000D991 2B0D[AC300100]      <1> 	sub	ecx, [u.count] ; actual transfer count
  7232 0000D997 F9                  <1> 	stc
  7233 0000D998 EBF1                <1> 	jmp	short ttub_3
  7234                              <1> 
  7235                              <1> transfer_from_user_buffer: ; fast transfer
  7236                              <1> 	; 27/05/2016
  7237                              <1> 	; 16/05/2016 - TRDOS 386 (TRDOS v2.0)
  7238                              <1> 	;
  7239                              <1> 	; INPUT ->
  7240                              <1> 	;	ESI = user's buffer address
  7241                              <1> 	;	EDI = destination address in system space
  7242                              <1> 	;	ECX = transfer (byte) count
  7243                              <1> 	;	[u.pgdir] = user's page directory
  7244                              <1> 	; OUTPUT ->
  7245                              <1> 	;	ecx = actual transfer count
  7246                              <1> 	;	cf = 1 -> error
  7247                              <1> 	;	[u.count] = remain byte count
  7248                              <1> 	;
  7249                              <1> 	; Modified registers: eax, ecx
  7250                              <1> 	;
  7251                              <1> 
  7252 0000D99A 21C9                <1> 	and	ecx, ecx
  7253                              <1> 	;jz	short tfub_4
  7254 0000D99C 74F1                <1> 	jz	short ttub_4
  7255                              <1> 
  7256 0000D99E 890D[AC300100]      <1> 	mov	[u.count], ecx
  7257                              <1> 	
  7258 0000D9A4 57                  <1> 	push	edi
  7259 0000D9A5 56                  <1> 	push	esi
  7260 0000D9A6 53                  <1> 	push	ebx
  7261 0000D9A7 52                  <1> 	push	edx
  7262 0000D9A8 51                  <1> 	push	ecx
  7263                              <1> 
  7264 0000D9A9 89F3                <1> 	mov	ebx, esi
  7265 0000D9AB 81C300004000        <1> 	add	ebx, CORE ; 27/05/2016
  7266                              <1> tfub_1:
  7267                              <1> 	; ebx = virtual (linear) address
  7268                              <1> 	; [u.pgdir] = user's page directory
  7269 0000D9B1 E82A73FFFF          <1>        	call	get_physical_addr_x ; get physical address
  7270                              <1> 	;jc	short tfub_5
  7271 0000D9B6 72D8                <1> 	jc	short ttub_5
  7272                              <1> 	; eax = physical address 
  7273                              <1> 	; ecx = remain byte count in page (1-4096)
  7274 0000D9B8 89C6                <1> 	mov	esi, eax
  7275 0000D9BA A1[AC300100]        <1> 	mov	eax, [u.count]
  7276 0000D9BF 39C1                <1> 	cmp	ecx, eax
  7277 0000D9C1 7602                <1> 	jna	short tfub_2
  7278 0000D9C3 89C1                <1> 	mov	ecx, eax
  7279                              <1> tfub_2:	
  7280 0000D9C5 29C8                <1> 	sub	eax, ecx
  7281 0000D9C7 01CB                <1> 	add	ebx, ecx
  7282 0000D9C9 F3A4                <1> 	rep	movsb
  7283 0000D9CB A3[AC300100]        <1> 	mov	[u.count], eax
  7284 0000D9D0 09C0                <1> 	or	eax, eax
  7285 0000D9D2 75DD                <1> 	jnz	short tfub_1
  7286                              <1> 
  7287 0000D9D4 EBB4                <1> 	jmp	short tfub_retn
  7288                              <1> 
  7289                              <1> ;tfub_retn:
  7290                              <1> ;	pop	ecx ; transfer count = actual transfer count
  7291                              <1> ;tfub_3:
  7292                              <1> ;	pop	edx
  7293                              <1> ;	pop	ebx
  7294                              <1> ;	pop	esi
  7295                              <1> ;	pop	edi
  7296                              <1> ;tfub_4:
  7297                              <1> ;	retn
  7298                              <1> ;tfub_5:
  7299                              <1> ;	pop	ecx
  7300                              <1> ;	sub	ecx, [u.count] ; actual transfer count
  7301                              <1> ;	stc
  7302                              <1> ;	jmp	short tfub_3
  7303                              <1> 	
  7304                              <1> ; temporary - 24/01/2016
  7305                              <1> 
  7306                              <1> iget:
  7307 0000D9D6 C3                  <1> 	retn
  7308                              <1> poke:
  7309 0000D9D7 C3                  <1> 	retn
  7310                              <1> isintr:
  7311 0000D9D8 C3                  <1> 	retn
  7312                              <1> writei:
  7313 0000D9D9 C3                  <1> 	retn
  7314                              <1> iopen:
  7315 0000D9DA C3                  <1> 	retn
  7316                              <1> iclose:
  7317 0000D9DB C3                  <1> 	retn
  7318                              <1> itrunc:
  7319 0000D9DC C3                  <1> 	retn
  7320                              <1> setimod:
  7321 0000D9DD C3                  <1> 	retn
  7322                              <1> ottyp:
  7323 0000D9DE C3                  <1> 	retn
  7324                              <1> cttyp:
  7325 0000D9DF C3                  <1> 	retn
  7326                              <1> sndc:
  7327 0000D9E0 C3                  <1> 	retn
  7328                              <1> access:
  7329 0000D9E1 C3                  <1> 	retn
  7330                              <1> passc:
  7331 0000D9E2 C3                  <1> 	retn
  7332                              <1> epoch:
  7333 0000D9E3 C3                  <1> 	retn
  7334                              <1> set_date_time:
  7335 0000D9E4 C3                  <1> 	retn
  7336                              <1> imap:
  7337 0000D9E5 C3                  <1> 	retn
  7338                              <1> diskio:
  7339 0000D9E6 C3                  <1> 	retn
  7340                              <1> idle:
  7341 0000D9E7 C3                  <1> 	retn
  7342                              <1> sleep:
  7343 0000D9E8 C3                  <1> 	retn
  1924                                  %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 0000D9E9 807E0500            <1> 	cmp	byte [esi+LD_LBAYes], 0
    20 0000D9ED 777B                <1>         ja      short lba_write
    21                              <1> 
    22                              <1> chs_write:
    23                              <1> 	; 25/02/2016
    24                              <1> 	; 23/02/2016
    25 0000D9EF C605[61290100]03    <1> 	mov	byte [disk_rw_op], 3 ; CHS write
    26 0000D9F6 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 0000D9F8 807E0500            <1> 	cmp	byte [esi+LD_LBAYes], 0
    47 0000D9FC 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 0000D9FE C605[61290100]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 0000DA05 C605[62290100]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 0000DA0C 50                  <1> 	push	eax			; Linear sector #
    80 0000DA0D 51                  <1> 	push	ecx			; # of FAT/FILE/DIR sectors
    81                              <1>                 
    82 0000DA0E 0FB74E1E            <1> 	movzx	ecx, word [esi+LD_BPB+SecPerTrack]
    83                              <1> 	;movzx	ecx, byte [disk_rw_spt] ; 23/02/2016
    84 0000DA12 29D2                <1> 	sub	edx, edx
    85 0000DA14 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 0000DA16 6689D1              <1> 	mov	cx, dx			; Sector (zero based)
    90 0000DA19 6641                <1> 	inc	cx			; To make it 1 based
    91 0000DA1B 6651                <1> 	push	cx
    92 0000DA1D 668B4E20            <1> 	mov	cx, [esi+LD_BPB+Heads]
    93 0000DA21 6629D2              <1> 	sub	dx, dx
    94 0000DA24 F7F1                <1> 	div	ecx			; Convert track to head & cyl
    95                              <1> 	; eax (ax) = cylinder, dx (dl) = head (max. FFh)
    96 0000DA26 88D6                <1> 	mov	dh, dl
    97 0000DA28 6659                <1> 	pop	cx			; AX=Cyl, DH=Head, CX=Sector
    98 0000DA2A 8A5602              <1> 	mov	dl, [esi+LD_PhyDrvNo]
    99                              <1> 
   100 0000DA2D 88C5                <1> 	mov	ch, al			; NOTE: max. 1023 cylinders !                   
   101 0000DA2F C0CC02              <1> 	ror	ah, 2			; Rotate 2 bits right
   102 0000DA32 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 0000DA34 B001                <1> 	mov	al, 1 ; 25/02/2016
   113 0000DA36 8A25[61290100]      <1> 	mov	ah, [disk_rw_op]  ; 02h = chs read, 03h = chs write 
   114                              <1> 	;
   115 0000DA3C E81062FFFF          <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 0000DA41 8825[63290100]      <1> 	mov	[disk_rw_err], ah
   122                              <1> 	
   123 0000DA47 59                  <1> 	pop	ecx
   124 0000DA48 58                  <1> 	pop	eax
   125 0000DA49 7314                <1> 	jnc	short chs_read_ok
   126                              <1> 
   127 0000DA4B 803D[63290100]09    <1> 	cmp	byte [disk_rw_err], 09h ; DMA crossed 64K segment boundary
   128 0000DA52 7408                <1> 	je	short chs_read_error_retn
   129                              <1>              
   130 0000DA54 FE0D[62290100]      <1> 	dec	byte [retry_count]
   131 0000DA5A 75B0                <1> 	jnz	short chs_read_retry
   132                              <1> 
   133                              <1> chs_read_error_retn:
   134 0000DA5C F9                  <1> 	stc
   135                              <1> 	;retn
   136 0000DA5D 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 0000DA5F 40                  <1> 	inc	eax ; next sector
   154 0000DA60 81C300020000        <1> 	add	ebx, 512
   155 0000DA66 E29D                <1> 	loop	chs_read_next_sector
   156 0000DA68 EB5E                <1> 	jmp	short update_drv_error_byte
   157                              <1> 
   158                              <1> lba_write:
   159                              <1> 	; 23/02/2016
   160 0000DA6A C605[61290100]1C    <1> 	mov	byte [disk_rw_op], 1Ch ; LBA write
   161 0000DA71 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 0000DA73 C605[61290100]1B    <1> 	mov	byte [disk_rw_op], 1Bh ; LBA read
   185                              <1> 
   186                              <1> lba_rw:
   187                              <1> 	; 17/02/2016
   188 0000DA7A 57                  <1> 	push	edi
   189                              <1> 
   190 0000DA7B 890D[64290100]      <1> 	mov	[sector_count], ecx ; total sector (read) count
   191                              <1> 
   192 0000DA81 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 0000DA84 81F900010000        <1> 	cmp	ecx, 256
   197 0000DA8A 7605                <1> 	jna	short lba_read_rsc
   198 0000DA8C B900010000          <1> 	mov	ecx, 256 ; 17/02/2016
   199                              <1> lba_read_rsc:
   200 0000DA91 290D[64290100]      <1> 	sub	[sector_count], ecx ; remain sectors
   201                              <1> 
   202 0000DA97 89CF                <1> 	mov	edi, ecx 
   203 0000DA99 89C1                <1> 	mov	ecx, eax ; sector number/address
   204                              <1> 
   205 0000DA9B C605[62290100]04    <1> 	mov	byte [retry_count], 4
   206                              <1> lba_read_retry:
   207 0000DAA2 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 0000DAA4 8A25[61290100]      <1> 	mov	ah, [disk_rw_op] ; 1Bh = LBA read, 1Ch = LBA write
   217 0000DAAA E8A261FFFF          <1> 	call	int13h
   218                              <1> 	; al = ? (changed)
   219                              <1> 	; ah = error code
   220 0000DAAF 8825[63290100]      <1> 	mov	[disk_rw_err], ah
   221 0000DAB5 7334                <1> 	jnc	short lba_read_ok
   222 0000DAB7 80FC80              <1> 	cmp	ah, 80h ; time out?
   223 0000DABA 740A                <1>         je      short lba_read_stc_retn
   224 0000DABC FE0D[62290100]      <1> 	dec	byte [retry_count]
   225 0000DAC2 7FDE                <1> 	jg	short lba_read_retry
   226 0000DAC4 743A                <1> 	jz	short lba_read_reset
   227                              <1> 	; sf =  1
   228                              <1> 
   229                              <1> lba_read_stc_retn:
   230 0000DAC6 F9                  <1> 	stc
   231                              <1> lba_read_retn:
   232 0000DAC7 5F                  <1> 	pop	edi
   233                              <1> 
   234                              <1> update_drv_error_byte:
   235 0000DAC8 9C                  <1> 	pushf
   236 0000DAC9 53                  <1> 	push	ebx
   237 0000DACA 6651                <1> 	push	cx
   238                              <1> 	;or	ecx, ecx
   239                              <1> 	;jz	short udrv_errb0
   240 0000DACC 8A0D[63290100]      <1> 	mov	cl, [disk_rw_err]
   241                              <1> udrv_errb0:
   242 0000DAD2 0FB65E02            <1> 	movzx	ebx, byte [esi+LD_PhyDrvNo]
   243 0000DAD6 80FB02              <1> 	cmp	bl, 2
   244 0000DAD9 7203                <1>         jb      short udrv_errb1
   245 0000DADB 80EB7E              <1> 	sub	bl, 7Eh
   246                              <1> 	;cmp	bl, 5
   247                              <1> 	;ja	short udrv_errb2	
   248                              <1> udrv_errb1:
   249 0000DADE 81C3[4BED0000]      <1>         add     ebx, drv.error ; 13/02/2016
   250 0000DAE4 880B                <1> 	mov	[ebx], cl ; error code
   251                              <1> udrv_errb2:
   252 0000DAE6 6659                <1> 	pop	cx
   253 0000DAE8 5B                  <1> 	pop	ebx
   254 0000DAE9 9D                  <1> 	popf
   255 0000DAEA C3                  <1> 	retn
   256                              <1> 
   257                              <1> lba_read_ok:
   258 0000DAEB 89C8                <1> 	mov	eax, ecx ; sector number
   259 0000DAED 01F8                <1> 	add	eax, edi ; sector number (next)
   260 0000DAEF C1E709              <1> 	shl	edi, 9 ; sector count * 512
   261 0000DAF2 01FB                <1> 	add	ebx, edi ; next buffer offset
   262                              <1> 
   263 0000DAF4 8B0D[64290100]      <1> 	mov	ecx, [sector_count] ; remaining sectors
   264 0000DAFA 09C9                <1> 	or	ecx, ecx
   265 0000DAFC 7586                <1> 	jnz	short lba_read_next
   266 0000DAFE EBC7                <1> 	jmp	short lba_read_retn
   267                              <1> 
   268                              <1> lba_read_reset:
   269 0000DB00 B40D                <1> 	mov	ah, 0Dh ; Alternate reset
   270 0000DB02 E84A61FFFF          <1>         call	int13h
   271                              <1> 	; al = ? (changed)
   272                              <1> 	; ah = error code
   273 0000DB07 7399                <1> 	jnc	short lba_read_retry
   274 0000DB09 EBBC                <1> 	jmp	short lba_read_retn
  1925                                  %include 'trdosk8.s' ; 24/01/2016
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.0) - MAIN PROGRAM : trdosk8.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 20/06/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 '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> 
    14                              <1> set_run_sequence:
    15                              <1> 	; 10/06/2016
    16                              <1> 	; 22/05/2016
    17                              <1> 	; 20/05/2016
    18                              <1> 	; 19/05/2016 - TRDOS 386 (TRDOS v2.0)
    19                              <1> 	; TRDOS 386 feature only !
    20                              <1> 	;
    21                              <1> 	; INPUT ->
    22                              <1> 	;	AL = process number (next process)
    23                              <1> 	;
    24                              <1> 	;	this process must be added to run sequence
    25                              <1> 	;
    26                              <1> 	;	[u.pri] = priority of present process
    27                              <1> 	;
    28                              <1> 	;	DL = priority (queue)
    29                              <1> 	;	     0 = background (low) ; run on background 
    30                              <1> 	;	     1 = regular (normal) ; run as regular
    31                              <1> 	;	     2 = event (high)     ; run for event
    32                              <1> 	;
    33                              <1> 	;	1) If the requested process is already running:
    34                              <1> 	;	   a) If present priority is high ([u.pri]=2) 
    35                              <1> 	;	      and requested priority is also high, 
    36                              <1> 	;	      there is nothing to do! Because it has been
    37                              <1> 	;	      done already (before this attempt).		 	
    38                              <1> 	;	   b) If present priority is high ([u.pri]=2)
    39                              <1> 	;	      and requested priority is not high, there is
    40                              <1> 	;	      nothing to do! Because, it's current
    41                              <1> 	;	      run queue is unspecified, here. (It may be in
    42                              <1> 	;	      a waiting list or in a run queue; if the new
    43                              <1> 	;	      priority would be used to add it to relavant
    44                              <1>         ;             run queue, this would be wrong, unnecessary
    45                              <1> 	;	      and destabilizing duplication!)
    46                              <1> 	;	   c) If present priority is not high ([u.pri]<2)
    47                              <1>         ;             and requested priority is high (event),
    48                              <1> 	;	      process will be added to present priority's
    49                              <1> 	;	      run queue and then, priority will be changed
    50                              <1> 	;	      to high ([u.pri]=2).
    51                              <1> 	;	   d) If present priority is not high ([u.pri]<2)
    52                              <1> 	;	      and requested priority is not high, [u.pri]
    53                              <1> 	;	      value will be changed. There is nothing to do
    54                              <1> 	;	      in addition. (The new priority value will be
    55                              <1> 	;	      used by 'tswap/tswitch' procedure at 'sysret'
    56                              <1> 	;	      or 'sysrele' stage.)
    57                              <1> 	;
    58                              <1> 	;	2) If the requested process is not running:
    59                              <1> 	;	   a) If requested priority of the requested
    60                              <1> 	;	      (next) process is high (event) and priority
    61                              <1> 	;	      of present process is not high, the requested
    62                              <1> 	;	      process will be added to ('runq_event') high
    63                              <1> 	;	      priority run queue and then present (running)
    64                              <1> 	;	      process will be stopped (swapped/switched out)
    65                              <1> 	;	      immediately if it is in user mode, or it's 
    66                              <1> 	;	      [u.quant] value will be reset to 0 and (then) 
    67                              <1> 	;	      it will be stopped at 'sysret' stage.			
    68                              <1> 	;	   b) If requested priority of the requested
    69                              <1> 	;	      (next) process is high (event) and priority
    70                              <1> 	;	      of present process is also high, the requested
    71                              <1> 	;	      process will be added to ('runq_event') high
    72                              <1> 	;	      priority run queue and present (running) 
    73                              <1> 	;	      process will be allowed to run until it's 
    74                              <1> 	;	      time quantum will be elapsed ([u.quant]=0).	
    75                              <1> 	;	   c) If requested priority of the requested
    76                              <1> 	;	      (next) process is not high ('run for event'), 
    77                              <1> 	;	      there is nothing to do. Because, it's current
    78                              <1> 	;	      run queue is unspecified, here. (It may be in
    79                              <1> 	;	      a waiting list or in a run queue; if the new
    80                              <1> 	;	      priority would be used to add it to relavant
    81                              <1>         ;             run queue, this would be wrong, unnecessary
    82                              <1> 	;	      and destabilizing duplication!) 
    83                              <1> 	;
    84                              <1> 	; OUTPUT ->
    85                              <1> 	;	none
    86                              <1> 	;
    87                              <1> 	;	[u.pri] = priority of present process
    88                              <1> 	;
    89                              <1> 	;	cf = 1, if the request could not be fulfilled.
    90                              <1> 	;			 	     	  
    91                              <1> 	;	NOTE: 
    92                              <1>         ;          * Processes in 'run as regular' queue can run
    93                              <1> 	;	     if there is no process in 'run for event' queue
    94                              <1> 	;	     ('run for event' processes have higher priority)	 		 
    95                              <1> 	;	   * When [u.quant] time quantum of a process is
    96                              <1> 	;	     elapsed, it's high priority ('run for event')
    97                              <1> 	;	     status will be disabled, it can be run in sequence
    98                              <1> 	;	     of it's actual run queue.
    99                              <1> 	;	   * A 'run on background' process will always be 
   100                              <1> 	;	     sequenced in 'run on background' (low priority)
   101                              <1> 	;	     queue, it can run only when other priority queues
   102                              <1> 	;	     are empty. (idle time processes, e.g. printing)  	 	
   103                              <1> 	;
   104                              <1> 	; Modified registers: eax, ebx, edx, edi
   105                              <1> 	;
   106                              <1> 
   107                              <1> srunseq_0:
   108 0000DB0B 89C3                <1> 	mov	ebx, eax
   109 0000DB0D 31C0                <1> 	xor	eax, eax
   110 0000DB0F BF[6C2D0100]        <1> 	mov	edi, p.pid
   111                              <1> srunseq_1:
   112 0000DB14 3A05[D7300100]      <1>         cmp     al, [u.uno]     ; same process ?
   113 0000DB1A 7514                <1> 	jne	short srunseq_4 ; no
   114                              <1> 
   115 0000DB1C 8A25[CB300100]      <1> 	mov	ah, [u.pri] 	; present/current priority
   116 0000DB22 80FC02              <1> 	cmp	ah, 2       	; 'run for event' priority level
   117 0000DB25 7229                <1> 	jb	short srunseq_8 ; no
   118                              <1> 
   119                              <1> srunseq_2:
   120                              <1> 	; there is nothing to do!
   121 0000DB27 C3                  <1> 	retn
   122                              <1> 
   123                              <1> srunseq_3:
   124 0000DB28 3C10                <1>         cmp     al, nproc       ; number of processes = 16 
   125 0000DB2A 7322                <1> 	jnb	short srunseq_7 ; 'p.pid' values do not match !!!???
   126                              <1> 
   127 0000DB2C 47                  <1> 	inc	edi
   128 0000DB2D 47                  <1> 	inc	edi
   129 0000DB2E EBE4                <1> 	jmp	short srunseq_1
   130                              <1> 
   131                              <1> srunseq_4:
   132                              <1> 	; dl = priority
   133 0000DB30 80FA02              <1> 	cmp	dl, 2 		; event queue
   134 0000DB33 72F2                <1> 	jb	short srunseq_2 ; requested process is not present
   135                              <1> 				; process and priority of requested
   136                              <1> 				; process is not high (event), 
   137                              <1> 				; there is nothing to do!
   138                              <1> 	
   139                              <1> 	; requested process is not present process
   140                              <1> 	; & priority of requested process is high
   141 0000DB35 3A15[CB300100]      <1> 	cmp	dl, [u.pri] 	; priority of present process
   142 0000DB3B 7606                <1> 	jna	short srunseq_5 ; is high, also
   143                              <1> 	;
   144                              <1> 	; present process will be swapped/switched out
   145 0000DB3D FE05[2D2D0100]      <1> 	inc	byte [p_change] ; 1
   146                              <1> 
   147                              <1> srunseq_5:
   148                              <1> 	; add process to 'runq_event' queue for new event
   149 0000DB43 BB[76300100]        <1> 	mov	ebx, runq_event ; high priority run queue
   150                              <1> 
   151                              <1> srunseq_6:
   152                              <1> 	; al = process number
   153                              <1> 	; ebx = run queue
   154 0000DB48 E818FDFFFF          <1> 	call	putlu
   155 0000DB4D C3                  <1> 	retn
   156                              <1> 
   157                              <1> srunseq_7:
   158 0000DB4E F5                  <1> 	cmc
   159 0000DB4F C3                  <1> 	retn
   160                              <1> 
   161                              <1> srunseq_8:
   162                              <1> 	; present priority of the process is not high
   163                              <1> 	
   164 0000DB50 8815[CB300100]      <1> 	mov	[u.pri], dl ; new priority 
   165                              <1> 			    ; (will be used by 'tswap')
   166                              <1> 
   167 0000DB56 80FA02              <1> 	cmp	dl, 2 		; high priority ?
   168 0000DB59 72F3                <1> 	jb	short srunseq_7 ; no, there is nothing to do
   169                              <1> 				; in addition
   170                              <1> 
   171                              <1> 	; process must be added to relevant run queue, here!
   172                              <1> 	; (new priority is high/event priority and process
   173                              <1> 	; will not be added to a run queue by 'tswap')
   174                              <1> 
   175 0000DB5B BB[78300100]        <1> 	mov	ebx, runq_normal ; 'run as regular' queue
   176                              <1> 
   177 0000DB60 20E4                <1> 	and	ah, ah  ;  previous value of [u.pri]
   178 0000DB62 75E4                <1> 	jnz	short srunseq_6
   179                              <1> 
   180 0000DB64 43                  <1> 	inc	ebx
   181 0000DB65 43                  <1> 	inc	ebx
   182                              <1> 	; ebx = runq_background ; 'run on backgroud' queue 
   183                              <1> 
   184 0000DB66 EBE0                <1> 	jmp	short srunseq_6
   185                              <1> 
   186                              <1> clock:
   187                              <1> 	; 23/05/2016
   188                              <1> 	; 22/05/2016
   189                              <1> 	; 20/05/2016
   190                              <1> 	; 19/05/2016 - TRDOS 386 (TRDOS v2.0)
   191                              <1> 	; 14/05/2015 - 14/10/2015 (Retro UNIX 386 v1)
   192                              <1> 	; 07/12/2013 - 10/04/2014 (Retro UNIX 8086 v1)
   193                              <1> 
   194 0000DB68 803D[CA300100]00    <1> 	cmp	byte [u.quant], 0
   195 0000DB6F 772C                <1> 	ja	short clk_1
   196                              <1> 	;
   197 0000DB71 803D[D7300100]01    <1> 	cmp     byte [u.uno], 1 ; /etc/init ? (for Retro UNIX 8086 & 386 v1)
   198                              <1> 				; MainProg (Kernel's Command Interpreter)
   199                              <1> 				; for TRDOS 386.
   200 0000DB78 7623                <1> 	jna	short clk_1 ; yes, do not swap out
   201                              <1> 	;
   202 0000DB7A 803D[7F300100]FF    <1> 	cmp     byte [sysflg], 0FFh ; user or system space ?
   203 0000DB81 7520                <1> 	jne	short clk_2 	    ; system space (sysflg <> 0FFh)
   204                              <1> 	;
   205 0000DB83 66833D[CC300100]00  <1> 	cmp	word [u.intr], 0
   206 0000DB8B 7616                <1> 	jna	short clk_2
   207                              <1> 	;
   208                              <1> 	; 23/05/2016
   209 0000DB8D 803D[2E2D0100]00    <1> 	cmp	byte [multi_tasking], 0
   210 0000DB94 760D                <1> 	jna	short clk_2
   211                              <1> 	;
   212 0000DB96 FE05[2D2D0100]      <1> 	inc	byte [p_change] ; it is time to change running process	
   213 0000DB9C C3                  <1> 	retn
   214                              <1> clk_1:
   215 0000DB9D FE0D[CA300100]      <1> 	dec	byte [u.quant]
   216                              <1> clk_2:
   217 0000DBA3 C3                  <1> 	retn   ; return to (hardware) timer interrupt routine
   218                              <1> 
   219                              <1> 
   220                              <1> ; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
   221                              <1> int34h:  ; #IOCTL# (I/O port access support for ring 3)
   222                              <1> ; 23/05/2016
   223                              <1> 	; 20/06/2016
   224                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
   225                              <1> 	;
   226                              <1> 	; INPUT ->
   227                              <1> 	;	AH = 0 -> read port  (physical IO port)
   228                              <1> 	;	AH = 1 -> write port (physical IO port)
   229                              <1> 	;	AL = data byte
   230                              <1> 	;	DX = Port number (<= 0FFFFh)    	
   231                              <1> 	; OUTPUT ->
   232                              <1> 	;	AL = data byte
   233                              <1> 	;
   234                              <1> 	; Modified registers: none (except AL)
   235                              <1> 	;
   236 0000DBA4 FB                  <1> 	sti	; enable interrupts
   237 0000DBA5 80642408FE          <1> 	and	byte [esp+8], 11111110b	; clear carry bit of eflags register
   238 0000DBAA 80FC01              <1> 	cmp	ah, 1
   239 0000DBAD 7706                <1> 	ja	short int34h_3
   240 0000DBAF 7202                <1> 	jb	short int34h_2
   241                              <1> 	; AH = 1 -> write port
   242 0000DBB1 EE                  <1> 	out	dx, al
   243 0000DBB2 CF                  <1> 	iretd
   244                              <1> int34h_2:
   245                              <1> 	; AH = 0 -> read port
   246 0000DBB3 EC                  <1> 	in	al, dx	
   247 0000DBB4 CF                  <1> 	iretd
   248                              <1> int34h_3:
   249                              <1> 	; AH > 1 -> invalid function for now ; 20/06/2016
   250 0000DBB5 30C0                <1> 	xor	al, al ; 0
   251 0000DBB7 804C240801          <1> 	or	byte [esp+8], 1	; set carry bit of eflags register
   252 0000DBBC CF                  <1> 	iretd
   253                              <1> 
   254                              <1> INT4Ah:
   255                              <1> 	; 24/01/2016
   256                              <1> 	; this procedure will be called by 'RTC_INT' (in 'timer.s')
   257 0000DBBD C3                  <1> 	retn
   258                              <1> 
   259                              <1> ; u0.s
   260                              <1> ; Retro UNIX 386 v1 Kernel (v0.2) - SYS0.INC
   261                              <1> ; Last Modification: 20/11/2015
   262                              <1> 
   263                              <1> com2_int:
   264                              <1> 	; 07/11/2015 
   265                              <1> 	; 24/10/2015
   266                              <1> 	; 23/10/2015
   267                              <1> 	; 14/03/2015 (Retro UNIX 386 v1 - Beginning)
   268                              <1> 	; 28/07/2014 (Retro UNIX 8086 v1)
   269                              <1> 	; < serial port 2 interrupt handler >
   270                              <1> 	;
   271 0000DBBE 890424              <1> 	mov 	[esp], eax ; overwrite call return address
   272                              <1> 	;push	eax
   273 0000DBC1 66B80900            <1> 	mov	ax, 9
   274 0000DBC5 EB07                <1> 	jmp	short comm_int
   275                              <1> com1_int:
   276                              <1> 	; 07/11/2015
   277                              <1> 	; 24/10/2015
   278 0000DBC7 890424              <1> 	mov 	[esp], eax ; overwrite call return address
   279                              <1> 	; 23/10/2015
   280                              <1> 	;push	eax
   281 0000DBCA 66B80800            <1> 	mov	ax, 8
   282                              <1> comm_int:
   283                              <1> 	; 20/11/2015
   284                              <1> 	; 18/11/2015
   285                              <1> 	; 17/11/2015
   286                              <1> 	; 16/11/2015
   287                              <1> 	; 09/11/2015
   288                              <1> 	; 08/11/2015
   289                              <1> 	; 07/11/2015
   290                              <1> 	; 06/11/2015 (serial4.asm, 'serial')	
   291                              <1> 	; 01/11/2015
   292                              <1> 	; 26/10/2015
   293                              <1> 	; 23/10/2015
   294 0000DBCE 53                  <1> 	push	ebx
   295 0000DBCF 56                  <1> 	push	esi
   296 0000DBD0 57                  <1> 	push	edi
   297 0000DBD1 1E                  <1> 	push 	ds
   298 0000DBD2 06                  <1> 	push 	es
   299                              <1> 	; 18/11/2015
   300 0000DBD3 0F20DB              <1> 	mov	ebx, cr3
   301 0000DBD6 53                  <1> 	push	ebx ; ****
   302                              <1> 	;
   303 0000DBD7 51                  <1> 	push	ecx ; ***
   304 0000DBD8 52                  <1> 	push	edx ; **
   305                              <1> 	;
   306 0000DBD9 BB10000000          <1> 	mov	ebx, KDATA
   307 0000DBDE 8EDB                <1> 	mov	ds, bx
   308 0000DBE0 8EC3                <1> 	mov	es, bx
   309                              <1> 	;
   310 0000DBE2 8B0D[A81F0100]      <1> 	mov	ecx, [k_page_dir]
   311 0000DBE8 0F22D9              <1> 	mov	cr3, ecx
   312                              <1> 	; 20/11/2015
   313                              <1> 	; Interrupt identification register
   314 0000DBEB 66BAFA02            <1> 	mov	dx, 2FAh ; COM2
   315                              <1> 	;
   316 0000DBEF 3C08                <1> 	cmp 	al, 8 
   317 0000DBF1 7702                <1> 	ja 	short com_i0
   318                              <1> 	;
   319                              <1> 	; 20/11/2015
   320                              <1> 	; 17/11/2015
   321                              <1> 	; 16/11/2015
   322                              <1> 	; 15/11/2015
   323                              <1> 	; 24/10/2015
   324                              <1> 	; 14/03/2015 (Retro UNIX 386 v1 - Beginning)
   325                              <1> 	; 28/07/2014 (Retro UNIX 8086 v1)
   326                              <1> 	; < serial port 1 interrupt handler >
   327                              <1> 	;
   328 0000DBF3 FEC6                <1> 	inc	dh ; 3FAh ; COM1 Interrupt id. register
   329                              <1> com_i0:
   330                              <1> 	;push	eax ; *
   331                              <1> 	; 07/11/2015
   332 0000DBF5 A2[12200100]        <1> 	mov 	byte [ccomport], al
   333                              <1> 	; 09/11/2015
   334 0000DBFA 0FB7D8              <1> 	movzx	ebx, ax ; 8 or 9
   335                              <1> 	; 17/11/2015
   336                              <1>  	; reset request for response status
   337 0000DBFD 88A3[08200100]      <1> 	mov	[ebx+req_resp-8], ah ; 0
   338                              <1> 	;
   339                              <1> 	; 20/11/2015
   340 0000DC03 EC                  <1> 	in	al, dx		; read interrupt id. register
   341 0000DC04 EB00                <1> 	JMP	$+2	   	; I/O DELAY
   342 0000DC06 2404                <1> 	and	al, 4		; received data available?	
   343 0000DC08 7470                <1> 	jz	short com_eoi	; (transmit. holding reg. empty)
   344                              <1> 	;
   345                              <1> 	; 20/11/2015
   346 0000DC0A 80EA02              <1> 	sub	dl, 3FAh-3F8h	; data register (3F8h, 2F8h)
   347 0000DC0D EC                  <1> 	in	al, dx     	; read character
   348                              <1> 	;JMP	$+2	   	; I/O DELAY
   349                              <1> 	; 08/11/2015
   350                              <1> 	; 07/11/2015
   351 0000DC0E 89DE                <1> 	mov	esi, ebx 
   352 0000DC10 89DF                <1> 	mov	edi, ebx
   353 0000DC12 81C6[0C200100]      <1> 	add 	esi, rchar - 8 ; points to last received char
   354 0000DC18 81C7[0E200100]      <1> 	add	edi, schar - 8 ; points to last sent char
   355 0000DC1E 8806                <1> 	mov	[esi], al ; received char (current char)
   356                              <1> 	; query
   357 0000DC20 20C0                <1> 	and	al, al
   358 0000DC22 7527                <1> 	jnz	short com_i2
   359                              <1>    	; response
   360                              <1> 	; 17/11/2015
   361                              <1> 	; set request for response status
   362 0000DC24 FE83[08200100]      <1>         inc     byte [ebx+req_resp-8] ; 1 
   363                              <1> 	;
   364 0000DC2A 6683C205            <1> 	add	dx, 3FDh-3F8h	; (3FDh, 2FDh)
   365 0000DC2E EC                  <1> 	in	al, dx	   	; read line status register 
   366 0000DC2F EB00                <1> 	JMP	$+2	   	; I/O DELAY
   367 0000DC31 2420                <1> 	and	al, 20h	   	; transmitter holding reg. empty?
   368 0000DC33 7445                <1> 	jz	short com_eoi 	; no
   369 0000DC35 B0FF                <1> 	mov 	al, 0FFh   	; response			
   370 0000DC37 6683EA05            <1> 	sub	dx, 3FDh-3F8h 	; data port (3F8h, 2F8h)
   371 0000DC3B EE                  <1> 	out	dx, al	   	; send on serial port
   372                              <1> 	; 17/11/2015
   373 0000DC3C 803F00              <1> 	cmp 	byte [edi], 0   ; query ? (schar)
   374 0000DC3F 7502                <1> 	jne 	short com_i1    ; no
   375 0000DC41 8807                <1> 	mov	[edi], al 	; 0FFh (responded)
   376                              <1> com_i1:
   377                              <1> 	; 17/11/2015
   378                              <1> 	; reset request for response status (again)
   379 0000DC43 FE8B[08200100]      <1>         dec     byte [ebx+req_resp-8] ; 0 
   380 0000DC49 EB2F                <1> 	jmp	short com_eoi
   381                              <1> com_i2:	
   382                              <1> 	; 08/11/2015
   383 0000DC4B 3CFF                <1> 	cmp 	al, 0FFh	; (response ?)
   384 0000DC4D 7417                <1> 	je	short com_i3	; (check for response signal)
   385                              <1> 	; 07/11/2015
   386 0000DC4F 3C04                <1> 	cmp	al, 04h	; EOT
   387 0000DC51 751C                <1> 	jne	short com_i4	
   388                              <1> 	; EOT = 04h (End of Transmit) - 'CTRL + D'
   389                              <1> 	;(an EOT char is supposed as a ctrl+brk from the terminal)
   390                              <1> 	; 08/11/2015
   391                              <1> 		; ptty -> tty 0 to 7 (pseudo screens)
   392 0000DC53 861D[D61F0100]      <1> 	xchg	bl, [ptty]  ; tty number (8 or 9)
   393 0000DC59 E84D79FFFF          <1> 	call 	ctrlbrk
   394 0000DC5E 861D[D61F0100]      <1> 	xchg	[ptty], bl ; (restore ptty value and BL value)
   395                              <1> 	;mov	al, 04h ; EOT
   396                              <1> 	; 08/11/2015
   397 0000DC64 EB09                <1> 	jmp	short com_i4	
   398                              <1> com_i3:
   399                              <1> 	; 08/11/2015
   400                              <1> 	; If 0FFh has been received just after a query
   401                              <1> 	; (schar, ZERO), it is a response signal.
   402                              <1> 	; 17/11/2015
   403 0000DC66 803F00              <1>         cmp     byte [edi], 0 ; query ? (schar)
   404 0000DC69 7704                <1> 	ja	short com_i4 ; no
   405                              <1> 	; reset query status (schar)
   406 0000DC6B 8807                <1> 	mov	[edi], al ; 0FFh
   407 0000DC6D FEC0                <1> 	inc	al ; 0
   408                              <1> com_i4:
   409                              <1> 	; 27/07/2014
   410                              <1> 	; 09/07/2014
   411 0000DC6F D0E3                <1> 	shl	bl, 1	
   412 0000DC71 81C3[D81F0100]      <1> 	add	ebx, ttychr
   413                              <1> 	; 23/07/2014 (always overwrite)
   414                              <1> 	;;cmp	word [ebx], 0
   415                              <1> 	;;ja	short com_eoi
   416                              <1> 	;
   417 0000DC77 668903              <1> 	mov	[ebx], ax   ; Save ascii code
   418                              <1> 			    ; scan code = 0
   419                              <1> com_eoi:
   420                              <1> 	;mov	al, 20h
   421                              <1> 	;out	20h, al	   ; end of interrupt
   422                              <1> 	;
   423                              <1> 	; 07/11/2015
   424                              <1>       	;pop	eax ; *
   425 0000DC7A A0[12200100]        <1> 	mov	al, byte [ccomport] ; current COM port
   426                              <1> 	 ; al = tty number (8 or 9)
   427 0000DC7F E85E010000          <1>         call	wakeup
   428                              <1> com_iret:
   429                              <1> 	; 23/10/2015
   430 0000DC84 5A                  <1> 	pop	edx ; **
   431 0000DC85 59                  <1> 	pop	ecx ; ***
   432                              <1> 	; 18/11/2015
   433                              <1> 	;pop	eax ; ****
   434                              <1> 	;mov	cr3, eax
   435                              <1> 	;jmp	iiret
   436 0000DC86 E9482DFFFF          <1> 	jmp	iiretp
   437                              <1> 
   438                              <1> ;iiretp: ; 01/09/2015
   439                              <1> ;	; 28/08/2015
   440                              <1> ;	pop	eax ; (*) page directory
   441                              <1> ;	mov	cr3, eax
   442                              <1> ;iiret:
   443                              <1> ;	; 22/08/2014
   444                              <1> ;	mov	al, 20h ; END OF INTERRUPT COMMAND TO 8259
   445                              <1> ;	out	20h, al	; 8259 PORT
   446                              <1> ;	;
   447                              <1> ;	pop	es
   448                              <1> ;	pop	ds
   449                              <1> ;	pop	edi
   450                              <1> ;	pop	esi
   451                              <1> ;	pop	ebx ; 29/08/2014
   452                              <1> ;	pop 	eax
   453                              <1> ;	iretd
   454                              <1> 
   455                              <1> sp_init:
   456                              <1> 	; 07/11/2015
   457                              <1> 	; 29/10/2015
   458                              <1> 	; 26/10/2015
   459                              <1> 	; 23/10/2015
   460                              <1> 	; 29/06/2015
   461                              <1> 	; 14/03/2015 (Retro UNIX 386 v1 - 115200 baud)
   462                              <1> 	; 28/07/2014 (Retro UNIX 8086 v1 - 9600 baud)
   463                              <1> 	; Initialization of Serial Port Communication Parameters
   464                              <1> 	; (COM1 base port address = 3F8h, COM1 Interrupt = IRQ 4)
   465                              <1> 	; (COM2 base port address = 2F8h, COM1 Interrupt = IRQ 3)
   466                              <1> 	;
   467                              <1> 	; ((Modified registers: EAX, ECX, EDX, EBX))
   468                              <1> 	;
   469                              <1> 	; INPUT:  (29/06/2015)
   470                              <1> 	;	AL = 0 for COM1
   471                              <1> 	;	     1 for COM2
   472                              <1> 	;	AH = Communication parameters	
   473                              <1> 	;
   474                              <1> 	;  (*) Communication parameters (except BAUD RATE):
   475                              <1> 	;	Bit	4	3	2	1	0
   476                              <1> 	;		-PARITY--   STOP BIT  -WORD LENGTH-	 		 
   477                              <1> 	;  this one -->	00 = none    0 = 1 bit  11 = 8 bits
   478                              <1> 	;		01 = odd     1 = 2 bits	10 = 7 bits
   479                              <1> 	;		11 = even
   480                              <1> 	;  Baud rate setting bits: (29/06/2015)
   481                              <1> 	;		Retro UNIX 386 v1 feature only !
   482                              <1> 	;	Bit	7    6    5  | Baud rate
   483                              <1> 	;		------------------------
   484                              <1> 	;	value	0    0    0  | Default (Divisor = 1)
   485                              <1> 	;		0    0    1  | 9600 (12)
   486                              <1> 	;		0    1    0  | 19200 (6) 
   487                              <1> 	;		0    1	  1  | 38400 (3) 
   488                              <1> 	;		1    0	  0  | 14400 (8)
   489                              <1> 	;		1    0	  1  | 28800 (4)
   490                              <1> 	;		1    1    0  | 57600 (2)
   491                              <1> 	;		1    1    1  | 115200 (1) 	
   492                              <1> 	
   493                              <1> 	; References:	
   494                              <1> 	; (1) IBM PC-XT Model 286 BIOS Source Code
   495                              <1> 	;     RS232.ASM --- 10/06/1985 COMMUNICATIONS BIOS (RS232)
   496                              <1> 	; (2) Award BIOS 1999 - ATORGS.ASM
   497                              <1> 	; (3) http://wiki.osdev.org/Serial_Ports
   498                              <1> 	;
   499                              <1> 	; Set communication parameters for COM1 (= 03h)	
   500                              <1> 	;
   501 0000DC8B BB[0E200100]        <1> 	mov	ebx, com1p		; COM1 parameters  
   502 0000DC90 66BAF803            <1> 	mov	dx, 3F8h		; COM1
   503                              <1> 	 ; 29/10/2015
   504 0000DC94 66B90103            <1> 	mov	cx, 301h  ; divisor = 1 (115200 baud)
   505 0000DC98 E86F000000          <1> 	call	sp_i3	; call A4	
   506 0000DC9D A880                <1> 	test	al, 80h
   507 0000DC9F 7410                <1> 	jz	short sp_i0 ; OK..
   508                              <1> 		; Error !
   509                              <1> 	;mov	dx, 3F8h
   510 0000DCA1 80EA05              <1> 	sub	dl, 5 ; 3FDh -> 3F8h
   511 0000DCA4 66B90E03            <1> 	mov	cx, 30Eh  ; divisor = 12 (9600 baud)
   512 0000DCA8 E85F000000          <1> 	call	sp_i3	; call A4	
   513 0000DCAD A880                <1> 	test	al, 80h
   514 0000DCAF 7508                <1> 	jnz	short sp_i1
   515                              <1> sp_i0:
   516                              <1>         ; (Note: Serial port interrupts will be disabled here...)	
   517                              <1>         ; (INT 14h initialization code disables interrupts.)
   518                              <1> 	;
   519 0000DCB1 C603E3              <1> 	mov	byte [ebx], 0E3h ; 11100011b
   520 0000DCB4 E8DC000000          <1> 	call	sp_i5 ; 29/06/2015
   521                              <1> sp_i1:
   522 0000DCB9 43                  <1> 	inc	ebx
   523 0000DCBA 66BAF802            <1> 	mov	dx, 2F8h		; COM2
   524                              <1> 	 ; 29/10/2015
   525 0000DCBE 66B90103            <1> 	mov	cx, 301h  ; divisor = 1 (115200 baud)
   526 0000DCC2 E845000000          <1> 	call	sp_i3	; call A4	
   527 0000DCC7 A880                <1> 	test	al, 80h
   528 0000DCC9 7410                <1> 	jz	short sp_i2 ; OK..
   529                              <1> 		; Error !
   530                              <1> 	;mov	dx, 2F8h
   531 0000DCCB 80EA05              <1> 	sub	dl, 5 ; 2FDh -> 2F8h
   532 0000DCCE 66B90E03            <1> 	mov	cx, 30Eh  ; divisor = 12 (9600 baud)
   533 0000DCD2 E835000000          <1> 	call	sp_i3	; call A4	
   534 0000DCD7 A880                <1> 	test	al, 80h
   535 0000DCD9 7530                <1> 	jnz	short sp_i7
   536                              <1> sp_i2:
   537 0000DCDB C603E3              <1> 	mov	byte [ebx], 0E3h ; 11100011b
   538                              <1> sp_i6:
   539                              <1> 	;; COM2 - enabling IRQ 3
   540                              <1> 	; 07/11/2015
   541                              <1> 	; 26/10/2015
   542 0000DCDE 9C                  <1> 	pushf
   543 0000DCDF FA                  <1> 	cli
   544                              <1> 	;
   545 0000DCE0 66BAFC02            <1> 	mov	dx, 2FCh   		; modem control register
   546 0000DCE4 EC                  <1> 	in	al, dx 	   		; read register
   547 0000DCE5 EB00                <1> 	JMP	$+2	   		; I/O DELAY
   548 0000DCE7 0C08                <1> 	or	al, 8      		; enable bit 3 (OUT2)
   549 0000DCE9 EE                  <1> 	out	dx, al     		; write back to register
   550 0000DCEA EB00                <1> 	JMP	$+2	   		; I/O DELAY
   551 0000DCEC 66BAF902            <1> 	mov	dx, 2F9h   		; interrupt enable register
   552 0000DCF0 EC                  <1> 	in	al, dx     		; read register
   553 0000DCF1 EB00                <1> 	JMP	$+2	   		; I/O DELAY
   554                              <1> 	;or	al, 1      		; receiver data interrupt enable and
   555 0000DCF3 0C03                <1> 	or	al, 3	   		; transmitter empty interrupt enable
   556 0000DCF5 EE                  <1> 	out	dx, al 	   		; write back to register
   557 0000DCF6 EB00                <1> 	JMP	$+2        		; I/O DELAY
   558 0000DCF8 E421                <1> 	in	al, 21h    		; read interrupt mask register
   559 0000DCFA EB00                <1> 	JMP	$+2	   		; I/O DELAY
   560 0000DCFC 24F7                <1> 	and	al, 0F7h   		; enable IRQ 3 (COM2)
   561 0000DCFE E621                <1> 	out	21h, al    		; write back to register
   562                              <1> 	;
   563                              <1> 	; 23/10/2015
   564 0000DD00 B8[BEDB0000]        <1> 	mov 	eax, com2_int
   565 0000DD05 A3[DDDD0000]        <1> 	mov	[com2_irq3], eax
   566                              <1> 	; 26/10/2015
   567 0000DD0A 9D                  <1> 	popf	
   568                              <1> sp_i7:
   569 0000DD0B C3                  <1> 	retn
   570                              <1> 
   571                              <1> sp_i3:
   572                              <1> ;A4:  	;-----	INITIALIZE THE COMMUNICATIONS PORT
   573                              <1> 	; 28/10/2015
   574 0000DD0C FEC2                <1> 	inc	dl	; 3F9h (2F9h)	; 3F9h, COM1 Interrupt enable register 
   575 0000DD0E B000                <1> 	mov	al, 0
   576 0000DD10 EE                  <1> 	out	dx, al			; disable serial port interrupt
   577 0000DD11 EB00                <1> 	JMP	$+2			; I/O DELAY
   578 0000DD13 80C202              <1> 	add	dl, 2 	; 3FBh (2FBh)	; COM1 Line control register (3FBh)
   579 0000DD16 B080                <1> 	mov	al, 80h			
   580 0000DD18 EE                  <1> 	out	dx, al			; SET DLAB=1 ; divisor latch access bit
   581                              <1> 	;-----	SET BAUD RATE DIVISOR
   582                              <1> 	; 26/10/2015
   583 0000DD19 80EA03              <1> 	sub 	dl, 3   ; 3F8h (2F8h)	; register for least significant byte
   584                              <1> 					; of the divisor value
   585 0000DD1C 88C8                <1> 	mov	al, cl	; 1
   586 0000DD1E EE                  <1> 	out	dx, al			; 1 = 115200 baud (Retro UNIX 386 v1)
   587                              <1> 					; 2 = 57600 baud
   588                              <1> 					; 3 = 38400 baud
   589                              <1> 					; 6 = 19200 baud
   590                              <1> 					; 12 = 9600 baud (Retro UNIX 8086 v1)
   591 0000DD1F EB00                <1> 	JMP	$+2			; I/O DELAY
   592 0000DD21 28C0                <1> 	sub	al, al
   593 0000DD23 FEC2                <1> 	inc	dl      ; 3F9h (2F9h)	; register for most significant byte
   594                              <1> 					; of the divisor value
   595 0000DD25 EE                  <1> 	out	dx, al ; 0
   596 0000DD26 EB00                <1> 	JMP	$+2			; I/O DELAY
   597                              <1> 	;	
   598 0000DD28 88E8                <1> 	mov	al, ch ; 3		; 8 data bits, 1 stop bit, no parity
   599                              <1> 	;and	al, 1Fh ; Bits 0,1,2,3,4	
   600 0000DD2A 80C202              <1> 	add	dl, 2	; 3FBh (2FBh)	; Line control register
   601 0000DD2D EE                  <1> 	out	dx, al			
   602 0000DD2E EB00                <1> 	JMP	$+2			; I/O DELAY
   603                              <1> 	; 29/10/2015
   604 0000DD30 FECA                <1> 	dec 	dl 	; 3FAh (2FAh)	; FIFO Control register (16550/16750)
   605 0000DD32 30C0                <1> 	xor	al, al			; 0
   606 0000DD34 EE                  <1> 	out	dx, al			; Disable FIFOs (reset to 8250 mode)
   607 0000DD35 EB00                <1> 	JMP	$+2	
   608                              <1> sp_i4:
   609                              <1> ;A18:	;-----	COMM PORT STATUS ROUTINE
   610                              <1> 	; 29/06/2015 (line status after modem status)
   611 0000DD37 80C204              <1> 	add	dl, 4	; 3FEh (2FEh)	; Modem status register
   612                              <1> sp_i4s:
   613 0000DD3A EC                  <1> 	in	al, dx			; GET MODEM CONTROL STATUS
   614 0000DD3B EB00                <1> 	JMP	$+2			; I/O DELAY
   615 0000DD3D 88C4                <1> 	mov	ah, al			; PUT IN (AH) FOR RETURN
   616 0000DD3F FECA                <1> 	dec	dl	; 3FDh (2FDh)	; POINT TO LINE STATUS REGISTER
   617                              <1> 					; dx = 3FDh for COM1, 2FDh for COM2
   618 0000DD41 EC                  <1> 	in	al, dx			; GET LINE CONTROL STATUS
   619                              <1> 	; AL = Line status, AH = Modem status
   620 0000DD42 C3                  <1> 	retn
   621                              <1> 
   622                              <1> sp_status:
   623                              <1> 	; 29/06/2015
   624                              <1> 	; 27/06/2015 (Retro UNIX 386 v1)
   625                              <1> 	; Get serial port status
   626 0000DD43 66BAFE03            <1> 	mov	dx, 3FEh		; Modem status register (COM1)
   627 0000DD47 28C6                <1> 	sub	dh, al			; dh = 2 for COM2 (al = 1)
   628                              <1> 					; dx = 2FEh for COM2
   629 0000DD49 EBEF                <1> 	jmp	short sp_i4s
   630                              <1> 
   631                              <1> sp_setp: ; Set serial port communication parameters
   632                              <1> 	; 07/11/2015
   633                              <1> 	; 29/10/2015
   634                              <1> 	; 29/06/2015
   635                              <1> 	; Retro UNIX 386 v1 feature only !	
   636                              <1> 	;
   637                              <1> 	; INPUT:
   638                              <1> 	;	AL = 0 for COM1
   639                              <1> 	;	     1 for COM2
   640                              <1> 	;	AH = Communication parameters (*)
   641                              <1> 	; OUTPUT:
   642                              <1> 	;	CL = Line status
   643                              <1> 	;	CH = Modem status
   644                              <1> 	;   If cf = 1 -> Error code in [u.error]
   645                              <1> 	;		 'invalid parameter !' 
   646                              <1> 	;		 	 or
   647                              <1> 	;		 'device not ready !' error
   648                              <1> 	;	
   649                              <1> 	;  (*) Communication parameters (except BAUD RATE):
   650                              <1> 	;	Bit	4	3	2	1	0
   651                              <1> 	;		-PARITY--   STOP BIT  -WORD LENGTH-	 		 
   652                              <1> 	;  this one -->	00 = none    0 = 1 bit  11 = 8 bits
   653                              <1> 	;		01 = odd     1 = 2 bits	10 = 7 bits
   654                              <1> 	;		11 = even
   655                              <1> 	;  Baud rate setting bits: (29/06/2015)
   656                              <1> 	;		Retro UNIX 386 v1 feature only !
   657                              <1> 	;	Bit	7    6    5  | Baud rate
   658                              <1> 	;		------------------------
   659                              <1> 	;	value	0    0    0  | Default (Divisor = 1)
   660                              <1> 	;		0    0    1  | 9600 (12)
   661                              <1> 	;		0    1    0  | 19200 (6) 
   662                              <1> 	;		0    1	  1  | 38400 (3) 
   663                              <1> 	;		1    0	  0  | 14400 (8)
   664                              <1> 	;		1    0	  1  | 28800 (4)
   665                              <1> 	;		1    1    0  | 57600 (2)
   666                              <1> 	;		1    1    1  | 115200 (1) 
   667                              <1> 	;
   668                              <1> 	; (COM1 base port address = 3F8h, COM1 Interrupt = IRQ 4)
   669                              <1> 	; (COM2 base port address = 2F8h, COM1 Interrupt = IRQ 3)
   670                              <1> 	;
   671                              <1> 	; ((Modified registers: EAX, ECX, EDX, EBX))
   672                              <1> 	;
   673 0000DD4B 66BAF803            <1> 	mov	dx, 3F8h
   674 0000DD4F BB[0E200100]        <1> 	mov	ebx, com1p ; COM1 control byte offset
   675 0000DD54 3C01                <1> 	cmp	al, 1
   676 0000DD56 776B                <1> 	ja 	short sp_invp_err
   677 0000DD58 7203                <1> 	jb	short sp_setp1 ;  COM1 (AL = 0)
   678 0000DD5A FECE                <1> 	dec	dh ; 2F8h
   679 0000DD5C 43                  <1> 	inc	ebx ; COM2 control byte offset
   680                              <1> sp_setp1:
   681                              <1> 	; 29/10/2015
   682 0000DD5D 8823                <1> 	mov	[ebx], ah
   683 0000DD5F 0FB6CC              <1> 	movzx 	ecx, ah
   684 0000DD62 C0E905              <1> 	shr	cl, 5 ; -> baud rate index
   685 0000DD65 80E41F              <1> 	and	ah, 1Fh ; communication parameters except baud rate
   686 0000DD68 8A81[D2DD0000]      <1> 	mov	al, [ecx+b_div_tbl]
   687 0000DD6E 6689C1              <1> 	mov	cx, ax
   688 0000DD71 E896FFFFFF          <1> 	call	sp_i3
   689 0000DD76 6689C1              <1> 	mov	cx, ax ; CL = Line status, CH = Modem status
   690 0000DD79 A880                <1> 	test	al, 80h
   691 0000DD7B 740F                <1> 	jz	short sp_setp2
   692 0000DD7D C603E3              <1>         mov     byte [ebx], 0E3h ; Reset to initial value (11100011b)
   693                              <1> stp_dnr_err:
   694 0000DD80 C705[DD300100]0F00- <1> 	mov	dword [u.error], ERR_DEV_NOT_RDY ; 'device not ready !'
   694 0000DD88 0000                <1>
   695                              <1> 	; CL = Line status, CH = Modem status
   696 0000DD8A F9                  <1> 	stc
   697 0000DD8B C3                  <1> 	retn
   698                              <1> sp_setp2:
   699 0000DD8C 80FE02              <1> 	cmp	dh, 2 ; COM2 (2F?h)
   700 0000DD8F 0F8649FFFFFF        <1>         jna     sp_i6 
   701                              <1> 		      ; COM1 (3F?h)
   702                              <1> sp_i5: 
   703                              <1> 	; 07/11/2015
   704                              <1> 	; 26/10/2015
   705                              <1> 	; 29/06/2015
   706                              <1> 	;
   707                              <1> 	;; COM1 - enabling IRQ 4
   708 0000DD95 9C                  <1> 	pushf
   709 0000DD96 FA                  <1> 	cli
   710 0000DD97 66BAFC03            <1> 	mov	dx, 3FCh   		; modem control register
   711 0000DD9B EC                  <1> 	in	al, dx 	   		; read register
   712 0000DD9C EB00                <1> 	JMP	$+2			; I/O DELAY
   713 0000DD9E 0C08                <1> 	or	al, 8      		; enable bit 3 (OUT2)
   714 0000DDA0 EE                  <1> 	out	dx, al     		; write back to register
   715 0000DDA1 EB00                <1> 	JMP	$+2			; I/O DELAY
   716 0000DDA3 66BAF903            <1> 	mov	dx, 3F9h   		; interrupt enable register
   717 0000DDA7 EC                  <1> 	in	al, dx     		; read register
   718 0000DDA8 EB00                <1> 	JMP	$+2			; I/O DELAY
   719                              <1> 	;or	al, 1      		; receiver data interrupt enable and
   720 0000DDAA 0C03                <1> 	or	al, 3	   		; transmitter empty interrupt enable
   721 0000DDAC EE                  <1> 	out	dx, al 	   		; write back to register
   722 0000DDAD EB00                <1> 	JMP	$+2        		; I/O DELAY
   723 0000DDAF E421                <1> 	in	al, 21h    		; read interrupt mask register
   724 0000DDB1 EB00                <1> 	JMP	$+2			; I/O DELAY
   725 0000DDB3 24EF                <1> 	and	al, 0EFh   		; enable IRQ 4 (COM1)
   726 0000DDB5 E621                <1> 	out	21h, al    		; write back to register
   727                              <1> 	;
   728                              <1> 	; 23/10/2015
   729 0000DDB7 B8[C7DB0000]        <1> 	mov 	eax, com1_int
   730 0000DDBC A3[D9DD0000]        <1> 	mov	[com1_irq4], eax
   731                              <1> 	; 26/10/2015
   732 0000DDC1 9D                  <1> 	popf
   733 0000DDC2 C3                  <1> 	retn
   734                              <1> 
   735                              <1> sp_invp_err:
   736 0000DDC3 C705[DD300100]1700- <1> 	mov	dword [u.error], ERR_INV_PARAMETER ; 'invalid parameter !' 
   736 0000DDCB 0000                <1>
   737 0000DDCD 31C9                <1> 	xor	ecx, ecx
   738 0000DDCF 49                  <1> 	dec	ecx ; 0FFFFh
   739 0000DDD0 F9                  <1> 	stc
   740 0000DDD1 C3                  <1> 	retn
   741                              <1> 
   742                              <1> ; 29/10/2015
   743                              <1> b_div_tbl: ; Baud rate divisor table (115200/divisor)
   744 0000DDD2 010C0603080401      <1> 	db 1, 12, 6, 3, 8, 4, 1
   745                              <1> 
   746                              <1> 
   747                              <1> ; 23/10/2015
   748                              <1> com1_irq4:
   749 0000DDD9 [E1DD0000]          <1> 	dd dummy_retn
   750                              <1> com2_irq3:
   751 0000DDDD [E1DD0000]          <1> 	dd dummy_retn
   752                              <1> 
   753                              <1> dummy_retn:
   754 0000DDE1 C3                  <1> 	retn
   755                              <1> 
   756                              <1> wakeup:
   757                              <1> 	; 24/01/2016
   758 0000DDE2 C3                  <1> 	retn
  1926                                  %include 'trdosk9.s' ; 04/01/2016
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.0) - INITIALIZED DATA : trdosk9.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 30/07/2016
     5                              <1> ; ----------------------------------------------------------------------------
     6                              <1> ; Beginning: 04/01/2016
     7                              <1> ; ----------------------------------------------------------------------------
     8                              <1> ; ----------------------------------------------------------------------------
     9                              <1> ; Assembler: NASM version 2.11 (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 0000DDE3 01                  <1> 		db 1 ; A: = 0 & B: = 1
    22                              <1> 
    23                              <1> Restore_CDIR:	
    24 0000DDE4 FF                  <1> 		db 0FFh ; Initial value -> any number except 0
    25                              <1> 
    26                              <1> msg_CRLF_temp:  
    27 0000DDE5 070D0A00            <1> 		db  07h, 0Dh, 0Ah, 0
    28                              <1> 
    29                              <1> Magic_Bytes:
    30 0000DDE9 04                  <1> 		db 4
    31 0000DDEA 01                  <1> 		db 1
    32                              <1> mainprog_Version:
    33 0000DDEB 07                  <1> 		db 7
    34 0000DDEC 5B5452444F535D204D- <1> 		db "[TRDOS] Main Program v2.0.300716"
    34 0000DDF5 61696E2050726F6772- <1>
    34 0000DDFE 616D2076322E302E33- <1>
    34 0000DE07 3030373136          <1>
    35 0000DE0C 0D0A                <1> 		db 0Dh, 0Ah
    36 0000DE0E 286329204572646F67- <1> 		db "(c) Erdogan Tan 2005-2016"
    36 0000DE17 616E2054616E203230- <1>
    36 0000DE20 30352D32303136      <1>
    37 0000DE27 0D0A00              <1> 		db 0Dh, 0Ah, 0
    38                              <1> 
    39                              <1> MainProgCfgFile: ; 14/04/2016
    40 0000DE2A 4D41494E50524F472E- <1> 		db "MAINPROG.CFG", 0
    40 0000DE33 43464700            <1>
    41                              <1> 
    42                              <1> TRDOSPromptLabel:
    43 0000DE37 5452444F53          <1> 		db "TRDOS"
    44 0000DE3C 00                  <1> 		db 0
    45 0000DE3D 00<rept>            <1>                 times 5 db 0
    46 0000DE42 00                  <1> 		db 0
    47                              <1> 
    48                              <1> ; INTERNAL COMMANDS
    49                              <1> Command_List:
    50 0000DE43 44495200            <1> Cmd_Dir:	db "DIR", 0
    51 0000DE47 434400              <1> Cmd_Cd:		db "CD", 0
    52 0000DE4A 433A00              <1> Cmd_Drive:	db "C:", 0
    53 0000DE4D 56455200            <1> Cmd_Ver:	db "VER", 0
    54 0000DE51 4558495400          <1> Cmd_Exit:	db "EXIT", 0
    55 0000DE56 50524F4D505400      <1> Cmd_Prompt:	db "PROMPT", 0
    56 0000DE5D 564F4C554D4500      <1> Cmd_Volume:	db "VOLUME", 0
    57 0000DE64 4C4F4E474E414D4500  <1> Cmd_LongName:	db "LONGNAME", 0
    58 0000DE6D 4441544500          <1> Cmd_Date:	db "DATE", 0
    59 0000DE72 54494D4500          <1> Cmd_Time:	db "TIME", 0
    60 0000DE77 52554E00            <1> Cmd_Run:	db "RUN", 0
    61 0000DE7B 53455400            <1> Cmd_Set:	db "SET", 0 
    62 0000DE7F 434C5300            <1> Cmd_Cls:	db "CLS", 0
    63 0000DE83 53484F5700          <1> Cmd_Show:	db "SHOW", 0
    64 0000DE88 44454C00            <1> Cmd_Del:	db "DEL", 0
    65 0000DE8C 41545452494200      <1> Cmd_Attrib:	db "ATTRIB", 0
    66 0000DE93 52454E414D4500      <1> Cmd_Rename:	db "RENAME", 0
    67 0000DE9A 524D44495200        <1> Cmd_Rmdir:	db "RMDIR", 0
    68 0000DEA0 4D4B44495200        <1> Cmd_Mkdir:	db "MKDIR", 0
    69 0000DEA6 434F505900          <1> Cmd_Copy:	db "COPY", 0
    70 0000DEAB 4D4F564500          <1> Cmd_Move:	db "MOVE", 0
    71 0000DEB0 5041544800          <1> Cmd_Path:	db "PATH", 0
    72 0000DEB5 4D454D00            <1> Cmd_Mem:	db "MEM", 0
    73 0000DEB9 00                  <1> 		db 0
    74 0000DEBA 46494E4400          <1> Cmd_Find:	db "FIND", 0
    75 0000DEBF 5245414446494C4500  <1> Cmd_ReadFile:	db "READFILE", 0
    76 0000DEC8 4543484F00          <1> Cmd_Echo:	db "ECHO", 0
    77 0000DECD 2A00                <1> Cmd_Remark:	db "*", 0
    78 0000DECF 3F00                <1> Cmd_Help:	db "?", 0
    79 0000DED1 44455649434500      <1> Cmd_Device:	db "DEVICE", 0
    80 0000DED8 4445564C49535400    <1> Cmd_DevList:	db "DEVLIST", 0
    81 0000DEE0 434844495200        <1> Cmd_Chdir:	db "CHDIR", 0
    82 0000DEE6 4245455000          <1> Cmd_Beep:	db "BEEP", 0
    83                              <1> 		
    84 0000DEEB 00                  <1> 		db 0
    85                              <1> 
    86                              <1> ; 15/02/2016 (FILE.ASM, 09/10/2011)
    87                              <1> invalid_fname_chars:
    88 0000DEEC 222728292A2B2C2F    <1> 		db 22h, 27h, 28h, 29h, 2Ah, 2Bh, 2Ch, 2Fh
    89 0000DEF4 3A3B3C3D3E3F40      <1> 		db 3Ah, 3Bh, 3Ch, 3Dh, 3Eh, 3Fh, 40h
    90 0000DEFB 5B5C5D5E60          <1> 		db 5Bh, 5Ch, 5Dh, 5Eh, 60h
    91                              <1> sizeInvFnChars  equ ($ - invalid_fname_chars)                
    92                              <1> ;
    93                              <1> 
    94                              <1> Msg_Enter_Date:
    95 0000DF00 456E746572206E6577- <1>                 db 'Enter new date (dd-mm-yy): '
    95 0000DF09 206461746520286464- <1>
    95 0000DF12 2D6D6D2D7979293A20  <1>
    96 0000DF1B 00                  <1>                 db 0
    97                              <1> Msg_Show_Date:
    98 0000DF1C 43757272656E742064- <1>                 db   'Current date is '
    98 0000DF25 61746520697320      <1>
    99 0000DF2C 30                  <1> Day:            db   '0'
   100 0000DF2D 30                  <1> 		db   '0'
   101 0000DF2E 2F                  <1>                 db   '/'
   102 0000DF2F 30                  <1> Month:          db   '0'
   103 0000DF30 30                  <1> 		db   '0'
   104 0000DF31 2F                  <1>                 db   '/'
   105 0000DF32 30                  <1> Century:        db   '0'
   106 0000DF33 30                  <1>                 db   '0'
   107 0000DF34 30                  <1> Year:           db   '0'
   108 0000DF35 30                  <1> 		db   '0'
   109 0000DF36 0D0A00              <1>                 db   0Dh, 0Ah, 0
   110                              <1> 
   111                              <1> Msg_Enter_Time:
   112 0000DF39 456E746572206E6577- <1> 		db 'Enter new time: '
   112 0000DF42 2074696D653A20      <1>
   113 0000DF49 00                  <1> 		db 0
   114                              <1> Msg_Show_Time:
   115 0000DF4A 43757272656E742074- <1> 		db   'Current time is '
   115 0000DF53 696D6520697320      <1>
   116 0000DF5A 30                  <1> Hour:           db   '0'
   117 0000DF5B 30                  <1> 		db   '0'
   118 0000DF5C 3A                  <1> 		db   ':'
   119 0000DF5D 30                  <1> Minute:         db   '0'
   120 0000DF5E 30                  <1> 		db   '0'
   121 0000DF5F 3A                  <1> 		db   ':'
   122 0000DF60 30                  <1> Second:         db   '0'
   123 0000DF61 30                  <1> 		db   '0'
   124 0000DF62 0D0A00              <1> 		db   0Dh, 0Ah, 0
   125                              <1> 
   126                              <1> ;VolSize_Unit1:   dd 0
   127                              <1> ;VolSize_Unit2:   dd 0
   128                              <1> 
   129                              <1> VolSize_KiloBytes:
   130 0000DF65 206B696C6F62797465- <1> 		db " kilobytes", 0Dh, 0Ah, 0
   130 0000DF6E 730D0A00            <1>
   131                              <1> VolSize_Bytes:
   132 0000DF72 2062797465730D0A00  <1> 		db " bytes", 0Dh, 0Ah, 0
   133                              <1> Volume_in_drive:
   134 0000DF7B 0D0A                <1> 		db 0Dh, 0Ah
   135                              <1> Vol_FS_Name:
   136 0000DF7D 54522046533120      <1> 		db "TR FS1 "
   137 0000DF84 566F6C756D6520696E- <1> 		db "Volume in drive "
   137 0000DF8D 20647269766520      <1>
   138 0000DF94 30                  <1> Vol_Drv_Name:   db 30h
   139 0000DF95 3A                  <1> 		db ":"
   140 0000DF96 20697320            <1> 		db " is "
   141 0000DF9A 0D0A00              <1> 		db 0Dh, 0Ah, 0
   142                              <1> Dir_Drive_Str:
   143 0000DF9D 54522D444F53204472- <1>                 db "TR-DOS Drive "
   143 0000DFA6 69766520            <1>
   144                              <1> Dir_Drive_Name:
   145 0000DFAA 303A                <1>                 db "0:"
   146 0000DFAC 0D0A                <1>                 db  0Dh, 0Ah
   147                              <1> Vol_Str_Header:
   148 0000DFAE 566F6C756D65204E61- <1>                 db "Volume Name: "
   148 0000DFB7 6D653A20            <1>
   149                              <1> Vol_Name:
   150 0000DFBB 00<rept>            <1> 		times 64 db 0
   151 0000DFFB 00                  <1> 		db 0
   152                              <1> Vol_Serial_Header:
   153 0000DFFC 0D0A                <1> 		db 0Dh, 0Ah
   154 0000DFFE 566F6C756D65205365- <1> 		db "Volume Serial No: "
   154 0000E007 7269616C204E6F3A20  <1>
   155                              <1> Vol_Serial1:
   156 0000E010 30303030            <1> 		db "0000"
   157 0000E014 2D                  <1> 		db "-"
   158                              <1> Vol_Serial2:
   159 0000E015 30303030            <1> 		db "0000"
   160 0000E019 0D0A00              <1> 		db 0Dh, 0Ah, 0
   161                              <1> 
   162                              <1> ;Vol_Tot_Sec_Str_Start:
   163                              <1> ;		dd 0
   164                              <1> Vol_Total_Sector_Header:
   165 0000E01C 0D0A                <1> 		db 0Dh, 0Ah
   166 0000E01E 566F6C756D65205369- <1> 		db "Volume Size : ", 0
   166 0000E027 7A65203A2000        <1>
   167                              <1> ;Vol_Tot_Sec_Str: 
   168                              <1> ;		db "0000000000"
   169                              <1> ;Vol_Tot_Sec_Str_End:
   170                              <1> ;		db 0
   171                              <1> ;Vol_Free_Sectors_Str_Start:
   172                              <1> ;		dd 0
   173                              <1> Vol_Free_Sectors_Header:
   174 0000E02D 467265652053706163- <1> 		db "Free Space  : ", 0
   174 0000E036 6520203A2000        <1>
   175                              <1> ;Vol_Free_Sectors_Str:
   176                              <1> ;		db "0000000000"
   177                              <1> ;Vol_Free_Sectors_Str_End:
   178                              <1> ;		db 0
   179                              <1> 
   180                              <1> Dir_Str_Header:
   181 0000E03C 4469726563746F7279- <1>                 db "Directory: "
   181 0000E045 3A20                <1>
   182 0000E047 2F                  <1> Dir_Str_Root:   db "/"
   183 0000E048 00<rept>            <1> Dir_Str:        times 64 db 0
   184 0000E088 00000000            <1>                 dd 0
   185 0000E08C 00                  <1>                 db 0
   186                              <1> 
   187                              <1> Msg_Bad_Command:
   188 0000E08D 42616420636F6D6D61- <1>                 db "Bad command or file name!"
   188 0000E096 6E64206F722066696C- <1>
   188 0000E09F 65206E616D6521      <1>
   189 0000E0A6 0D0A00              <1>                 db 0Dh, 0Ah, 0
   190                              <1> 
   191                              <1> msgl_drv_not_ready: 
   192 0000E0A9 070D0A              <1> 		db 07h, 0Dh, 0Ah
   193                              <1> 
   194                              <1> ; CMD_INTR.ASM - 09/11/2011 - Messages
   195                              <1> 
   196                              <1> Msg_Not_Ready_Read_Err:
   197 0000E0AC 4472697665206E6F74- <1>                 db "Drive not ready or read error!"
   197 0000E0B5 207265616479206F72- <1>
   197 0000E0BE 207265616420657272- <1>
   197 0000E0C7 6F7221              <1>
   198 0000E0CA 0D0A00              <1>                 db 0Dh, 0Ah, 0
   199                              <1> 
   200                              <1> Msg_Not_Ready_Write_Err:
   201 0000E0CD 4472697665206E6F74- <1>                 db "Drive not ready or write error!"
   201 0000E0D6 207265616479206F72- <1>
   201 0000E0DF 207772697465206572- <1>
   201 0000E0E8 726F7221            <1>
   202 0000E0EC 0D0A00              <1>                 db 0Dh, 0Ah, 0
   203                              <1> 
   204                              <1> Msg_Dir_Not_Found:
   205 0000E0EF 4469726563746F7279- <1>                 db "Directory not found!"
   205 0000E0F8 206E6F7420666F756E- <1>
   205 0000E101 6421                <1>
   206 0000E103 0D0A00              <1>                 db 0Dh, 0Ah, 0
   207                              <1> 
   208                              <1> Msg_File_Not_Found:
   209 0000E106 46696C65206E6F7420- <1>                 db "File not found!"
   209 0000E10F 666F756E6421        <1>
   210 0000E115 0D0A00              <1>                 db 0Dh, 0Ah, 0
   211                              <1> 
   212                              <1> Msg_File_Directory_Not_Found:
   213 0000E118 46696C65206F722064- <1>                 db "File or directory not found!"
   213 0000E121 69726563746F727920- <1>
   213 0000E12A 6E6F7420666F756E64- <1>
   213 0000E133 21                  <1>
   214 0000E134 0D0A00              <1>                 db 0Dh, 0Ah, 0
   215                              <1> 
   216                              <1> Msg_LongName_Not_Found:
   217 0000E137 4C6F6E67206E616D65- <1>                 db "Long name not found!"
   217 0000E140 206E6F7420666F756E- <1>
   217 0000E149 6421                <1>
   218 0000E14B 0D0A00              <1>                 db 0Dh, 0Ah, 0
   219                              <1> 
   220                              <1> Msg_Insufficient_Memory:
   221 0000E14E 496E73756666696369- <1>                 db "Insufficient memory!"
   221 0000E157 656E74206D656D6F72- <1>
   221 0000E160 7921                <1>
   222 0000E162 0D0A00              <1>                 db 0Dh, 0Ah, 0
   223                              <1> 
   224                              <1> Msg_Error_Code:
   225 0000E165 436F6D6D616E642066- <1>                 db 'Command failed! Error code : '
   225 0000E16E 61696C656421204572- <1>
   225 0000E177 726F7220636F646520- <1>
   225 0000E180 3A20                <1>
   226 0000E182 303068              <1> error_code_hex: db '00h'
   227 0000E185 0A0A00              <1>                 db 0Ah, 0Ah, 0
   228                              <1> 
   229                              <1> align 2
   230                              <1> 
   231                              <1> ; 10/02/2016
   232                              <1> ; DIR.ASM - 09/10/2011
   233                              <1> 
   234 0000E188 3C4449523E20202020- <1> Type_Dir:       db '<DIR>     ' ; 10 bytes
   234 0000E191 20                  <1>
   235                              <1> 
   236                              <1> File_Name:
   237 0000E192 20<rept>            <1>                 times 12 db 20h
   238 0000E19E 20                  <1> 		db 20h
   239                              <1> Dir_Or_FileSize:
   240 0000E19F 20<rept>            <1>                 times 10 db 20h
   241 0000E1A9 20                  <1> 		db 20h
   242                              <1> File_Attribute:
   243 0000E1AA 20202020            <1> 		dd 20202020h
   244 0000E1AE 20                  <1> 		db 20h
   245                              <1> File_Day:
   246 0000E1AF 3030                <1>                 db '0','0'
   247 0000E1B1 2F                  <1> 		db '/'
   248                              <1> File_Month:
   249 0000E1B2 3030                <1>                 db '0','0'
   250 0000E1B4 2F                  <1> 		db '/'
   251                              <1> File_Year:
   252 0000E1B5 30303030            <1>                 db '0','0','0','0'
   253 0000E1B9 20                  <1> 		db 20h
   254                              <1> File_Hour:
   255 0000E1BA 3030                <1>                 db '0','0'
   256 0000E1BC 3A                  <1> 		db ':'
   257                              <1> File_Minute:
   258 0000E1BD 3030                <1>                 db '0','0'
   259 0000E1BF 00                  <1> 		db 0
   260                              <1> 
   261                              <1> Decimal_File_Count_Header:
   262 0000E1C0 0D0A                <1> 		db 0Dh, 0Ah
   263                              <1> Decimal_File_Count:
   264 0000E1C2 00<rept>            <1> 		times 6 db 0
   265                              <1> 
   266 0000E1C8 2066696C6528732920- <1> str_files:	db " file(s) & "
   266 0000E1D1 2620                <1>
   267                              <1> Decimal_Dir_Count: 
   268 0000E1D3 00<rept>            <1> 		times 6 db 0
   269                              <1> str_dirs:       
   270 0000E1D9 206469726563746F72- <1> 		db " directory(s) "
   270 0000E1E2 7928732920          <1>
   271 0000E1E7 0D0A00              <1> 		db 0Dh, 0Ah, 0
   272                              <1> 
   273 0000E1EA 206279746528732920- <1> str_bytes:	db " byte(s) in file(s)"
   273 0000E1F3 696E2066696C652873- <1>
   273 0000E1FC 29                  <1>
   274 0000E1FD 0D0A00              <1> 		db 0Dh, 0Ah, 0
   275                              <1> 
   276                              <1> ; CMD_INTR.ASM - 09/11/2011
   277                              <1> ; 07/10/2010
   278                              <1> Msg_invalid_name_chars:
   279 0000E200 496E76616C69642066- <1>                 db "Invalid file or directory name characters!"
   279 0000E209 696C65206F72206469- <1>
   279 0000E212 726563746F7279206E- <1>
   279 0000E21B 616D65206368617261- <1>
   279 0000E224 637465727321        <1>
   280 0000E22A 0D0A00              <1>         	db 0Dh, 0Ah, 0
   281                              <1> ; 21/02/2016
   282 0000E22D 46696C65206F722064- <1> Msg_Name_Exists: db "File or directory name exists!"
   282 0000E236 69726563746F727920- <1>
   282 0000E23F 6E616D652065786973- <1>
   282 0000E248 747321              <1>
   283 0000E24B 0D0A00              <1>                 db 0Dh, 0Ah, 0
   284                              <1> Msg_DoYouWantMkdir:
   285 0000E24E 446F20796F75207761- <1>                 db "Do you want to make directory ", 0
   285 0000E257 6E7420746F206D616B- <1>
   285 0000E260 65206469726563746F- <1>
   285 0000E269 72792000            <1>
   286 0000E26D 2028592F4E29203F20- <1> Msg_YesNo:      db " (Y/N) ? ", 0  
   286 0000E276 00                  <1>
   287 0000E277 000D0A00            <1> Y_N_nextline:	db 0, 0Dh, 0Ah, 0 
   288 0000E27B 4F4B2E0D0A00        <1> Msg_OK:		db "OK.", 0Dh, 0Ah, 0
   289                              <1> 
   290                              <1> ; 27/02/2016
   291                              <1> Msg_DoYouWantRmDir:
   292 0000E281 446F20796F75207761- <1>                 db "Do you want to delete directory ", 0
   292 0000E28A 6E7420746F2064656C- <1>
   292 0000E293 657465206469726563- <1>
   292 0000E29C 746F72792000        <1>
   293                              <1> Msg_Dir_Not_Empty:
   294 0000E2A2 4469726563746F7279- <1>                 db "Directory not empty!"
   294 0000E2AB 206E6F7420656D7074- <1>
   294 0000E2B4 7921                <1>
   295 0000E2B6 0D0A00              <1>                 db 0Dh, 0Ah, 0
   296                              <1> 
   297                              <1> Msg_DoYouWantDelete:
   298 0000E2B9 446F20796F75207761- <1>                 db "Do you want to delete file ",0
   298 0000E2C2 6E7420746F2064656C- <1>
   298 0000E2CB 6574652066696C6520- <1>
   298 0000E2D4 00                  <1>
   299                              <1> 
   300 0000E2D5 44656C657465642E2E- <1> Msg_Deleted:    db "Deleted...", 0Dh, 0Ah, 0
   300 0000E2DE 2E0D0A00            <1>
   301                              <1> 
   302                              <1> Msg_Permission_Denied:
   303 0000E2E2 07                  <1>                 db 7
   304 0000E2E3 5065726D697373696F- <1>                 db "Permission denied!", 0Dh, 0Ah, 0
   304 0000E2EC 6E2064656E69656421- <1>
   304 0000E2F5 0D0A00              <1>
   305                              <1> 
   306                              <1> ; 04/03/2016
   307 0000E2F8 4E657720            <1> Msg_New:        db "New "
   308 0000E2FC 00                  <1>                 db 0
   309                              <1> Str_Attributes:
   310 0000E2FD 417474726962757465- <1>                 db "Attributes : "
   310 0000E306 73203A20            <1>
   311 0000E30A 4E4F524D414C        <1> Attr_Chars:     db "NORMAL"
   312 0000E310 00                  <1>                 db 0
   313                              <1> 
   314                              <1> ; 06/03/2016
   315                              <1> ; CMD_INTR.ASM - 16/11/2010 
   316                              <1> Msg_DoYouWantRename:
   317 0000E311 446F20796F75207761- <1>                 db "Do you want to rename ", 0
   317 0000E31A 6E7420746F2072656E- <1>
   317 0000E323 616D652000          <1>
   318 0000E328 66696C652000        <1> Rename_File:    db "file ", 0
   319 0000E32E 6469726563746F7279- <1> Rename_Directory: db "directory ", 0
   319 0000E337 2000                <1>
   320 0000E339 00<rept>            <1> Rename_OldName: times 13 db 0
   321 0000E346 20617320            <1> Msg_File_rename_as: db " as "
   322 0000E34A 00<rept>            <1> Rename_NewName: times 13 db 0
   323                              <1> 
   324                              <1> ; 08/03/2016
   325                              <1> ; CMD_INTR.ASM - 01/08/2010 - 23/04/2011
   326                              <1> msg_not_same_drv:
   327 0000E357 4E6F742073616D6520- <1>                 db "Not same drive!" 
   327 0000E360 647269766521        <1>
   328 0000E366 0D0A00              <1>                 db 0Dh, 0Ah, 0 
   329                              <1> 
   330                              <1> Msg_DoYouWantMoveFile:
   331 0000E369 446F20796F75207761- <1>                 db "Do you want to move file", 0
   331 0000E372 6E7420746F206D6F76- <1>
   331 0000E37B 652066696C6500      <1>
   332                              <1> 
   333                              <1> msg_insufficient_disk_space:
   334 0000E382 496E73756666696369- <1>                 db "Insufficient disk space!" 
   334 0000E38B 656E74206469736B20- <1>
   334 0000E394 737061636521        <1>
   335 0000E39A 0D0A00              <1>                 db 0Dh, 0Ah, 0
   336                              <1> 
   337                              <1> ; 01/08/2010
   338                              <1> msg_source_file: 
   339 0000E39D 0D0A536F7572636520- <1> 		db 0Dh, 0Ah, "Source file name      :   "
   339 0000E3A6 66696C65206E616D65- <1>
   339 0000E3AF 2020202020203A2020- <1>
   339 0000E3B8 20                  <1>
   340                              <1> msg_source_file_drv: 
   341 0000E3B9 203A00              <1> 		db " :", 0
   342                              <1> msg_destination_file: 
   343 0000E3BC 0D0A44657374696E61- <1> 		db 0Dh, 0Ah, "Destination file name :   "
   343 0000E3C5 74696F6E2066696C65- <1>
   343 0000E3CE 206E616D65203A2020- <1>
   343 0000E3D7 20                  <1>
   344                              <1> msg_destination_file_drv: 
   345 0000E3D8 203A00              <1> 		db " :", 0
   346                              <1> msg_copy_nextline: 
   347 0000E3DB 0D0A00              <1> 		db 0Dh, 0Ah, 0
   348                              <1> 
   349                              <1> ; 15/03/2016
   350                              <1> ; CMD_INTR.ASM
   351                              <1> 
   352                              <1> Msg_DoYouWantOverWriteFile:
   353 0000E3DE 446F20796F75207761- <1>                 db "Do you want to overwrite file ",0
   353 0000E3E7 6E7420746F206F7665- <1>
   353 0000E3F0 727772697465206669- <1>
   353 0000E3F9 6C652000            <1>
   354                              <1>   
   355                              <1> Msg_DoYouWantCopyFile:
   356 0000E3FD 446F20796F75207761- <1>                 db "Do you want to copy file",0
   356 0000E406 6E7420746F20636F70- <1>
   356 0000E40F 792066696C6500      <1>
   357                              <1> 
   358                              <1> Msg_read_file_error_before_EOF:
   359 0000E416 46696C652072656164- <1> 		db "File reading error! (before EOF)"
   359 0000E41F 696E67206572726F72- <1>
   359 0000E428 2120286265666F7265- <1>
   359 0000E431 20454F4629          <1>
   360 0000E436 0A0A00              <1> 		db 0Ah, 0Ah, 0
   361                              <1> 
   362                              <1> ; 18/03/2016
   363                              <1> ; TRDOS 386 (v2.0) mainprog copy procedure
   364                              <1> msg_reading:
   365 0000E439 52656164696E672E2E- <1> 		db "Reading... ", 0
   365 0000E442 2E2000              <1>
   366                              <1> msg_writing:
   367 0000E445 57726974696E672E2E- <1> 		db "Writing... ", 0
   367 0000E44E 2E2000              <1>
   368                              <1> percentagestr:
   369 0000E451 2020202500          <1> 		db "   %", 0  ; "  0%" .. "100%"
   370                              <1> ; 11/04/2016
   371                              <1> Msg_No_Set_Space:
   372 0000E456 496E73756666696369- <1>                 db "Insufficient environment space!"
   372 0000E45F 656E7420656E766972- <1>
   372 0000E468 6F6E6D656E74207370- <1>
   372 0000E471 61636521            <1>
   373 0000E475 0D0A00              <1>                 db 0Dh, 0Ah, 0
   374                              <1> ; 18/04/2016
   375                              <1> isc_msg:	
   376 0000E478 0D0A                <1> 		db 0Dh, 0Ah
   377 0000E47A 494E56414C49442053- <1> 		db "INVALID SYSTEM CALL", 0
   377 0000E483 595354454D2043414C- <1>
   377 0000E48C 4C00                <1>
   378                              <1> usi_msg:
   379 0000E48E 0D0A                <1> 		db 0Dh, 0Ah
   380 0000E490 554E444546494E4544- <1> 		db "UNDEFINED SOFTWARE INTERRUPT", 0
   380 0000E499 20534F465457415245- <1>
   380 0000E4A2 20494E544552525550- <1>
   380 0000E4AB 5400                <1>
   381                              <1> ifc_msg:
   382 0000E4AD 0D0A                <1> 		db 0Dh, 0Ah
   383 0000E4AF 494E56414C49442046- <1> 		db "INVALID FUNCTION CALL"
   383 0000E4B8 554E4354494F4E2043- <1>
   383 0000E4C1 414C4C              <1>
   384                              <1> inv_msg_for_trdos_v2:
   385 0000E4C4 20                  <1> 		db 20h
   386 0000E4C5 666F72205452444F53- <1> 		db "for TRDOS v2!"
   386 0000E4CE 20763221            <1>
   387 0000E4D2 07                  <1> 		db 07h
   388 0000E4D3 0D0A                <1> 		db 0Dh, 0Ah
   389 0000E4D5 0D0A                <1> 		db 0Dh, 0Ah
   390 0000E4D7 494E5420            <1> 		db "INT "
   391 0000E4DB 303068              <1> int_num_str:	db "00h"
   392 0000E4DE 0D0A                <1> 		db 0Dh, 0Ah
   393 0000E4E0 454158203A20        <1> 		db "EAX : "
   394 0000E4E6 303030303030303068- <1> eax_str:	db "00000000h", 0Dh, 0Ah
   394 0000E4EF 0D0A                <1>
   395 0000E4F1 454950203A20        <1> 		db "EIP : "
   396 0000E4F7 303030303030303068- <1> eip_str:	db "00000000h", 0Dh, 0Ah, 0
   396 0000E500 0D0A00              <1>
   397                              <1> 		
  1927                                  
  1928                                  ; 15/04/2016
  1929                                  ; TRDOS 386 (TRDOS v2.0)
  1930                                  
  1931                                  ; 29/04/2016
  1932                                  int30h:
  1933                                  trdos_isc_routine:
  1934                                  	; 02/05/2016
  1935                                  	; 01/05/2016
  1936                                  	; 29/04/2016
  1937                                  	; 18/04/2016
  1938                                  	; 15/04/2016 (TRDOS 386 = TRDOS v2.0)
  1939                                  	; 17/04/2011 (TRDOS v1.0, 'IFC.ASM')
  1940                                  	; 03/02/2011 ('trdos_ifc_routine')
  1941                                  	;
  1942 0000E503 8B1C24                  	mov	ebx, [esp] ; EIP (next)
  1943 0000E506 83EB02                  	sub	ebx, 2 ; EIP (CD ##h)
  1944                                  
  1945 0000E509 89C1                    	mov	ecx, eax
  1946 0000E50B 8A4301                  	mov	al, [ebx+1] ; CDh ##h
  1947                                  
  1948 0000E50E 66BA1000                	mov	dx, KDATA
  1949 0000E512 8EDA                    	mov	ds, dx
  1950 0000E514 8EC2                    	mov	es, dx
  1951                                  
  1952 0000E516 FC                      	cld
  1953 0000E517 8B15[A81F0100]          	mov	edx, [k_page_dir]
  1954 0000E51D 0F22DA                  	mov	cr3, edx
  1955                                  
  1956 0000E520 E8EF47FFFF              	call	bytetohex
  1957 0000E525 66A3[DBE40000]          	mov	[int_num_str], ax
  1958                                  
  1959 0000E52B 89D8                    	mov	eax, ebx ; EIP
  1960 0000E52D E82248FFFF              	call	dwordtohex
  1961 0000E532 8915[F7E40000]          	mov	[eip_str], edx
  1962 0000E538 A3[FBE40000]            	mov	[eip_str+4], eax
  1963                                  
  1964 0000E53D 89C8                    	mov	eax, ecx
  1965 0000E53F E81048FFFF              	call	dwordtohex
  1966 0000E544 8915[E6E40000]          	mov	[eax_str], edx
  1967 0000E54A A3[EAE40000]            	mov	[eax_str+4], eax 	
  1968                                  
  1969 0000E54F 43                      	inc	ebx
  1970 0000E550 8A03                    	mov	al, [ebx] ; Interrupt number
  1971                                  
  1972                                  trdos_isc_handler:
  1973 0000E552 80FE30                  	cmp	dh, 30h ; Retro UNIX, SINGLIX System calls
  1974 0000E555 7507                    	jne	short trdos_usi_handler
  1975 0000E557 BE[78E40000]            	mov	esi, isc_msg
  1976 0000E55C EB05                    	jmp	short loc_write_inv_system_call_msg
  1977                                  
  1978                                  trdos_usi_handler:
  1979 0000E55E BE[8EE40000]            	mov	esi, usi_msg
  1980                                  
  1981                                  loc_write_inv_system_call_msg:
  1982 0000E563 E8CA6FFFFF              	call	print_msg
  1983                                  	; 29/04/2016
  1984 0000E568 BE[C4E40000]            	mov	esi, inv_msg_for_trdos_v2
  1985 0000E56D E8C06FFFFF              	call	print_msg
  1986                                  
  1987                                  loc_ifc_terminate_process:
  1988                                  	; u.uno = process number
  1989                                  	; 29/04/2016
  1990                                  
  1991                                  	; 02/05/2016
  1992 0000E572 FE05[7F300100]          	inc	byte [sysflg] ; 0FFh -> 0
  1993                                  
  1994 0000E578 B801000000              	mov	eax, 1
  1995 0000E57D E987D1FFFF              	jmp	sysexit
  1996                                  
  1997                                  ; 07/03/2015
  1998                                  ; Temporary Code
  1999                                  display_disks:
  2000 0000E582 803D[F8EC0000]00        	cmp 	byte [fd0_type], 0
  2001 0000E589 7605                    	jna 	short ddsks1
  2002 0000E58B E87D000000              	call	pdskm
  2003                                  ddsks1:
  2004 0000E590 803D[F9EC0000]00        	cmp	byte [fd1_type], 0
  2005 0000E597 760C                    	jna	short ddsks2
  2006 0000E599 C605[7AEE0000]31        	mov	byte [dskx], '1'
  2007 0000E5A0 E868000000              	call	pdskm
  2008                                  ddsks2:
  2009 0000E5A5 803D[FAEC0000]00        	cmp	byte [hd0_type], 0
  2010 0000E5AC 7654                    	jna	short ddsk6
  2011 0000E5AE 66C705[78EE0000]68-     	mov	word [dsktype], 'hd'
  2011 0000E5B6 64                 
  2012 0000E5B7 C605[7AEE0000]30        	mov	byte [dskx], '0'
  2013 0000E5BE E84A000000              	call	pdskm
  2014                                  ddsks3:
  2015 0000E5C3 803D[FBEC0000]00        	cmp	byte [hd1_type], 0
  2016 0000E5CA 7636                    	jna	short ddsk6
  2017 0000E5CC C605[7AEE0000]31        	mov	byte [dskx], '1'
  2018 0000E5D3 E835000000              	call	pdskm
  2019                                  ddsks4:
  2020 0000E5D8 803D[FCEC0000]00        	cmp	byte [hd2_type], 0
  2021 0000E5DF 7621                    	jna	short ddsk6
  2022 0000E5E1 C605[7AEE0000]32        	mov	byte [dskx], '2'
  2023 0000E5E8 E820000000              	call	pdskm
  2024                                  ddsks5:
  2025 0000E5ED 803D[FDEC0000]00        	cmp	byte [hd3_type], 0
  2026 0000E5F4 760C                    	jna	short ddsk6
  2027 0000E5F6 C605[7AEE0000]33        	mov	byte [dskx], '3'
  2028 0000E5FD E80B000000              	call	pdskm
  2029                                  ddsk6:
  2030 0000E602 BE[8BEE0000]            	mov	esi, nextline
  2031 0000E607 E806000000              	call	pdskml
  2032                                  pdskm_ok:
  2033 0000E60C C3                      	retn
  2034                                  pdskm:
  2035 0000E60D BE[76EE0000]            	mov	esi, dsk_ready_msg
  2036                                  pdskml:	
  2037 0000E612 AC                      	lodsb
  2038 0000E613 08C0                    	or	al, al
  2039 0000E615 74F5                    	jz	short pdskm_ok
  2040 0000E617 56                      	push	esi
  2041                                  	; 13/05/2016
  2042 0000E618 BB07000000                      mov     ebx, 7  ; Black background, 
  2043                                  			; light gray forecolor
  2044                                  			; Video page 0 (bh=0)
  2045 0000E61D E8FA34FFFF              	call	_write_tty
  2046 0000E622 5E                      	pop	esi
  2047 0000E623 EBED                    	jmp	short pdskml
  2048                                  
  2049 0000E625 90<rept>                align 16
  2050                                  
  2051                                  gdt:	; Global Descriptor Table
  2052                                  	; (30/07/2015, conforming cs)
  2053                                  	; (26/03/2015)
  2054                                  	; (24/03/2015, tss)
  2055                                  	; (19/03/2015)
  2056                                  	; (29/12/2013)
  2057                                  	;
  2058 0000E630 0000000000000000        	dw 0, 0, 0, 0		; NULL descriptor
  2059                                  	; 18/08/2014
  2060                                  			; 8h kernel code segment, base = 00000000h		
  2061 0000E638 FFFF0000009ACF00        	dw 0FFFFh, 0, 9A00h, 00CFh	; KCODE
  2062                                  			; 10h kernel data segment, base = 00000000h	
  2063 0000E640 FFFF00000092CF00        	dw 0FFFFh, 0, 9200h, 00CFh	; KDATA
  2064                                  			; 1Bh user code segment, base address = 400000h ; CORE
  2065 0000E648 FFFB000040FACF00        	dw 0FBFFh, 0, 0FA40h, 00CFh	; UCODE 
  2066                                  			; 23h user data segment, base address = 400000h ; CORE
  2067 0000E650 FFFB000040F2CF00        	dw 0FBFFh, 0, 0F240h, 00CFh	; UDATA
  2068                                  			; Task State Segment
  2069 0000E658 6700                    	dw 0067h ; Limit = 103 ; (104-1, tss size = 104 byte, 
  2070                                  			       ;  no IO permission in ring 3)
  2071                                  gdt_tss0:
  2072 0000E65A 0000                    	dw 0  ; TSS base address, bits 0-15 
  2073                                  gdt_tss1:
  2074 0000E65C 00                      	db 0  ; TSS base address, bits 16-23 
  2075                                  	      		; 49h	
  2076 0000E65D E9                      	db 11101001b ; E9h => P=1/DPL=11/0/1/0/B/1 --> B = Task is busy (1)
  2077 0000E65E 00                      	db 0 ; G/0/0/AVL/LIMIT=0000 ; (Limit bits 16-19 = 0000) (G=0, 1 byte)
  2078                                  gdt_tss2:
  2079 0000E65F 00                      	db 0  ; TSS base address, bits 24-31 
  2080                                  
  2081                                  gdt_end:
  2082                                  	;; 9Ah = 1001 1010b (GDT byte 5) P=1/DPL=00/1/TYPE=1010, 
  2083                                  					;; Type= 1 (code)/C=0/R=1/A=0
  2084                                  		; P= Present, DPL=0=ring 0,  1= user (0= system)
  2085                                  		; 1= Code C= non-Conforming, R= Readable, A = Accessed
  2086                                  
  2087                                  	;; 92h = 1001 0010b (GDT byte 5) P=1/DPL=00/1/TYPE=1010, 
  2088                                  					;; Type= 0 (data)/E=0/W=1/A=0
  2089                                  		; P= Present, DPL=0=ring 0,  1= user (0= system)
  2090                                  		; 0= Data E= Expansion direction (1= down, 0= up)
  2091                                  		; W= Writeable, A= Accessed
  2092                                  	
  2093                                  	;; FAh = 1111 1010b (GDT byte 5) P=1/DPL=11/1/TYPE=1010, 
  2094                                  					;; Type= 1 (code)/C=0/R=1/A=0
  2095                                  		; P= Present, DPL=3=ring 3,  1= user (0= system)
  2096                                  		; 1= Code C= non-Conforming, R= Readable, A = Accessed
  2097                                  
  2098                                  	;; F2h = 1111 0010b (GDT byte 5) P=1/DPL=11/1/TYPE=0010, 
  2099                                  					;; Type= 0 (data)/E=0/W=1/A=0
  2100                                  		; P= Present, DPL=3=ring 3,  1= user (0= system)
  2101                                  		; 0= Data E= Expansion direction (1= down, 0= up)
  2102                                  	
  2103                                  	;; CFh = 1100 1111b (GDT byte 6) G=1/B=1/0/AVL=0, Limit=1111b (3)
  2104                                  
  2105                                  		;; Limit = FFFFFh (=> FFFFFh+1= 100000h) // bits 0-15, 48-51 //
  2106                                  		;	 = 100000h * 1000h (G=1) = 4GB
  2107                                  		;; Limit = FFBFFh (=> FFBFFh+1= FFC00h) // bits 0-15, 48-51 //
  2108                                  		;	 = FFC00h * 1000h (G=1) = 4GB - 4MB
  2109                                  		; G= Granularity (1= 4KB), B= Big (32 bit), 
  2110                                  		; AVL= Available to programmers	
  2111                                  
  2112                                  gdtd:
  2113 0000E660 2F00                            dw gdt_end - gdt - 1    ; Limit (size)
  2114 0000E662 [30E60000]                      dd gdt			; Address of the GDT
  2115                                  
  2116                                  	; 20/08/2014
  2117                                  idtd:
  2118 0000E666 7F02                            dw idt_end - idt - 1    ; Limit (size)
  2119 0000E668 [C01C0100]                      dd idt			; Address of the IDT
  2120                                  
  2121                                  Align 4
  2122                                  	; 15/04/2016
  2123                                  	; TRDOS 386 (TRDOS v2.0)
  2124                                  
  2125                                  	; 21/08/2014
  2126                                  ilist:
  2127                                  	;times 	32 dd cpu_except ; INT 0 to INT 1Fh
  2128                                  	;
  2129                                  	; Exception list
  2130                                  	; 25/08/2014	
  2131 0000E66C [4B080000]              	dd	exc0	; 0h,  Divide-by-zero Error
  2132 0000E670 [52080000]              	dd	exc1	
  2133 0000E674 [59080000]              	dd 	exc2	
  2134 0000E678 [60080000]              	dd	exc3	
  2135 0000E67C [64080000]              	dd	exc4	
  2136 0000E680 [68080000]              	dd	exc5	
  2137 0000E684 [6C080000]              	dd 	exc6	; 06h,  Invalid Opcode
  2138 0000E688 [70080000]              	dd	exc7	
  2139 0000E68C [74080000]              	dd	exc8	
  2140 0000E690 [78080000]              	dd	exc9	
  2141 0000E694 [7C080000]              	dd 	exc10	
  2142 0000E698 [80080000]              	dd	exc11
  2143 0000E69C [84080000]              	dd	exc12
  2144 0000E6A0 [88080000]              	dd	exc13	; 0Dh, General Protection Fault
  2145 0000E6A4 [8C080000]              	dd 	exc14	; 0Eh, Page Fault
  2146 0000E6A8 [90080000]              	dd	exc15
  2147 0000E6AC [94080000]              	dd	exc16
  2148 0000E6B0 [98080000]              	dd	exc17
  2149 0000E6B4 [9C080000]              	dd 	exc18
  2150 0000E6B8 [A0080000]              	dd	exc19
  2151 0000E6BC [A4080000]              	dd 	exc20
  2152 0000E6C0 [A8080000]              	dd	exc21
  2153 0000E6C4 [AC080000]              	dd	exc22
  2154 0000E6C8 [B0080000]              	dd	exc23
  2155 0000E6CC [B4080000]              	dd 	exc24
  2156 0000E6D0 [B8080000]              	dd	exc25
  2157 0000E6D4 [BC080000]              	dd	exc26
  2158 0000E6D8 [C0080000]              	dd	exc27
  2159 0000E6DC [C4080000]              	dd 	exc28
  2160 0000E6E0 [C8080000]              	dd	exc29
  2161 0000E6E4 [CC080000]              	dd 	exc30
  2162 0000E6E8 [D0080000]              	dd	exc31
  2163                                  	; Interrupt list
  2164 0000E6EC [40060000]              	dd	timer_int	; INT 20h
  2165                                  		;dd	irq0	
  2166 0000E6F0 [AC0C0000]              	dd	kb_int		; 24/01/2016
  2167                                  		;dd	irq1
  2168 0000E6F4 [A1070000]              	dd	irq2
  2169                                  		; COM2 int
  2170 0000E6F8 [A5070000]              	dd	irq3
  2171                                  		; COM1 int
  2172 0000E6FC [B0070000]              	dd	irq4
  2173 0000E700 [BB070000]              	dd	irq5
  2174                                  ;DISKETTE_INT: ;06/02/2015
  2175 0000E704 [FB3B0000]              	dd	fdc_int		; 16/02/2015, IRQ 6 handler	
  2176                                  		;dd	irq6
  2177                                  ; Default IRQ 7 handler against spurious IRQs (from master PIC)
  2178                                  ; 25/02/2015 (source: http://wiki.osdev.org/8259_PIC)
  2179 0000E708 [AC0A0000]              	dd	default_irq7	; 25/02/2015
  2180                                  		;dd	irq7
  2181                                  ; Real Time Clock Interrupt
  2182 0000E70C [1D070000]              	dd	rtc_int		; 23/02/2015, IRQ 8 handler
  2183                                  		;dd	irq8	; INT 28h
  2184 0000E710 [CB070000]              	dd	irq9
  2185 0000E714 [CF070000]              	dd	irq10
  2186 0000E718 [D3070000]              	dd	irq11
  2187 0000E71C [D7070000]              	dd	irq12
  2188 0000E720 [DB070000]              	dd	irq13
  2189                                  ;HDISK_INT1:  ;06/02/2015 	
  2190 0000E724 [75450000]              	dd	hdc1_int 	; 21/02/2015, IRQ 14 handler		
  2191                                  		;dd	irq14
  2192                                  ;HDISK_INT2:  ;06/02/2015
  2193 0000E728 [9C450000]              	dd	hdc2_int 	; 21/02/2015, IRQ 15 handler		
  2194                                  		;dd	irq15	; INT 2Fh
  2195                                  		; 14/08/2015
  2196                                  	;dd	sysent		; INT 30h (system calls)
  2197                                  
  2198                                  	; 15/04/2016
  2199                                  	; TRDOS 386(TRDOS v2.0) Software Interrupts
  2200                                  
  2201 0000E72C [03E50000]              	dd	int30h		; Reserved for
  2202                                  				; !!! Retro UNIX (RUNIX) !!!
  2203                                  				; !!! SINGLIX !!! System Calls
  2204 0000E730 [9F130000]              	dd	int31h		; Video BIOS (IBM PC/AT, Int 10h)
  2205 0000E734 [D40A0000]              	dd	int32h		; Keyboard Functions (IBM PC/AT, Int 16h)
  2206 0000E738 [B23C0000]              	dd	int33h		; DISK I/O (IBM PC/AT, Int 13h)
  2207 0000E73C [A4DB0000]              	dd	int34h		; #IOCTL# (I/O port access support for ring 3)
  2208 0000E740 [7C510000]              	dd	int35h		; Time/Date Functions (IBM PC/AT, Int 1Ah)
  2209 0000E744 [A1090000]              	dd	ignore_int	; INT 36h : Timer Functions	
  2210 0000E748 [A1090000]              	dd	ignore_int	; INT 37h	
  2211 0000E74C [A1090000]              	dd	ignore_int	; INT 38h
  2212 0000E750 [A1090000]              	dd	ignore_int	; INT 39h
  2213 0000E754 [A1090000]              	dd	ignore_int	; INT 3Ah	
  2214 0000E758 [A1090000]              	dd	ignore_int	; INT 3Bh
  2215 0000E75C [A1090000]              	dd	ignore_int	; INT 3Ch
  2216 0000E760 [A1090000]              	dd	ignore_int	; INT 3Dh	
  2217 0000E764 [A1090000]              	dd	ignore_int	; INT 3Eh
  2218 0000E768 [A1090000]              	dd	ignore_int	; INT 3Fh
  2219 0000E76C [F8B40000]              	dd	sysent		; INT 40h : !!! TRDOS 386 System Calls !!!
  2220                                  	;dd	ignore_int
  2221 0000E770 00000000                	dd	0
  2222                                  ;;;
  2223                                  ;;; 11/03/2015
  2224                                  %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 0000E774 524F50514B          <1> K30:	db	82,79,80,81,75
    36 0000E779 4C4D474849          <1> 	db	76,77,71,72,73		; 10 NUMBER ON KEYPAD
    37                              <1> ;-----	SUPER-SHIFT-TABLE 
    38 0000E77E 101112131415        <1> 	db	16,17,18,19,20,21	; A-Z TYPEWRITER CHARS
    39 0000E784 161718191E1F        <1> 	db	22,23,24,25,30,31
    40 0000E78A 202122232425        <1> 	db	32,33,34,35,36,37
    41 0000E790 262C2D2E2F30        <1> 	db	38,44,45,46,47,48
    42 0000E796 3132                <1> 	db	49,50
    43                              <1> 
    44                              <1> ;-----	TABLE OF SHIFT KEYS AND MASK VALUES
    45                              <1> ;-----	KEY_TABLE 
    46 0000E798 52                  <1> _K6:    db      INS_KEY                 ; INSERT KEY
    47 0000E799 3A4546381D          <1> 	db	CAPS_KEY,NUM_KEY,SCROLL_KEY,ALT_KEY,CTL_KEY
    48 0000E79E 2A36                <1>         db      LEFT_KEY,RIGHT_KEY
    49                              <1> _K6L    equ     $-_K6
    50                              <1> 
    51                              <1> ;-----	MASK_TABLE
    52 0000E7A0 80                  <1> _K7:    db      INS_SHIFT               ; INSERT MODE SHIFT
    53 0000E7A1 4020100804          <1> 	db	CAPS_SHIFT,NUM_SHIFT,SCROLL_SHIFT,ALT_SHIFT,CTL_SHIFT
    54 0000E7A6 0201                <1> 	db	LEFT_SHIFT,RIGHT_SHIFT
    55                              <1> 
    56                              <1> ;-----	TABLES FOR CTRL CASE		;---- CHARACTERS ------
    57 0000E7A8 1BFF00FFFFFF        <1> _K8:	db	27,-1,0,-1,-1,-1	; Esc, 1, 2, 3, 4, 5
    58 0000E7AE 1EFFFFFFFF1F        <1> 	db 	30,-1,-1,-1,-1,31	; 6, 7, 8, 9, 0, -
    59 0000E7B4 FF7FFF111705        <1> 	db	-1,127,-1,17,23,5	; =, Bksp, Tab, Q, W, E
    60 0000E7BA 12141915090F        <1> 	db	18,20,25,21,9,15	; R, T, Y, U, I, O
    61 0000E7C0 101B1D0AFF01        <1> 	db	16,27,29,10,-1,1	; P, [, ], Enter, Ctrl, A
    62 0000E7C6 13040607080A        <1> 	db	19,4,6,7,8,10		; S, D, F, G, H, J
    63 0000E7CC 0B0CFFFFFFFF        <1> 	db	11,12,-1,-1,-1,-1	; K, L, :, ', `, LShift
    64 0000E7D2 1C1A18031602        <1> 	db	28,26,24,3,22,2		; Bkslash, Z, X, C, V, B
    65 0000E7D8 0E0DFFFFFFFF        <1> 	db	14,13,-1,-1,-1,-1	; N, M, ,, ., /, RShift
    66 0000E7DE 96FF20FF            <1> 	db	150,-1,' ',-1		; *, ALT, Spc, CL
    67                              <1> 	;				;----- FUNCTIONS ------		
    68 0000E7E2 5E5F60616263        <1> 	db 	94,95,96,97,98,99	; F1 - F6
    69 0000E7E8 64656667FFFF        <1> 	db	100,101,102,103,-1,-1	; F7 - F10, NL, SL
    70 0000E7EE 778D848E738F        <1> 	db	119,141,132,142,115,143	; Home, Up, PgUp, -, Left, Pad5
    71 0000E7F4 749075917692        <1> 	db 	116,144,117,145,118,146 ; Right, +, End, Down, PgDn, Ins
    72 0000E7FA 93FFFFFF898A        <1> 	db	147,-1,-1,-1,137,138	; Del, SysReq, Undef, WT, F11, F12
    73                              <1> 
    74                              <1> ;-----	TABLES FOR LOWER CASE ----------
    75 0000E800 1B3132333435363738- <1> K10:	db 	27,'1234567890-=',8,9
    75 0000E809 39302D3D0809        <1>
    76 0000E80F 71776572747975696F- <1> 	db 	'qwertyuiop[]',13,-1,'asdfghjkl;',39
    76 0000E818 705B5D0DFF61736466- <1>
    76 0000E821 67686A6B6C3B27      <1>
    77 0000E828 60FF5C7A786376626E- <1> 	db	96,-1,92,'zxcvbnm,./',-1,'*',-1,' ',-1
    77 0000E831 6D2C2E2FFF2AFF20FF  <1>
    78                              <1> ;-----	LC TABLE SCAN
    79 0000E83A 3B3C3D3E3F          <1> 	db	59,60,61,62,63		; BASE STATE OF F1 - F10
    80 0000E83F 4041424344          <1> 	db	64,65,66,67,68
    81 0000E844 FFFF                <1> 	db	-1,-1			; NL, SL
    82                              <1> 
    83                              <1> ;-----	KEYPAD TABLE
    84 0000E846 474849FF4BFF        <1> K15:	db	71,72,73,-1,75,-1	; BASE STATE OF KEYPAD KEYS
    85 0000E84C 4DFF4F50515253      <1> 	db	77,-1,79,80,81,82,83
    86 0000E853 FFFF5C8586          <1> 	db	-1,-1,92,133,134	; SysRq, Undef, WT, F11, F12
    87                              <1> 
    88                              <1> ;-----	TABLES FOR UPPER CASE ----------
    89 0000E858 1B21402324255E262A- <1> K11:	db 	27,'!@#$%',94,'&*()_+',8,0
    89 0000E861 28295F2B0800        <1>
    90 0000E867 51574552545955494F- <1> 	db 	'QWERTYUIOP{}',13,-1,'ASDFGHJKL:"'
    90 0000E870 507B7D0DFF41534446- <1>
    90 0000E879 47484A4B4C3A22      <1>
    91 0000E880 7EFF7C5A584356424E- <1> 	db	126,-1,'|ZXCVBNM<>?',-1,'*',-1,' ',-1
    91 0000E889 4D3C3E3FFF2AFF20FF  <1>
    92                              <1> ;-----	UC TABLE SCAN
    93 0000E892 5455565758          <1> K12:	db	84,85,86,87,88		; SHIFTED STATE OF F1 - F10
    94 0000E897 595A5B5C5D          <1> 	db	89,90,91,92,93
    95 0000E89C FFFF                <1> 	db	-1,-1			; NL, SL
    96                              <1> 
    97                              <1> ;-----	NUM STATE TABLE
    98 0000E89E 3738392D3435362B31- <1> K14:	db 	'789-456+1230.'		; NUMLOCK STATE OF KEYPAD KEYS
    98 0000E8A7 3233302E            <1>
    99                              <1> 	;
   100 0000E8AB 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 0000E8B0 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 0000E8B1 00                  <1> KB_FLAG		db	0		; KEYBOARD SHIFT STATE AND STATUS FLAGS
   118 0000E8B2 00                  <1> KB_FLAG_1	db	0		; SECOND BYTE OF KEYBOARD STATUS
   119 0000E8B3 00                  <1> KB_FLAG_2	db	0		; KEYBOARD LED FLAGS
   120 0000E8B4 00                  <1> KB_FLAG_3	db	0		; KEYBOARD MODE STATE AND TYPE FLAGS
   121 0000E8B5 00                  <1> ALT_INPUT	db	0		; STORAGE FOR ALTERNATE KEY PAD ENTRY
   122 0000E8B6 [C6E80000]          <1> BUFFER_START	dd	KB_BUFFER 	; OFFSET OF KEYBOARD BUFFER START
   123 0000E8BA [E6E80000]          <1> BUFFER_END	dd	KB_BUFFER + 32	; OFFSET OF END OF BUFFER
   124 0000E8BE [C6E80000]          <1> BUFFER_HEAD	dd	KB_BUFFER 	; POINTER TO HEAD OF KEYBOARD BUFFER
   125 0000E8C2 [C6E80000]          <1> BUFFER_TAIL	dd	KB_BUFFER 	; POINTER TO TAIL OF KEYBOARD BUFFER
   126                              <1> ; ------	HEAD = TAIL	INDICATES THAT THE BUFFER IS EMPTY
   127 0000E8C6 0000<rept>          <1> KB_BUFFER	times	16 dw 0		; ROOM FOR 16 SCAN CODE ENTRIES
   128                              <1> 
   129                              <1> ; /// End Of KEYBOARD DATA ///
  2225                                  %include 'vidata.s'	; VIDEO (BIOS) DATA
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.0 - vidata.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 29/07/2016
     5                              <1> ; ----------------------------------------------------------------------------
     6                              <1> ; Beginning: 16/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> ; 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 0000E8E6 03                  <1> CRT_MODE:	db	3	; CURRENT DISPLAY MODE (TYPE)
    29 0000E8E7 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 0000E8E8 50                  <1> CRT_COLS:	db	80	; Number of columns
    52                              <1> 
    53                              <1> ; 01/07/2016
    54 0000E8E9 00                  <1> CRT_PALETTE:	db 	0	; Current palette setting
    55                              <1> 
    56                              <1> ; 03/07/2016
    57 0000E8EA 10                  <1> CHAR_HEIGHT:	db	16	; Default character height
    58 0000E8EB 60                  <1> VGA_VIDEO_CTL:	db	60h	; ROM BIOS DATA AREA Offset 87h
    59 0000E8EC F9                  <1> VGA_SWITCHES:	db 	0F9h	; Feature Bit Switches (the basic screen)
    60 0000E8ED 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 0000E8EE 19                  <1> VGA_ROWS:	db	25
    73                              <1> 
    74                              <1> ; 16/01/2016
    75                              <1> chr_attrib:  ; Character color/attributes for viode pages (0 to 7)
    76 0000E8EF 0707070707070707    <1> 	db	07h, 07h, 07h, 07h, 07h, 07h, 07h, 07h
    77                              <1> ; 30/01/2016
    78                              <1> vmode:
    79 0000E8F7 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 0000E8FF 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 0000E901 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 0000E902 0302010007040506    <1> 	db 	03h, 02h, 01h, 00h, 07h, 04h, 05h, 06h
    96 0000E90A 13F0126A0D0E1011    <1> 	db	13h, 0F0h, 12h, 6Ah, 0Dh, 0Eh, 10h, 11h
    97                              <1> vga_mode_count equ $ - vga_modes
    98                              <1> 
    99                              <1> vga_mode_tbl_ptr:
   100                              <1> 	; 25/07/2016
   101 0000E912 [72E90000]          <1> 	dd	vga_mode_03h
   102 0000E916 [72E90000]          <1> 	dd	vga_mode_03h ; mode 02h -> mode 03h 
   103 0000E91A [B2E90000]          <1> 	dd	vga_mode_01h
   104 0000E91E [B2E90000]          <1> 	dd	vga_mode_01h ; mode 00h -> mode 01h
   105                              <1> 	;dd	vga_mode_07h
   106 0000E922 [72E90000]          <1> 	dd	vga_mode_03h ; mode 07h -> mode 03h
   107 0000E926 [F2E90000]          <1> 	dd	vga_mode_04h
   108 0000E92A [F2E90000]          <1> 	dd	vga_mode_04h ; mode 05h -> mode 04h	
   109 0000E92E [32EA0000]          <1> 	dd	vga_mode_06h
   110 0000E932 [72EA0000]          <1> 	dd	vga_mode_13h
   111 0000E936 [B2EA0000]          <1> 	dd	vga_mode_F0h
   112 0000E93A [F2EA0000]          <1> 	dd	vga_mode_12h
   113 0000E93E [32EB0000]          <1> 	dd	vga_mode_6Ah
   114 0000E942 [72EB0000]          <1> 	dd	vga_mode_0Dh
   115 0000E946 [B2EB0000]          <1> 	dd	vga_mode_0Eh
   116 0000E94A [F2EB0000]          <1> 	dd	vga_mode_10h
   117 0000E94E [32EC0000]          <1> 	dd	vga_mode_11h	
   118                              <1> 
   119                              <1> vga_memmodel: 
   120                              <1> 	; 25/07/2016
   121                              <1> 	; 07/07/2016
   122                              <1> 	CTEXT	equ 0
   123                              <1> 	;MTEXT	equ 1
   124                              <1> 	MTEXT	equ 0 ; mode 07h -> mode 03h
   125                              <1> 	CGA	equ 2
   126                              <1> 	LINEAR8 equ 5
   127                              <1> 	PLANAR4	equ 4
   128                              <1> 	PLANAR1	equ 3
   129 0000E952 0000000000020202    <1> 	db	CTEXT, CTEXT, CTEXT, CTEXT, MTEXT, CGA, CGA, CGA
   130 0000E95A 0504040404040403    <1> 	db	LINEAR8, PLANAR4, PLANAR4, PLANAR4, PLANAR4, PLANAR4, PLANAR4, PLANAR1
   131                              <1> ;vga_pixbits:
   132                              <1> ;	; 25/07/2016
   133                              <1> ;	; 08/07/2016
   134                              <1> ;	db 	4, 4, 4, 4, 4, 2, 2, 1, 8, 4, 4, 4, 4, 4, 4, 1
   135                              <1> vga_dac_s:
   136 0000E962 020202020001010103- <1> 	db	2, 2, 2, 2, 0, 1, 1, 1, 3, 3, 2, 2, 1, 1, 2, 2
   136 0000E96B 03020201010202      <1>
   137                              <1> 
   138                              <1> vga_params:
   139                              <1> 	; 25/07/2016 
   140                              <1> 	; 19/07/2016
   141                              <1> 	; 03/07/2016
   142                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
   143                              <1> 	; vgabios-0.7a (2011)
   144                              <1> 	; by the LGPL VGABios Developers Team (2001-2008)
   145                              <1> 	; 'vgatables.h'
   146                              <1> 	; Oracle VirtualBox 5.0.24 VGABios Source Code
   147                              <1> 	; ('vgabios.c', 'vgatables.h', 'vgafonts.h', 'vgarom.asm')
   148                              <1> 	;
   149                              <1> vga_mode_03h:  ; mode 03h, 80*25 text, CGA colors
   150 0000E972 5018100010          <1>  	db	80, 24, 16, 00h, 10h ; tw, th-1, ch, slength (5)
   151 0000E977 00030002            <1>  	db	00h, 03h, 00h, 02h ; sequ regs (4)
   152 0000E97B 67                  <1>  	db	67h	; misc reg (1)
   153 0000E97C 5F4F50825581BF1F    <1>  	db	5Fh, 4Fh, 50h, 82h, 55h, 81h, 0BFh, 1Fh
   154 0000E984 004F                <1>  	db	00h, 4Fh
   155                              <1> vga_p_cm_pos equ $ - vga_mode_03h
   156 0000E986 0D0E00000000        <1> 	db	0Dh, 0Eh, 00h, 00h, 00h, 00h
   157 0000E98C 9C8E8F281F96B9A3    <1>  	db	9Ch, 8Eh, 8Fh, 28h, 1Fh, 96h, 0B9h, 0A3h
   158 0000E994 FF                  <1> 	db	0FFh	; crtc_regs (25)
   159 0000E995 0001020304051407    <1> 	db	00h, 01h, 02h, 03h, 04h, 05h, 14h, 07h
   160 0000E99D 38393A3B3C3D3E3F    <1>  	db	38h, 39h, 3Ah, 3Bh, 3Ch, 3Dh, 3Eh, 3Fh
   161 0000E9A5 0C000F08            <1>  	db	0Ch, 00h, 0Fh, 08h  ; actl regs (20)
   162 0000E9A9 0000000000100E0FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 10h, 0Eh, 0Fh, 0FFh ; grdc regs (9)
   163                              <1> vga_mode_01h:	; mode 01h, 40*25 text, CGA colors
   164 0000E9B2 2818100008          <1> 	db	40, 24, 16, 00h, 08h ; tw, th-1, ch, slength
   165 0000E9B7 08030002            <1> 	db	08h, 03h, 00h, 02h  ; sequ regs
   166 0000E9BB 67                  <1> 	db	67h	; misc reg
   167 0000E9BC 2D2728902BA0BF1F    <1> 	db	2Dh, 27h, 28h, 90h, 2Bh, 0A0h, 0BFh, 1Fh
   168 0000E9C4 004F0D0E00000000    <1> 	db	00h, 4Fh, 0Dh, 0Eh, 00h, 00h, 00h, 00h
   169 0000E9CC 9C8E8F141F96B9A3    <1> 	db	9Ch, 8Eh, 8Fh, 14h, 1Fh, 96h, 0B9h, 0A3h
   170 0000E9D4 FF                  <1> 	db	0FFh	; crtc_regs
   171 0000E9D5 0001020304051407    <1> 	db	00h, 01h, 02h, 03h, 04h, 05h, 14h, 07h
   172 0000E9DD 38393A3B3C3D3E3F    <1> 	db	38h, 39h, 3Ah, 3Bh, 3Ch, 3Dh, 3Eh, 3Fh
   173 0000E9E5 0C000F08            <1> 	db	0Ch, 00h, 0Fh, 08h  ; actl regs
   174 0000E9E9 0000000000100E0FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 10h, 0Eh, 0Fh, 0FFh ; grdc regs
   175                              <1> ;vga_mode_07h:	; mode 07h, 80*25 text, mono color
   176                              <1> ;	db	80, 24, 16, 00h, 10h  ; tw, th-1, ch, slength
   177                              <1> ;	db	00h, 03h, 00h, 02h ; sequ regs
   178                              <1> ;	db	66h	; misc reg
   179                              <1> ;	db	5Fh, 4Fh, 50h, 82h, 55h, 81h, 0BFh, 1Fh
   180                              <1> ;	db	00h, 4Fh, 0Dh, 0Eh, 00h, 00h, 00h, 00h
   181                              <1> ;	db	9Ch, 8Eh, 8Fh, 28h, 0Fh, 96h, 0B9h, 0A3h
   182                              <1> ;	db	0FFh	; crtc regs
   183                              <1> ;	db	00h, 08h, 08h, 08h, 08h, 08h, 08h, 08h
   184                              <1> ;	db	10h, 18h, 18h, 18h, 18h, 18h, 18h, 18h
   185                              <1> ;	db	0Eh, 00h, 0Fh, 08h  ; actl regs
   186                              <1> ;	db	00h, 00h, 00h, 00h, 00h, 10h, 0Ah, 0Fh, 0FFh ; grdc regs
   187                              <1> vga_mode_04h:	; 320*200 graphics, 4 colors, CGA
   188 0000E9F2 2818080008          <1> 	db	40, 24, 8, 00h, 08h   ; tw, th-1, ch, slength
   189 0000E9F7 09030002            <1> 	db	09h, 03h, 00h, 02h ; sequ regs
   190 0000E9FB 63                  <1> 	db	63h	; misc reg
   191 0000E9FC 2D2728902B80BF1F    <1> 	db	2Dh, 27h, 28h, 90h, 2Bh, 80h, 0BFh, 1Fh
   192 0000EA04 00C1000000000000    <1> 	db	00h, 0C1h, 00h, 00h, 00h, 00h, 00h, 00h
   193 0000EA0C 9C8E8F140096B9A2    <1> 	db	9Ch, 8Eh, 8Fh, 14h, 00h, 96h, 0B9h, 0A2h
   194 0000EA14 FF                  <1> 	db	0FFh	; crtc_regs
   195 0000EA15 0013151702040607    <1> 	db	00h, 13h, 15h, 17h, 02h, 04h, 06h, 07h
   196 0000EA1D 1011121314151617    <1> 	db	10h, 11h, 12h, 13h, 14h, 15h, 16h, 17h
   197 0000EA25 01000300            <1> 	db	01h, 00h, 03h, 00h ; actl regs
   198 0000EA29 0000000000300F0FFF  <1> 	db 	00h, 00h, 00h, 00h, 00h, 30h, 0Fh, 0Fh, 0FFh ; grdc regs
   199                              <1> vga_mode_06h:	; 640*200 graphics, 2 colors, CGA
   200 0000EA32 5018080010          <1> 	db	80, 24, 8, 00h, 10h   ;	tw, th-1, ch, slength
   201 0000EA37 01010006            <1> 	db	01h, 01h, 00h, 06h ; sequ regs
   202 0000EA3B 63                  <1> 	db	63h	; misc reg
   203 0000EA3C 5F4F50825480BF1F    <1> 	db	5Fh, 4Fh, 50h, 82h, 54h, 80h, 0BFh, 1Fh
   204 0000EA44 00C1000000000000    <1> 	db	00h, 0C1h, 00h, 00h, 00h, 00h, 00h, 00h
   205 0000EA4C 9C8E8F280096B9C2    <1> 	db	9Ch, 8Eh, 8Fh, 28h, 00h, 96h, 0B9h, 0C2h
   206 0000EA54 FF                  <1> 	db	0FFh	; crtc regs
   207 0000EA55 0017171717171717    <1> 	db	00h, 17h, 17h, 17h, 17h, 17h, 17h, 17h
   208 0000EA5D 1717171717171717    <1> 	db	17h, 17h, 17h, 17h, 17h, 17h, 17h, 17h
   209 0000EA65 01000100            <1> 	db	01h, 00h, 01, 00h  ; actl regs
   210 0000EA69 0000000000000D0FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 00h, 0Dh, 0Fh, 0FFh ; grdc regs
   211                              <1> vga_mode_13h:  ; mode 13h, 300*200, 256 colors, linear
   212 0000EA72 2818080000          <1> 	db 	40, 24, 8, 0, 0	; tw, th-1, ch, slength (5)
   213 0000EA77 010F000E            <1> 	db	01h, 0Fh, 00h, 0Eh ; sequ regs (4)
   214 0000EA7B 63                  <1> 	db	63h	; misc reg (1)
   215 0000EA7C 5F4F50825480BF1F    <1> 	db	5Fh, 4Fh, 50h, 82h, 54h, 80h, 0BFh, 1Fh 
   216 0000EA84 0041000000000000    <1>  	db 	00h, 41h, 00h, 00h, 00h, 00h, 00h, 00h
   217 0000EA8C 9C8E8F284096B9A3    <1> 	db	9Ch, 8Eh, 8Fh, 28h, 40h, 96h, 0B9h, 0A3h
   218 0000EA94 FF                  <1> 	db	0FFh	; crtc regs (25)
   219 0000EA95 0001020304050607    <1> 	db	00h, 01h, 02h, 03h, 04h, 05h, 06h, 07h
   220 0000EA9D 08090A0B0C0D0E0F    <1>  	db	08h, 09h, 0Ah, 0Bh, 0Ch, 0Dh, 0Eh, 0Fh
   221 0000EAA5 41000F00            <1>  	db	41h, 00h, 0Fh, 00h  ; actl regs (20)
   222 0000EAA9 000000000040050FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 40h, 05h, 0Fh, 0FFh ; grdc regs (9)
   223                              <1> vga_mode_setl equ $ - vga_mode_13h  ; = 64
   224                              <1> vga_mode_F0h:  ; mode X ; 320*240, 256 colors, planar
   225 0000EAB2 2818080000          <1> 	db 	40, 24, 8, 0, 0	; tw, th-1, ch, slength
   226 0000EAB7 010F0006            <1> 	db	01h, 0Fh, 00h, 06h ; sequ regs
   227 0000EABB E3                  <1> 	db	0E3h	; misc reg
   228 0000EABC 5F4F508254800D3E    <1> 	db	5Fh, 4Fh, 50h, 82h, 54h, 80h, 0Dh, 3Eh 
   229 0000EAC4 0041000000000000    <1>  	db 	00h, 41h, 00h, 00h, 00h, 00h, 00h, 00h
   230 0000EACC EAACDF2800E706E3    <1> 	db	0EAh, 0ACh, 0DFh, 28h, 00h, 0E7h, 06h, 0E3h
   231 0000EAD4 FF                  <1> 	db	0FFh	; crtc regs (25)
   232 0000EAD5 0001020304050607    <1> 	db	00h, 01h, 02h, 03h, 04h, 05h, 06h, 07h
   233 0000EADD 08090A0B0C0D0E0F    <1>  	db	08h, 09h, 0Ah, 0Bh, 0Ch, 0Dh, 0Eh, 0Fh
   234 0000EAE5 41000F00            <1>  	db	41h, 00h, 0Fh, 00h  ; actl regs
   235 0000EAE9 000000000040050FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 40h, 05h, 0Fh, 0FFh ; grdc regs
   236                              <1> vga_mode_12h:  ; mode 12h, 640*480, 16 colors, planar
   237 0000EAF2 501D100000          <1>  	db 	80, 29, 16, 0, 0 ; tw, th-1, ch, slength
   238 0000EAF7 010F0006            <1> 	db	01h, 0Fh, 00h, 06h ; sequ regs
   239 0000EAFB E3                  <1> 	db 	0E3h	; misc reg
   240 0000EAFC 5F4F508254800B3E    <1> 	db	5Fh, 4Fh, 50h, 82h, 54h, 80h, 0Bh, 3Eh
   241 0000EB04 0040000000000000    <1> 	db	00h, 40h, 00h, 00h, 00h, 00h, 00h, 00h
   242 0000EB0C EA8CDF2800E704E3    <1>  	db	0EAh, 8Ch, 0DFh, 28h, 00h, 0E7h, 04h, 0E3h
   243 0000EB14 FF                  <1> 	db	0FFh	; crtc regs
   244 0000EB15 0001020304051407    <1> 	db	00h, 01h, 02h, 03h, 04h, 05h, 14h, 07h
   245 0000EB1D 38393A3B3C3D3E3F    <1> 	db	38h, 39h, 3Ah, 3Bh, 3Ch, 3Dh, 3Eh, 3Fh
   246 0000EB25 01000F00            <1> 	db	01h, 00h, 0Fh, 00h  ; actl regs
   247 0000EB29 000000000000050FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 00h, 05h, 0Fh, 0FFh ; grdc regs
   248                              <1> vga_mode_6Ah:  ; mode 6Ah, 800*600, 16 colors, planar
   249 0000EB32 6424100000          <1>  	db 	100, 36, 16, 0, 0 ; tw, th-1, ch, slength
   250 0000EB37 010F0006            <1> 	db	01h, 0Fh, 00h, 06h ; sequ regs
   251 0000EB3B E3                  <1> 	db 	0E3h	; misc reg
   252 0000EB3C 7F6363836B1B72F0    <1> 	db	7Fh, 63h, 63h, 83h, 6Bh, 1Bh, 72h, 0F0h
   253 0000EB44 0060000000000000    <1> 	db	00h, 60h, 00h, 00h, 00h, 00h, 00h, 00h
   254 0000EB4C 598D5732005773E3    <1>  	db	59h, 8Dh, 57h, 32h, 00h, 57h, 73h, 0E3h
   255 0000EB54 FF                  <1> 	db	0FFh	; crtc regs
   256 0000EB55 0001020304051407    <1> 	db	00h, 01h, 02h, 03h, 04h, 05h, 14h, 07h
   257 0000EB5D 38393A3B3C3D3E3F    <1> 	db	38h, 39h, 3Ah, 3Bh, 3Ch, 3Dh, 3Eh, 3Fh
   258 0000EB65 01000F00            <1> 	db	01h, 00h, 0Fh, 00h  ; actl regs
   259 0000EB69 000000000000050FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 00h, 05h, 0Fh, 0FFh ; grdc regs
   260                              <1> vga_mode_0Dh:  ; mode 0Dh, 320*200, 16 colors, planar
   261 0000EB72 2818080020          <1>  	db 	40, 24, 8, 0, 20h ; tw, th-1, ch, slength
   262 0000EB77 090F0006            <1> 	db	09h, 0Fh, 00h, 06h ; sequ regs
   263 0000EB7B 63                  <1> 	db 	63h	; misc reg
   264 0000EB7C 2D2728902B80BF1F    <1> 	db	2Dh, 27h, 28h, 90h, 2Bh, 80h, 0BFh, 1Fh
   265 0000EB84 00C0000000000000    <1> 	db	00h, 0C0h, 00h, 00h, 00h, 00h, 00h, 00h
   266 0000EB8C 9C8E8F140096B9E3    <1>  	db	9Ch, 8Eh, 8Fh, 14h, 00h, 96h, 0B9h, 0E3h
   267 0000EB94 FF                  <1> 	db	0FFh	; crtc regs
   268 0000EB95 0001020304050607    <1> 	db	00h, 01h, 02h, 03h, 04h, 05h, 06h, 07h
   269 0000EB9D 1011121314151617    <1> 	db	10h, 11h, 12h, 13h, 14h, 15h, 16h, 17h
   270 0000EBA5 01000F00            <1> 	db	01h, 00h, 0Fh, 00h  ; actl regs
   271 0000EBA9 000000000000050FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 00h, 05h, 0Fh, 0FFh ; grdc regs
   272                              <1> vga_mode_0Eh:  ; mode 0Eh, 640*200, 16 colors, planar
   273 0000EBB2 5018080040          <1>  	db 	80, 24, 8, 0, 40h ; tw, th-1, ch, slength
   274 0000EBB7 010F0006            <1> 	db	01h, 0Fh, 00h, 06h ; sequ regs
   275 0000EBBB 63                  <1> 	db 	63h	; misc reg
   276 0000EBBC 5F4F50825480BF1F    <1> 	db	5Fh, 4Fh, 50h, 82h, 54h, 80h, 0BFh, 1Fh
   277 0000EBC4 00C0000000000000    <1> 	db	00h, 0C0h, 00h, 00h, 00h, 00h, 00h, 00h
   278 0000EBCC 9C8E8F280096B9E3    <1>  	db	9Ch, 8Eh, 8Fh, 28h, 00h, 96h, 0B9h, 0E3h
   279 0000EBD4 FF                  <1> 	db	0FFh	; crtc regs
   280 0000EBD5 0001020304050607    <1> 	db	00h, 01h, 02h, 03h, 04h, 05h, 06h, 07h
   281 0000EBDD 1011121314151617    <1> 	db	10h, 11h, 12h, 13h, 14h, 15h, 16h, 17h
   282 0000EBE5 01000F00            <1> 	db	01h, 00h, 0Fh, 00h  ; actl regs
   283 0000EBE9 000000000000050FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 00h, 05h, 0Fh, 0FFh ; grdc regs
   284                              <1> vga_mode_10h: ; mode 10h, 640*350, 16 colors, planar
   285 0000EBF2 50180E0080          <1>  	db 	80, 24, 14, 0, 80h ; tw, th-1, ch, slength
   286 0000EBF7 010F0006            <1> 	db	01h, 0Fh, 00h, 06h ; sequ regs
   287 0000EBFB A3                  <1> 	db 	0A3h	; misc reg
   288 0000EBFC 5F4F50825480BF1F    <1> 	db	5Fh, 4Fh, 50h, 82h, 54h, 80h, 0BFh, 1Fh
   289 0000EC04 0040000000000000    <1> 	db	00h, 40h, 00h, 00h, 00h, 00h, 00h, 00h
   290 0000EC0C 83855D280F63BAE3    <1>  	db	83h, 85h, 5Dh, 28h, 0Fh, 63h, 0BAh, 0E3h
   291 0000EC14 FF                  <1> 	db	0FFh	; crtc regs
   292 0000EC15 0001020304051407    <1> 	db	00h, 01h, 02h, 03h, 04h, 05h, 14h, 07h
   293 0000EC1D 38393A3B3C3D3E3F    <1> 	db	38h, 39h, 3Ah, 3Bh, 3Ch, 3Dh, 3Eh, 3Fh
   294 0000EC25 01000F00            <1> 	db	01h, 00h, 0Fh, 00h  ; actl regs
   295 0000EC29 000000000000050FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 00h, 05h, 0Fh, 0FFh ; grdc regs
   296                              <1> vga_mode_11h: ; mode 11h, 640*480, mono color, planar
   297 0000EC32 501D100000          <1>  	db 	80, 29, 16, 0, 0   ; tw, th-1, ch, slength
   298 0000EC37 010F0006            <1> 	db	01h, 0Fh, 00h, 06h ; sequ regs
   299 0000EC3B E3                  <1> 	db 	0E3h	; misc reg
   300 0000EC3C 5F4F508254800B3E    <1> 	db	5Fh, 4Fh, 50h, 82h, 54h, 80h, 0Bh, 3Eh
   301 0000EC44 0040000000000000    <1> 	db	00h, 40h, 00h, 00h, 00h, 00h, 00h, 00h
   302 0000EC4C EA8CDF2800E704E3    <1>  	db	0EAh, 8Ch, 0DFh, 28h, 00h, 0E7h, 04h, 0E3h
   303 0000EC54 FF                  <1> 	db	0FFh	; crtc regs
   304 0000EC55 003F003F003F003F    <1> 	db	00h, 3Fh, 00h, 3Fh, 00h, 3Fh, 00h, 3Fh
   305 0000EC5D 003F003F003F003F    <1> 	db	00h, 3Fh, 00h, 3Fh, 00h, 3Fh, 00h, 3Fh
   306 0000EC65 01000F00            <1> 	db	01h, 00h, 0Fh, 00h  ; actl regs
   307 0000EC69 000000000000050FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 00h, 05h, 0Fh, 0FFh ; grdc regs
   308                              <1> end_of_vga_params:
   309                              <1> 
   310                              <1> ; /// End Of VIDEO DATA ///
  2226                                  %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 0000EC72 [D5EC0000]          <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 0000EC76 01                  <1> 		DB	01		;DRIVE TYPE, MEDIA TABLE
   113                              <1>                 ;DW      MD_TBL1
   114 0000EC77 [94EC0000]          <1> 		dd	MD_TBL1
   115 0000EC7B 82                  <1> 		DB	02+BIT7ON
   116                              <1> 		;DW      MD_TBL2
   117 0000EC7C [A1EC0000]          <1>                 dd      MD_TBL2
   118 0000EC80 02                  <1> DR_DEFAULT:	DB	02
   119                              <1>                 ;DW      MD_TBL3
   120 0000EC81 [AEEC0000]          <1> 		dd      MD_TBL3
   121 0000EC85 03                  <1> 		DB	03
   122                              <1>                 ;DW      MD_TBL4
   123 0000EC86 [BBEC0000]          <1> 		dd      MD_TBL4
   124 0000EC8A 84                  <1> 		DB	04+BIT7ON
   125                              <1>                 ;DW      MD_TBL5
   126 0000EC8B [C8EC0000]          <1> 		dd      MD_TBL5
   127 0000EC8F 04                  <1> 		DB	04
   128                              <1>                 ;DW      MD_TBL6
   129 0000EC90 [D5EC0000]          <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 0000EC94 DF                  <1> 	DB	11011111B	; SRT=D, HD UNLOAD=0F - 1ST SPECIFY BYTE
   141 0000EC95 02                  <1> 	DB	2		; HD LOAD=1, MODE=DMA - 2ND SPECIFY BYTE
   142 0000EC96 25                  <1> 	DB	MOTOR_WAIT	; WAIT TIME AFTER OPERATION TILL MOTOR OFF
   143 0000EC97 02                  <1> 	DB	2		; 512 BYTES/SECTOR
   144 0000EC98 09                  <1> 	DB	09		; EOT (LAST SECTOR ON TRACK)
   145 0000EC99 2A                  <1> 	DB	02AH		; GAP LENGTH
   146 0000EC9A FF                  <1> 	DB	0FFH		; DTL
   147 0000EC9B 50                  <1> 	DB	050H		; GAP LENGTH FOR FORMAT
   148 0000EC9C F6                  <1> 	DB	0F6H		; FILL BYTE FOR FORMAT
   149 0000EC9D 0F                  <1> 	DB	15		; HEAD SETTLE TIME (MILLISECONDS)
   150 0000EC9E 08                  <1> 	DB	8		; MOTOR START TIME (1/8 SECONDS)
   151 0000EC9F 27                  <1> 	DB	39		; MAX. TRACK NUMBER
   152 0000ECA0 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 0000ECA1 DF                  <1> 	DB	11011111B	; SRT=D, HD UNLOAD=0F - 1ST SPECIFY BYTE
   158 0000ECA2 02                  <1> 	DB	2		; HD LOAD=1, MODE=DMA - 2ND SPECIFY BYTE
   159 0000ECA3 25                  <1> 	DB	MOTOR_WAIT	; WAIT TIME AFTER OPERATION TILL MOTOR OFF
   160 0000ECA4 02                  <1> 	DB	2		; 512 BYTES/SECTOR
   161 0000ECA5 09                  <1> 	DB	09		; EOT (LAST SECTOR ON TRACK)
   162 0000ECA6 2A                  <1> 	DB	02AH		; GAP LENGTH
   163 0000ECA7 FF                  <1> 	DB	0FFH		; DTL
   164 0000ECA8 50                  <1> 	DB	050H		; GAP LENGTH FOR FORMAT
   165 0000ECA9 F6                  <1> 	DB	0F6H		; FILL BYTE FOR FORMAT
   166 0000ECAA 0F                  <1> 	DB	15		; HEAD SETTLE TIME (MILLISECONDS)
   167 0000ECAB 08                  <1> 	DB	8		; MOTOR START TIME (1/8 SECONDS)
   168 0000ECAC 27                  <1> 	DB	39		; MAX. TRACK NUMBER
   169 0000ECAD 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 0000ECAE DF                  <1> 	DB	11011111B	; SRT=D, HD UNLOAD=0F - 1ST SPECIFY BYTE
   175 0000ECAF 02                  <1> 	DB	2		; HD LOAD=1, MODE=DMA - 2ND SPECIFY BYTE
   176 0000ECB0 25                  <1> 	DB	MOTOR_WAIT	; WAIT TIME AFTER OPERATION TILL MOTOR OFF
   177 0000ECB1 02                  <1> 	DB	2		; 512 BYTES/SECTOR
   178 0000ECB2 0F                  <1> 	DB	15		; EOT (LAST SECTOR ON TRACK)
   179 0000ECB3 1B                  <1> 	DB	01BH		; GAP LENGTH
   180 0000ECB4 FF                  <1> 	DB	0FFH		; DTL
   181 0000ECB5 54                  <1> 	DB	054H		; GAP LENGTH FOR FORMAT
   182 0000ECB6 F6                  <1> 	DB	0F6H		; FILL BYTE FOR FORMAT
   183 0000ECB7 0F                  <1> 	DB	15		; HEAD SETTLE TIME (MILLISECONDS)
   184 0000ECB8 08                  <1> 	DB	8		; MOTOR START TIME (1/8 SECONDS)
   185 0000ECB9 4F                  <1> 	DB	79		; MAX. TRACK NUMBER
   186 0000ECBA 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 0000ECBB DF                  <1> 	DB	11011111B	; SRT=D, HD UNLOAD=0F - 1ST SPECIFY BYTE
   192 0000ECBC 02                  <1> 	DB	2		; HD LOAD=1, MODE=DMA - 2ND SPECIFY BYTE
   193 0000ECBD 25                  <1> 	DB	MOTOR_WAIT	; WAIT TIME AFTER OPERATION TILL MOTOR OFF
   194 0000ECBE 02                  <1> 	DB	2		; 512 BYTES/SECTOR
   195 0000ECBF 09                  <1> 	DB	09		; EOT (LAST SECTOR ON TRACK)
   196 0000ECC0 2A                  <1> 	DB	02AH		; GAP LENGTH
   197 0000ECC1 FF                  <1> 	DB	0FFH		; DTL
   198 0000ECC2 50                  <1> 	DB	050H		; GAP LENGTH FOR FORMAT
   199 0000ECC3 F6                  <1> 	DB	0F6H		; FILL BYTE FOR FORMAT
   200 0000ECC4 0F                  <1> 	DB	15		; HEAD SETTLE TIME (MILLISECONDS)
   201 0000ECC5 08                  <1> 	DB	8		; MOTOR START TIME (1/8 SECONDS)
   202 0000ECC6 4F                  <1> 	DB	79		; MAX. TRACK NUMBER
   203 0000ECC7 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 0000ECC8 DF                  <1> 	DB	11011111B	; SRT=D, HD UNLOAD=0F - 1ST SPECIFY BYTE
   209 0000ECC9 02                  <1> 	DB	2		; HD LOAD=1, MODE=DMA - 2ND SPECIFY BYTE
   210 0000ECCA 25                  <1> 	DB	MOTOR_WAIT	; WAIT TIME AFTER OPERATION TILL MOTOR OFF
   211 0000ECCB 02                  <1> 	DB	2		; 512 BYTES/SECTOR
   212 0000ECCC 09                  <1> 	DB	09		; EOT (LAST SECTOR ON TRACK)
   213 0000ECCD 2A                  <1> 	DB	02AH		; GAP LENGTH
   214 0000ECCE FF                  <1> 	DB	0FFH		; DTL
   215 0000ECCF 50                  <1> 	DB	050H		; GAP LENGTH FOR FORMAT
   216 0000ECD0 F6                  <1> 	DB	0F6H		; FILL BYTE FOR FORMAT
   217 0000ECD1 0F                  <1> 	DB	15		; HEAD SETTLE TIME (MILLISECONDS)
   218 0000ECD2 08                  <1> 	DB	8		; MOTOR START TIME (1/8 SECONDS)
   219 0000ECD3 4F                  <1> 	DB	79		; MAX. TRACK NUMBER
   220 0000ECD4 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 0000ECD5 AF                  <1> 	DB	10101111B	; SRT=A, HD UNLOAD=0F - 1ST SPECIFY BYTE
   226 0000ECD6 02                  <1> 	DB	2		; HD LOAD=1, MODE=DMA - 2ND SPECIFY BYTE
   227 0000ECD7 25                  <1> 	DB	MOTOR_WAIT	; WAIT TIME AFTER OPERATION TILL MOTOR OFF
   228 0000ECD8 02                  <1> 	DB	2		; 512 BYTES/SECTOR
   229 0000ECD9 12                  <1> 	DB	18		; EOT (LAST SECTOR ON TRACK)
   230 0000ECDA 1B                  <1> 	DB	01BH		; GAP LENGTH
   231 0000ECDB FF                  <1> 	DB	0FFH		; DTL
   232 0000ECDC 6C                  <1> 	DB	06CH		; GAP LENGTH FOR FORMAT
   233 0000ECDD F6                  <1> 	DB	0F6H		; FILL BYTE FOR FORMAT
   234 0000ECDE 0F                  <1> 	DB	15		; HEAD SETTLE TIME (MILLISECONDS)
   235 0000ECDF 08                  <1> 	DB	8		; MOTOR START TIME (1/8 SECONDS)
   236 0000ECE0 4F                  <1> 	DB	79		; MAX. TRACK NUMBER
   237 0000ECE1 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 0000ECE2 E0                  <1> 	db	NO_ERR
   280 0000ECE3 024001BB            <1> 	db	BAD_ADDR_MARK,BAD_SEEK,BAD_CMD,UNDEF_ERR
   281 0000ECE7 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 0000ECEB 00                  <1> cfd:		db 0			; current floppy drive (for GET_PARM)
   286                              <1> ; 17/12/2014				; instead of 'DISK_POINTER'
   287 0000ECEC 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 0000ECED 90                  <1> align 2
   293                              <1> 
   294 0000ECEE F001                <1> HF_PORT:	dw 	1F0h  ; Default = 1F0h
   295                              <1> 			      ; (170h)
   296 0000ECF0 F603                <1> HF_REG_PORT:	dw	3F6h  ; HF_PORT + 206h
   297                              <1> 
   298                              <1> ; 05/01/2015 
   299 0000ECF2 00                  <1> hf_m_s:         db      0     ; (0 = Master, 1 = Slave)
   300                              <1> 
   301                              <1> ; *****************************************************************************
  2227                                  ;;;
  2228                                  
  2229 0000ECF3 90                      Align 2
  2230                                  
  2231                                  ; 12/11/2014 (Retro UNIX 386 v1)
  2232 0000ECF4 00                      boot_drv:    db 0 ; boot drive number (physical)
  2233                                  ; 24/11/2014
  2234 0000ECF5 00                      drv:	     db 0 
  2235 0000ECF6 00                      last_drv:    db 0 ; last hdd
  2236 0000ECF7 00                      hdc:         db 0  ; number of hard disk drives
  2237                                  		     ; (present/detected)
  2238                                  ;
  2239                                  ; 24/11/2014 (Retro UNIX 386 v1)
  2240                                  ; Physical drive type & flags
  2241 0000ECF8 00                      fd0_type:    db 0  ; floppy drive type
  2242 0000ECF9 00                      fd1_type:    db 0  ; 4 = 1.44 Mb, 80 track, 3.5" (18 spt)
  2243                                  		     ; 6 = 2.88 Mb, 80 track, 3.5" (36 spt)
  2244                                  		     ; 3 = 720 Kb, 80 track, 3.5" (9 spt)
  2245                                  		     ; 2 = 1.2 Mb, 80 track, 5.25" (15 spt)
  2246                                  		     ; 1 = 360 Kb, 40 track, 5.25" (9 spt)		
  2247 0000ECFA 00                      hd0_type:    db 0  ; EDD status for hd0 (bit 7 = present flag)
  2248 0000ECFB 00                      hd1_type:    db 0  ; EDD status for hd1 (bit 7 = present flag)
  2249 0000ECFC 00                      hd2_type:    db 0  ; EDD status for hd2 (bit 7 = present flag)
  2250 0000ECFD 00                      hd3_type:    db 0  ; EDD status for hd3 (bit 7 = present flag)
  2251                                  		     ; bit 0 - Fixed disk access subset supported
  2252                                  		     ; bit 1 - Drive locking and ejecting
  2253                                  		     ; bit 2 - Enhanced disk drive support
  2254                                  		     ; bit 3 = Reserved (64 bit EDD support)
  2255                                  		     ; (If bit 0 is '1' Retro UNIX 386 v1
  2256                                  		     ; will interpret it as 'LBA ready'!)		
  2257                                  
  2258                                  ; 11/03/2015 - 10/07/2015
  2259 0000ECFE 000000000000000000-     drv.cylinders: dw 0,0,0,0,0,0,0
  2259 0000ED07 0000000000         
  2260 0000ED0C 000000000000000000-     drv.heads:     dw 0,0,0,0,0,0,0
  2260 0000ED15 0000000000         
  2261 0000ED1A 000000000000000000-     drv.spt:       dw 0,0,0,0,0,0,0
  2261 0000ED23 0000000000         
  2262 0000ED28 000000000000000000-     drv.size:      dd 0,0,0,0,0,0,0
  2262 0000ED31 000000000000000000-
  2262 0000ED3A 000000000000000000-
  2262 0000ED43 00                 
  2263 0000ED44 00000000000000          drv.status:    db 0,0,0,0,0,0,0
  2264 0000ED4B 00000000000000          drv.error:     db 0,0,0,0,0,0,0		
  2265                                  ;
  2266                                  
  2267                                  ; 27/08/2014
  2268                                  scr_row:
  2269 0000ED52 E0810B00                	dd 0B8000h + 0A0h + 0A0h + 0A0h ; Row 3
  2270                                  scr_col:
  2271 0000ED56 00000000                	dd 0
  2272                                  
  2273                                  ; 20/08/2014
  2274                                    ; /* This is the default interrupt "handler" :-) */ 
  2275                                    ; Linux v0.12 (head.s)
  2276                                  int_msg:
  2277 0000ED5A 556E6B6E6F776E2069-     	db "Unknown interrupt ! ", 0
  2277 0000ED63 6E7465727275707420-
  2277 0000ED6C 212000             
  2278                                  
  2279 0000ED6F 90                      Align 2
  2280                                  	; 21/08/2014
  2281                                  exc_msg:
  2282 0000ED70 435055206578636570-     	db "CPU exception ! "
  2282 0000ED79 74696F6E202120     
  2283                                  excnstr: 		; 25/08/2014
  2284 0000ED80 3F3F68202045495020-     	db "??h", "  EIP : "
  2284 0000ED89 3A20               
  2285                                  EIPstr: ; 29/08/2014
  2286 0000ED8B 00<rept>                	times 12 db 0
  2287                                  
  2288                                  	; 23/02/2015
  2289                                  	; 25/08/2014
  2290                                  ;scounter:
  2291                                  ;	db 5
  2292                                  ;	db 19
  2293                                  
  2294                                  ; 05/11/2014
  2295                                  msg_out_of_memory:
  2296 0000ED97 070D0A                  	db 	07h, 0Dh, 0Ah
  2297 0000ED9A 496E73756666696369-             db      'Insufficient memory !'
  2297 0000EDA3 656E74206D656D6F72-
  2297 0000EDAC 792021             
  2298 0000EDAF 0D0A                    	db	0Dh, 0Ah
  2299                                  _int13h_48h_buffer: ; 07/07/2016
  2300 0000EDB1 284D696E696D756D20-     	db	'(Minimum 2MB memory is needed.)'
  2300 0000EDBA 324D42206D656D6F72-
  2300 0000EDC3 79206973206E656564-
  2300 0000EDCC 65642E29           
  2301 0000EDD0 0D0A00                   	db	0Dh, 0Ah, 0
  2302                                  	;
  2303                                  setup_error_msg:
  2304 0000EDD3 0D0A                    	db 0Dh, 0Ah
  2305 0000EDD5 4469736B2053657475-     	db 'Disk Setup Error !' 
  2305 0000EDDE 70204572726F722021 
  2306 0000EDE7 0D0A00                  	db 0Dh, 0Ah,0
  2307                                  
  2308                                  ; 06/11/2014
  2309                                  ; Memory Information message
  2310                                  ; 14/08/2015
  2311                                  msg_memory_info:
  2312 0000EDEA 07                      	db	07h
  2313 0000EDEB 0D0A                    	db	0Dh, 0Ah
  2314                                  	;db 	"MEMORY ALLOCATION INFO", 0Dh, 0Ah, 0Dh, 0Ah
  2315 0000EDED 546F74616C206D656D-     	db	"Total memory : "
  2315 0000EDF6 6F7279203A20       
  2316                                  mem_total_b_str: ; 10 digits
  2317 0000EDFC 303030303030303030-     	db	"0000000000 bytes", 0Dh, 0Ah
  2317 0000EE05 302062797465730D0A 
  2318 0000EE0E 202020202020202020-     	db	"               ", 20h, 20h, 20h
  2318 0000EE17 202020202020202020 
  2319                                  mem_total_p_str: ; 7 digits
  2320 0000EE20 303030303030302070-     	db	"0000000 pages", 0Dh, 0Ah
  2320 0000EE29 616765730D0A       
  2321 0000EE2F 0D0A                    	db 	0Dh, 0Ah
  2322 0000EE31 46726565206D656D6F-     	db	"Free memory  : "
  2322 0000EE3A 727920203A20       
  2323                                  free_mem_b_str:  ; 10 digits
  2324 0000EE40 3F3F3F3F3F3F3F3F3F-     	db	"?????????? bytes", 0Dh, 0Ah
  2324 0000EE49 3F2062797465730D0A 
  2325 0000EE52 202020202020202020-     	db	"               ", 20h, 20h, 20h
  2325 0000EE5B 202020202020202020 
  2326                                  free_mem_p_str:  ; 7 digits
  2327 0000EE64 3F3F3F3F3F3F3F2070-     	db	"??????? pages", 0Dh, 0Ah
  2327 0000EE6D 616765730D0A       
  2328 0000EE73 0D0A00                  	db	0Dh, 0Ah, 0
  2329                                  
  2330                                  dsk_ready_msg:
  2331 0000EE76 0D0A                    	db 	0Dh, 0Ah
  2332                                  dsktype:
  2333 0000EE78 6664                    	db	'fd'
  2334                                  dskx:
  2335 0000EE7A 30                      	db	'0'
  2336 0000EE7B 20                      	db	20h
  2337 0000EE7C 697320524541445920-     	db 	'is READY ...'
  2337 0000EE85 2E2E2E             
  2338 0000EE88 00                      	db 	0
  2339                                  
  2340                                  next2line: ; 08/02/2016
  2341 0000EE89 0D0A                    	db	0Dh, 0Ah
  2342                                  nextline:
  2343 0000EE8B 0D0A00                  	db 	0Dh, 0Ah, 0
  2344                                  
  2345                                  ; KERNEL - SYSINIT Messages
  2346                                  ; 24/08/2015
  2347                                  ; 13/04/2015 - (Retro UNIX 386 v1 Beginning)
  2348                                  ; 14/07/2013
  2349                                  ;kernel_init_err_msg:
  2350                                  ;	db 0Dh, 0Ah
  2351                                  ;	db 07h
  2352                                  ;	db 'Kernel initialization ERROR !'
  2353                                  ;	db 0Dh, 0Ah, 0 
  2354                                  
  2355                                  ;welcome_msg: 
  2356                                  ;	db 0Dh, 0Ah
  2357                                  ;	db 07h
  2358                                  ;	db 'Welcome to TRDOS 386 Operating System !'
  2359                                  ;	db 0Dh, 0Ah
  2360                                  ;	db 'by Erdogan Tan - 30/07/2016 (v2.0.0)'
  2361                                  ;	db 0Dh, 0Ah, 0
  2362                                  
  2363                                  panic_msg:
  2364 0000EE8E 0D0A07                  	db 0Dh, 0Ah, 07h
  2365 0000EE91 4552524F523A204B65-     	db 'ERROR: Kernel Panic !'
  2365 0000EE9A 726E656C2050616E69-
  2365 0000EEA3 632021             
  2366 0000EEA6 0D0A00                  	db 0Dh, 0Ah, 0
  2367                                  
  2368 0000EEA9 90                      align 2
  2369                                  
  2370                                  ; EPOCH Variables
  2371                                  ; 13/04/2015 - Retro UNIX 386 v1 Beginning
  2372                                  ; 09/04/2013 epoch variables
  2373                                  ; Retro UNIX 8086 v1 Prototype: UNIXCOPY.ASM, 10/03/2013
  2374                                  ;
  2375 0000EEAA B207                    year: 	dw 1970
  2376 0000EEAC 0100                    month: 	dw 1
  2377 0000EEAE 0100                    day: 	dw 1
  2378 0000EEB0 0000                    hour: 	dw 0
  2379 0000EEB2 0000                    minute: dw 0
  2380 0000EEB4 0000                    second: dw 0
  2381                                  
  2382                                  DMonth:
  2383 0000EEB6 0000                    	dw 0
  2384 0000EEB8 1F00                    	dw 31
  2385 0000EEBA 3B00                    	dw 59
  2386 0000EEBC 5A00                    	dw 90
  2387 0000EEBE 7800                    	dw 120
  2388 0000EEC0 9700                    	dw 151
  2389 0000EEC2 B500                    	dw 181
  2390 0000EEC4 D400                    	dw 212
  2391 0000EEC6 F300                    	dw 243
  2392 0000EEC8 1101                    	dw 273
  2393 0000EECA 3001                    	dw 304
  2394 0000EECC 4E01                    	dw 334
  2395                                  
  2396                                  ; 04/11/2014 (Retro UNIX 386 v1)
  2397 0000EECE 0000                    mem_1m_1k:   dw 0  ; Number of contiguous KB between
  2398                                                       ; 1 and 16 MB, max. 3C00h = 15 MB.
  2399 0000EED0 0000                    mem_16m_64k: dw 0  ; Number of contiguous 64 KB blocks
  2400                                  		   ; between 16 MB and 4 GB.
  2401                                  
  2402                                  ;msgl_drv_not_ready: 
  2403                                  ;	db 07h, 0Dh, 0Ah
  2404                                  ;       db 'Drive not ready or read error !'
  2405                                  ;       db 0Dh, 0Ah, 0
  2406                                  
  2407                                  starting_msg:
  2408 0000EED2 5475726B6973682052-     	db "Turkish Rational DOS v2.0 [30/07/2016] ...", 0
  2408 0000EEDB 6174696F6E616C2044-
  2408 0000EEE4 4F532076322E30205B-
  2408 0000EEED 33302F30372F323031-
  2408 0000EEF6 365D202E2E2E00     
  2409                                  NextLine:
  2410 0000EEFD 0D0A00                  	db 0Dh, 0Ah, 0
  2411                                  
  2412                                  align 4
  2413                                  
  2414                                  %include 'vgadata.s' ; 04/07/2016
     1                              <1> ; ****************************************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.0 - vgadata.s  (palette and fond data)
     3                              <1> ; -----------------------------------------------------------------------------
     4                              <1> ; Last Update: 04/07/2016
     5                              <1> ; -----------------------------------------------------------------------------
     6                              <1> ; Beginning: 16/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 '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> ; 04/07/2016
    25                              <1> ; COLOR DATA
    26                              <1> 
    27                              <1> palette0:
    28 0000EF00 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
    28 0000EF09 00000000000000      <1>
    29 0000EF10 00000000000000002A- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah
    29 0000EF19 2A2A2A2A2A2A2A      <1>
    30 0000EF20 2A2A2A2A2A2A2A2A2A- <1>     db  02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah
    30 0000EF29 2A2A2A2A2A2A2A      <1>
    31 0000EF30 2A2A2A2A2A2A2A2A2A- <1>     db  02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah
    31 0000EF39 2A2A2A2A2A2A2A      <1>
    32 0000EF40 2A2A2A2A2A2A2A2A3F- <1>     db  02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh
    32 0000EF49 3F3F3F3F3F3F3F      <1>
    33 0000EF50 3F3F3F3F3F3F3F3F3F- <1>     db  03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh
    33 0000EF59 3F3F3F3F3F3F3F      <1>
    34 0000EF60 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
    34 0000EF69 00000000000000      <1>
    35 0000EF70 00000000000000002A- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah
    35 0000EF79 2A2A2A2A2A2A2A      <1>
    36 0000EF80 2A2A2A2A2A2A2A2A2A- <1>     db  02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah
    36 0000EF89 2A2A2A2A2A2A2A      <1>
    37 0000EF90 2A2A2A2A2A2A2A2A2A- <1>     db  02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah
    37 0000EF99 2A2A2A2A2A2A2A      <1>
    38 0000EFA0 2A2A2A2A2A2A2A2A3F- <1>     db  02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh
    38 0000EFA9 3F3F3F3F3F3F3F      <1>
    39 0000EFB0 3F3F3F3F3F3F3F3F3F- <1>     db  03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh
    39 0000EFB9 3F3F3F3F3F3F3F      <1>
    40                              <1> palette1:
    41 0000EFC0 00000000002A002A00- <1>     db  000h, 000h, 000h, 000h, 000h, 02ah, 000h, 02ah, 000h, 000h, 02ah, 02ah, 02ah, 000h, 000h, 02ah
    41 0000EFC9 002A2A2A00002A      <1>
    42 0000EFD0 002A2A15002A2A2A00- <1>     db  000h, 02ah, 02ah, 015h, 000h, 02ah, 02ah, 02ah, 000h, 000h, 000h, 000h, 000h, 02ah, 000h, 02ah
    42 0000EFD9 000000002A002A      <1>
    43 0000EFE0 00002A2A2A00002A00- <1>     db  000h, 000h, 02ah, 02ah, 02ah, 000h, 000h, 02ah, 000h, 02ah, 02ah, 015h, 000h, 02ah, 02ah, 02ah
    43 0000EFE9 2A2A15002A2A2A      <1>
    44 0000EFF0 15151515153F153F15- <1>     db  015h, 015h, 015h, 015h, 015h, 03fh, 015h, 03fh, 015h, 015h, 03fh, 03fh, 03fh, 015h, 015h, 03fh
    44 0000EFF9 153F3F3F15153F      <1>
    45 0000F000 153F3F3F153F3F3F15- <1>     db  015h, 03fh, 03fh, 03fh, 015h, 03fh, 03fh, 03fh, 015h, 015h, 015h, 015h, 015h, 03fh, 015h, 03fh
    45 0000F009 151515153F153F      <1>
    46 0000F010 15153F3F3F15153F15- <1>     db  015h, 015h, 03fh, 03fh, 03fh, 015h, 015h, 03fh, 015h, 03fh, 03fh, 03fh, 015h, 03fh, 03fh, 03fh
    46 0000F019 3F3F3F153F3F3F      <1>
    47 0000F020 00000000002A002A00- <1>     db  000h, 000h, 000h, 000h, 000h, 02ah, 000h, 02ah, 000h, 000h, 02ah, 02ah, 02ah, 000h, 000h, 02ah
    47 0000F029 002A2A2A00002A      <1>
    48 0000F030 002A2A15002A2A2A00- <1>     db  000h, 02ah, 02ah, 015h, 000h, 02ah, 02ah, 02ah, 000h, 000h, 000h, 000h, 000h, 02ah, 000h, 02ah
    48 0000F039 000000002A002A      <1>
    49 0000F040 00002A2A2A00002A00- <1>     db  000h, 000h, 02ah, 02ah, 02ah, 000h, 000h, 02ah, 000h, 02ah, 02ah, 015h, 000h, 02ah, 02ah, 02ah
    49 0000F049 2A2A15002A2A2A      <1>
    50 0000F050 15151515153F153F15- <1>     db  015h, 015h, 015h, 015h, 015h, 03fh, 015h, 03fh, 015h, 015h, 03fh, 03fh, 03fh, 015h, 015h, 03fh
    50 0000F059 153F3F3F15153F      <1>
    51 0000F060 153F3F3F153F3F3F15- <1>     db  015h, 03fh, 03fh, 03fh, 015h, 03fh, 03fh, 03fh, 015h, 015h, 015h, 015h, 015h, 03fh, 015h, 03fh
    51 0000F069 151515153F153F      <1>
    52 0000F070 15153F3F3F15153F15- <1>     db  015h, 015h, 03fh, 03fh, 03fh, 015h, 015h, 03fh, 015h, 03fh, 03fh, 03fh, 015h, 03fh, 03fh, 03fh
    52 0000F079 3F3F3F153F3F3F      <1>
    53                              <1> palette2:
    54 0000F080 00000000002A002A00- <1>     db  000h, 000h, 000h, 000h, 000h, 02ah, 000h, 02ah, 000h, 000h, 02ah, 02ah, 02ah, 000h, 000h, 02ah
    54 0000F089 002A2A2A00002A      <1>
    55 0000F090 002A2A2A002A2A2A00- <1>     db  000h, 02ah, 02ah, 02ah, 000h, 02ah, 02ah, 02ah, 000h, 000h, 015h, 000h, 000h, 03fh, 000h, 02ah
    55 0000F099 001500003F002A      <1>
    56 0000F0A0 15002A3F2A00152A00- <1>     db  015h, 000h, 02ah, 03fh, 02ah, 000h, 015h, 02ah, 000h, 03fh, 02ah, 02ah, 015h, 02ah, 02ah, 03fh
    56 0000F0A9 3F2A2A152A2A3F      <1>
    57 0000F0B0 00150000152A003F00- <1>     db  000h, 015h, 000h, 000h, 015h, 02ah, 000h, 03fh, 000h, 000h, 03fh, 02ah, 02ah, 015h, 000h, 02ah
    57 0000F0B9 003F2A2A15002A      <1>
    58 0000F0C0 152A2A3F002A3F2A00- <1>     db  015h, 02ah, 02ah, 03fh, 000h, 02ah, 03fh, 02ah, 000h, 015h, 015h, 000h, 015h, 03fh, 000h, 03fh
    58 0000F0C9 151500153F003F      <1>
    59 0000F0D0 15003F3F2A15152A15- <1>     db  015h, 000h, 03fh, 03fh, 02ah, 015h, 015h, 02ah, 015h, 03fh, 02ah, 03fh, 015h, 02ah, 03fh, 03fh
    59 0000F0D9 3F2A3F152A3F3F      <1>
    60 0000F0E0 15000015002A152A00- <1>     db  015h, 000h, 000h, 015h, 000h, 02ah, 015h, 02ah, 000h, 015h, 02ah, 02ah, 03fh, 000h, 000h, 03fh
    60 0000F0E9 152A2A3F00003F      <1>
    61 0000F0F0 002A3F2A003F2A2A15- <1>     db  000h, 02ah, 03fh, 02ah, 000h, 03fh, 02ah, 02ah, 015h, 000h, 015h, 015h, 000h, 03fh, 015h, 02ah
    61 0000F0F9 001515003F152A      <1>
    62 0000F100 15152A3F3F00153F00- <1>     db  015h, 015h, 02ah, 03fh, 03fh, 000h, 015h, 03fh, 000h, 03fh, 03fh, 02ah, 015h, 03fh, 02ah, 03fh
    62 0000F109 3F3F2A153F2A3F      <1>
    63 0000F110 15150015152A153F00- <1>     db  015h, 015h, 000h, 015h, 015h, 02ah, 015h, 03fh, 000h, 015h, 03fh, 02ah, 03fh, 015h, 000h, 03fh
    63 0000F119 153F2A3F15003F      <1>
    64 0000F120 152A3F3F003F3F2A15- <1>     db  015h, 02ah, 03fh, 03fh, 000h, 03fh, 03fh, 02ah, 015h, 015h, 015h, 015h, 015h, 03fh, 015h, 03fh
    64 0000F129 151515153F153F      <1>
    65 0000F130 15153F3F3F15153F15- <1>     db  015h, 015h, 03fh, 03fh, 03fh, 015h, 015h, 03fh, 015h, 03fh, 03fh, 03fh, 015h, 03fh, 03fh, 03fh
    65 0000F139 3F3F3F153F3F3F      <1>
    66                              <1> palette3:
    67 0000F140 00000000002A002A00- <1>     db  000h, 000h, 000h, 000h, 000h, 02ah, 000h, 02ah, 000h, 000h, 02ah, 02ah, 02ah, 000h, 000h, 02ah
    67 0000F149 002A2A2A00002A      <1>
    68 0000F150 002A2A15002A2A2A15- <1>     db  000h, 02ah, 02ah, 015h, 000h, 02ah, 02ah, 02ah, 015h, 015h, 015h, 015h, 015h, 03fh, 015h, 03fh
    68 0000F159 151515153F153F      <1>
    69 0000F160 15153F3F3F15153F15- <1>     db  015h, 015h, 03fh, 03fh, 03fh, 015h, 015h, 03fh, 015h, 03fh, 03fh, 03fh, 015h, 03fh, 03fh, 03fh
    69 0000F169 3F3F3F153F3F3F      <1>
    70 0000F170 000000050505080808- <1>     db  000h, 000h, 000h, 005h, 005h, 005h, 008h, 008h, 008h, 00bh, 00bh, 00bh, 00eh, 00eh, 00eh, 011h
    70 0000F179 0B0B0B0E0E0E11      <1>
    71 0000F180 11111414141818181C- <1>     db  011h, 011h, 014h, 014h, 014h, 018h, 018h, 018h, 01ch, 01ch, 01ch, 020h, 020h, 020h, 024h, 024h
    71 0000F189 1C1C2020202424      <1>
    72 0000F190 242828282D2D2D3232- <1>     db  024h, 028h, 028h, 028h, 02dh, 02dh, 02dh, 032h, 032h, 032h, 038h, 038h, 038h, 03fh, 03fh, 03fh
    72 0000F199 323838383F3F3F      <1>
    73 0000F1A0 00003F10003F1F003F- <1>     db  000h, 000h, 03fh, 010h, 000h, 03fh, 01fh, 000h, 03fh, 02fh, 000h, 03fh, 03fh, 000h, 03fh, 03fh
    73 0000F1A9 2F003F3F003F3F      <1>
    74 0000F1B0 002F3F001F3F00103F- <1>     db  000h, 02fh, 03fh, 000h, 01fh, 03fh, 000h, 010h, 03fh, 000h, 000h, 03fh, 010h, 000h, 03fh, 01fh
    74 0000F1B9 00003F10003F1F      <1>
    75 0000F1C0 003F2F003F3F002F3F- <1>     db  000h, 03fh, 02fh, 000h, 03fh, 03fh, 000h, 02fh, 03fh, 000h, 01fh, 03fh, 000h, 010h, 03fh, 000h
    75 0000F1C9 001F3F00103F00      <1>
    76 0000F1D0 003F00003F10003F1F- <1>     db  000h, 03fh, 000h, 000h, 03fh, 010h, 000h, 03fh, 01fh, 000h, 03fh, 02fh, 000h, 03fh, 03fh, 000h
    76 0000F1D9 003F2F003F3F00      <1>
    77 0000F1E0 2F3F001F3F00103F1F- <1>     db  02fh, 03fh, 000h, 01fh, 03fh, 000h, 010h, 03fh, 01fh, 01fh, 03fh, 027h, 01fh, 03fh, 02fh, 01fh
    77 0000F1E9 1F3F271F3F2F1F      <1>
    78 0000F1F0 3F371F3F3F1F3F3F1F- <1>     db  03fh, 037h, 01fh, 03fh, 03fh, 01fh, 03fh, 03fh, 01fh, 037h, 03fh, 01fh, 02fh, 03fh, 01fh, 027h
    78 0000F1F9 373F1F2F3F1F27      <1>
    79 0000F200 3F1F1F3F271F3F2F1F- <1>     db  03fh, 01fh, 01fh, 03fh, 027h, 01fh, 03fh, 02fh, 01fh, 03fh, 037h, 01fh, 03fh, 03fh, 01fh, 037h
    79 0000F209 3F371F3F3F1F37      <1>
    80 0000F210 3F1F2F3F1F273F1F1F- <1>     db  03fh, 01fh, 02fh, 03fh, 01fh, 027h, 03fh, 01fh, 01fh, 03fh, 01fh, 01fh, 03fh, 027h, 01fh, 03fh
    80 0000F219 3F1F1F3F271F3F      <1>
    81 0000F220 2F1F3F371F3F3F1F37- <1>     db  02fh, 01fh, 03fh, 037h, 01fh, 03fh, 03fh, 01fh, 037h, 03fh, 01fh, 02fh, 03fh, 01fh, 027h, 03fh
    81 0000F229 3F1F2F3F1F273F      <1>
    82 0000F230 2D2D3F312D3F362D3F- <1>     db  02dh, 02dh, 03fh, 031h, 02dh, 03fh, 036h, 02dh, 03fh, 03ah, 02dh, 03fh, 03fh, 02dh, 03fh, 03fh
    82 0000F239 3A2D3F3F2D3F3F      <1>
    83 0000F240 2D3A3F2D363F2D313F- <1>     db  02dh, 03ah, 03fh, 02dh, 036h, 03fh, 02dh, 031h, 03fh, 02dh, 02dh, 03fh, 031h, 02dh, 03fh, 036h
    83 0000F249 2D2D3F312D3F36      <1>
    84 0000F250 2D3F3A2D3F3F2D3A3F- <1>     db  02dh, 03fh, 03ah, 02dh, 03fh, 03fh, 02dh, 03ah, 03fh, 02dh, 036h, 03fh, 02dh, 031h, 03fh, 02dh
    84 0000F259 2D363F2D313F2D      <1>
    85 0000F260 2D3F2D2D3F312D3F36- <1>     db  02dh, 03fh, 02dh, 02dh, 03fh, 031h, 02dh, 03fh, 036h, 02dh, 03fh, 03ah, 02dh, 03fh, 03fh, 02dh
    85 0000F269 2D3F3A2D3F3F2D      <1>
    86 0000F270 3A3F2D363F2D313F00- <1>     db  03ah, 03fh, 02dh, 036h, 03fh, 02dh, 031h, 03fh, 000h, 000h, 01ch, 007h, 000h, 01ch, 00eh, 000h
    86 0000F279 001C07001C0E00      <1>
    87 0000F280 1C15001C1C001C1C00- <1>     db  01ch, 015h, 000h, 01ch, 01ch, 000h, 01ch, 01ch, 000h, 015h, 01ch, 000h, 00eh, 01ch, 000h, 007h
    87 0000F289 151C000E1C0007      <1>
    88 0000F290 1C00001C07001C0E00- <1>     db  01ch, 000h, 000h, 01ch, 007h, 000h, 01ch, 00eh, 000h, 01ch, 015h, 000h, 01ch, 01ch, 000h, 015h
    88 0000F299 1C15001C1C0015      <1>
    89 0000F2A0 1C000E1C00071C0000- <1>     db  01ch, 000h, 00eh, 01ch, 000h, 007h, 01ch, 000h, 000h, 01ch, 000h, 000h, 01ch, 007h, 000h, 01ch
    89 0000F2A9 1C00001C07001C      <1>
    90 0000F2B0 0E001C15001C1C0015- <1>     db  00eh, 000h, 01ch, 015h, 000h, 01ch, 01ch, 000h, 015h, 01ch, 000h, 00eh, 01ch, 000h, 007h, 01ch
    90 0000F2B9 1C000E1C00071C      <1>
    91 0000F2C0 0E0E1C110E1C150E1C- <1>     db  00eh, 00eh, 01ch, 011h, 00eh, 01ch, 015h, 00eh, 01ch, 018h, 00eh, 01ch, 01ch, 00eh, 01ch, 01ch
    91 0000F2C9 180E1C1C0E1C1C      <1>
    92 0000F2D0 0E181C0E151C0E111C- <1>     db  00eh, 018h, 01ch, 00eh, 015h, 01ch, 00eh, 011h, 01ch, 00eh, 00eh, 01ch, 011h, 00eh, 01ch, 015h
    92 0000F2D9 0E0E1C110E1C15      <1>
    93 0000F2E0 0E1C180E1C1C0E181C- <1>     db  00eh, 01ch, 018h, 00eh, 01ch, 01ch, 00eh, 018h, 01ch, 00eh, 015h, 01ch, 00eh, 011h, 01ch, 00eh
    93 0000F2E9 0E151C0E111C0E      <1>
    94 0000F2F0 0E1C0E0E1C110E1C15- <1>     db  00eh, 01ch, 00eh, 00eh, 01ch, 011h, 00eh, 01ch, 015h, 00eh, 01ch, 018h, 00eh, 01ch, 01ch, 00eh
    94 0000F2F9 0E1C180E1C1C0E      <1>
    95 0000F300 181C0E151C0E111C14- <1>     db  018h, 01ch, 00eh, 015h, 01ch, 00eh, 011h, 01ch, 014h, 014h, 01ch, 016h, 014h, 01ch, 018h, 014h
    95 0000F309 141C16141C1814      <1>
    96 0000F310 1C1A141C1C141C1C14- <1>     db  01ch, 01ah, 014h, 01ch, 01ch, 014h, 01ch, 01ch, 014h, 01ah, 01ch, 014h, 018h, 01ch, 014h, 016h
    96 0000F319 1A1C14181C1416      <1>
    97 0000F320 1C14141C16141C1814- <1>     db  01ch, 014h, 014h, 01ch, 016h, 014h, 01ch, 018h, 014h, 01ch, 01ah, 014h, 01ch, 01ch, 014h, 01ah
    97 0000F329 1C1A141C1C141A      <1>
    98 0000F330 1C14181C14161C1414- <1>     db  01ch, 014h, 018h, 01ch, 014h, 016h, 01ch, 014h, 014h, 01ch, 014h, 014h, 01ch, 016h, 014h, 01ch
    98 0000F339 1C14141C16141C      <1>
    99 0000F340 18141C1A141C1C141A- <1>     db  018h, 014h, 01ch, 01ah, 014h, 01ch, 01ch, 014h, 01ah, 01ch, 014h, 018h, 01ch, 014h, 016h, 01ch
    99 0000F349 1C14181C14161C      <1>
   100 0000F350 000010040010080010- <1>     db  000h, 000h, 010h, 004h, 000h, 010h, 008h, 000h, 010h, 00ch, 000h, 010h, 010h, 000h, 010h, 010h
   100 0000F359 0C001010001010      <1>
   101 0000F360 000C10000810000410- <1>     db  000h, 00ch, 010h, 000h, 008h, 010h, 000h, 004h, 010h, 000h, 000h, 010h, 004h, 000h, 010h, 008h
   101 0000F369 00001004001008      <1>
   102 0000F370 00100C001010000C10- <1>     db  000h, 010h, 00ch, 000h, 010h, 010h, 000h, 00ch, 010h, 000h, 008h, 010h, 000h, 004h, 010h, 000h
   102 0000F379 00081000041000      <1>
   103 0000F380 001000001004001008- <1>     db  000h, 010h, 000h, 000h, 010h, 004h, 000h, 010h, 008h, 000h, 010h, 00ch, 000h, 010h, 010h, 000h
   103 0000F389 00100C00101000      <1>
   104 0000F390 0C1000081000041008- <1>     db  00ch, 010h, 000h, 008h, 010h, 000h, 004h, 010h, 008h, 008h, 010h, 00ah, 008h, 010h, 00ch, 008h
   104 0000F399 08100A08100C08      <1>
   105 0000F3A0 100E08101008101008- <1>     db  010h, 00eh, 008h, 010h, 010h, 008h, 010h, 010h, 008h, 00eh, 010h, 008h, 00ch, 010h, 008h, 00ah
   105 0000F3A9 0E10080C10080A      <1>
   106 0000F3B0 100808100A08100C08- <1>     db  010h, 008h, 008h, 010h, 00ah, 008h, 010h, 00ch, 008h, 010h, 00eh, 008h, 010h, 010h, 008h, 00eh
   106 0000F3B9 100E081010080E      <1>
   107 0000F3C0 10080C10080A100808- <1>     db  010h, 008h, 00ch, 010h, 008h, 00ah, 010h, 008h, 008h, 010h, 008h, 008h, 010h, 00ah, 008h, 010h
   107 0000F3C9 100808100A0810      <1>
   108 0000F3D0 0C08100E081010080E- <1>     db  00ch, 008h, 010h, 00eh, 008h, 010h, 010h, 008h, 00eh, 010h, 008h, 00ch, 010h, 008h, 00ah, 010h
   108 0000F3D9 10080C10080A10      <1>
   109 0000F3E0 0B0B100C0B100D0B10- <1>     db  00bh, 00bh, 010h, 00ch, 00bh, 010h, 00dh, 00bh, 010h, 00fh, 00bh, 010h, 010h, 00bh, 010h, 010h
   109 0000F3E9 0F0B10100B1010      <1>
   110 0000F3F0 0B0F100B0D100B0C10- <1>     db  00bh, 00fh, 010h, 00bh, 00dh, 010h, 00bh, 00ch, 010h, 00bh, 00bh, 010h, 00ch, 00bh, 010h, 00dh
   110 0000F3F9 0B0B100C0B100D      <1>
   111 0000F400 0B100F0B10100B0F10- <1>     db  00bh, 010h, 00fh, 00bh, 010h, 010h, 00bh, 00fh, 010h, 00bh, 00dh, 010h, 00bh, 00ch, 010h, 00bh
   111 0000F409 0B0D100B0C100B      <1>
   112 0000F410 0B100B0B100C0B100D- <1>     db  00bh, 010h, 00bh, 00bh, 010h, 00ch, 00bh, 010h, 00dh, 00bh, 010h, 00fh, 00bh, 010h, 010h, 00bh
   112 0000F419 0B100F0B10100B      <1>
   113 0000F420 0F100B0D100B0C1000- <1>     db  00fh, 010h, 00bh, 00dh, 010h, 00bh, 00ch, 010h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   113 0000F429 00000000000000      <1>
   114 0000F430 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   114 0000F439 00000000000000      <1>
   115                              <1> 
   116                              <1> 
   117                              <1> ; 04/07/2016
   118                              <1> ; FONT DATA
   119                              <1> 
   120                              <1> CRT_CHAR_GEN:
   121                              <1> vgafont8: 
   122 0000F440 00000000000000007E- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 07eh, 081h, 0a5h, 081h, 0bdh, 099h, 081h, 07eh
   122 0000F449 81A581BD99817E      <1>
   123 0000F450 7EFFDBFFC3E7FF7E6C- <1>     db  07eh, 0ffh, 0dbh, 0ffh, 0c3h, 0e7h, 0ffh, 07eh, 06ch, 0feh, 0feh, 0feh, 07ch, 038h, 010h, 000h
   123 0000F459 FEFEFE7C381000      <1>
   124 0000F460 10387CFE7C38100038- <1>     db  010h, 038h, 07ch, 0feh, 07ch, 038h, 010h, 000h, 038h, 07ch, 038h, 0feh, 0feh, 07ch, 038h, 07ch
   124 0000F469 7C38FEFE7C387C      <1>
   125 0000F470 1010387CFE7C387C00- <1>     db  010h, 010h, 038h, 07ch, 0feh, 07ch, 038h, 07ch, 000h, 000h, 018h, 03ch, 03ch, 018h, 000h, 000h
   125 0000F479 00183C3C180000      <1>
   126 0000F480 FFFFE7C3C3E7FFFF00- <1>     db  0ffh, 0ffh, 0e7h, 0c3h, 0c3h, 0e7h, 0ffh, 0ffh, 000h, 03ch, 066h, 042h, 042h, 066h, 03ch, 000h
   126 0000F489 3C664242663C00      <1>
   127 0000F490 FFC399BDBD99C3FF0F- <1>     db  0ffh, 0c3h, 099h, 0bdh, 0bdh, 099h, 0c3h, 0ffh, 00fh, 007h, 00fh, 07dh, 0cch, 0cch, 0cch, 078h
   127 0000F499 070F7DCCCCCC78      <1>
   128 0000F4A0 3C6666663C187E183F- <1>     db  03ch, 066h, 066h, 066h, 03ch, 018h, 07eh, 018h, 03fh, 033h, 03fh, 030h, 030h, 070h, 0f0h, 0e0h
   128 0000F4A9 333F303070F0E0      <1>
   129 0000F4B0 7F637F636367E6C099- <1>     db  07fh, 063h, 07fh, 063h, 063h, 067h, 0e6h, 0c0h, 099h, 05ah, 03ch, 0e7h, 0e7h, 03ch, 05ah, 099h
   129 0000F4B9 5A3CE7E73C5A99      <1>
   130 0000F4C0 80E0F8FEF8E0800002- <1>     db  080h, 0e0h, 0f8h, 0feh, 0f8h, 0e0h, 080h, 000h, 002h, 00eh, 03eh, 0feh, 03eh, 00eh, 002h, 000h
   130 0000F4C9 0E3EFE3E0E0200      <1>
   131 0000F4D0 183C7E18187E3C1866- <1>     db  018h, 03ch, 07eh, 018h, 018h, 07eh, 03ch, 018h, 066h, 066h, 066h, 066h, 066h, 000h, 066h, 000h
   131 0000F4D9 66666666006600      <1>
   132 0000F4E0 7FDBDB7B1B1B1B003E- <1>     db  07fh, 0dbh, 0dbh, 07bh, 01bh, 01bh, 01bh, 000h, 03eh, 063h, 038h, 06ch, 06ch, 038h, 0cch, 078h
   132 0000F4E9 63386C6C38CC78      <1>
   133 0000F4F0 000000007E7E7E0018- <1>     db  000h, 000h, 000h, 000h, 07eh, 07eh, 07eh, 000h, 018h, 03ch, 07eh, 018h, 07eh, 03ch, 018h, 0ffh
   133 0000F4F9 3C7E187E3C18FF      <1>
   134 0000F500 183C7E181818180018- <1>     db  018h, 03ch, 07eh, 018h, 018h, 018h, 018h, 000h, 018h, 018h, 018h, 018h, 07eh, 03ch, 018h, 000h
   134 0000F509 1818187E3C1800      <1>
   135 0000F510 00180CFE0C18000000- <1>     db  000h, 018h, 00ch, 0feh, 00ch, 018h, 000h, 000h, 000h, 030h, 060h, 0feh, 060h, 030h, 000h, 000h
   135 0000F519 3060FE60300000      <1>
   136 0000F520 0000C0C0C0FE000000- <1>     db  000h, 000h, 0c0h, 0c0h, 0c0h, 0feh, 000h, 000h, 000h, 024h, 066h, 0ffh, 066h, 024h, 000h, 000h
   136 0000F529 2466FF66240000      <1>
   137 0000F530 00183C7EFFFF000000- <1>     db  000h, 018h, 03ch, 07eh, 0ffh, 0ffh, 000h, 000h, 000h, 0ffh, 0ffh, 07eh, 03ch, 018h, 000h, 000h
   137 0000F539 FFFF7E3C180000      <1>
   138 0000F540 000000000000000030- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 030h, 078h, 078h, 030h, 030h, 000h, 030h, 000h
   138 0000F549 78783030003000      <1>
   139 0000F550 6C6C6C00000000006C- <1>     db  06ch, 06ch, 06ch, 000h, 000h, 000h, 000h, 000h, 06ch, 06ch, 0feh, 06ch, 0feh, 06ch, 06ch, 000h
   139 0000F559 6CFE6CFE6C6C00      <1>
   140 0000F560 307CC0780CF8300000- <1>     db  030h, 07ch, 0c0h, 078h, 00ch, 0f8h, 030h, 000h, 000h, 0c6h, 0cch, 018h, 030h, 066h, 0c6h, 000h
   140 0000F569 C6CC183066C600      <1>
   141 0000F570 386C3876DCCC760060- <1>     db  038h, 06ch, 038h, 076h, 0dch, 0cch, 076h, 000h, 060h, 060h, 0c0h, 000h, 000h, 000h, 000h, 000h
   141 0000F579 60C00000000000      <1>
   142 0000F580 183060606030180060- <1>     db  018h, 030h, 060h, 060h, 060h, 030h, 018h, 000h, 060h, 030h, 018h, 018h, 018h, 030h, 060h, 000h
   142 0000F589 30181818306000      <1>
   143 0000F590 00663CFF3C66000000- <1>     db  000h, 066h, 03ch, 0ffh, 03ch, 066h, 000h, 000h, 000h, 030h, 030h, 0fch, 030h, 030h, 000h, 000h
   143 0000F599 3030FC30300000      <1>
   144 0000F5A0 000000000030306000- <1>     db  000h, 000h, 000h, 000h, 000h, 030h, 030h, 060h, 000h, 000h, 000h, 0fch, 000h, 000h, 000h, 000h
   144 0000F5A9 0000FC00000000      <1>
   145 0000F5B0 000000000030300006- <1>     db  000h, 000h, 000h, 000h, 000h, 030h, 030h, 000h, 006h, 00ch, 018h, 030h, 060h, 0c0h, 080h, 000h
   145 0000F5B9 0C183060C08000      <1>
   146 0000F5C0 7CC6CEDEF6E67C0030- <1>     db  07ch, 0c6h, 0ceh, 0deh, 0f6h, 0e6h, 07ch, 000h, 030h, 070h, 030h, 030h, 030h, 030h, 0fch, 000h
   146 0000F5C9 7030303030FC00      <1>
   147 0000F5D0 78CC0C3860CCFC0078- <1>     db  078h, 0cch, 00ch, 038h, 060h, 0cch, 0fch, 000h, 078h, 0cch, 00ch, 038h, 00ch, 0cch, 078h, 000h
   147 0000F5D9 CC0C380CCC7800      <1>
   148 0000F5E0 1C3C6CCCFE0C1E00FC- <1>     db  01ch, 03ch, 06ch, 0cch, 0feh, 00ch, 01eh, 000h, 0fch, 0c0h, 0f8h, 00ch, 00ch, 0cch, 078h, 000h
   148 0000F5E9 C0F80C0CCC7800      <1>
   149 0000F5F0 3860C0F8CCCC7800FC- <1>     db  038h, 060h, 0c0h, 0f8h, 0cch, 0cch, 078h, 000h, 0fch, 0cch, 00ch, 018h, 030h, 030h, 030h, 000h
   149 0000F5F9 CC0C1830303000      <1>
   150 0000F600 78CCCC78CCCC780078- <1>     db  078h, 0cch, 0cch, 078h, 0cch, 0cch, 078h, 000h, 078h, 0cch, 0cch, 07ch, 00ch, 018h, 070h, 000h
   150 0000F609 CCCC7C0C187000      <1>
   151 0000F610 003030000030300000- <1>     db  000h, 030h, 030h, 000h, 000h, 030h, 030h, 000h, 000h, 030h, 030h, 000h, 000h, 030h, 030h, 060h
   151 0000F619 30300000303060      <1>
   152 0000F620 183060C06030180000- <1>     db  018h, 030h, 060h, 0c0h, 060h, 030h, 018h, 000h, 000h, 000h, 0fch, 000h, 000h, 0fch, 000h, 000h
   152 0000F629 00FC0000FC0000      <1>
   153 0000F630 6030180C1830600078- <1>     db  060h, 030h, 018h, 00ch, 018h, 030h, 060h, 000h, 078h, 0cch, 00ch, 018h, 030h, 000h, 030h, 000h
   153 0000F639 CC0C1830003000      <1>
   154 0000F640 7CC6DEDEDEC0780030- <1>     db  07ch, 0c6h, 0deh, 0deh, 0deh, 0c0h, 078h, 000h, 030h, 078h, 0cch, 0cch, 0fch, 0cch, 0cch, 000h
   154 0000F649 78CCCCFCCCCC00      <1>
   155 0000F650 FC66667C6666FC003C- <1>     db  0fch, 066h, 066h, 07ch, 066h, 066h, 0fch, 000h, 03ch, 066h, 0c0h, 0c0h, 0c0h, 066h, 03ch, 000h
   155 0000F659 66C0C0C0663C00      <1>
   156 0000F660 F86C6666666CF800FE- <1>     db  0f8h, 06ch, 066h, 066h, 066h, 06ch, 0f8h, 000h, 0feh, 062h, 068h, 078h, 068h, 062h, 0feh, 000h
   156 0000F669 6268786862FE00      <1>
   157 0000F670 FE6268786860F0003C- <1>     db  0feh, 062h, 068h, 078h, 068h, 060h, 0f0h, 000h, 03ch, 066h, 0c0h, 0c0h, 0ceh, 066h, 03eh, 000h
   157 0000F679 66C0C0CE663E00      <1>
   158 0000F680 CCCCCCFCCCCCCC0078- <1>     db  0cch, 0cch, 0cch, 0fch, 0cch, 0cch, 0cch, 000h, 078h, 030h, 030h, 030h, 030h, 030h, 078h, 000h
   158 0000F689 30303030307800      <1>
   159 0000F690 1E0C0C0CCCCC7800E6- <1>     db  01eh, 00ch, 00ch, 00ch, 0cch, 0cch, 078h, 000h, 0e6h, 066h, 06ch, 078h, 06ch, 066h, 0e6h, 000h
   159 0000F699 666C786C66E600      <1>
   160 0000F6A0 F06060606266FE00C6- <1>     db  0f0h, 060h, 060h, 060h, 062h, 066h, 0feh, 000h, 0c6h, 0eeh, 0feh, 0feh, 0d6h, 0c6h, 0c6h, 000h
   160 0000F6A9 EEFEFED6C6C600      <1>
   161 0000F6B0 C6E6F6DECEC6C60038- <1>     db  0c6h, 0e6h, 0f6h, 0deh, 0ceh, 0c6h, 0c6h, 000h, 038h, 06ch, 0c6h, 0c6h, 0c6h, 06ch, 038h, 000h
   161 0000F6B9 6CC6C6C66C3800      <1>
   162 0000F6C0 FC66667C6060F00078- <1>     db  0fch, 066h, 066h, 07ch, 060h, 060h, 0f0h, 000h, 078h, 0cch, 0cch, 0cch, 0dch, 078h, 01ch, 000h
   162 0000F6C9 CCCCCCDC781C00      <1>
   163 0000F6D0 FC66667C6C66E60078- <1>     db  0fch, 066h, 066h, 07ch, 06ch, 066h, 0e6h, 000h, 078h, 0cch, 0e0h, 070h, 01ch, 0cch, 078h, 000h
   163 0000F6D9 CCE0701CCC7800      <1>
   164 0000F6E0 FCB4303030307800CC- <1>     db  0fch, 0b4h, 030h, 030h, 030h, 030h, 078h, 000h, 0cch, 0cch, 0cch, 0cch, 0cch, 0cch, 0fch, 000h
   164 0000F6E9 CCCCCCCCCCFC00      <1>
   165 0000F6F0 CCCCCCCCCC783000C6- <1>     db  0cch, 0cch, 0cch, 0cch, 0cch, 078h, 030h, 000h, 0c6h, 0c6h, 0c6h, 0d6h, 0feh, 0eeh, 0c6h, 000h
   165 0000F6F9 C6C6D6FEEEC600      <1>
   166 0000F700 C6C66C38386CC600CC- <1>     db  0c6h, 0c6h, 06ch, 038h, 038h, 06ch, 0c6h, 000h, 0cch, 0cch, 0cch, 078h, 030h, 030h, 078h, 000h
   166 0000F709 CCCC7830307800      <1>
   167 0000F710 FEC68C183266FE0078- <1>     db  0feh, 0c6h, 08ch, 018h, 032h, 066h, 0feh, 000h, 078h, 060h, 060h, 060h, 060h, 060h, 078h, 000h
   167 0000F719 60606060607800      <1>
   168 0000F720 C06030180C06020078- <1>     db  0c0h, 060h, 030h, 018h, 00ch, 006h, 002h, 000h, 078h, 018h, 018h, 018h, 018h, 018h, 078h, 000h
   168 0000F729 18181818187800      <1>
   169 0000F730 10386CC60000000000- <1>     db  010h, 038h, 06ch, 0c6h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ffh
   169 0000F739 000000000000FF      <1>
   170 0000F740 303018000000000000- <1>     db  030h, 030h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 078h, 00ch, 07ch, 0cch, 076h, 000h
   170 0000F749 00780C7CCC7600      <1>
   171 0000F750 E060607C6666DC0000- <1>     db  0e0h, 060h, 060h, 07ch, 066h, 066h, 0dch, 000h, 000h, 000h, 078h, 0cch, 0c0h, 0cch, 078h, 000h
   171 0000F759 0078CCC0CC7800      <1>
   172 0000F760 1C0C0C7CCCCC760000- <1>     db  01ch, 00ch, 00ch, 07ch, 0cch, 0cch, 076h, 000h, 000h, 000h, 078h, 0cch, 0fch, 0c0h, 078h, 000h
   172 0000F769 0078CCFCC07800      <1>
   173 0000F770 386C60F06060F00000- <1>     db  038h, 06ch, 060h, 0f0h, 060h, 060h, 0f0h, 000h, 000h, 000h, 076h, 0cch, 0cch, 07ch, 00ch, 0f8h
   173 0000F779 0076CCCC7C0CF8      <1>
   174 0000F780 E0606C766666E60030- <1>     db  0e0h, 060h, 06ch, 076h, 066h, 066h, 0e6h, 000h, 030h, 000h, 070h, 030h, 030h, 030h, 078h, 000h
   174 0000F789 00703030307800      <1>
   175 0000F790 0C000C0C0CCCCC78E0- <1>     db  00ch, 000h, 00ch, 00ch, 00ch, 0cch, 0cch, 078h, 0e0h, 060h, 066h, 06ch, 078h, 06ch, 0e6h, 000h
   175 0000F799 60666C786CE600      <1>
   176 0000F7A0 703030303030780000- <1>     db  070h, 030h, 030h, 030h, 030h, 030h, 078h, 000h, 000h, 000h, 0cch, 0feh, 0feh, 0d6h, 0c6h, 000h
   176 0000F7A9 00CCFEFED6C600      <1>
   177 0000F7B0 0000F8CCCCCCCC0000- <1>     db  000h, 000h, 0f8h, 0cch, 0cch, 0cch, 0cch, 000h, 000h, 000h, 078h, 0cch, 0cch, 0cch, 078h, 000h
   177 0000F7B9 0078CCCCCC7800      <1>
   178 0000F7C0 0000DC66667C60F000- <1>     db  000h, 000h, 0dch, 066h, 066h, 07ch, 060h, 0f0h, 000h, 000h, 076h, 0cch, 0cch, 07ch, 00ch, 01eh
   178 0000F7C9 0076CCCC7C0C1E      <1>
   179 0000F7D0 0000DC766660F00000- <1>     db  000h, 000h, 0dch, 076h, 066h, 060h, 0f0h, 000h, 000h, 000h, 07ch, 0c0h, 078h, 00ch, 0f8h, 000h
   179 0000F7D9 007CC0780CF800      <1>
   180 0000F7E0 10307C303034180000- <1>     db  010h, 030h, 07ch, 030h, 030h, 034h, 018h, 000h, 000h, 000h, 0cch, 0cch, 0cch, 0cch, 076h, 000h
   180 0000F7E9 00CCCCCCCC7600      <1>
   181 0000F7F0 0000CCCCCC78300000- <1>     db  000h, 000h, 0cch, 0cch, 0cch, 078h, 030h, 000h, 000h, 000h, 0c6h, 0d6h, 0feh, 0feh, 06ch, 000h
   181 0000F7F9 00C6D6FEFE6C00      <1>
   182 0000F800 0000C66C386CC60000- <1>     db  000h, 000h, 0c6h, 06ch, 038h, 06ch, 0c6h, 000h, 000h, 000h, 0cch, 0cch, 0cch, 07ch, 00ch, 0f8h
   182 0000F809 00CCCCCC7C0CF8      <1>
   183 0000F810 0000FC983064FC001C- <1>     db  000h, 000h, 0fch, 098h, 030h, 064h, 0fch, 000h, 01ch, 030h, 030h, 0e0h, 030h, 030h, 01ch, 000h
   183 0000F819 3030E030301C00      <1>
   184 0000F820 1818180018181800E0- <1>     db  018h, 018h, 018h, 000h, 018h, 018h, 018h, 000h, 0e0h, 030h, 030h, 01ch, 030h, 030h, 0e0h, 000h
   184 0000F829 30301C3030E000      <1>
   185 0000F830 76DC00000000000000- <1>     db  076h, 0dch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 010h, 038h, 06ch, 0c6h, 0c6h, 0feh, 000h
   185 0000F839 10386CC6C6FE00      <1>
   186 0000F840 78CCC0CC78180C7800- <1>     db  078h, 0cch, 0c0h, 0cch, 078h, 018h, 00ch, 078h, 000h, 0cch, 000h, 0cch, 0cch, 0cch, 07eh, 000h
   186 0000F849 CC00CCCCCC7E00      <1>
   187 0000F850 1C0078CCFCC078007E- <1>     db  01ch, 000h, 078h, 0cch, 0fch, 0c0h, 078h, 000h, 07eh, 0c3h, 03ch, 006h, 03eh, 066h, 03fh, 000h
   187 0000F859 C33C063E663F00      <1>
   188 0000F860 CC00780C7CCC7E00E0- <1>     db  0cch, 000h, 078h, 00ch, 07ch, 0cch, 07eh, 000h, 0e0h, 000h, 078h, 00ch, 07ch, 0cch, 07eh, 000h
   188 0000F869 00780C7CCC7E00      <1>
   189 0000F870 3030780C7CCC7E0000- <1>     db  030h, 030h, 078h, 00ch, 07ch, 0cch, 07eh, 000h, 000h, 000h, 078h, 0c0h, 0c0h, 078h, 00ch, 038h
   189 0000F879 0078C0C0780C38      <1>
   190 0000F880 7EC33C667E603C00CC- <1>     db  07eh, 0c3h, 03ch, 066h, 07eh, 060h, 03ch, 000h, 0cch, 000h, 078h, 0cch, 0fch, 0c0h, 078h, 000h
   190 0000F889 0078CCFCC07800      <1>
   191 0000F890 E00078CCFCC07800CC- <1>     db  0e0h, 000h, 078h, 0cch, 0fch, 0c0h, 078h, 000h, 0cch, 000h, 070h, 030h, 030h, 030h, 078h, 000h
   191 0000F899 00703030307800      <1>
   192 0000F8A0 7CC6381818183C00E0- <1>     db  07ch, 0c6h, 038h, 018h, 018h, 018h, 03ch, 000h, 0e0h, 000h, 070h, 030h, 030h, 030h, 078h, 000h
   192 0000F8A9 00703030307800      <1>
   193 0000F8B0 C6386CC6FEC6C60030- <1>     db  0c6h, 038h, 06ch, 0c6h, 0feh, 0c6h, 0c6h, 000h, 030h, 030h, 000h, 078h, 0cch, 0fch, 0cch, 000h
   193 0000F8B9 300078CCFCCC00      <1>
   194 0000F8C0 1C00FC607860FC0000- <1>     db  01ch, 000h, 0fch, 060h, 078h, 060h, 0fch, 000h, 000h, 000h, 07fh, 00ch, 07fh, 0cch, 07fh, 000h
   194 0000F8C9 007F0C7FCC7F00      <1>
   195 0000F8D0 3E6CCCFECCCCCE0078- <1>     db  03eh, 06ch, 0cch, 0feh, 0cch, 0cch, 0ceh, 000h, 078h, 0cch, 000h, 078h, 0cch, 0cch, 078h, 000h
   195 0000F8D9 CC0078CCCC7800      <1>
   196 0000F8E0 00CC0078CCCC780000- <1>     db  000h, 0cch, 000h, 078h, 0cch, 0cch, 078h, 000h, 000h, 0e0h, 000h, 078h, 0cch, 0cch, 078h, 000h
   196 0000F8E9 E00078CCCC7800      <1>
   197 0000F8F0 78CC00CCCCCC7E0000- <1>     db  078h, 0cch, 000h, 0cch, 0cch, 0cch, 07eh, 000h, 000h, 0e0h, 000h, 0cch, 0cch, 0cch, 07eh, 000h
   197 0000F8F9 E000CCCCCC7E00      <1>
   198 0000F900 00CC00CCCC7C0CF8C3- <1>     db  000h, 0cch, 000h, 0cch, 0cch, 07ch, 00ch, 0f8h, 0c3h, 018h, 03ch, 066h, 066h, 03ch, 018h, 000h
   198 0000F909 183C66663C1800      <1>
   199 0000F910 CC00CCCCCCCC780018- <1>     db  0cch, 000h, 0cch, 0cch, 0cch, 0cch, 078h, 000h, 018h, 018h, 07eh, 0c0h, 0c0h, 07eh, 018h, 018h
   199 0000F919 187EC0C07E1818      <1>
   200 0000F920 386C64F060E6FC00CC- <1>     db  038h, 06ch, 064h, 0f0h, 060h, 0e6h, 0fch, 000h, 0cch, 0cch, 078h, 0fch, 030h, 0fch, 030h, 030h
   200 0000F929 CC78FC30FC3030      <1>
   201 0000F930 F8CCCCFAC6CFC6C70E- <1>     db  0f8h, 0cch, 0cch, 0fah, 0c6h, 0cfh, 0c6h, 0c7h, 00eh, 01bh, 018h, 03ch, 018h, 018h, 0d8h, 070h
   201 0000F939 1B183C1818D870      <1>
   202 0000F940 1C00780C7CCC7E0038- <1>     db  01ch, 000h, 078h, 00ch, 07ch, 0cch, 07eh, 000h, 038h, 000h, 070h, 030h, 030h, 030h, 078h, 000h
   202 0000F949 00703030307800      <1>
   203 0000F950 001C0078CCCC780000- <1>     db  000h, 01ch, 000h, 078h, 0cch, 0cch, 078h, 000h, 000h, 01ch, 000h, 0cch, 0cch, 0cch, 07eh, 000h
   203 0000F959 1C00CCCCCC7E00      <1>
   204 0000F960 00F800F8CCCCCC00FC- <1>     db  000h, 0f8h, 000h, 0f8h, 0cch, 0cch, 0cch, 000h, 0fch, 000h, 0cch, 0ech, 0fch, 0dch, 0cch, 000h
   204 0000F969 00CCECFCDCCC00      <1>
   205 0000F970 3C6C6C3E007E000038- <1>     db  03ch, 06ch, 06ch, 03eh, 000h, 07eh, 000h, 000h, 038h, 06ch, 06ch, 038h, 000h, 07ch, 000h, 000h
   205 0000F979 6C6C38007C0000      <1>
   206 0000F980 30003060C0CC780000- <1>     db  030h, 000h, 030h, 060h, 0c0h, 0cch, 078h, 000h, 000h, 000h, 000h, 0fch, 0c0h, 0c0h, 000h, 000h
   206 0000F989 0000FCC0C00000      <1>
   207 0000F990 000000FC0C0C0000C3- <1>     db  000h, 000h, 000h, 0fch, 00ch, 00ch, 000h, 000h, 0c3h, 0c6h, 0cch, 0deh, 033h, 066h, 0cch, 00fh
   207 0000F999 C6CCDE3366CC0F      <1>
   208 0000F9A0 C3C6CCDB376FCF0318- <1>     db  0c3h, 0c6h, 0cch, 0dbh, 037h, 06fh, 0cfh, 003h, 018h, 018h, 000h, 018h, 018h, 018h, 018h, 000h
   208 0000F9A9 18001818181800      <1>
   209 0000F9B0 003366CC6633000000- <1>     db  000h, 033h, 066h, 0cch, 066h, 033h, 000h, 000h, 000h, 0cch, 066h, 033h, 066h, 0cch, 000h, 000h
   209 0000F9B9 CC663366CC0000      <1>
   210 0000F9C0 228822882288228855- <1>     db  022h, 088h, 022h, 088h, 022h, 088h, 022h, 088h, 055h, 0aah, 055h, 0aah, 055h, 0aah, 055h, 0aah
   210 0000F9C9 AA55AA55AA55AA      <1>
   211 0000F9D0 DB77DBEEDB77DBEE18- <1>     db  0dbh, 077h, 0dbh, 0eeh, 0dbh, 077h, 0dbh, 0eeh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
   211 0000F9D9 18181818181818      <1>
   212 0000F9E0 18181818F818181818- <1>     db  018h, 018h, 018h, 018h, 0f8h, 018h, 018h, 018h, 018h, 018h, 0f8h, 018h, 0f8h, 018h, 018h, 018h
   212 0000F9E9 18F818F8181818      <1>
   213 0000F9F0 36363636F636363600- <1>     db  036h, 036h, 036h, 036h, 0f6h, 036h, 036h, 036h, 000h, 000h, 000h, 000h, 0feh, 036h, 036h, 036h
   213 0000F9F9 000000FE363636      <1>
   214 0000FA00 0000F818F818181836- <1>     db  000h, 000h, 0f8h, 018h, 0f8h, 018h, 018h, 018h, 036h, 036h, 0f6h, 006h, 0f6h, 036h, 036h, 036h
   214 0000FA09 36F606F6363636      <1>
   215 0000FA10 363636363636363600- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 000h, 000h, 0feh, 006h, 0f6h, 036h, 036h, 036h
   215 0000FA19 00FE06F6363636      <1>
   216 0000FA20 3636F606FE00000036- <1>     db  036h, 036h, 0f6h, 006h, 0feh, 000h, 000h, 000h, 036h, 036h, 036h, 036h, 0feh, 000h, 000h, 000h
   216 0000FA29 363636FE000000      <1>
   217 0000FA30 1818F818F800000000- <1>     db  018h, 018h, 0f8h, 018h, 0f8h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0f8h, 018h, 018h, 018h
   217 0000FA39 000000F8181818      <1>
   218 0000FA40 181818181F00000018- <1>     db  018h, 018h, 018h, 018h, 01fh, 000h, 000h, 000h, 018h, 018h, 018h, 018h, 0ffh, 000h, 000h, 000h
   218 0000FA49 181818FF000000      <1>
   219 0000FA50 00000000FF18181818- <1>     db  000h, 000h, 000h, 000h, 0ffh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 01fh, 018h, 018h, 018h
   219 0000FA59 1818181F181818      <1>
   220 0000FA60 00000000FF00000018- <1>     db  000h, 000h, 000h, 000h, 0ffh, 000h, 000h, 000h, 018h, 018h, 018h, 018h, 0ffh, 018h, 018h, 018h
   220 0000FA69 181818FF181818      <1>
   221 0000FA70 18181F181F18181836- <1>     db  018h, 018h, 01fh, 018h, 01fh, 018h, 018h, 018h, 036h, 036h, 036h, 036h, 037h, 036h, 036h, 036h
   221 0000FA79 36363637363636      <1>
   222 0000FA80 363637303F00000000- <1>     db  036h, 036h, 037h, 030h, 03fh, 000h, 000h, 000h, 000h, 000h, 03fh, 030h, 037h, 036h, 036h, 036h
   222 0000FA89 003F3037363636      <1>
   223 0000FA90 3636F700FF00000000- <1>     db  036h, 036h, 0f7h, 000h, 0ffh, 000h, 000h, 000h, 000h, 000h, 0ffh, 000h, 0f7h, 036h, 036h, 036h
   223 0000FA99 00FF00F7363636      <1>
   224 0000FAA0 363637303736363600- <1>     db  036h, 036h, 037h, 030h, 037h, 036h, 036h, 036h, 000h, 000h, 0ffh, 000h, 0ffh, 000h, 000h, 000h
   224 0000FAA9 00FF00FF000000      <1>
   225 0000FAB0 3636F700F736363618- <1>     db  036h, 036h, 0f7h, 000h, 0f7h, 036h, 036h, 036h, 018h, 018h, 0ffh, 000h, 0ffh, 000h, 000h, 000h
   225 0000FAB9 18FF00FF000000      <1>
   226 0000FAC0 36363636FF00000000- <1>     db  036h, 036h, 036h, 036h, 0ffh, 000h, 000h, 000h, 000h, 000h, 0ffh, 000h, 0ffh, 018h, 018h, 018h
   226 0000FAC9 00FF00FF181818      <1>
   227 0000FAD0 00000000FF36363636- <1>     db  000h, 000h, 000h, 000h, 0ffh, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 03fh, 000h, 000h, 000h
   227 0000FAD9 3636363F000000      <1>
   228 0000FAE0 18181F181F00000000- <1>     db  018h, 018h, 01fh, 018h, 01fh, 000h, 000h, 000h, 000h, 000h, 01fh, 018h, 01fh, 018h, 018h, 018h
   228 0000FAE9 001F181F181818      <1>
   229 0000FAF0 000000003F36363636- <1>     db  000h, 000h, 000h, 000h, 03fh, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 0ffh, 036h, 036h, 036h
   229 0000FAF9 363636FF363636      <1>
   230 0000FB00 1818FF18FF18181818- <1>     db  018h, 018h, 0ffh, 018h, 0ffh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 0f8h, 000h, 000h, 000h
   230 0000FB09 181818F8000000      <1>
   231 0000FB10 000000001F181818FF- <1>     db  000h, 000h, 000h, 000h, 01fh, 018h, 018h, 018h, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh
   231 0000FB19 FFFFFFFFFFFFFF      <1>
   232 0000FB20 00000000FFFFFFFFF0- <1>     db  000h, 000h, 000h, 000h, 0ffh, 0ffh, 0ffh, 0ffh, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h
   232 0000FB29 F0F0F0F0F0F0F0      <1>
   233 0000FB30 0F0F0F0F0F0F0F0FFF- <1>     db  00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 0ffh, 0ffh, 0ffh, 0ffh, 000h, 000h, 000h, 000h
   233 0000FB39 FFFFFF00000000      <1>
   234 0000FB40 000076DCC8DC760000- <1>     db  000h, 000h, 076h, 0dch, 0c8h, 0dch, 076h, 000h, 000h, 078h, 0cch, 0f8h, 0cch, 0f8h, 0c0h, 0c0h
   234 0000FB49 78CCF8CCF8C0C0      <1>
   235 0000FB50 00FCCCC0C0C0C00000- <1>     db  000h, 0fch, 0cch, 0c0h, 0c0h, 0c0h, 0c0h, 000h, 000h, 0feh, 06ch, 06ch, 06ch, 06ch, 06ch, 000h
   235 0000FB59 FE6C6C6C6C6C00      <1>
   236 0000FB60 FCCC603060CCFC0000- <1>     db  0fch, 0cch, 060h, 030h, 060h, 0cch, 0fch, 000h, 000h, 000h, 07eh, 0d8h, 0d8h, 0d8h, 070h, 000h
   236 0000FB69 007ED8D8D87000      <1>
   237 0000FB70 00666666667C60C000- <1>     db  000h, 066h, 066h, 066h, 066h, 07ch, 060h, 0c0h, 000h, 076h, 0dch, 018h, 018h, 018h, 018h, 000h
   237 0000FB79 76DC1818181800      <1>
   238 0000FB80 FC3078CCCC7830FC38- <1>     db  0fch, 030h, 078h, 0cch, 0cch, 078h, 030h, 0fch, 038h, 06ch, 0c6h, 0feh, 0c6h, 06ch, 038h, 000h
   238 0000FB89 6CC6FEC66C3800      <1>
   239 0000FB90 386CC6C66C6CEE001C- <1>     db  038h, 06ch, 0c6h, 0c6h, 06ch, 06ch, 0eeh, 000h, 01ch, 030h, 018h, 07ch, 0cch, 0cch, 078h, 000h
   239 0000FB99 30187CCCCC7800      <1>
   240 0000FBA0 00007EDBDB7E000006- <1>     db  000h, 000h, 07eh, 0dbh, 0dbh, 07eh, 000h, 000h, 006h, 00ch, 07eh, 0dbh, 0dbh, 07eh, 060h, 0c0h
   240 0000FBA9 0C7EDBDB7E60C0      <1>
   241 0000FBB0 3860C0F8C060380078- <1>     db  038h, 060h, 0c0h, 0f8h, 0c0h, 060h, 038h, 000h, 078h, 0cch, 0cch, 0cch, 0cch, 0cch, 0cch, 000h
   241 0000FBB9 CCCCCCCCCCCC00      <1>
   242 0000FBC0 00FC00FC00FC000030- <1>     db  000h, 0fch, 000h, 0fch, 000h, 0fch, 000h, 000h, 030h, 030h, 0fch, 030h, 030h, 000h, 0fch, 000h
   242 0000FBC9 30FC303000FC00      <1>
   243 0000FBD0 603018306000FC0018- <1>     db  060h, 030h, 018h, 030h, 060h, 000h, 0fch, 000h, 018h, 030h, 060h, 030h, 018h, 000h, 0fch, 000h
   243 0000FBD9 3060301800FC00      <1>
   244 0000FBE0 0E1B1B181818181818- <1>     db  00eh, 01bh, 01bh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 0d8h, 0d8h, 070h
   244 0000FBE9 18181818D8D870      <1>
   245 0000FBF0 303000FC0030300000- <1>     db  030h, 030h, 000h, 0fch, 000h, 030h, 030h, 000h, 000h, 076h, 0dch, 000h, 076h, 0dch, 000h, 000h
   245 0000FBF9 76DC0076DC0000      <1>
   246 0000FC00 386C6C380000000000- <1>     db  038h, 06ch, 06ch, 038h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h, 000h, 000h, 000h
   246 0000FC09 00001818000000      <1>
   247 0000FC10 00000000180000000F- <1>     db  000h, 000h, 000h, 000h, 018h, 000h, 000h, 000h, 00fh, 00ch, 00ch, 00ch, 0ech, 06ch, 03ch, 01ch
   247 0000FC19 0C0C0CEC6C3C1C      <1>
   248 0000FC20 786C6C6C6C00000070- <1>     db  078h, 06ch, 06ch, 06ch, 06ch, 000h, 000h, 000h, 070h, 018h, 030h, 060h, 078h, 000h, 000h, 000h
   248 0000FC29 18306078000000      <1>
   249 0000FC30 00003C3C3C3C000000- <1>     db  000h, 000h, 03ch, 03ch, 03ch, 03ch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   249 0000FC39 00000000000000      <1>
   250                              <1> vgafont14:
   251 0000FC40 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   251 0000FC49 00000000000000      <1>
   252 0000FC50 7E81A58181BD99817E- <1>     db  07eh, 081h, 0a5h, 081h, 081h, 0bdh, 099h, 081h, 07eh, 000h, 000h, 000h, 000h, 000h, 07eh, 0ffh
   252 0000FC59 00000000007EFF      <1>
   253 0000FC60 DBFFFFC3E7FF7E0000- <1>     db  0dbh, 0ffh, 0ffh, 0c3h, 0e7h, 0ffh, 07eh, 000h, 000h, 000h, 000h, 000h, 000h, 06ch, 0feh, 0feh
   253 0000FC69 000000006CFEFE      <1>
   254 0000FC70 FEFE7C381000000000- <1>     db  0feh, 0feh, 07ch, 038h, 010h, 000h, 000h, 000h, 000h, 000h, 000h, 010h, 038h, 07ch, 0feh, 07ch
   254 0000FC79 000010387CFE7C      <1>
   255 0000FC80 381000000000000018- <1>     db  038h, 010h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 03ch, 03ch, 0e7h, 0e7h, 0e7h, 018h, 018h
   255 0000FC89 3C3CE7E7E71818      <1>
   256 0000FC90 3C0000000000183C7E- <1>     db  03ch, 000h, 000h, 000h, 000h, 000h, 018h, 03ch, 07eh, 0ffh, 0ffh, 07eh, 018h, 018h, 03ch, 000h
   256 0000FC99 FFFF7E18183C00      <1>
   257 0000FCA0 00000000000000183C- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 03ch, 03ch, 018h, 000h, 000h, 000h, 000h, 000h
   257 0000FCA9 3C180000000000      <1>
   258 0000FCB0 FFFFFFFFFFE7C3C3E7- <1>     db  0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0e7h, 0c3h, 0c3h, 0e7h, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 000h, 000h
   258 0000FCB9 FFFFFFFFFF0000      <1>
   259 0000FCC0 00003C664242663C00- <1>     db  000h, 000h, 03ch, 066h, 042h, 042h, 066h, 03ch, 000h, 000h, 000h, 000h, 0ffh, 0ffh, 0ffh, 0ffh
   259 0000FCC9 000000FFFFFFFF      <1>
   260 0000FCD0 C399BDBD99C3FFFFFF- <1>     db  0c3h, 099h, 0bdh, 0bdh, 099h, 0c3h, 0ffh, 0ffh, 0ffh, 0ffh, 000h, 000h, 01eh, 00eh, 01ah, 032h
   260 0000FCD9 FF00001E0E1A32      <1>
   261 0000FCE0 78CCCCCC7800000000- <1>     db  078h, 0cch, 0cch, 0cch, 078h, 000h, 000h, 000h, 000h, 000h, 03ch, 066h, 066h, 066h, 03ch, 018h
   261 0000FCE9 003C6666663C18      <1>
   262 0000FCF0 7E181800000000003F- <1>     db  07eh, 018h, 018h, 000h, 000h, 000h, 000h, 000h, 03fh, 033h, 03fh, 030h, 030h, 030h, 070h, 0f0h
   262 0000FCF9 333F30303070F0      <1>
   263 0000FD00 E000000000007F637F- <1>     db  0e0h, 000h, 000h, 000h, 000h, 000h, 07fh, 063h, 07fh, 063h, 063h, 063h, 067h, 0e7h, 0e6h, 0c0h
   263 0000FD09 63636367E7E6C0      <1>
   264 0000FD10 000000001818DB3CE7- <1>     db  000h, 000h, 000h, 000h, 018h, 018h, 0dbh, 03ch, 0e7h, 03ch, 0dbh, 018h, 018h, 000h, 000h, 000h
   264 0000FD19 3CDB1818000000      <1>
   265 0000FD20 000080C0E0F8FEF8E0- <1>     db  000h, 000h, 080h, 0c0h, 0e0h, 0f8h, 0feh, 0f8h, 0e0h, 0c0h, 080h, 000h, 000h, 000h, 000h, 000h
   265 0000FD29 C0800000000000      <1>
   266 0000FD30 02060E3EFE3E0E0602- <1>     db  002h, 006h, 00eh, 03eh, 0feh, 03eh, 00eh, 006h, 002h, 000h, 000h, 000h, 000h, 000h, 018h, 03ch
   266 0000FD39 0000000000183C      <1>
   267 0000FD40 7E1818187E3C180000- <1>     db  07eh, 018h, 018h, 018h, 07eh, 03ch, 018h, 000h, 000h, 000h, 000h, 000h, 066h, 066h, 066h, 066h
   267 0000FD49 00000066666666      <1>
   268 0000FD50 666600666600000000- <1>     db  066h, 066h, 000h, 066h, 066h, 000h, 000h, 000h, 000h, 000h, 07fh, 0dbh, 0dbh, 0dbh, 07bh, 01bh
   268 0000FD59 007FDBDBDB7B1B      <1>
   269 0000FD60 1B1B1B000000007CC6- <1>     db  01bh, 01bh, 01bh, 000h, 000h, 000h, 000h, 07ch, 0c6h, 060h, 038h, 06ch, 0c6h, 0c6h, 06ch, 038h
   269 0000FD69 60386CC6C66C38      <1>
   270 0000FD70 0CC67C000000000000- <1>     db  00ch, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0feh, 0feh, 0feh, 000h
   270 0000FD79 000000FEFEFE00      <1>
   271 0000FD80 00000000183C7E1818- <1>     db  000h, 000h, 000h, 000h, 018h, 03ch, 07eh, 018h, 018h, 018h, 07eh, 03ch, 018h, 07eh, 000h, 000h
   271 0000FD89 187E3C187E0000      <1>
   272 0000FD90 0000183C7E18181818- <1>     db  000h, 000h, 018h, 03ch, 07eh, 018h, 018h, 018h, 018h, 018h, 018h, 000h, 000h, 000h, 000h, 000h
   272 0000FD99 18180000000000      <1>
   273 0000FDA0 1818181818187E3C18- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 07eh, 03ch, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   273 0000FDA9 00000000000000      <1>
   274 0000FDB0 180CFE0C1800000000- <1>     db  018h, 00ch, 0feh, 00ch, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 030h, 060h
   274 0000FDB9 00000000003060      <1>
   275 0000FDC0 FE6030000000000000- <1>     db  0feh, 060h, 030h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0c0h, 0c0h, 0c0h
   275 0000FDC9 00000000C0C0C0      <1>
   276 0000FDD0 FE0000000000000000- <1>     db  0feh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 028h, 06ch, 0feh, 06ch, 028h, 000h
   276 0000FDD9 00286CFE6C2800      <1>
   277 0000FDE0 000000000000001038- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 010h, 038h, 038h, 07ch, 07ch, 0feh, 0feh, 000h, 000h
   277 0000FDE9 387C7CFEFE0000      <1>
   278 0000FDF0 0000000000FEFE7C7C- <1>     db  000h, 000h, 000h, 000h, 000h, 0feh, 0feh, 07ch, 07ch, 038h, 038h, 010h, 000h, 000h, 000h, 000h
   278 0000FDF9 38381000000000      <1>
   279 0000FE00 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   279 0000FE09 00000000000000      <1>
   280 0000FE10 183C3C3C1818001818- <1>     db  018h, 03ch, 03ch, 03ch, 018h, 018h, 000h, 018h, 018h, 000h, 000h, 000h, 000h, 066h, 066h, 066h
   280 0000FE19 00000000666666      <1>
   281 0000FE20 240000000000000000- <1>     db  024h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 06ch, 06ch, 0feh, 06ch
   281 0000FE29 0000006C6CFE6C      <1>
   282 0000FE30 6C6CFE6C6C00000018- <1>     db  06ch, 06ch, 0feh, 06ch, 06ch, 000h, 000h, 000h, 018h, 018h, 07ch, 0c6h, 0c2h, 0c0h, 07ch, 006h
   282 0000FE39 187CC6C2C07C06      <1>
   283 0000FE40 86C67C181800000000- <1>     db  086h, 0c6h, 07ch, 018h, 018h, 000h, 000h, 000h, 000h, 000h, 0c2h, 0c6h, 00ch, 018h, 030h, 066h
   283 0000FE49 00C2C60C183066      <1>
   284 0000FE50 C60000000000386C6C- <1>     db  0c6h, 000h, 000h, 000h, 000h, 000h, 038h, 06ch, 06ch, 038h, 076h, 0dch, 0cch, 0cch, 076h, 000h
   284 0000FE59 3876DCCCCC7600      <1>
   285 0000FE60 000000303030600000- <1>     db  000h, 000h, 000h, 030h, 030h, 030h, 060h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   285 0000FE69 00000000000000      <1>
   286 0000FE70 00000C183030303030- <1>     db  000h, 000h, 00ch, 018h, 030h, 030h, 030h, 030h, 030h, 018h, 00ch, 000h, 000h, 000h, 000h, 000h
   286 0000FE79 180C0000000000      <1>
   287 0000FE80 30180C0C0C0C0C1830- <1>     db  030h, 018h, 00ch, 00ch, 00ch, 00ch, 00ch, 018h, 030h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   287 0000FE89 00000000000000      <1>
   288 0000FE90 663CFF3C6600000000- <1>     db  066h, 03ch, 0ffh, 03ch, 066h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h
   288 0000FE99 00000000001818      <1>
   289 0000FEA0 7E1818000000000000- <1>     db  07eh, 018h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   289 0000FEA9 00000000000000      <1>
   290 0000FEB0 181818300000000000- <1>     db  018h, 018h, 018h, 030h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0feh, 000h, 000h, 000h
   290 0000FEB9 000000FE000000      <1>
   291 0000FEC0 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h, 000h
   291 0000FEC9 00000000181800      <1>
   292 0000FED0 0000000002060C1830- <1>     db  000h, 000h, 000h, 000h, 002h, 006h, 00ch, 018h, 030h, 060h, 0c0h, 080h, 000h, 000h, 000h, 000h
   292 0000FED9 60C08000000000      <1>
   293 0000FEE0 00007CC6CEDEF6E6C6- <1>     db  000h, 000h, 07ch, 0c6h, 0ceh, 0deh, 0f6h, 0e6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h
   293 0000FEE9 C67C0000000000      <1>
   294 0000FEF0 18387818181818187E- <1>     db  018h, 038h, 078h, 018h, 018h, 018h, 018h, 018h, 07eh, 000h, 000h, 000h, 000h, 000h, 07ch, 0c6h
   294 0000FEF9 00000000007CC6      <1>
   295 0000FF00 060C183060C6FE0000- <1>     db  006h, 00ch, 018h, 030h, 060h, 0c6h, 0feh, 000h, 000h, 000h, 000h, 000h, 07ch, 0c6h, 006h, 006h
   295 0000FF09 0000007CC60606      <1>
   296 0000FF10 3C0606C67C00000000- <1>     db  03ch, 006h, 006h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h, 00ch, 01ch, 03ch, 06ch, 0cch, 0feh
   296 0000FF19 000C1C3C6CCCFE      <1>
   297 0000FF20 0C0C1E0000000000FE- <1>     db  00ch, 00ch, 01eh, 000h, 000h, 000h, 000h, 000h, 0feh, 0c0h, 0c0h, 0c0h, 0fch, 006h, 006h, 0c6h
   297 0000FF29 C0C0C0FC0606C6      <1>
   298 0000FF30 7C00000000003860C0- <1>     db  07ch, 000h, 000h, 000h, 000h, 000h, 038h, 060h, 0c0h, 0c0h, 0fch, 0c6h, 0c6h, 0c6h, 07ch, 000h
   298 0000FF39 C0FCC6C6C67C00      <1>
   299 0000FF40 00000000FEC6060C18- <1>     db  000h, 000h, 000h, 000h, 0feh, 0c6h, 006h, 00ch, 018h, 030h, 030h, 030h, 030h, 000h, 000h, 000h
   299 0000FF49 30303030000000      <1>
   300 0000FF50 00007CC6C6C67CC6C6- <1>     db  000h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 07ch, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h
   300 0000FF59 C67C0000000000      <1>
   301 0000FF60 7CC6C6C67E06060C78- <1>     db  07ch, 0c6h, 0c6h, 0c6h, 07eh, 006h, 006h, 00ch, 078h, 000h, 000h, 000h, 000h, 000h, 000h, 018h
   301 0000FF69 00000000000018      <1>
   302 0000FF70 180000001818000000- <1>     db  018h, 000h, 000h, 000h, 018h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h, 000h
   302 0000FF79 00000000181800      <1>
   303 0000FF80 000018183000000000- <1>     db  000h, 000h, 018h, 018h, 030h, 000h, 000h, 000h, 000h, 000h, 006h, 00ch, 018h, 030h, 060h, 030h
   303 0000FF89 00060C18306030      <1>
   304 0000FF90 180C06000000000000- <1>     db  018h, 00ch, 006h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 07eh, 000h, 000h, 07eh, 000h
   304 0000FF99 00007E00007E00      <1>
   305 0000FFA0 000000000000603018- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 060h, 030h, 018h, 00ch, 006h, 00ch, 018h, 030h, 060h, 000h
   305 0000FFA9 0C060C18306000      <1>
   306 0000FFB0 000000007CC6C60C18- <1>     db  000h, 000h, 000h, 000h, 07ch, 0c6h, 0c6h, 00ch, 018h, 018h, 000h, 018h, 018h, 000h, 000h, 000h
   306 0000FFB9 18001818000000      <1>
   307 0000FFC0 00007CC6C6DEDEDEDC- <1>     db  000h, 000h, 07ch, 0c6h, 0c6h, 0deh, 0deh, 0deh, 0dch, 0c0h, 07ch, 000h, 000h, 000h, 000h, 000h
   307 0000FFC9 C07C0000000000      <1>
   308 0000FFD0 10386CC6C6FEC6C6C6- <1>     db  010h, 038h, 06ch, 0c6h, 0c6h, 0feh, 0c6h, 0c6h, 0c6h, 000h, 000h, 000h, 000h, 000h, 0fch, 066h
   308 0000FFD9 0000000000FC66      <1>
   309 0000FFE0 66667C666666FC0000- <1>     db  066h, 066h, 07ch, 066h, 066h, 066h, 0fch, 000h, 000h, 000h, 000h, 000h, 03ch, 066h, 0c2h, 0c0h
   309 0000FFE9 0000003C66C2C0      <1>
   310 0000FFF0 C0C0C2663C00000000- <1>     db  0c0h, 0c0h, 0c2h, 066h, 03ch, 000h, 000h, 000h, 000h, 000h, 0f8h, 06ch, 066h, 066h, 066h, 066h
   310 0000FFF9 00F86C66666666      <1>
   311 00010000 666CF80000000000FE- <1>     db  066h, 06ch, 0f8h, 000h, 000h, 000h, 000h, 000h, 0feh, 066h, 062h, 068h, 078h, 068h, 062h, 066h
   311 00010009 66626878686266      <1>
   312 00010010 FE0000000000FE6662- <1>     db  0feh, 000h, 000h, 000h, 000h, 000h, 0feh, 066h, 062h, 068h, 078h, 068h, 060h, 060h, 0f0h, 000h
   312 00010019 6878686060F000      <1>
   313 00010020 000000003C66C2C0C0- <1>     db  000h, 000h, 000h, 000h, 03ch, 066h, 0c2h, 0c0h, 0c0h, 0deh, 0c6h, 066h, 03ah, 000h, 000h, 000h
   313 00010029 DEC6663A000000      <1>
   314 00010030 0000C6C6C6C6FEC6C6- <1>     db  000h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 0feh, 0c6h, 0c6h, 0c6h, 0c6h, 000h, 000h, 000h, 000h, 000h
   314 00010039 C6C60000000000      <1>
   315 00010040 3C181818181818183C- <1>     db  03ch, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h, 000h, 01eh, 00ch
   315 00010049 00000000001E0C      <1>
   316 00010050 0C0C0C0CCCCC780000- <1>     db  00ch, 00ch, 00ch, 00ch, 0cch, 0cch, 078h, 000h, 000h, 000h, 000h, 000h, 0e6h, 066h, 06ch, 06ch
   316 00010059 000000E6666C6C      <1>
   317 00010060 786C6C66E600000000- <1>     db  078h, 06ch, 06ch, 066h, 0e6h, 000h, 000h, 000h, 000h, 000h, 0f0h, 060h, 060h, 060h, 060h, 060h
   317 00010069 00F06060606060      <1>
   318 00010070 6266FE0000000000C6- <1>     db  062h, 066h, 0feh, 000h, 000h, 000h, 000h, 000h, 0c6h, 0eeh, 0feh, 0feh, 0d6h, 0c6h, 0c6h, 0c6h
   318 00010079 EEFEFED6C6C6C6      <1>
   319 00010080 C60000000000C6E6F6- <1>     db  0c6h, 000h, 000h, 000h, 000h, 000h, 0c6h, 0e6h, 0f6h, 0feh, 0deh, 0ceh, 0c6h, 0c6h, 0c6h, 000h
   319 00010089 FEDECEC6C6C600      <1>
   320 00010090 00000000386CC6C6C6- <1>     db  000h, 000h, 000h, 000h, 038h, 06ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 06ch, 038h, 000h, 000h, 000h
   320 00010099 C6C66C38000000      <1>
   321 000100A0 0000FC6666667C6060- <1>     db  000h, 000h, 0fch, 066h, 066h, 066h, 07ch, 060h, 060h, 060h, 0f0h, 000h, 000h, 000h, 000h, 000h
   321 000100A9 60F00000000000      <1>
   322 000100B0 7CC6C6C6C6D6DE7C0C- <1>     db  07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0d6h, 0deh, 07ch, 00ch, 00eh, 000h, 000h, 000h, 000h, 0fch, 066h
   322 000100B9 0E00000000FC66      <1>
   323 000100C0 66667C6C6666E60000- <1>     db  066h, 066h, 07ch, 06ch, 066h, 066h, 0e6h, 000h, 000h, 000h, 000h, 000h, 07ch, 0c6h, 0c6h, 060h
   323 000100C9 0000007CC6C660      <1>
   324 000100D0 380CC6C67C00000000- <1>     db  038h, 00ch, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h, 07eh, 07eh, 05ah, 018h, 018h, 018h
   324 000100D9 007E7E5A181818      <1>
   325 000100E0 18183C0000000000C6- <1>     db  018h, 018h, 03ch, 000h, 000h, 000h, 000h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h
   325 000100E9 C6C6C6C6C6C6C6      <1>
   326 000100F0 7C0000000000C6C6C6- <1>     db  07ch, 000h, 000h, 000h, 000h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 06ch, 038h, 010h, 000h
   326 000100F9 C6C6C66C381000      <1>
   327 00010100 00000000C6C6C6C6D6- <1>     db  000h, 000h, 000h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 0d6h, 0d6h, 0feh, 07ch, 06ch, 000h, 000h, 000h
   327 00010109 D6FE7C6C000000      <1>
   328 00010110 0000C6C66C3838386C- <1>     db  000h, 000h, 0c6h, 0c6h, 06ch, 038h, 038h, 038h, 06ch, 0c6h, 0c6h, 000h, 000h, 000h, 000h, 000h
   328 00010119 C6C60000000000      <1>
   329 00010120 666666663C1818183C- <1>     db  066h, 066h, 066h, 066h, 03ch, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h, 000h, 0feh, 0c6h
   329 00010129 0000000000FEC6      <1>
   330 00010130 8C183060C2C6FE0000- <1>     db  08ch, 018h, 030h, 060h, 0c2h, 0c6h, 0feh, 000h, 000h, 000h, 000h, 000h, 03ch, 030h, 030h, 030h
   330 00010139 0000003C303030      <1>
   331 00010140 303030303C00000000- <1>     db  030h, 030h, 030h, 030h, 03ch, 000h, 000h, 000h, 000h, 000h, 080h, 0c0h, 0e0h, 070h, 038h, 01ch
   331 00010149 0080C0E070381C      <1>
   332 00010150 0E060200000000003C- <1>     db  00eh, 006h, 002h, 000h, 000h, 000h, 000h, 000h, 03ch, 00ch, 00ch, 00ch, 00ch, 00ch, 00ch, 00ch
   332 00010159 0C0C0C0C0C0C0C      <1>
   333 00010160 3C00000010386CC600- <1>     db  03ch, 000h, 000h, 000h, 010h, 038h, 06ch, 0c6h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   333 00010169 00000000000000      <1>
   334 00010170 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ffh, 000h
   334 00010179 0000000000FF00      <1>
   335 00010180 303018000000000000- <1>     db  030h, 030h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   335 00010189 00000000000000      <1>
   336 00010190 000000780C7CCCCC76- <1>     db  000h, 000h, 000h, 078h, 00ch, 07ch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h, 000h, 0e0h, 060h
   336 00010199 0000000000E060      <1>
   337 000101A0 60786C6666667C0000- <1>     db  060h, 078h, 06ch, 066h, 066h, 066h, 07ch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 07ch
   337 000101A9 0000000000007C      <1>
   338 000101B0 C6C0C0C67C00000000- <1>     db  0c6h, 0c0h, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h, 01ch, 00ch, 00ch, 03ch, 06ch, 0cch
   338 000101B9 001C0C0C3C6CCC      <1>
   339 000101C0 CCCC76000000000000- <1>     db  0cch, 0cch, 076h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 07ch, 0c6h, 0feh, 0c0h, 0c6h
   339 000101C9 00007CC6FEC0C6      <1>
   340 000101D0 7C0000000000386C64- <1>     db  07ch, 000h, 000h, 000h, 000h, 000h, 038h, 06ch, 064h, 060h, 0f0h, 060h, 060h, 060h, 0f0h, 000h
   340 000101D9 60F0606060F000      <1>
   341 000101E0 0000000000000076CC- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 076h, 0cch, 0cch, 0cch, 07ch, 00ch, 0cch, 078h, 000h
   341 000101E9 CCCC7C0CCC7800      <1>
   342 000101F0 0000E060606C766666- <1>     db  000h, 000h, 0e0h, 060h, 060h, 06ch, 076h, 066h, 066h, 066h, 0e6h, 000h, 000h, 000h, 000h, 000h
   342 000101F9 66E60000000000      <1>
   343 00010200 18180038181818183C- <1>     db  018h, 018h, 000h, 038h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h, 000h, 006h, 006h
   343 00010209 00000000000606      <1>
   344 00010210 000E0606060666663C- <1>     db  000h, 00eh, 006h, 006h, 006h, 006h, 066h, 066h, 03ch, 000h, 000h, 000h, 0e0h, 060h, 060h, 066h
   344 00010219 000000E0606066      <1>
   345 00010220 6C786C66E600000000- <1>     db  06ch, 078h, 06ch, 066h, 0e6h, 000h, 000h, 000h, 000h, 000h, 038h, 018h, 018h, 018h, 018h, 018h
   345 00010229 00381818181818      <1>
   346 00010230 18183C000000000000- <1>     db  018h, 018h, 03ch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ech, 0feh, 0d6h, 0d6h, 0d6h
   346 00010239 0000ECFED6D6D6      <1>
   347 00010240 C60000000000000000- <1>     db  0c6h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0dch, 066h, 066h, 066h, 066h, 066h, 000h
   347 00010249 DC666666666600      <1>
   348 00010250 000000000000007CC6- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h
   348 00010259 C6C6C67C000000      <1>
   349 00010260 0000000000DC666666- <1>     db  000h, 000h, 000h, 000h, 000h, 0dch, 066h, 066h, 066h, 07ch, 060h, 060h, 0f0h, 000h, 000h, 000h
   349 00010269 7C6060F0000000      <1>
   350 00010270 00000076CCCCCC7C0C- <1>     db  000h, 000h, 000h, 076h, 0cch, 0cch, 0cch, 07ch, 00ch, 00ch, 01eh, 000h, 000h, 000h, 000h, 000h
   350 00010279 0C1E0000000000      <1>
   351 00010280 00DC76666060F00000- <1>     db  000h, 0dch, 076h, 066h, 060h, 060h, 0f0h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 07ch
   351 00010289 0000000000007C      <1>
   352 00010290 C6701CC67C00000000- <1>     db  0c6h, 070h, 01ch, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h, 010h, 030h, 030h, 0fch, 030h, 030h
   352 00010299 00103030FC3030      <1>
   353 000102A0 30361C000000000000- <1>     db  030h, 036h, 01ch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0cch, 0cch, 0cch, 0cch, 0cch
   353 000102A9 0000CCCCCCCCCC      <1>
   354 000102B0 760000000000000000- <1>     db  076h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 066h, 066h, 066h, 066h, 03ch, 018h, 000h
   354 000102B9 666666663C1800      <1>
   355 000102C0 00000000000000C6C6- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 0c6h, 0c6h, 0d6h, 0d6h, 0feh, 06ch, 000h, 000h, 000h
   355 000102C9 D6D6FE6C000000      <1>
   356 000102D0 0000000000C66C3838- <1>     db  000h, 000h, 000h, 000h, 000h, 0c6h, 06ch, 038h, 038h, 06ch, 0c6h, 000h, 000h, 000h, 000h, 000h
   356 000102D9 6CC60000000000      <1>
   357 000102E0 000000C6C6C6C67E06- <1>     db  000h, 000h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 07eh, 006h, 00ch, 0f8h, 000h, 000h, 000h, 000h, 000h
   357 000102E9 0CF80000000000      <1>
   358 000102F0 00FECC183066FE0000- <1>     db  000h, 0feh, 0cch, 018h, 030h, 066h, 0feh, 000h, 000h, 000h, 000h, 000h, 00eh, 018h, 018h, 018h
   358 000102F9 0000000E181818      <1>
   359 00010300 701818180E00000000- <1>     db  070h, 018h, 018h, 018h, 00eh, 000h, 000h, 000h, 000h, 000h, 018h, 018h, 018h, 018h, 000h, 018h
   359 00010309 00181818180018      <1>
   360 00010310 181818000000000070- <1>     db  018h, 018h, 018h, 000h, 000h, 000h, 000h, 000h, 070h, 018h, 018h, 018h, 00eh, 018h, 018h, 018h
   360 00010319 1818180E181818      <1>
   361 00010320 70000000000076DC00- <1>     db  070h, 000h, 000h, 000h, 000h, 000h, 076h, 0dch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   361 00010329 00000000000000      <1>
   362 00010330 00000000000010386C- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 010h, 038h, 06ch, 0c6h, 0c6h, 0feh, 000h, 000h, 000h, 000h
   362 00010339 C6C6FE00000000      <1>
   363 00010340 00003C66C2C0C0C266- <1>     db  000h, 000h, 03ch, 066h, 0c2h, 0c0h, 0c0h, 0c2h, 066h, 03ch, 00ch, 006h, 07ch, 000h, 000h, 000h
   363 00010349 3C0C067C000000      <1>
   364 00010350 CCCC00CCCCCCCCCC76- <1>     db  0cch, 0cch, 000h, 0cch, 0cch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h, 00ch, 018h, 030h
   364 00010359 000000000C1830      <1>
   365 00010360 007CC6FEC0C67C0000- <1>     db  000h, 07ch, 0c6h, 0feh, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 010h, 038h, 06ch, 000h, 078h
   365 00010369 000010386C0078      <1>
   366 00010370 0C7CCCCC7600000000- <1>     db  00ch, 07ch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h, 000h, 0cch, 0cch, 000h, 078h, 00ch, 07ch
   366 00010379 00CCCC00780C7C      <1>
   367 00010380 CCCC76000000006030- <1>     db  0cch, 0cch, 076h, 000h, 000h, 000h, 000h, 060h, 030h, 018h, 000h, 078h, 00ch, 07ch, 0cch, 0cch
   367 00010389 1800780C7CCCCC      <1>
   368 00010390 7600000000386C3800- <1>     db  076h, 000h, 000h, 000h, 000h, 038h, 06ch, 038h, 000h, 078h, 00ch, 07ch, 0cch, 0cch, 076h, 000h
   368 00010399 780C7CCCCC7600      <1>
   369 000103A0 0000000000003C6660- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 03ch, 066h, 060h, 066h, 03ch, 00ch, 006h, 03ch, 000h, 000h
   369 000103A9 663C0C063C0000      <1>
   370 000103B0 0010386C007CC6FEC0- <1>     db  000h, 010h, 038h, 06ch, 000h, 07ch, 0c6h, 0feh, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h
   370 000103B9 C67C0000000000      <1>
   371 000103C0 CCCC007CC6FEC0C67C- <1>     db  0cch, 0cch, 000h, 07ch, 0c6h, 0feh, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 060h, 030h, 018h
   371 000103C9 00000000603018      <1>
   372 000103D0 007CC6FEC0C67C0000- <1>     db  000h, 07ch, 0c6h, 0feh, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h, 066h, 066h, 000h, 038h
   372 000103D9 00000066660038      <1>
   373 000103E0 181818183C00000000- <1>     db  018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h, 018h, 03ch, 066h, 000h, 038h, 018h, 018h
   373 000103E9 183C6600381818      <1>
   374 000103F0 18183C000000006030- <1>     db  018h, 018h, 03ch, 000h, 000h, 000h, 000h, 060h, 030h, 018h, 000h, 038h, 018h, 018h, 018h, 018h
   374 000103F9 18003818181818      <1>
   375 00010400 3C00000000C6C61038- <1>     db  03ch, 000h, 000h, 000h, 000h, 0c6h, 0c6h, 010h, 038h, 06ch, 0c6h, 0c6h, 0feh, 0c6h, 0c6h, 000h
   375 00010409 6CC6C6FEC6C600      <1>
   376 00010410 0000386C3800386CC6- <1>     db  000h, 000h, 038h, 06ch, 038h, 000h, 038h, 06ch, 0c6h, 0c6h, 0feh, 0c6h, 0c6h, 000h, 000h, 000h
   376 00010419 C6FEC6C6000000      <1>
   377 00010420 18306000FE66607C60- <1>     db  018h, 030h, 060h, 000h, 0feh, 066h, 060h, 07ch, 060h, 066h, 0feh, 000h, 000h, 000h, 000h, 000h
   377 00010429 66FE0000000000      <1>
   378 00010430 0000CC76367ED8D86E- <1>     db  000h, 000h, 0cch, 076h, 036h, 07eh, 0d8h, 0d8h, 06eh, 000h, 000h, 000h, 000h, 000h, 03eh, 06ch
   378 00010439 00000000003E6C      <1>
   379 00010440 CCCCFECCCCCCCE0000- <1>     db  0cch, 0cch, 0feh, 0cch, 0cch, 0cch, 0ceh, 000h, 000h, 000h, 000h, 010h, 038h, 06ch, 000h, 07ch
   379 00010449 000010386C007C      <1>
   380 00010450 C6C6C6C67C00000000- <1>     db  0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h, 0c6h, 0c6h, 000h, 07ch, 0c6h, 0c6h
   380 00010459 00C6C6007CC6C6      <1>
   381 00010460 C6C67C000000006030- <1>     db  0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 060h, 030h, 018h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h
   381 00010469 18007CC6C6C6C6      <1>
   382 00010470 7C000000003078CC00- <1>     db  07ch, 000h, 000h, 000h, 000h, 030h, 078h, 0cch, 000h, 0cch, 0cch, 0cch, 0cch, 0cch, 076h, 000h
   382 00010479 CCCCCCCCCC7600      <1>
   383 00010480 00000060301800CCCC- <1>     db  000h, 000h, 000h, 060h, 030h, 018h, 000h, 0cch, 0cch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h
   383 00010489 CCCCCC76000000      <1>
   384 00010490 0000C6C600C6C6C6C6- <1>     db  000h, 000h, 0c6h, 0c6h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 07eh, 006h, 00ch, 078h, 000h, 000h, 0c6h
   384 00010499 7E060C780000C6      <1>
   385 000104A0 C6386CC6C6C6C66C38- <1>     db  0c6h, 038h, 06ch, 0c6h, 0c6h, 0c6h, 0c6h, 06ch, 038h, 000h, 000h, 000h, 000h, 0c6h, 0c6h, 000h
   385 000104A9 00000000C6C600      <1>
   386 000104B0 C6C6C6C6C6C67C0000- <1>     db  0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 018h, 018h, 03ch, 066h, 060h
   386 000104B9 000018183C6660      <1>
   387 000104C0 60663C181800000000- <1>     db  060h, 066h, 03ch, 018h, 018h, 000h, 000h, 000h, 000h, 038h, 06ch, 064h, 060h, 0f0h, 060h, 060h
   387 000104C9 386C6460F06060      <1>
   388 000104D0 60E6FC000000000066- <1>     db  060h, 0e6h, 0fch, 000h, 000h, 000h, 000h, 000h, 066h, 066h, 03ch, 018h, 07eh, 018h, 07eh, 018h
   388 000104D9 663C187E187E18      <1>
   389 000104E0 1800000000F8CCCCF8- <1>     db  018h, 000h, 000h, 000h, 000h, 0f8h, 0cch, 0cch, 0f8h, 0c4h, 0cch, 0deh, 0cch, 0cch, 0c6h, 000h
   389 000104E9 C4CCDECCCCC600      <1>
   390 000104F0 0000000E1B1818187E- <1>     db  000h, 000h, 000h, 00eh, 01bh, 018h, 018h, 018h, 07eh, 018h, 018h, 018h, 018h, 0d8h, 070h, 000h
   390 000104F9 18181818D87000      <1>
   391 00010500 0018306000780C7CCC- <1>     db  000h, 018h, 030h, 060h, 000h, 078h, 00ch, 07ch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h, 00ch
   391 00010509 CC76000000000C      <1>
   392 00010510 18300038181818183C- <1>     db  018h, 030h, 000h, 038h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h, 018h, 030h, 060h
   392 00010519 00000000183060      <1>
   393 00010520 007CC6C6C6C67C0000- <1>     db  000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 018h, 030h, 060h, 000h, 0cch
   393 00010529 000018306000CC      <1>
   394 00010530 CCCCCCCC7600000000- <1>     db  0cch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h, 000h, 076h, 0dch, 000h, 0dch, 066h, 066h
   394 00010539 0076DC00DC6666      <1>
   395 00010540 66666600000076DC00- <1>     db  066h, 066h, 066h, 000h, 000h, 000h, 076h, 0dch, 000h, 0c6h, 0e6h, 0f6h, 0feh, 0deh, 0ceh, 0c6h
   395 00010549 C6E6F6FEDECEC6      <1>
   396 00010550 C6000000003C6C6C3E- <1>     db  0c6h, 000h, 000h, 000h, 000h, 03ch, 06ch, 06ch, 03eh, 000h, 07eh, 000h, 000h, 000h, 000h, 000h
   396 00010559 007E0000000000      <1>
   397 00010560 000000386C6C38007C- <1>     db  000h, 000h, 000h, 038h, 06ch, 06ch, 038h, 000h, 07ch, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   397 00010569 00000000000000      <1>
   398 00010570 0000303000303060C6- <1>     db  000h, 000h, 030h, 030h, 000h, 030h, 030h, 060h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h
   398 00010579 C67C0000000000      <1>
   399 00010580 00000000FEC0C0C000- <1>     db  000h, 000h, 000h, 000h, 0feh, 0c0h, 0c0h, 0c0h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   399 00010589 00000000000000      <1>
   400 00010590 0000FE060606000000- <1>     db  000h, 000h, 0feh, 006h, 006h, 006h, 000h, 000h, 000h, 000h, 000h, 0c0h, 0c0h, 0c6h, 0cch, 0d8h
   400 00010599 0000C0C0C6CCD8      <1>
   401 000105A0 3060DC860C183E0000- <1>     db  030h, 060h, 0dch, 086h, 00ch, 018h, 03eh, 000h, 000h, 0c0h, 0c0h, 0c6h, 0cch, 0d8h, 030h, 066h
   401 000105A9 C0C0C6CCD83066      <1>
   402 000105B0 CE9E3E060600000018- <1>     db  0ceh, 09eh, 03eh, 006h, 006h, 000h, 000h, 000h, 018h, 018h, 000h, 018h, 018h, 03ch, 03ch, 03ch
   402 000105B9 180018183C3C3C      <1>
   403 000105C0 180000000000000036- <1>     db  018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 036h, 06ch, 0d8h, 06ch, 036h, 000h, 000h, 000h
   403 000105C9 6CD86C36000000      <1>
   404 000105D0 000000000000D86C36- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 0d8h, 06ch, 036h, 06ch, 0d8h, 000h, 000h, 000h, 000h, 000h
   404 000105D9 6CD80000000000      <1>
   405 000105E0 114411441144114411- <1>     db  011h, 044h, 011h, 044h, 011h, 044h, 011h, 044h, 011h, 044h, 011h, 044h, 011h, 044h, 055h, 0aah
   405 000105E9 441144114455AA      <1>
   406 000105F0 55AA55AA55AA55AA55- <1>     db  055h, 0aah, 055h, 0aah, 055h, 0aah, 055h, 0aah, 055h, 0aah, 055h, 0aah, 0ddh, 077h, 0ddh, 077h
   406 000105F9 AA55AADD77DD77      <1>
   407 00010600 DD77DD77DD77DD77DD- <1>     db  0ddh, 077h, 0ddh, 077h, 0ddh, 077h, 0ddh, 077h, 0ddh, 077h, 018h, 018h, 018h, 018h, 018h, 018h
   407 00010609 77181818181818      <1>
   408 00010610 181818181818181818- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 0f8h
   408 00010619 181818181818F8      <1>
   409 00010620 181818181818181818- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 0f8h, 018h, 0f8h, 018h, 018h
   409 00010629 1818F818F81818      <1>
   410 00010630 181818183636363636- <1>     db  018h, 018h, 018h, 018h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 0f6h, 036h, 036h, 036h, 036h
   410 00010639 3636F636363636      <1>
   411 00010640 363600000000000000- <1>     db  036h, 036h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0feh, 036h, 036h, 036h, 036h, 036h, 036h
   411 00010649 FE363636363636      <1>
   412 00010650 0000000000F818F818- <1>     db  000h, 000h, 000h, 000h, 000h, 0f8h, 018h, 0f8h, 018h, 018h, 018h, 018h, 018h, 018h, 036h, 036h
   412 00010659 18181818183636      <1>
   413 00010660 363636F606F6363636- <1>     db  036h, 036h, 036h, 0f6h, 006h, 0f6h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
   413 00010669 36363636363636      <1>
   414 00010670 363636363636363636- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 000h, 000h, 000h, 000h, 000h, 0feh
   414 00010679 360000000000FE      <1>
   415 00010680 06F636363636363636- <1>     db  006h, 0f6h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 0f6h, 006h, 0feh
   415 00010689 36363636F606FE      <1>
   416 00010690 000000000000363636- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 0feh, 000h, 000h
   416 00010699 36363636FE0000      <1>
   417 000106A0 000000001818181818- <1>     db  000h, 000h, 000h, 000h, 018h, 018h, 018h, 018h, 018h, 0f8h, 018h, 0f8h, 000h, 000h, 000h, 000h
   417 000106A9 F818F800000000      <1>
   418 000106B0 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0f8h, 018h, 018h, 018h, 018h, 018h, 018h
   418 000106B9 F8181818181818      <1>
   419 000106C0 181818181818181F00- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 01fh, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h
   419 000106C9 00000000001818      <1>
   420 000106D0 1818181818FF000000- <1>     db  018h, 018h, 018h, 018h, 018h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   420 000106D9 00000000000000      <1>
   421 000106E0 000000FF1818181818- <1>     db  000h, 000h, 000h, 0ffh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
   421 000106E9 18181818181818      <1>
   422 000106F0 181F18181818181800- <1>     db  018h, 01fh, 018h, 018h, 018h, 018h, 018h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ffh
   422 000106F9 000000000000FF      <1>
   423 00010700 000000000000181818- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 0ffh, 018h, 018h
   423 00010709 18181818FF1818      <1>
   424 00010710 181818181818181818- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 01fh, 018h, 01fh, 018h, 018h, 018h, 018h
   424 00010719 1F181F18181818      <1>
   425 00010720 181836363636363636- <1>     db  018h, 018h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 037h, 036h, 036h, 036h, 036h, 036h, 036h
   425 00010729 37363636363636      <1>
   426 00010730 363636363637303F00- <1>     db  036h, 036h, 036h, 036h, 036h, 037h, 030h, 03fh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   426 00010739 00000000000000      <1>
   427 00010740 0000003F3037363636- <1>     db  000h, 000h, 000h, 03fh, 030h, 037h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
   427 00010749 36363636363636      <1>
   428 00010750 36F700FF0000000000- <1>     db  036h, 0f7h, 000h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ffh
   428 00010759 000000000000FF      <1>
   429 00010760 00F736363636363636- <1>     db  000h, 0f7h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 037h, 030h, 037h
   429 00010769 36363636373037      <1>
   430 00010770 363636363636000000- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 000h, 000h, 000h, 000h, 000h, 0ffh, 000h, 0ffh, 000h, 000h
   430 00010779 0000FF00FF0000      <1>
   431 00010780 000000003636363636- <1>     db  000h, 000h, 000h, 000h, 036h, 036h, 036h, 036h, 036h, 0f7h, 000h, 0f7h, 036h, 036h, 036h, 036h
   431 00010789 F700F736363636      <1>
   432 00010790 36361818181818FF00- <1>     db  036h, 036h, 018h, 018h, 018h, 018h, 018h, 0ffh, 000h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h
   432 00010799 FF000000000000      <1>
   433 000107A0 36363636363636FF00- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   433 000107A9 00000000000000      <1>
   434 000107B0 000000FF00FF181818- <1>     db  000h, 000h, 000h, 0ffh, 000h, 0ffh, 018h, 018h, 018h, 018h, 018h, 018h, 000h, 000h, 000h, 000h
   434 000107B9 18181800000000      <1>
   435 000107C0 000000FF3636363636- <1>     db  000h, 000h, 000h, 0ffh, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
   435 000107C9 36363636363636      <1>
   436 000107D0 363F00000000000018- <1>     db  036h, 03fh, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h, 018h, 018h, 018h, 01fh, 018h, 01fh
   436 000107D9 181818181F181F      <1>
   437 000107E0 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 01fh, 018h, 01fh, 018h, 018h
   437 000107E9 00001F181F1818      <1>
   438 000107F0 181818180000000000- <1>     db  018h, 018h, 018h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 03fh, 036h, 036h, 036h, 036h
   438 000107F9 00003F36363636      <1>
   439 00010800 363636363636363636- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 0ffh, 036h, 036h, 036h, 036h, 036h, 036h
   439 00010809 FF363636363636      <1>
   440 00010810 1818181818FF18FF18- <1>     db  018h, 018h, 018h, 018h, 018h, 0ffh, 018h, 0ffh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
   440 00010819 18181818181818      <1>
   441 00010820 1818181818F8000000- <1>     db  018h, 018h, 018h, 018h, 018h, 0f8h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   441 00010829 00000000000000      <1>
   442 00010830 0000001F1818181818- <1>     db  000h, 000h, 000h, 01fh, 018h, 018h, 018h, 018h, 018h, 018h, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh
   442 00010839 18FFFFFFFFFFFF      <1>
   443 00010840 FFFFFFFFFFFFFFFF00- <1>     db  0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ffh
   443 00010849 000000000000FF      <1>
   444 00010850 FFFFFFFFFFFFF0F0F0- <1>     db  0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h
   444 00010859 F0F0F0F0F0F0F0      <1>
   445 00010860 F0F0F0F00F0F0F0F0F- <1>     db  0f0h, 0f0h, 0f0h, 0f0h, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh
   445 00010869 0F0F0F0F0F0F0F      <1>
   446 00010870 0F0FFFFFFFFFFFFFFF- <1>     db  00fh, 00fh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   446 00010879 00000000000000      <1>
   447 00010880 000000000076DCD8D8- <1>     db  000h, 000h, 000h, 000h, 000h, 076h, 0dch, 0d8h, 0d8h, 0dch, 076h, 000h, 000h, 000h, 000h, 000h
   447 00010889 DC760000000000      <1>
   448 00010890 00007CC6FCC6C6FCC0- <1>     db  000h, 000h, 07ch, 0c6h, 0fch, 0c6h, 0c6h, 0fch, 0c0h, 0c0h, 040h, 000h, 000h, 000h, 0feh, 0c6h
   448 00010899 C040000000FEC6      <1>
   449 000108A0 C6C0C0C0C0C0C00000- <1>     db  0c6h, 0c0h, 0c0h, 0c0h, 0c0h, 0c0h, 0c0h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0feh, 06ch
   449 000108A9 0000000000FE6C      <1>
   450 000108B0 6C6C6C6C6C00000000- <1>     db  06ch, 06ch, 06ch, 06ch, 06ch, 000h, 000h, 000h, 000h, 000h, 0feh, 0c6h, 060h, 030h, 018h, 030h
   450 000108B9 00FEC660301830      <1>
   451 000108C0 60C6FE000000000000- <1>     db  060h, 0c6h, 0feh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 07eh, 0d8h, 0d8h, 0d8h, 0d8h
   451 000108C9 00007ED8D8D8D8      <1>
   452 000108D0 700000000000000066- <1>     db  070h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 066h, 066h, 066h, 066h, 07ch, 060h, 060h, 0c0h
   452 000108D9 6666667C6060C0      <1>
   453 000108E0 00000000000076DC18- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 076h, 0dch, 018h, 018h, 018h, 018h, 018h, 000h, 000h, 000h
   453 000108E9 18181818000000      <1>
   454 000108F0 00007E183C6666663C- <1>     db  000h, 000h, 07eh, 018h, 03ch, 066h, 066h, 066h, 03ch, 018h, 07eh, 000h, 000h, 000h, 000h, 000h
   454 000108F9 187E0000000000      <1>
   455 00010900 386CC6C6FEC6C66C38- <1>     db  038h, 06ch, 0c6h, 0c6h, 0feh, 0c6h, 0c6h, 06ch, 038h, 000h, 000h, 000h, 000h, 000h, 038h, 06ch
   455 00010909 0000000000386C      <1>
   456 00010910 C6C6C66C6C6CEE0000- <1>     db  0c6h, 0c6h, 0c6h, 06ch, 06ch, 06ch, 0eeh, 000h, 000h, 000h, 000h, 000h, 01eh, 030h, 018h, 00ch
   456 00010919 0000001E30180C      <1>
   457 00010920 3E6666663C00000000- <1>     db  03eh, 066h, 066h, 066h, 03ch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 07eh, 0dbh, 0dbh
   457 00010929 000000007EDBDB      <1>
   458 00010930 7E0000000000000003- <1>     db  07eh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 003h, 006h, 07eh, 0dbh, 0dbh, 0f3h, 07eh, 060h
   458 00010939 067EDBDBF37E60      <1>
   459 00010940 C000000000001C3060- <1>     db  0c0h, 000h, 000h, 000h, 000h, 000h, 01ch, 030h, 060h, 060h, 07ch, 060h, 060h, 030h, 01ch, 000h
   459 00010949 607C6060301C00      <1>
   460 00010950 00000000007CC6C6C6- <1>     db  000h, 000h, 000h, 000h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 000h, 000h, 000h
   460 00010959 C6C6C6C6000000      <1>
   461 00010960 000000FE0000FE0000- <1>     db  000h, 000h, 000h, 0feh, 000h, 000h, 0feh, 000h, 000h, 0feh, 000h, 000h, 000h, 000h, 000h, 000h
   461 00010969 FE000000000000      <1>
   462 00010970 0018187E18180000FF- <1>     db  000h, 018h, 018h, 07eh, 018h, 018h, 000h, 000h, 0ffh, 000h, 000h, 000h, 000h, 000h, 030h, 018h
   462 00010979 00000000003018      <1>
   463 00010980 0C060C1830007E0000- <1>     db  00ch, 006h, 00ch, 018h, 030h, 000h, 07eh, 000h, 000h, 000h, 000h, 000h, 00ch, 018h, 030h, 060h
   463 00010989 0000000C183060      <1>
   464 00010990 30180C007E00000000- <1>     db  030h, 018h, 00ch, 000h, 07eh, 000h, 000h, 000h, 000h, 000h, 00eh, 01bh, 01bh, 018h, 018h, 018h
   464 00010999 000E1B1B181818      <1>
   465 000109A0 181818181818181818- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 0d8h, 0d8h
   465 000109A9 1818181818D8D8      <1>
   466 000109B0 700000000000001818- <1>     db  070h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h, 000h, 07eh, 000h, 018h, 018h, 000h, 000h
   466 000109B9 007E0018180000      <1>
   467 000109C0 00000000000076DC00- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 076h, 0dch, 000h, 076h, 0dch, 000h, 000h, 000h, 000h, 000h
   467 000109C9 76DC0000000000      <1>
   468 000109D0 00386C6C3800000000- <1>     db  000h, 038h, 06ch, 06ch, 038h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   468 000109D9 00000000000000      <1>
   469 000109E0 000000001818000000- <1>     db  000h, 000h, 000h, 000h, 018h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   469 000109E9 00000000000000      <1>
   470 000109F0 000000180000000000- <1>     db  000h, 000h, 000h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 00fh, 00ch, 00ch, 00ch, 00ch
   470 000109F9 00000F0C0C0C0C      <1>
   471 00010A00 0CEC6C3C1C00000000- <1>     db  00ch, 0ech, 06ch, 03ch, 01ch, 000h, 000h, 000h, 000h, 0d8h, 06ch, 06ch, 06ch, 06ch, 06ch, 000h
   471 00010A09 D86C6C6C6C6C00      <1>
   472 00010A10 0000000000000070D8- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 070h, 0d8h, 030h, 060h, 0c8h, 0f8h, 000h, 000h, 000h
   472 00010A19 3060C8F8000000      <1>
   473 00010A20 00000000000000007C- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 07ch, 07ch, 07ch, 07ch, 07ch, 07ch, 000h, 000h
   473 00010A29 7C7C7C7C7C0000      <1>
   474 00010A30 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   474 00010A39 00000000000000      <1>
   475                              <1> vgafont16:
   476 00010A40 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   476 00010A49 00000000000000      <1>
   477 00010A50 00007E81A58181BD99- <1>     db  000h, 000h, 07eh, 081h, 0a5h, 081h, 081h, 0bdh, 099h, 081h, 081h, 07eh, 000h, 000h, 000h, 000h
   477 00010A59 81817E00000000      <1>
   478 00010A60 00007EFFDBFFFFC3E7- <1>     db  000h, 000h, 07eh, 0ffh, 0dbh, 0ffh, 0ffh, 0c3h, 0e7h, 0ffh, 0ffh, 07eh, 000h, 000h, 000h, 000h
   478 00010A69 FFFF7E00000000      <1>
   479 00010A70 000000006CFEFEFEFE- <1>     db  000h, 000h, 000h, 000h, 06ch, 0feh, 0feh, 0feh, 0feh, 07ch, 038h, 010h, 000h, 000h, 000h, 000h
   479 00010A79 7C381000000000      <1>
   480 00010A80 0000000010387CFE7C- <1>     db  000h, 000h, 000h, 000h, 010h, 038h, 07ch, 0feh, 07ch, 038h, 010h, 000h, 000h, 000h, 000h, 000h
   480 00010A89 38100000000000      <1>
   481 00010A90 000000183C3CE7E7E7- <1>     db  000h, 000h, 000h, 018h, 03ch, 03ch, 0e7h, 0e7h, 0e7h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
   481 00010A99 18183C00000000      <1>
   482 00010AA0 000000183C7EFFFF7E- <1>     db  000h, 000h, 000h, 018h, 03ch, 07eh, 0ffh, 0ffh, 07eh, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
   482 00010AA9 18183C00000000      <1>
   483 00010AB0 000000000000183C3C- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 018h, 03ch, 03ch, 018h, 000h, 000h, 000h, 000h, 000h, 000h
   483 00010AB9 18000000000000      <1>
   484 00010AC0 FFFFFFFFFFFFE7C3C3- <1>     db  0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0e7h, 0c3h, 0c3h, 0e7h, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh
   484 00010AC9 E7FFFFFFFFFFFF      <1>
   485 00010AD0 00000000003C664242- <1>     db  000h, 000h, 000h, 000h, 000h, 03ch, 066h, 042h, 042h, 066h, 03ch, 000h, 000h, 000h, 000h, 000h
   485 00010AD9 663C0000000000      <1>
   486 00010AE0 FFFFFFFFFFC399BDBD- <1>     db  0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0c3h, 099h, 0bdh, 0bdh, 099h, 0c3h, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh
   486 00010AE9 99C3FFFFFFFFFF      <1>
   487 00010AF0 00001E0E1A3278CCCC- <1>     db  000h, 000h, 01eh, 00eh, 01ah, 032h, 078h, 0cch, 0cch, 0cch, 0cch, 078h, 000h, 000h, 000h, 000h
   487 00010AF9 CCCC7800000000      <1>
   488 00010B00 00003C666666663C18- <1>     db  000h, 000h, 03ch, 066h, 066h, 066h, 066h, 03ch, 018h, 07eh, 018h, 018h, 000h, 000h, 000h, 000h
   488 00010B09 7E181800000000      <1>
   489 00010B10 00003F333F30303030- <1>     db  000h, 000h, 03fh, 033h, 03fh, 030h, 030h, 030h, 030h, 070h, 0f0h, 0e0h, 000h, 000h, 000h, 000h
   489 00010B19 70F0E000000000      <1>
   490 00010B20 00007F637F63636363- <1>     db  000h, 000h, 07fh, 063h, 07fh, 063h, 063h, 063h, 063h, 067h, 0e7h, 0e6h, 0c0h, 000h, 000h, 000h
   490 00010B29 67E7E6C0000000      <1>
   491 00010B30 0000001818DB3CE73C- <1>     db  000h, 000h, 000h, 018h, 018h, 0dbh, 03ch, 0e7h, 03ch, 0dbh, 018h, 018h, 000h, 000h, 000h, 000h
   491 00010B39 DB181800000000      <1>
   492 00010B40 0080C0E0F0F8FEF8F0- <1>     db  000h, 080h, 0c0h, 0e0h, 0f0h, 0f8h, 0feh, 0f8h, 0f0h, 0e0h, 0c0h, 080h, 000h, 000h, 000h, 000h
   492 00010B49 E0C08000000000      <1>
   493 00010B50 0002060E1E3EFE3E1E- <1>     db  000h, 002h, 006h, 00eh, 01eh, 03eh, 0feh, 03eh, 01eh, 00eh, 006h, 002h, 000h, 000h, 000h, 000h
   493 00010B59 0E060200000000      <1>
   494 00010B60 0000183C7E1818187E- <1>     db  000h, 000h, 018h, 03ch, 07eh, 018h, 018h, 018h, 07eh, 03ch, 018h, 000h, 000h, 000h, 000h, 000h
   494 00010B69 3C180000000000      <1>
   495 00010B70 000066666666666666- <1>     db  000h, 000h, 066h, 066h, 066h, 066h, 066h, 066h, 066h, 000h, 066h, 066h, 000h, 000h, 000h, 000h
   495 00010B79 00666600000000      <1>
   496 00010B80 00007FDBDBDB7B1B1B- <1>     db  000h, 000h, 07fh, 0dbh, 0dbh, 0dbh, 07bh, 01bh, 01bh, 01bh, 01bh, 01bh, 000h, 000h, 000h, 000h
   496 00010B89 1B1B1B00000000      <1>
   497 00010B90 007CC660386CC6C66C- <1>     db  000h, 07ch, 0c6h, 060h, 038h, 06ch, 0c6h, 0c6h, 06ch, 038h, 00ch, 0c6h, 07ch, 000h, 000h, 000h
   497 00010B99 380CC67C000000      <1>
   498 00010BA0 0000000000000000FE- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0feh, 0feh, 0feh, 0feh, 000h, 000h, 000h, 000h
   498 00010BA9 FEFEFE00000000      <1>
   499 00010BB0 0000183C7E1818187E- <1>     db  000h, 000h, 018h, 03ch, 07eh, 018h, 018h, 018h, 07eh, 03ch, 018h, 07eh, 000h, 000h, 000h, 000h
   499 00010BB9 3C187E00000000      <1>
   500 00010BC0 0000183C7E18181818- <1>     db  000h, 000h, 018h, 03ch, 07eh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 000h, 000h, 000h, 000h
   500 00010BC9 18181800000000      <1>
   501 00010BD0 000018181818181818- <1>     db  000h, 000h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 07eh, 03ch, 018h, 000h, 000h, 000h, 000h
   501 00010BD9 7E3C1800000000      <1>
   502 00010BE0 0000000000180CFE0C- <1>     db  000h, 000h, 000h, 000h, 000h, 018h, 00ch, 0feh, 00ch, 018h, 000h, 000h, 000h, 000h, 000h, 000h
   502 00010BE9 18000000000000      <1>
   503 00010BF0 00000000003060FE60- <1>     db  000h, 000h, 000h, 000h, 000h, 030h, 060h, 0feh, 060h, 030h, 000h, 000h, 000h, 000h, 000h, 000h
   503 00010BF9 30000000000000      <1>
   504 00010C00 000000000000C0C0C0- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 0c0h, 0c0h, 0c0h, 0feh, 000h, 000h, 000h, 000h, 000h, 000h
   504 00010C09 FE000000000000      <1>
   505 00010C10 00000000002466FF66- <1>     db  000h, 000h, 000h, 000h, 000h, 024h, 066h, 0ffh, 066h, 024h, 000h, 000h, 000h, 000h, 000h, 000h
   505 00010C19 24000000000000      <1>
   506 00010C20 000000001038387C7C- <1>     db  000h, 000h, 000h, 000h, 010h, 038h, 038h, 07ch, 07ch, 0feh, 0feh, 000h, 000h, 000h, 000h, 000h
   506 00010C29 FEFE0000000000      <1>
   507 00010C30 00000000FEFE7C7C38- <1>     db  000h, 000h, 000h, 000h, 0feh, 0feh, 07ch, 07ch, 038h, 038h, 010h, 000h, 000h, 000h, 000h, 000h
   507 00010C39 38100000000000      <1>
   508 00010C40 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   508 00010C49 00000000000000      <1>
   509 00010C50 0000183C3C3C181818- <1>     db  000h, 000h, 018h, 03ch, 03ch, 03ch, 018h, 018h, 018h, 000h, 018h, 018h, 000h, 000h, 000h, 000h
   509 00010C59 00181800000000      <1>
   510 00010C60 006666662400000000- <1>     db  000h, 066h, 066h, 066h, 024h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   510 00010C69 00000000000000      <1>
   511 00010C70 0000006C6CFE6C6C6C- <1>     db  000h, 000h, 000h, 06ch, 06ch, 0feh, 06ch, 06ch, 06ch, 0feh, 06ch, 06ch, 000h, 000h, 000h, 000h
   511 00010C79 FE6C6C00000000      <1>
   512 00010C80 18187CC6C2C07C0606- <1>     db  018h, 018h, 07ch, 0c6h, 0c2h, 0c0h, 07ch, 006h, 006h, 086h, 0c6h, 07ch, 018h, 018h, 000h, 000h
   512 00010C89 86C67C18180000      <1>
   513 00010C90 00000000C2C60C1830- <1>     db  000h, 000h, 000h, 000h, 0c2h, 0c6h, 00ch, 018h, 030h, 060h, 0c6h, 086h, 000h, 000h, 000h, 000h
   513 00010C99 60C68600000000      <1>
   514 00010CA0 0000386C6C3876DCCC- <1>     db  000h, 000h, 038h, 06ch, 06ch, 038h, 076h, 0dch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
   514 00010CA9 CCCC7600000000      <1>
   515 00010CB0 003030306000000000- <1>     db  000h, 030h, 030h, 030h, 060h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   515 00010CB9 00000000000000      <1>
   516 00010CC0 00000C183030303030- <1>     db  000h, 000h, 00ch, 018h, 030h, 030h, 030h, 030h, 030h, 030h, 018h, 00ch, 000h, 000h, 000h, 000h
   516 00010CC9 30180C00000000      <1>
   517 00010CD0 000030180C0C0C0C0C- <1>     db  000h, 000h, 030h, 018h, 00ch, 00ch, 00ch, 00ch, 00ch, 00ch, 018h, 030h, 000h, 000h, 000h, 000h
   517 00010CD9 0C183000000000      <1>
   518 00010CE0 0000000000663CFF3C- <1>     db  000h, 000h, 000h, 000h, 000h, 066h, 03ch, 0ffh, 03ch, 066h, 000h, 000h, 000h, 000h, 000h, 000h
   518 00010CE9 66000000000000      <1>
   519 00010CF0 000000000018187E18- <1>     db  000h, 000h, 000h, 000h, 000h, 018h, 018h, 07eh, 018h, 018h, 000h, 000h, 000h, 000h, 000h, 000h
   519 00010CF9 18000000000000      <1>
   520 00010D00 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h, 018h, 030h, 000h, 000h, 000h
   520 00010D09 18181830000000      <1>
   521 00010D10 00000000000000FE00- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 0feh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   521 00010D19 00000000000000      <1>
   522 00010D20 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h, 000h, 000h, 000h, 000h
   522 00010D29 00181800000000      <1>
   523 00010D30 0000000002060C1830- <1>     db  000h, 000h, 000h, 000h, 002h, 006h, 00ch, 018h, 030h, 060h, 0c0h, 080h, 000h, 000h, 000h, 000h
   523 00010D39 60C08000000000      <1>
   524 00010D40 00003C66C3C3DBDBC3- <1>     db  000h, 000h, 03ch, 066h, 0c3h, 0c3h, 0dbh, 0dbh, 0c3h, 0c3h, 066h, 03ch, 000h, 000h, 000h, 000h
   524 00010D49 C3663C00000000      <1>
   525 00010D50 000018387818181818- <1>     db  000h, 000h, 018h, 038h, 078h, 018h, 018h, 018h, 018h, 018h, 018h, 07eh, 000h, 000h, 000h, 000h
   525 00010D59 18187E00000000      <1>
   526 00010D60 00007CC6060C183060- <1>     db  000h, 000h, 07ch, 0c6h, 006h, 00ch, 018h, 030h, 060h, 0c0h, 0c6h, 0feh, 000h, 000h, 000h, 000h
   526 00010D69 C0C6FE00000000      <1>
   527 00010D70 00007CC606063C0606- <1>     db  000h, 000h, 07ch, 0c6h, 006h, 006h, 03ch, 006h, 006h, 006h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   527 00010D79 06C67C00000000      <1>
   528 00010D80 00000C1C3C6CCCFE0C- <1>     db  000h, 000h, 00ch, 01ch, 03ch, 06ch, 0cch, 0feh, 00ch, 00ch, 00ch, 01eh, 000h, 000h, 000h, 000h
   528 00010D89 0C0C1E00000000      <1>
   529 00010D90 0000FEC0C0C0FC0606- <1>     db  000h, 000h, 0feh, 0c0h, 0c0h, 0c0h, 0fch, 006h, 006h, 006h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   529 00010D99 06C67C00000000      <1>
   530 00010DA0 00003860C0C0FCC6C6- <1>     db  000h, 000h, 038h, 060h, 0c0h, 0c0h, 0fch, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   530 00010DA9 C6C67C00000000      <1>
   531 00010DB0 0000FEC606060C1830- <1>     db  000h, 000h, 0feh, 0c6h, 006h, 006h, 00ch, 018h, 030h, 030h, 030h, 030h, 000h, 000h, 000h, 000h
   531 00010DB9 30303000000000      <1>
   532 00010DC0 00007CC6C6C67CC6C6- <1>     db  000h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   532 00010DC9 C6C67C00000000      <1>
   533 00010DD0 00007CC6C6C67E0606- <1>     db  000h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 07eh, 006h, 006h, 006h, 00ch, 078h, 000h, 000h, 000h, 000h
   533 00010DD9 060C7800000000      <1>
   534 00010DE0 000000001818000000- <1>     db  000h, 000h, 000h, 000h, 018h, 018h, 000h, 000h, 000h, 018h, 018h, 000h, 000h, 000h, 000h, 000h
   534 00010DE9 18180000000000      <1>
   535 00010DF0 000000001818000000- <1>     db  000h, 000h, 000h, 000h, 018h, 018h, 000h, 000h, 000h, 018h, 018h, 030h, 000h, 000h, 000h, 000h
   535 00010DF9 18183000000000      <1>
   536 00010E00 000000060C18306030- <1>     db  000h, 000h, 000h, 006h, 00ch, 018h, 030h, 060h, 030h, 018h, 00ch, 006h, 000h, 000h, 000h, 000h
   536 00010E09 180C0600000000      <1>
   537 00010E10 00000000007E00007E- <1>     db  000h, 000h, 000h, 000h, 000h, 07eh, 000h, 000h, 07eh, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   537 00010E19 00000000000000      <1>
   538 00010E20 0000006030180C060C- <1>     db  000h, 000h, 000h, 060h, 030h, 018h, 00ch, 006h, 00ch, 018h, 030h, 060h, 000h, 000h, 000h, 000h
   538 00010E29 18306000000000      <1>
   539 00010E30 00007CC6C60C181818- <1>     db  000h, 000h, 07ch, 0c6h, 0c6h, 00ch, 018h, 018h, 018h, 000h, 018h, 018h, 000h, 000h, 000h, 000h
   539 00010E39 00181800000000      <1>
   540 00010E40 0000007CC6C6DEDEDE- <1>     db  000h, 000h, 000h, 07ch, 0c6h, 0c6h, 0deh, 0deh, 0deh, 0dch, 0c0h, 07ch, 000h, 000h, 000h, 000h
   540 00010E49 DCC07C00000000      <1>
   541 00010E50 000010386CC6C6FEC6- <1>     db  000h, 000h, 010h, 038h, 06ch, 0c6h, 0c6h, 0feh, 0c6h, 0c6h, 0c6h, 0c6h, 000h, 000h, 000h, 000h
   541 00010E59 C6C6C600000000      <1>
   542 00010E60 0000FC6666667C6666- <1>     db  000h, 000h, 0fch, 066h, 066h, 066h, 07ch, 066h, 066h, 066h, 066h, 0fch, 000h, 000h, 000h, 000h
   542 00010E69 6666FC00000000      <1>
   543 00010E70 00003C66C2C0C0C0C0- <1>     db  000h, 000h, 03ch, 066h, 0c2h, 0c0h, 0c0h, 0c0h, 0c0h, 0c2h, 066h, 03ch, 000h, 000h, 000h, 000h
   543 00010E79 C2663C00000000      <1>
   544 00010E80 0000F86C6666666666- <1>     db  000h, 000h, 0f8h, 06ch, 066h, 066h, 066h, 066h, 066h, 066h, 06ch, 0f8h, 000h, 000h, 000h, 000h
   544 00010E89 666CF800000000      <1>
   545 00010E90 0000FE666268786860- <1>     db  000h, 000h, 0feh, 066h, 062h, 068h, 078h, 068h, 060h, 062h, 066h, 0feh, 000h, 000h, 000h, 000h
   545 00010E99 6266FE00000000      <1>
   546 00010EA0 0000FE666268786860- <1>     db  000h, 000h, 0feh, 066h, 062h, 068h, 078h, 068h, 060h, 060h, 060h, 0f0h, 000h, 000h, 000h, 000h
   546 00010EA9 6060F000000000      <1>
   547 00010EB0 00003C66C2C0C0DEC6- <1>     db  000h, 000h, 03ch, 066h, 0c2h, 0c0h, 0c0h, 0deh, 0c6h, 0c6h, 066h, 03ah, 000h, 000h, 000h, 000h
   547 00010EB9 C6663A00000000      <1>
   548 00010EC0 0000C6C6C6C6FEC6C6- <1>     db  000h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 0feh, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 000h, 000h, 000h, 000h
   548 00010EC9 C6C6C600000000      <1>
   549 00010ED0 00003C181818181818- <1>     db  000h, 000h, 03ch, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
   549 00010ED9 18183C00000000      <1>
   550 00010EE0 00001E0C0C0C0C0CCC- <1>     db  000h, 000h, 01eh, 00ch, 00ch, 00ch, 00ch, 00ch, 0cch, 0cch, 0cch, 078h, 000h, 000h, 000h, 000h
   550 00010EE9 CCCC7800000000      <1>
   551 00010EF0 0000E666666C78786C- <1>     db  000h, 000h, 0e6h, 066h, 066h, 06ch, 078h, 078h, 06ch, 066h, 066h, 0e6h, 000h, 000h, 000h, 000h
   551 00010EF9 6666E600000000      <1>
   552 00010F00 0000F0606060606060- <1>     db  000h, 000h, 0f0h, 060h, 060h, 060h, 060h, 060h, 060h, 062h, 066h, 0feh, 000h, 000h, 000h, 000h
   552 00010F09 6266FE00000000      <1>
   553 00010F10 0000C3E7FFFFDBC3C3- <1>     db  000h, 000h, 0c3h, 0e7h, 0ffh, 0ffh, 0dbh, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 000h, 000h, 000h, 000h
   553 00010F19 C3C3C300000000      <1>
   554 00010F20 0000C6E6F6FEDECEC6- <1>     db  000h, 000h, 0c6h, 0e6h, 0f6h, 0feh, 0deh, 0ceh, 0c6h, 0c6h, 0c6h, 0c6h, 000h, 000h, 000h, 000h
   554 00010F29 C6C6C600000000      <1>
   555 00010F30 00007CC6C6C6C6C6C6- <1>     db  000h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   555 00010F39 C6C67C00000000      <1>
   556 00010F40 0000FC6666667C6060- <1>     db  000h, 000h, 0fch, 066h, 066h, 066h, 07ch, 060h, 060h, 060h, 060h, 0f0h, 000h, 000h, 000h, 000h
   556 00010F49 6060F000000000      <1>
   557 00010F50 00007CC6C6C6C6C6C6- <1>     db  000h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0d6h, 0deh, 07ch, 00ch, 00eh, 000h, 000h
   557 00010F59 D6DE7C0C0E0000      <1>
   558 00010F60 0000FC6666667C6C66- <1>     db  000h, 000h, 0fch, 066h, 066h, 066h, 07ch, 06ch, 066h, 066h, 066h, 0e6h, 000h, 000h, 000h, 000h
   558 00010F69 6666E600000000      <1>
   559 00010F70 00007CC6C660380C06- <1>     db  000h, 000h, 07ch, 0c6h, 0c6h, 060h, 038h, 00ch, 006h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   559 00010F79 C6C67C00000000      <1>
   560 00010F80 0000FFDB9918181818- <1>     db  000h, 000h, 0ffh, 0dbh, 099h, 018h, 018h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
   560 00010F89 18183C00000000      <1>
   561 00010F90 0000C6C6C6C6C6C6C6- <1>     db  000h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   561 00010F99 C6C67C00000000      <1>
   562 00010FA0 0000C3C3C3C3C3C3C3- <1>     db  000h, 000h, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 066h, 03ch, 018h, 000h, 000h, 000h, 000h
   562 00010FA9 663C1800000000      <1>
   563 00010FB0 0000C3C3C3C3C3DBDB- <1>     db  000h, 000h, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 0dbh, 0dbh, 0ffh, 066h, 066h, 000h, 000h, 000h, 000h
   563 00010FB9 FF666600000000      <1>
   564 00010FC0 0000C3C3663C18183C- <1>     db  000h, 000h, 0c3h, 0c3h, 066h, 03ch, 018h, 018h, 03ch, 066h, 0c3h, 0c3h, 000h, 000h, 000h, 000h
   564 00010FC9 66C3C300000000      <1>
   565 00010FD0 0000C3C3C3663C1818- <1>     db  000h, 000h, 0c3h, 0c3h, 0c3h, 066h, 03ch, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
   565 00010FD9 18183C00000000      <1>
   566 00010FE0 0000FFC3860C183060- <1>     db  000h, 000h, 0ffh, 0c3h, 086h, 00ch, 018h, 030h, 060h, 0c1h, 0c3h, 0ffh, 000h, 000h, 000h, 000h
   566 00010FE9 C1C3FF00000000      <1>
   567 00010FF0 00003C303030303030- <1>     db  000h, 000h, 03ch, 030h, 030h, 030h, 030h, 030h, 030h, 030h, 030h, 03ch, 000h, 000h, 000h, 000h
   567 00010FF9 30303C00000000      <1>
   568 00011000 00000080C0E070381C- <1>     db  000h, 000h, 000h, 080h, 0c0h, 0e0h, 070h, 038h, 01ch, 00eh, 006h, 002h, 000h, 000h, 000h, 000h
   568 00011009 0E060200000000      <1>
   569 00011010 00003C0C0C0C0C0C0C- <1>     db  000h, 000h, 03ch, 00ch, 00ch, 00ch, 00ch, 00ch, 00ch, 00ch, 00ch, 03ch, 000h, 000h, 000h, 000h
   569 00011019 0C0C3C00000000      <1>
   570 00011020 10386CC60000000000- <1>     db  010h, 038h, 06ch, 0c6h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   570 00011029 00000000000000      <1>
   571 00011030 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ffh, 000h, 000h
   571 00011039 00000000FF0000      <1>
   572 00011040 303018000000000000- <1>     db  030h, 030h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   572 00011049 00000000000000      <1>
   573 00011050 0000000000780C7CCC- <1>     db  000h, 000h, 000h, 000h, 000h, 078h, 00ch, 07ch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
   573 00011059 CCCC7600000000      <1>
   574 00011060 0000E06060786C6666- <1>     db  000h, 000h, 0e0h, 060h, 060h, 078h, 06ch, 066h, 066h, 066h, 066h, 07ch, 000h, 000h, 000h, 000h
   574 00011069 66667C00000000      <1>
   575 00011070 00000000007CC6C0C0- <1>     db  000h, 000h, 000h, 000h, 000h, 07ch, 0c6h, 0c0h, 0c0h, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   575 00011079 C0C67C00000000      <1>
   576 00011080 00001C0C0C3C6CCCCC- <1>     db  000h, 000h, 01ch, 00ch, 00ch, 03ch, 06ch, 0cch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
   576 00011089 CCCC7600000000      <1>
   577 00011090 00000000007CC6FEC0- <1>     db  000h, 000h, 000h, 000h, 000h, 07ch, 0c6h, 0feh, 0c0h, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   577 00011099 C0C67C00000000      <1>
   578 000110A0 0000386C6460F06060- <1>     db  000h, 000h, 038h, 06ch, 064h, 060h, 0f0h, 060h, 060h, 060h, 060h, 0f0h, 000h, 000h, 000h, 000h
   578 000110A9 6060F000000000      <1>
   579 000110B0 000000000076CCCCCC- <1>     db  000h, 000h, 000h, 000h, 000h, 076h, 0cch, 0cch, 0cch, 0cch, 0cch, 07ch, 00ch, 0cch, 078h, 000h
   579 000110B9 CCCC7C0CCC7800      <1>
   580 000110C0 0000E060606C766666- <1>     db  000h, 000h, 0e0h, 060h, 060h, 06ch, 076h, 066h, 066h, 066h, 066h, 0e6h, 000h, 000h, 000h, 000h
   580 000110C9 6666E600000000      <1>
   581 000110D0 000018180038181818- <1>     db  000h, 000h, 018h, 018h, 000h, 038h, 018h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
   581 000110D9 18183C00000000      <1>
   582 000110E0 00000606000E060606- <1>     db  000h, 000h, 006h, 006h, 000h, 00eh, 006h, 006h, 006h, 006h, 006h, 006h, 066h, 066h, 03ch, 000h
   582 000110E9 06060666663C00      <1>
   583 000110F0 0000E06060666C7878- <1>     db  000h, 000h, 0e0h, 060h, 060h, 066h, 06ch, 078h, 078h, 06ch, 066h, 0e6h, 000h, 000h, 000h, 000h
   583 000110F9 6C66E600000000      <1>
   584 00011100 000038181818181818- <1>     db  000h, 000h, 038h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
   584 00011109 18183C00000000      <1>
   585 00011110 0000000000E6FFDBDB- <1>     db  000h, 000h, 000h, 000h, 000h, 0e6h, 0ffh, 0dbh, 0dbh, 0dbh, 0dbh, 0dbh, 000h, 000h, 000h, 000h
   585 00011119 DBDBDB00000000      <1>
   586 00011120 0000000000DC666666- <1>     db  000h, 000h, 000h, 000h, 000h, 0dch, 066h, 066h, 066h, 066h, 066h, 066h, 000h, 000h, 000h, 000h
   586 00011129 66666600000000      <1>
   587 00011130 00000000007CC6C6C6- <1>     db  000h, 000h, 000h, 000h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   587 00011139 C6C67C00000000      <1>
   588 00011140 0000000000DC666666- <1>     db  000h, 000h, 000h, 000h, 000h, 0dch, 066h, 066h, 066h, 066h, 066h, 07ch, 060h, 060h, 0f0h, 000h
   588 00011149 66667C6060F000      <1>
   589 00011150 000000000076CCCCCC- <1>     db  000h, 000h, 000h, 000h, 000h, 076h, 0cch, 0cch, 0cch, 0cch, 0cch, 07ch, 00ch, 00ch, 01eh, 000h
   589 00011159 CCCC7C0C0C1E00      <1>
   590 00011160 0000000000DC766660- <1>     db  000h, 000h, 000h, 000h, 000h, 0dch, 076h, 066h, 060h, 060h, 060h, 0f0h, 000h, 000h, 000h, 000h
   590 00011169 6060F000000000      <1>
   591 00011170 00000000007CC66038- <1>     db  000h, 000h, 000h, 000h, 000h, 07ch, 0c6h, 060h, 038h, 00ch, 0c6h, 07ch, 000h, 000h, 000h, 000h
   591 00011179 0CC67C00000000      <1>
   592 00011180 0000103030FC303030- <1>     db  000h, 000h, 010h, 030h, 030h, 0fch, 030h, 030h, 030h, 030h, 036h, 01ch, 000h, 000h, 000h, 000h
   592 00011189 30361C00000000      <1>
   593 00011190 0000000000CCCCCCCC- <1>     db  000h, 000h, 000h, 000h, 000h, 0cch, 0cch, 0cch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
   593 00011199 CCCC7600000000      <1>
   594 000111A0 0000000000C3C3C3C3- <1>     db  000h, 000h, 000h, 000h, 000h, 0c3h, 0c3h, 0c3h, 0c3h, 066h, 03ch, 018h, 000h, 000h, 000h, 000h
   594 000111A9 663C1800000000      <1>
   595 000111B0 0000000000C3C3C3DB- <1>     db  000h, 000h, 000h, 000h, 000h, 0c3h, 0c3h, 0c3h, 0dbh, 0dbh, 0ffh, 066h, 000h, 000h, 000h, 000h
   595 000111B9 DBFF6600000000      <1>
   596 000111C0 0000000000C3663C18- <1>     db  000h, 000h, 000h, 000h, 000h, 0c3h, 066h, 03ch, 018h, 03ch, 066h, 0c3h, 000h, 000h, 000h, 000h
   596 000111C9 3C66C300000000      <1>
   597 000111D0 0000000000C6C6C6C6- <1>     db  000h, 000h, 000h, 000h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07eh, 006h, 00ch, 0f8h, 000h
   597 000111D9 C6C67E060CF800      <1>
   598 000111E0 0000000000FECC1830- <1>     db  000h, 000h, 000h, 000h, 000h, 0feh, 0cch, 018h, 030h, 060h, 0c6h, 0feh, 000h, 000h, 000h, 000h
   598 000111E9 60C6FE00000000      <1>
   599 000111F0 00000E181818701818- <1>     db  000h, 000h, 00eh, 018h, 018h, 018h, 070h, 018h, 018h, 018h, 018h, 00eh, 000h, 000h, 000h, 000h
   599 000111F9 18180E00000000      <1>
   600 00011200 000018181818001818- <1>     db  000h, 000h, 018h, 018h, 018h, 018h, 000h, 018h, 018h, 018h, 018h, 018h, 000h, 000h, 000h, 000h
   600 00011209 18181800000000      <1>
   601 00011210 0000701818180E1818- <1>     db  000h, 000h, 070h, 018h, 018h, 018h, 00eh, 018h, 018h, 018h, 018h, 070h, 000h, 000h, 000h, 000h
   601 00011219 18187000000000      <1>
   602 00011220 000076DC0000000000- <1>     db  000h, 000h, 076h, 0dch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   602 00011229 00000000000000      <1>
   603 00011230 0000000010386CC6C6- <1>     db  000h, 000h, 000h, 000h, 010h, 038h, 06ch, 0c6h, 0c6h, 0c6h, 0feh, 000h, 000h, 000h, 000h, 000h
   603 00011239 C6FE0000000000      <1>
   604 00011240 00003C66C2C0C0C0C2- <1>     db  000h, 000h, 03ch, 066h, 0c2h, 0c0h, 0c0h, 0c0h, 0c2h, 066h, 03ch, 00ch, 006h, 07ch, 000h, 000h
   604 00011249 663C0C067C0000      <1>
   605 00011250 0000CC0000CCCCCCCC- <1>     db  000h, 000h, 0cch, 000h, 000h, 0cch, 0cch, 0cch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
   605 00011259 CCCC7600000000      <1>
   606 00011260 000C1830007CC6FEC0- <1>     db  000h, 00ch, 018h, 030h, 000h, 07ch, 0c6h, 0feh, 0c0h, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   606 00011269 C0C67C00000000      <1>
   607 00011270 0010386C00780C7CCC- <1>     db  000h, 010h, 038h, 06ch, 000h, 078h, 00ch, 07ch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
   607 00011279 CCCC7600000000      <1>
   608 00011280 0000CC0000780C7CCC- <1>     db  000h, 000h, 0cch, 000h, 000h, 078h, 00ch, 07ch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
   608 00011289 CCCC7600000000      <1>
   609 00011290 0060301800780C7CCC- <1>     db  000h, 060h, 030h, 018h, 000h, 078h, 00ch, 07ch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
   609 00011299 CCCC7600000000      <1>
   610 000112A0 00386C3800780C7CCC- <1>     db  000h, 038h, 06ch, 038h, 000h, 078h, 00ch, 07ch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
   610 000112A9 CCCC7600000000      <1>
   611 000112B0 000000003C66606066- <1>     db  000h, 000h, 000h, 000h, 03ch, 066h, 060h, 060h, 066h, 03ch, 00ch, 006h, 03ch, 000h, 000h, 000h
   611 000112B9 3C0C063C000000      <1>
   612 000112C0 0010386C007CC6FEC0- <1>     db  000h, 010h, 038h, 06ch, 000h, 07ch, 0c6h, 0feh, 0c0h, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   612 000112C9 C0C67C00000000      <1>
   613 000112D0 0000C600007CC6FEC0- <1>     db  000h, 000h, 0c6h, 000h, 000h, 07ch, 0c6h, 0feh, 0c0h, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   613 000112D9 C0C67C00000000      <1>
   614 000112E0 00603018007CC6FEC0- <1>     db  000h, 060h, 030h, 018h, 000h, 07ch, 0c6h, 0feh, 0c0h, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   614 000112E9 C0C67C00000000      <1>
   615 000112F0 000066000038181818- <1>     db  000h, 000h, 066h, 000h, 000h, 038h, 018h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
   615 000112F9 18183C00000000      <1>
   616 00011300 00183C660038181818- <1>     db  000h, 018h, 03ch, 066h, 000h, 038h, 018h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
   616 00011309 18183C00000000      <1>
   617 00011310 006030180038181818- <1>     db  000h, 060h, 030h, 018h, 000h, 038h, 018h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
   617 00011319 18183C00000000      <1>
   618 00011320 00C60010386CC6C6FE- <1>     db  000h, 0c6h, 000h, 010h, 038h, 06ch, 0c6h, 0c6h, 0feh, 0c6h, 0c6h, 0c6h, 000h, 000h, 000h, 000h
   618 00011329 C6C6C600000000      <1>
   619 00011330 386C3800386CC6C6FE- <1>     db  038h, 06ch, 038h, 000h, 038h, 06ch, 0c6h, 0c6h, 0feh, 0c6h, 0c6h, 0c6h, 000h, 000h, 000h, 000h
   619 00011339 C6C6C600000000      <1>
   620 00011340 18306000FE66607C60- <1>     db  018h, 030h, 060h, 000h, 0feh, 066h, 060h, 07ch, 060h, 060h, 066h, 0feh, 000h, 000h, 000h, 000h
   620 00011349 6066FE00000000      <1>
   621 00011350 00000000006E3B1B7E- <1>     db  000h, 000h, 000h, 000h, 000h, 06eh, 03bh, 01bh, 07eh, 0d8h, 0dch, 077h, 000h, 000h, 000h, 000h
   621 00011359 D8DC7700000000      <1>
   622 00011360 00003E6CCCCCFECCCC- <1>     db  000h, 000h, 03eh, 06ch, 0cch, 0cch, 0feh, 0cch, 0cch, 0cch, 0cch, 0ceh, 000h, 000h, 000h, 000h
   622 00011369 CCCCCE00000000      <1>
   623 00011370 0010386C007CC6C6C6- <1>     db  000h, 010h, 038h, 06ch, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   623 00011379 C6C67C00000000      <1>
   624 00011380 0000C600007CC6C6C6- <1>     db  000h, 000h, 0c6h, 000h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   624 00011389 C6C67C00000000      <1>
   625 00011390 00603018007CC6C6C6- <1>     db  000h, 060h, 030h, 018h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   625 00011399 C6C67C00000000      <1>
   626 000113A0 003078CC00CCCCCCCC- <1>     db  000h, 030h, 078h, 0cch, 000h, 0cch, 0cch, 0cch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
   626 000113A9 CCCC7600000000      <1>
   627 000113B0 0060301800CCCCCCCC- <1>     db  000h, 060h, 030h, 018h, 000h, 0cch, 0cch, 0cch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
   627 000113B9 CCCC7600000000      <1>
   628 000113C0 0000C60000C6C6C6C6- <1>     db  000h, 000h, 0c6h, 000h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07eh, 006h, 00ch, 078h, 000h
   628 000113C9 C6C67E060C7800      <1>
   629 000113D0 00C6007CC6C6C6C6C6- <1>     db  000h, 0c6h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   629 000113D9 C6C67C00000000      <1>
   630 000113E0 00C600C6C6C6C6C6C6- <1>     db  000h, 0c6h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   630 000113E9 C6C67C00000000      <1>
   631 000113F0 0018187EC3C0C0C0C3- <1>     db  000h, 018h, 018h, 07eh, 0c3h, 0c0h, 0c0h, 0c0h, 0c3h, 07eh, 018h, 018h, 000h, 000h, 000h, 000h
   631 000113F9 7E181800000000      <1>
   632 00011400 00386C6460F0606060- <1>     db  000h, 038h, 06ch, 064h, 060h, 0f0h, 060h, 060h, 060h, 060h, 0e6h, 0fch, 000h, 000h, 000h, 000h
   632 00011409 60E6FC00000000      <1>
   633 00011410 0000C3663C18FF18FF- <1>     db  000h, 000h, 0c3h, 066h, 03ch, 018h, 0ffh, 018h, 0ffh, 018h, 018h, 018h, 000h, 000h, 000h, 000h
   633 00011419 18181800000000      <1>
   634 00011420 00FC66667C62666F66- <1>     db  000h, 0fch, 066h, 066h, 07ch, 062h, 066h, 06fh, 066h, 066h, 066h, 0f3h, 000h, 000h, 000h, 000h
   634 00011429 6666F300000000      <1>
   635 00011430 000E1B1818187E1818- <1>     db  000h, 00eh, 01bh, 018h, 018h, 018h, 07eh, 018h, 018h, 018h, 018h, 018h, 0d8h, 070h, 000h, 000h
   635 00011439 181818D8700000      <1>
   636 00011440 0018306000780C7CCC- <1>     db  000h, 018h, 030h, 060h, 000h, 078h, 00ch, 07ch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
   636 00011449 CCCC7600000000      <1>
   637 00011450 000C18300038181818- <1>     db  000h, 00ch, 018h, 030h, 000h, 038h, 018h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
   637 00011459 18183C00000000      <1>
   638 00011460 00183060007CC6C6C6- <1>     db  000h, 018h, 030h, 060h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   638 00011469 C6C67C00000000      <1>
   639 00011470 0018306000CCCCCCCC- <1>     db  000h, 018h, 030h, 060h, 000h, 0cch, 0cch, 0cch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
   639 00011479 CCCC7600000000      <1>
   640 00011480 000076DC00DC666666- <1>     db  000h, 000h, 076h, 0dch, 000h, 0dch, 066h, 066h, 066h, 066h, 066h, 066h, 000h, 000h, 000h, 000h
   640 00011489 66666600000000      <1>
   641 00011490 76DC00C6E6F6FEDECE- <1>     db  076h, 0dch, 000h, 0c6h, 0e6h, 0f6h, 0feh, 0deh, 0ceh, 0c6h, 0c6h, 0c6h, 000h, 000h, 000h, 000h
   641 00011499 C6C6C600000000      <1>
   642 000114A0 003C6C6C3E007E0000- <1>     db  000h, 03ch, 06ch, 06ch, 03eh, 000h, 07eh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   642 000114A9 00000000000000      <1>
   643 000114B0 00386C6C38007C0000- <1>     db  000h, 038h, 06ch, 06ch, 038h, 000h, 07ch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   643 000114B9 00000000000000      <1>
   644 000114C0 0000303000303060C0- <1>     db  000h, 000h, 030h, 030h, 000h, 030h, 030h, 060h, 0c0h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   644 000114C9 C6C67C00000000      <1>
   645 000114D0 000000000000FEC0C0- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 0feh, 0c0h, 0c0h, 0c0h, 0c0h, 000h, 000h, 000h, 000h, 000h
   645 000114D9 C0C00000000000      <1>
   646 000114E0 000000000000FE0606- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 0feh, 006h, 006h, 006h, 006h, 000h, 000h, 000h, 000h, 000h
   646 000114E9 06060000000000      <1>
   647 000114F0 00C0C0C2C6CC183060- <1>     db  000h, 0c0h, 0c0h, 0c2h, 0c6h, 0cch, 018h, 030h, 060h, 0ceh, 09bh, 006h, 00ch, 01fh, 000h, 000h
   647 000114F9 CE9B060C1F0000      <1>
   648 00011500 00C0C0C2C6CC183066- <1>     db  000h, 0c0h, 0c0h, 0c2h, 0c6h, 0cch, 018h, 030h, 066h, 0ceh, 096h, 03eh, 006h, 006h, 000h, 000h
   648 00011509 CE963E06060000      <1>
   649 00011510 00001818001818183C- <1>     db  000h, 000h, 018h, 018h, 000h, 018h, 018h, 018h, 03ch, 03ch, 03ch, 018h, 000h, 000h, 000h, 000h
   649 00011519 3C3C1800000000      <1>
   650 00011520 0000000000366CD86C- <1>     db  000h, 000h, 000h, 000h, 000h, 036h, 06ch, 0d8h, 06ch, 036h, 000h, 000h, 000h, 000h, 000h, 000h
   650 00011529 36000000000000      <1>
   651 00011530 0000000000D86C366C- <1>     db  000h, 000h, 000h, 000h, 000h, 0d8h, 06ch, 036h, 06ch, 0d8h, 000h, 000h, 000h, 000h, 000h, 000h
   651 00011539 D8000000000000      <1>
   652 00011540 114411441144114411- <1>     db  011h, 044h, 011h, 044h, 011h, 044h, 011h, 044h, 011h, 044h, 011h, 044h, 011h, 044h, 011h, 044h
   652 00011549 44114411441144      <1>
   653 00011550 55AA55AA55AA55AA55- <1>     db  055h, 0aah, 055h, 0aah, 055h, 0aah, 055h, 0aah, 055h, 0aah, 055h, 0aah, 055h, 0aah, 055h, 0aah
   653 00011559 AA55AA55AA55AA      <1>
   654 00011560 DD77DD77DD77DD77DD- <1>     db  0ddh, 077h, 0ddh, 077h, 0ddh, 077h, 0ddh, 077h, 0ddh, 077h, 0ddh, 077h, 0ddh, 077h, 0ddh, 077h
   654 00011569 77DD77DD77DD77      <1>
   655 00011570 181818181818181818- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
   655 00011579 18181818181818      <1>
   656 00011580 18181818181818F818- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 0f8h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
   656 00011589 18181818181818      <1>
   657 00011590 1818181818F818F818- <1>     db  018h, 018h, 018h, 018h, 018h, 0f8h, 018h, 0f8h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
   657 00011599 18181818181818      <1>
   658 000115A0 36363636363636F636- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 0f6h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
   658 000115A9 36363636363636      <1>
   659 000115B0 00000000000000FE36- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 0feh, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
   659 000115B9 36363636363636      <1>
   660 000115C0 0000000000F818F818- <1>     db  000h, 000h, 000h, 000h, 000h, 0f8h, 018h, 0f8h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
   660 000115C9 18181818181818      <1>
   661 000115D0 3636363636F606F636- <1>     db  036h, 036h, 036h, 036h, 036h, 0f6h, 006h, 0f6h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
   661 000115D9 36363636363636      <1>
   662 000115E0 363636363636363636- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
   662 000115E9 36363636363636      <1>
   663 000115F0 0000000000FE06F636- <1>     db  000h, 000h, 000h, 000h, 000h, 0feh, 006h, 0f6h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
   663 000115F9 36363636363636      <1>
   664 00011600 3636363636F606FE00- <1>     db  036h, 036h, 036h, 036h, 036h, 0f6h, 006h, 0feh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   664 00011609 00000000000000      <1>
   665 00011610 36363636363636FE00- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 0feh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   665 00011619 00000000000000      <1>
   666 00011620 1818181818F818F800- <1>     db  018h, 018h, 018h, 018h, 018h, 0f8h, 018h, 0f8h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   666 00011629 00000000000000      <1>
   667 00011630 00000000000000F818- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 0f8h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
   667 00011639 18181818181818      <1>
   668 00011640 181818181818181F00- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 01fh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   668 00011649 00000000000000      <1>
   669 00011650 18181818181818FF00- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   669 00011659 00000000000000      <1>
   670 00011660 00000000000000FF18- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ffh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
   670 00011669 18181818181818      <1>
   671 00011670 181818181818181F18- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 01fh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
   671 00011679 18181818181818      <1>
   672 00011680 00000000000000FF00- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   672 00011689 00000000000000      <1>
   673 00011690 18181818181818FF18- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 0ffh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
   673 00011699 18181818181818      <1>
   674 000116A0 18181818181F181F18- <1>     db  018h, 018h, 018h, 018h, 018h, 01fh, 018h, 01fh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
   674 000116A9 18181818181818      <1>
   675 000116B0 363636363636363736- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 037h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
   675 000116B9 36363636363636      <1>
   676 000116C0 363636363637303F00- <1>     db  036h, 036h, 036h, 036h, 036h, 037h, 030h, 03fh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   676 000116C9 00000000000000      <1>
   677 000116D0 00000000003F303736- <1>     db  000h, 000h, 000h, 000h, 000h, 03fh, 030h, 037h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
   677 000116D9 36363636363636      <1>
   678 000116E0 3636363636F700FF00- <1>     db  036h, 036h, 036h, 036h, 036h, 0f7h, 000h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   678 000116E9 00000000000000      <1>
   679 000116F0 0000000000FF00F736- <1>     db  000h, 000h, 000h, 000h, 000h, 0ffh, 000h, 0f7h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
   679 000116F9 36363636363636      <1>
   680 00011700 363636363637303736- <1>     db  036h, 036h, 036h, 036h, 036h, 037h, 030h, 037h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
   680 00011709 36363636363636      <1>
   681 00011710 0000000000FF00FF00- <1>     db  000h, 000h, 000h, 000h, 000h, 0ffh, 000h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   681 00011719 00000000000000      <1>
   682 00011720 3636363636F700F736- <1>     db  036h, 036h, 036h, 036h, 036h, 0f7h, 000h, 0f7h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
   682 00011729 36363636363636      <1>
   683 00011730 1818181818FF00FF00- <1>     db  018h, 018h, 018h, 018h, 018h, 0ffh, 000h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   683 00011739 00000000000000      <1>
   684 00011740 36363636363636FF00- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   684 00011749 00000000000000      <1>
   685 00011750 0000000000FF00FF18- <1>     db  000h, 000h, 000h, 000h, 000h, 0ffh, 000h, 0ffh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
   685 00011759 18181818181818      <1>
   686 00011760 00000000000000FF36- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ffh, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
   686 00011769 36363636363636      <1>
   687 00011770 363636363636363F00- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 03fh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   687 00011779 00000000000000      <1>
   688 00011780 18181818181F181F00- <1>     db  018h, 018h, 018h, 018h, 018h, 01fh, 018h, 01fh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   688 00011789 00000000000000      <1>
   689 00011790 00000000001F181F18- <1>     db  000h, 000h, 000h, 000h, 000h, 01fh, 018h, 01fh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
   689 00011799 18181818181818      <1>
   690 000117A0 000000000000003F36- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 03fh, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
   690 000117A9 36363636363636      <1>
   691 000117B0 36363636363636FF36- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 0ffh, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
   691 000117B9 36363636363636      <1>
   692 000117C0 1818181818FF18FF18- <1>     db  018h, 018h, 018h, 018h, 018h, 0ffh, 018h, 0ffh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
   692 000117C9 18181818181818      <1>
   693 000117D0 18181818181818F800- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 0f8h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   693 000117D9 00000000000000      <1>
   694 000117E0 000000000000001F18- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 01fh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
   694 000117E9 18181818181818      <1>
   695 000117F0 FFFFFFFFFFFFFFFFFF- <1>     db  0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh
   695 000117F9 FFFFFFFFFFFFFF      <1>
   696 00011800 00000000000000FFFF- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh
   696 00011809 FFFFFFFFFFFFFF      <1>
   697 00011810 F0F0F0F0F0F0F0F0F0- <1>     db  0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h
   697 00011819 F0F0F0F0F0F0F0      <1>
   698 00011820 0F0F0F0F0F0F0F0F0F- <1>     db  00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh
   698 00011829 0F0F0F0F0F0F0F      <1>
   699 00011830 FFFFFFFFFFFFFF0000- <1>     db  0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   699 00011839 00000000000000      <1>
   700 00011840 000000000076DCD8D8- <1>     db  000h, 000h, 000h, 000h, 000h, 076h, 0dch, 0d8h, 0d8h, 0d8h, 0dch, 076h, 000h, 000h, 000h, 000h
   700 00011849 D8DC7600000000      <1>
   701 00011850 000078CCCCCCD8CCC6- <1>     db  000h, 000h, 078h, 0cch, 0cch, 0cch, 0d8h, 0cch, 0c6h, 0c6h, 0c6h, 0cch, 000h, 000h, 000h, 000h
   701 00011859 C6C6CC00000000      <1>
   702 00011860 0000FEC6C6C0C0C0C0- <1>     db  000h, 000h, 0feh, 0c6h, 0c6h, 0c0h, 0c0h, 0c0h, 0c0h, 0c0h, 0c0h, 0c0h, 000h, 000h, 000h, 000h
   702 00011869 C0C0C000000000      <1>
   703 00011870 00000000FE6C6C6C6C- <1>     db  000h, 000h, 000h, 000h, 0feh, 06ch, 06ch, 06ch, 06ch, 06ch, 06ch, 06ch, 000h, 000h, 000h, 000h
   703 00011879 6C6C6C00000000      <1>
   704 00011880 000000FEC660301830- <1>     db  000h, 000h, 000h, 0feh, 0c6h, 060h, 030h, 018h, 030h, 060h, 0c6h, 0feh, 000h, 000h, 000h, 000h
   704 00011889 60C6FE00000000      <1>
   705 00011890 00000000007ED8D8D8- <1>     db  000h, 000h, 000h, 000h, 000h, 07eh, 0d8h, 0d8h, 0d8h, 0d8h, 0d8h, 070h, 000h, 000h, 000h, 000h
   705 00011899 D8D87000000000      <1>
   706 000118A0 000000006666666666- <1>     db  000h, 000h, 000h, 000h, 066h, 066h, 066h, 066h, 066h, 07ch, 060h, 060h, 0c0h, 000h, 000h, 000h
   706 000118A9 7C6060C0000000      <1>
   707 000118B0 0000000076DC181818- <1>     db  000h, 000h, 000h, 000h, 076h, 0dch, 018h, 018h, 018h, 018h, 018h, 018h, 000h, 000h, 000h, 000h
   707 000118B9 18181800000000      <1>
   708 000118C0 0000007E183C666666- <1>     db  000h, 000h, 000h, 07eh, 018h, 03ch, 066h, 066h, 066h, 03ch, 018h, 07eh, 000h, 000h, 000h, 000h
   708 000118C9 3C187E00000000      <1>
   709 000118D0 000000386CC6C6FEC6- <1>     db  000h, 000h, 000h, 038h, 06ch, 0c6h, 0c6h, 0feh, 0c6h, 0c6h, 06ch, 038h, 000h, 000h, 000h, 000h
   709 000118D9 C66C3800000000      <1>
   710 000118E0 0000386CC6C6C66C6C- <1>     db  000h, 000h, 038h, 06ch, 0c6h, 0c6h, 0c6h, 06ch, 06ch, 06ch, 06ch, 0eeh, 000h, 000h, 000h, 000h
   710 000118E9 6C6CEE00000000      <1>
   711 000118F0 00001E30180C3E6666- <1>     db  000h, 000h, 01eh, 030h, 018h, 00ch, 03eh, 066h, 066h, 066h, 066h, 03ch, 000h, 000h, 000h, 000h
   711 000118F9 66663C00000000      <1>
   712 00011900 00000000007EDBDBDB- <1>     db  000h, 000h, 000h, 000h, 000h, 07eh, 0dbh, 0dbh, 0dbh, 07eh, 000h, 000h, 000h, 000h, 000h, 000h
   712 00011909 7E000000000000      <1>
   713 00011910 00000003067EDBDBF3- <1>     db  000h, 000h, 000h, 003h, 006h, 07eh, 0dbh, 0dbh, 0f3h, 07eh, 060h, 0c0h, 000h, 000h, 000h, 000h
   713 00011919 7E60C000000000      <1>
   714 00011920 00001C3060607C6060- <1>     db  000h, 000h, 01ch, 030h, 060h, 060h, 07ch, 060h, 060h, 060h, 030h, 01ch, 000h, 000h, 000h, 000h
   714 00011929 60301C00000000      <1>
   715 00011930 0000007CC6C6C6C6C6- <1>     db  000h, 000h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 000h, 000h, 000h, 000h
   715 00011939 C6C6C600000000      <1>
   716 00011940 00000000FE0000FE00- <1>     db  000h, 000h, 000h, 000h, 0feh, 000h, 000h, 0feh, 000h, 000h, 0feh, 000h, 000h, 000h, 000h, 000h
   716 00011949 00FE0000000000      <1>
   717 00011950 0000000018187E1818- <1>     db  000h, 000h, 000h, 000h, 018h, 018h, 07eh, 018h, 018h, 000h, 000h, 0ffh, 000h, 000h, 000h, 000h
   717 00011959 0000FF00000000      <1>
   718 00011960 00000030180C060C18- <1>     db  000h, 000h, 000h, 030h, 018h, 00ch, 006h, 00ch, 018h, 030h, 000h, 07eh, 000h, 000h, 000h, 000h
   718 00011969 30007E00000000      <1>
   719 00011970 0000000C1830603018- <1>     db  000h, 000h, 000h, 00ch, 018h, 030h, 060h, 030h, 018h, 00ch, 000h, 07eh, 000h, 000h, 000h, 000h
   719 00011979 0C007E00000000      <1>
   720 00011980 00000E1B1B18181818- <1>     db  000h, 000h, 00eh, 01bh, 01bh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
   720 00011989 18181818181818      <1>
   721 00011990 1818181818181818D8- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 0d8h, 0d8h, 0d8h, 070h, 000h, 000h, 000h, 000h
   721 00011999 D8D87000000000      <1>
   722 000119A0 000000001818007E00- <1>     db  000h, 000h, 000h, 000h, 018h, 018h, 000h, 07eh, 000h, 018h, 018h, 000h, 000h, 000h, 000h, 000h
   722 000119A9 18180000000000      <1>
   723 000119B0 000000000076DC0076- <1>     db  000h, 000h, 000h, 000h, 000h, 076h, 0dch, 000h, 076h, 0dch, 000h, 000h, 000h, 000h, 000h, 000h
   723 000119B9 DC000000000000      <1>
   724 000119C0 00386C6C3800000000- <1>     db  000h, 038h, 06ch, 06ch, 038h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   724 000119C9 00000000000000      <1>
   725 000119D0 000000000000001818- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   725 000119D9 00000000000000      <1>
   726 000119E0 000000000000000018- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   726 000119E9 00000000000000      <1>
   727 000119F0 000F0C0C0C0C0CEC6C- <1>     db  000h, 00fh, 00ch, 00ch, 00ch, 00ch, 00ch, 0ech, 06ch, 06ch, 03ch, 01ch, 000h, 000h, 000h, 000h
   727 000119F9 6C3C1C00000000      <1>
   728 00011A00 00D86C6C6C6C6C0000- <1>     db  000h, 0d8h, 06ch, 06ch, 06ch, 06ch, 06ch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   728 00011A09 00000000000000      <1>
   729 00011A10 0070D83060C8F80000- <1>     db  000h, 070h, 0d8h, 030h, 060h, 0c8h, 0f8h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   729 00011A19 00000000000000      <1>
   730 00011A20 000000007C7C7C7C7C- <1>     db  000h, 000h, 000h, 000h, 07ch, 07ch, 07ch, 07ch, 07ch, 07ch, 07ch, 000h, 000h, 000h, 000h, 000h
   730 00011A29 7C7C0000000000      <1>
   731 00011A30 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   731 00011A39 00000000000000      <1>
   732                              <1> vgafont14alt:
   733 00011A40 1D000000002466FF66- <1>     db  01dh, 000h, 000h, 000h, 000h, 024h, 066h, 0ffh, 066h, 024h, 000h, 000h, 000h, 000h, 000h, 022h
   733 00011A49 24000000000022      <1>
   734 00011A50 006363632200000000- <1>     db  000h, 063h, 063h, 063h, 022h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 02bh, 000h
   734 00011A59 00000000002B00      <1>
   735 00011A60 0000181818FF181818- <1>     db  000h, 000h, 018h, 018h, 018h, 0ffh, 018h, 018h, 018h, 000h, 000h, 000h, 000h, 02dh, 000h, 000h
   735 00011A69 000000002D0000      <1>
   736 00011A70 00000000FF00000000- <1>     db  000h, 000h, 000h, 000h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 04dh, 000h, 000h, 0c3h
   736 00011A79 0000004D0000C3      <1>
   737 00011A80 E7FFDBC3C3C3C3C300- <1>     db  0e7h, 0ffh, 0dbh, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 000h, 000h, 000h, 054h, 000h, 000h, 0ffh, 0dbh
   737 00011A89 0000540000FFDB      <1>
   738 00011A90 9918181818183C0000- <1>     db  099h, 018h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 056h, 000h, 000h, 0c3h, 0c3h, 0c3h
   738 00011A99 00560000C3C3C3      <1>
   739 00011AA0 C3C3C3663C18000000- <1>     db  0c3h, 0c3h, 0c3h, 066h, 03ch, 018h, 000h, 000h, 000h, 057h, 000h, 000h, 0c3h, 0c3h, 0c3h, 0c3h
   739 00011AA9 570000C3C3C3C3      <1>
   740 00011AB0 DBDBFF666600000058- <1>     db  0dbh, 0dbh, 0ffh, 066h, 066h, 000h, 000h, 000h, 058h, 000h, 000h, 0c3h, 0c3h, 066h, 03ch, 018h
   740 00011AB9 0000C3C3663C18      <1>
   741 00011AC0 3C66C3C30000005900- <1>     db  03ch, 066h, 0c3h, 0c3h, 000h, 000h, 000h, 059h, 000h, 000h, 0c3h, 0c3h, 0c3h, 066h, 03ch, 018h
   741 00011AC9 00C3C3C3663C18      <1>
   742 00011AD0 18183C0000005A0000- <1>     db  018h, 018h, 03ch, 000h, 000h, 000h, 05ah, 000h, 000h, 0ffh, 0c3h, 086h, 00ch, 018h, 030h, 061h
   742 00011AD9 FFC3860C183061      <1>
   743 00011AE0 C3FF0000006D000000- <1>     db  0c3h, 0ffh, 000h, 000h, 000h, 06dh, 000h, 000h, 000h, 000h, 000h, 0e6h, 0ffh, 0dbh, 0dbh, 0dbh
   743 00011AE9 0000E6FFDBDBDB      <1>
   744 00011AF0 DB0000007600000000- <1>     db  0dbh, 000h, 000h, 000h, 076h, 000h, 000h, 000h, 000h, 000h, 0c3h, 0c3h, 0c3h, 066h, 03ch, 018h
   744 00011AF9 00C3C3C3663C18      <1>
   745 00011B00 000000770000000000- <1>     db  000h, 000h, 000h, 077h, 000h, 000h, 000h, 000h, 000h, 0c3h, 0c3h, 0dbh, 0dbh, 0ffh, 066h, 000h
   745 00011B09 C3C3DBDBFF6600      <1>
   746 00011B10 000091000000006E3B- <1>     db  000h, 000h, 091h, 000h, 000h, 000h, 000h, 06eh, 03bh, 01bh, 07eh, 0d8h, 0dch, 077h, 000h, 000h
   746 00011B19 1B7ED8DC770000      <1>
   747 00011B20 009B0018187EC3C0C0- <1>     db  000h, 09bh, 000h, 018h, 018h, 07eh, 0c3h, 0c0h, 0c0h, 0c3h, 07eh, 018h, 018h, 000h, 000h, 000h
   747 00011B29 C37E1818000000      <1>
   748 00011B30 9D0000C3663C18FF18- <1>     db  09dh, 000h, 000h, 0c3h, 066h, 03ch, 018h, 0ffh, 018h, 0ffh, 018h, 018h, 000h, 000h, 000h, 09eh
   748 00011B39 FF18180000009E      <1>
   749 00011B40 00FC66667C62666F66- <1>     db  000h, 0fch, 066h, 066h, 07ch, 062h, 066h, 06fh, 066h, 066h, 0f3h, 000h, 000h, 000h, 0f1h, 000h
   749 00011B49 66F3000000F100      <1>
   750 00011B50 00181818FF18181800- <1>     db  000h, 018h, 018h, 018h, 0ffh, 018h, 018h, 018h, 000h, 0ffh, 000h, 000h, 000h, 0f6h, 000h, 000h
   750 00011B59 FF000000F60000      <1>
   751 00011B60 18180000FF00001818- <1>     db  018h, 018h, 000h, 000h, 0ffh, 000h, 000h, 018h, 018h, 000h, 000h, 000h, 000h
   751 00011B69 00000000            <1>
   752                              <1> vgafont16alt:
   753 00011B6D 1D00000000002466FF- <1>     db  01dh, 000h, 000h, 000h, 000h, 000h, 024h, 066h, 0ffh, 066h, 024h, 000h, 000h, 000h, 000h, 000h
   753 00011B76 66240000000000      <1>
   754 00011B7D 003000003C66C3C3DB- <1>     db  000h, 030h, 000h, 000h, 03ch, 066h, 0c3h, 0c3h, 0dbh, 0dbh, 0c3h, 0c3h, 066h, 03ch, 000h, 000h
   754 00011B86 DBC3C3663C0000      <1>
   755 00011B8D 00004D0000C3E7FFFF- <1>     db  000h, 000h, 04dh, 000h, 000h, 0c3h, 0e7h, 0ffh, 0ffh, 0dbh, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 000h
   755 00011B96 DBC3C3C3C3C300      <1>
   756 00011B9D 000000540000FFDB99- <1>     db  000h, 000h, 000h, 054h, 000h, 000h, 0ffh, 0dbh, 099h, 018h, 018h, 018h, 018h, 018h, 018h, 03ch
   756 00011BA6 1818181818183C      <1>
   757 00011BAD 00000000560000C3C3- <1>     db  000h, 000h, 000h, 000h, 056h, 000h, 000h, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 066h, 03ch
   757 00011BB6 C3C3C3C3C3663C      <1>
   758 00011BBD 1800000000570000C3- <1>     db  018h, 000h, 000h, 000h, 000h, 057h, 000h, 000h, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 0dbh, 0dbh, 0ffh
   758 00011BC6 C3C3C3C3DBDBFF      <1>
   759 00011BCD 666600000000580000- <1>     db  066h, 066h, 000h, 000h, 000h, 000h, 058h, 000h, 000h, 0c3h, 0c3h, 066h, 03ch, 018h, 018h, 03ch
   759 00011BD6 C3C3663C18183C      <1>
   760 00011BDD 66C3C3000000005900- <1>     db  066h, 0c3h, 0c3h, 000h, 000h, 000h, 000h, 059h, 000h, 000h, 0c3h, 0c3h, 0c3h, 066h, 03ch, 018h
   760 00011BE6 00C3C3C3663C18      <1>
   761 00011BED 1818183C000000005A- <1>     db  018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h, 05ah, 000h, 000h, 0ffh, 0c3h, 086h, 00ch, 018h
   761 00011BF6 0000FFC3860C18      <1>
   762 00011BFD 3060C1C3FF00000000- <1>     db  030h, 060h, 0c1h, 0c3h, 0ffh, 000h, 000h, 000h, 000h, 06dh, 000h, 000h, 000h, 000h, 000h, 0e6h
   762 00011C06 6D0000000000E6      <1>
   763 00011C0D FFDBDBDBDBDB000000- <1>     db  0ffh, 0dbh, 0dbh, 0dbh, 0dbh, 0dbh, 000h, 000h, 000h, 000h, 076h, 000h, 000h, 000h, 000h, 000h
   763 00011C16 00760000000000      <1>
   764 00011C1D C3C3C3C3663C180000- <1>     db  0c3h, 0c3h, 0c3h, 0c3h, 066h, 03ch, 018h, 000h, 000h, 000h, 000h, 077h, 000h, 000h, 000h, 000h
   764 00011C26 00007700000000      <1>
   765 00011C2D 00C3C3C3DBDBFF6600- <1>     db  000h, 0c3h, 0c3h, 0c3h, 0dbh, 0dbh, 0ffh, 066h, 000h, 000h, 000h, 000h, 078h, 000h, 000h, 000h
   765 00011C36 00000078000000      <1>
   766 00011C3D 0000C3663C183C66C3- <1>     db  000h, 000h, 0c3h, 066h, 03ch, 018h, 03ch, 066h, 0c3h, 000h, 000h, 000h, 000h, 091h, 000h, 000h
   766 00011C46 00000000910000      <1>
   767 00011C4D 0000006E3B1B7ED8DC- <1>     db  000h, 000h, 000h, 06eh, 03bh, 01bh, 07eh, 0d8h, 0dch, 077h, 000h, 000h, 000h, 000h, 09bh, 000h
   767 00011C56 77000000009B00      <1>
   768 00011C5D 18187EC3C0C0C0C37E- <1>     db  018h, 018h, 07eh, 0c3h, 0c0h, 0c0h, 0c0h, 0c3h, 07eh, 018h, 018h, 000h, 000h, 000h, 000h, 09dh
   768 00011C66 1818000000009D      <1>
   769 00011C6D 0000C3663C18FF18FF- <1>     db  000h, 000h, 0c3h, 066h, 03ch, 018h, 0ffh, 018h, 0ffh, 018h, 018h, 018h, 000h, 000h, 000h, 000h
   769 00011C76 18181800000000      <1>
   770 00011C7D 9E00FC66667C62666F- <1>     db  09eh, 000h, 0fch, 066h, 066h, 07ch, 062h, 066h, 06fh, 066h, 066h, 066h, 0f3h, 000h, 000h, 000h
   770 00011C86 666666F3000000      <1>
   771 00011C8D 00AB00C0C0C2C6CC18- <1>     db  000h, 0abh, 000h, 0c0h, 0c0h, 0c2h, 0c6h, 0cch, 018h, 030h, 060h, 0ceh, 09bh, 006h, 00ch, 01fh
   771 00011C96 3060CE9B060C1F      <1>
   772 00011C9D 0000AC00C0C0C2C6CC- <1>     db  000h, 000h, 0ach, 000h, 0c0h, 0c0h, 0c2h, 0c6h, 0cch, 018h, 030h, 066h, 0ceh, 096h, 03eh, 006h
   772 00011CA6 183066CE963E06      <1>
   773 00011CAD 06000000            <1>     db  006h, 000h, 000h, 000h
  2415                                  
  2416 00011CB1 90<rept>                align 16
  2417                                  
  2418                                  KERNELFSIZE  equ $  ; 04/07/2016
  2419                                  
  2420                                  
  2421                                  bss_start:
  2422                                  
  2423                                  ABSOLUTE bss_start
  2424                                  
  2425                                  	; 15/04/2016
  2426                                  	; TRDOS 386 (TRDOS v2.0)
  2427                                  	; 	80 interrupts 	
  2428                                  	; 11/03/2015
  2429                                  	; Interrupt Descriptor Table (20/08/2014)
  2430                                  idt:
  2431                                  	;resb	64*8 ; INT 0 to INT 3Fh
  2432                                  	; 15/04/2016
  2433 00011CC0 <res 00000280>          	resb	80*8 ; INT 0 to INT 4Fh
  2434                                  
  2435                                  idt_end:
  2436                                  
  2437                                  ;alignb 4
  2438                                  
  2439                                  task_state_segment:
  2440                                  	; 24/03/2015
  2441 00011F40 <res 00000002>          tss.link:   resw 1
  2442 00011F42 <res 00000002>          	    resw 1
  2443                                  ; tss offset 4	
  2444 00011F44 <res 00000004>          tss.esp0:   resd 1
  2445 00011F48 <res 00000002>          tss.ss0:    resw 1
  2446 00011F4A <res 00000002>          	    resw 1	
  2447 00011F4C <res 00000004>          tss.esp1:   resd 1
  2448 00011F50 <res 00000002>          tss.ss1:    resw 1
  2449 00011F52 <res 00000002>          	    resw 1 	
  2450 00011F54 <res 00000004>          tss.esp2:   resd 1
  2451 00011F58 <res 00000002>          tss.ss2:    resw 1
  2452 00011F5A <res 00000002>          	    resw 1
  2453                                  ; tss offset 28
  2454 00011F5C <res 00000004>          tss.CR3:    resd 1
  2455 00011F60 <res 00000004>          tss.eip:    resd 1
  2456 00011F64 <res 00000004>          tss.eflags: resd 1
  2457                                  ; tss offset 40
  2458 00011F68 <res 00000004>          tss.eax:    resd 1		 		
  2459 00011F6C <res 00000004>          tss.ecx:    resd 1
  2460 00011F70 <res 00000004>          tss.edx:    resd 1
  2461 00011F74 <res 00000004>          tss.ebx:    resd 1
  2462 00011F78 <res 00000004>          tss.esp:    resd 1
  2463 00011F7C <res 00000004>          tss.ebp:    resd 1
  2464 00011F80 <res 00000004>          tss.esi:    resd 1
  2465 00011F84 <res 00000004>          tss.edi:    resd 1
  2466                                  ; tss offset 72
  2467 00011F88 <res 00000002>          tss.ES:     resw 1
  2468 00011F8A <res 00000002>          	    resw 1	
  2469 00011F8C <res 00000002>          tss.CS:	    resw 1
  2470 00011F8E <res 00000002>          	    resw 1
  2471 00011F90 <res 00000002>          tss.SS:	    resw 1
  2472 00011F92 <res 00000002>          	    resw 1
  2473 00011F94 <res 00000002>          tss.DS:	    resw 1
  2474 00011F96 <res 00000002>          	    resw 1
  2475 00011F98 <res 00000002>          tss.FS:	    resw 1
  2476 00011F9A <res 00000002>          	    resw 1
  2477 00011F9C <res 00000002>          tss.GS:	    resw 1
  2478 00011F9E <res 00000002>          	    resw 1		
  2479 00011FA0 <res 00000002>          tss.LDTR:   resw 1
  2480 00011FA2 <res 00000002>          	    resw 1
  2481                                  ; tss offset 100		
  2482 00011FA4 <res 00000002>          	    resw 1		
  2483 00011FA6 <res 00000002>          tss.IOPB:   resw 1
  2484                                  ; tss offset 104 
  2485                                  tss_end:
  2486                                  
  2487 00011FA8 <res 00000004>          k_page_dir:  resd 1 ; Kernel's (System) Page Directory address
  2488                                  		    ; (Physical address = Virtual address)	 	
  2489 00011FAC <res 00000004>          memory_size: resd 1 ; memory size in pages
  2490 00011FB0 <res 00000004>          free_pages:  resd 1 ; number of free pages		
  2491 00011FB4 <res 00000004>          next_page:   resd 1 ; offset value in M.A.T. for
  2492                                  		    ; first free page search
  2493 00011FB8 <res 00000004>          last_page:   resd 1 ; offset value in M.A.T. which
  2494                                  		    ; next free page search will be
  2495                                  		    ; stopped after it. (end of M.A.T.)
  2496 00011FBC <res 00000004>          first_page:  resd 1 ; offset value in M.A.T. which
  2497                                  		    ; first free page search
  2498                                  		    ; will be started on it. (for user)
  2499 00011FC0 <res 00000004>          mat_size:    resd 1 ; Memory Allocation Table size in pages		
  2500                                  
  2501                                  ; 02/09/2014 (Retro UNIX 386 v1)
  2502                                  ; 04/12/2013 (Retro UNIX 8086 v1)
  2503 00011FC4 <res 00000002>          CRT_START:   resw 1 	  ; starting address in regen buffer
  2504                                  			  ; NOTE: active page only	
  2505 00011FC6 <res 00000010>          CURSOR_POSN: resw 8 ; cursor positions for video pages
  2506                                  ACTIVE_PAGE: 
  2507 00011FD6 <res 00000001>          ptty: 	     resb 1 ; current tty
  2508                                  ; 01/07/2015 - 29/01/2016
  2509 00011FD7 <res 00000001>          ccolor:	     resb 1 ; current color attribute
  2510                                  ; 26/10/2015
  2511                                  ; 07/09/2014
  2512 00011FD8 <res 00000014>          ttychr:      resw ntty+2 ; Character buffer (multiscreen)
  2513                                  
  2514                                  ; 18/05/2015 (03/06/2013 - Retro UNIX 8086 v1 feature only!)
  2515 00011FEC <res 00000004>          p_time:      resd 1     ; present time (for systime & sysmdate)
  2516                                  
  2517                                  ; 18/05/2015 (16/08/2013 - Retro UNIX 8086 v1 feature only !)
  2518                                  ; (open mode locks for pseudo TTYs)
  2519                                  ; [ major tty locks (return error in any conflicts) ]
  2520 00011FF0 <res 00000014>          ttyl:        resw ntty+2 ; opening locks for TTYs.
  2521                                  
  2522                                  ; 15/04/2015 (Retro UNIX 386 v1)
  2523                                  ; 22/09/2013 (Retro UNIX 8086 v1)
  2524 00012004 <res 0000000A>          wlist:       resb ntty+2 ; wait channel list (0 to 9 for TTYs)
  2525                                  ; 15/04/2015 (Retro UNIX 386 v1)
  2526                                  ;; 12/07/2014 -> sp_init set comm. parameters as 0E3h
  2527                                  ;; 0 means serial port is not available 
  2528                                  ;;comprm: ; 25/06/2014
  2529 0001200E <res 00000001>          com1p:       resb 1  ;;0E3h
  2530 0001200F <res 00000001>          com2p:       resb 1  ;;0E3h
  2531                                  
  2532                                  ; 17/11/2015
  2533                                  ; request for response (from the terminal)	
  2534 00012010 <res 00000002>          req_resp:    resw 1 			
  2535                                  ; 07/11/2015
  2536 00012012 <res 00000001>          ccomport:    resb 1 ; current COM (serial) port
  2537                                  		    ; (0= COM1, 1= COM2)
  2538                                  ; 09/11/2015
  2539 00012013 <res 00000001>          comqr:	     resb 1 ; 'query or response' sign (u9.s, 'sndc')
  2540                                  ; 07/11/2015
  2541 00012014 <res 00000002>          rchar:	     resw 1 ; last received char for COM 1 and COM 2		
  2542 00012016 <res 00000002>          schar:	     resw 1 ; last sent char for COM 1 and COM 2
  2543                                  
  2544                                  ; 22/08/2014 (RTC)
  2545                                  ; (Packed BCD)
  2546 00012018 <res 00000001>          time_seconds: resb 1
  2547 00012019 <res 00000001>          time_minutes: resb 1
  2548 0001201A <res 00000001>          time_hours:   resb 1
  2549 0001201B <res 00000001>          date_wday:    resb 1
  2550 0001201C <res 00000001>          date_day:     resb 1
  2551 0001201D <res 00000001>          date_month:   resb 1			
  2552 0001201E <res 00000001>          date_year:    resb 1
  2553 0001201F <res 00000001>          date_century: resb 1
  2554                                  
  2555                                  ; 24/01/2016
  2556 00012020 <res 00000004>          RTC_LH:	       resd 1
  2557 00012024 <res 00000001>          RTC_WAIT_FLAG: resb 1
  2558 00012025 <res 00000001>          USER_FLAG:     resb 1
  2559                                  ; 19/05/2016
  2560                                  ;RTC_second:
  2561 00012026 <res 00000001>          RTC_2Hz:       resb 1 ;  from 2Hz interrupt to 1Hz timer event function	
  2562                                  
  2563                                  %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 00012027 <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 00012028 <res 00000002>      <1> TIMER_LOW:      resw	1               ; LOW WORD OF TIMER COUNT
    31 0001202A <res 00000002>      <1> TIMER_HIGH:     resw	1               ; HIGH WORD OF TIMER COUNT
    32 0001202C <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 0001202D <res 00000001>      <1> SEEK_STATUS:	resb	1
    39 0001202E <res 00000001>      <1> MOTOR_STATUS:	resb	1
    40 0001202F <res 00000001>      <1> MOTOR_COUNT:	resb	1
    41 00012030 <res 00000001>      <1> DSKETTE_STATUS:	resb	1
    42 00012031 <res 00000007>      <1> NEC_STATUS:	resb	7
    43                              <1> 
    44                              <1> ;----------------------------------------
    45                              <1> ;	ADDITIONAL MEDIA DATA		:
    46                              <1> ;----------------------------------------
    47                              <1> 
    48 00012038 <res 00000001>      <1> LASTRATE:	resb 	1
    49 00012039 <res 00000001>      <1> HF_STATUS:	resb 	1
    50 0001203A <res 00000001>      <1> HF_ERROR:	resb 	1
    51 0001203B <res 00000001>      <1> HF_INT_FLAG:	resb 	1
    52 0001203C <res 00000001>      <1> HF_CNTRL:	resb 	1
    53 0001203D <res 00000004>      <1> DSK_STATE:	resb 	4
    54 00012041 <res 00000002>      <1> DSK_TRK:	resb 	2
    55                              <1> 
    56                              <1> ;----------------------------------------
    57                              <1> ;	FIXED DISK DATA AREAS		:
    58                              <1> ;----------------------------------------
    59                              <1> 
    60 00012043 <res 00000001>      <1> DISK_STATUS1:	resb 	1		; FIXED DISK STATUS
    61 00012044 <res 00000001>      <1> HF_NUM:		resb 	1		; COUNT OF FIXED DISK DRIVES
    62 00012045 <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 00012046 <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 00012048 <res 00000004>      <1> HDPM_TBL_VEC:	resd	1 		; Primary master disk param. tbl. pointer
    73 0001204C <res 00000004>      <1> HDPS_TBL_VEC:	resd	1		; Primary slave disk param. tbl. pointer
    74 00012050 <res 00000004>      <1> HDSM_TBL_VEC:	resd	1 		; Secondary master disk param. tbl. pointer
    75 00012054 <res 00000004>      <1> HDSS_TBL_VEC:	resd	1		; Secondary slave disk param. tbl. pointer
    76                              <1> 
    77                              <1> ; 03/01/2015
    78 00012058 <res 00000001>      <1> LBAMode:     	resb	1
    79                              <1> 
    80                              <1> ; *****************************************************************************
  2564                                  
  2565                                  ;;; Real Mode Data (10/07/2015 - BSS)
  2566                                  
  2567                                  ;alignb 2
  2568                                  
  2569                                  ; 10/01/2016
  2570                                  %include 'trdoskx.s'	; UNINITIALIZED KERNEL (Logical Drive & FS) DATA
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.0) - UNINITIALIZED DATA : trdoskx.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 29/07/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> ; 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 00012059 <res 00000003>      <1> alignb 4
    20                              <1> 
    21                              <1> ; MAINPROG.ASM
    22 0001205C <res 00000004>      <1> MainProgCfg_FileSize:   resd 1 ; 14/04/2016
    23 00012060 <res 00000004>      <1> MainProgCfg_LineOffset: resd 1 ; 14/04/2016
    24                              <1> 
    25 00012064 <res 00000004>      <1> Current_VolSerial: resd 1
    26                              <1> 
    27 00012068 <res 00000004>      <1> Current_Dir_FCluster: resd 1
    28                              <1> 
    29 0001206C <res 00000001>      <1> Current_Dir_Level: resb 1
    30 0001206D <res 00000001>      <1> Current_FATType: resb 1
    31 0001206E <res 00000001>      <1> Current_Drv: resb 1
    32 0001206F <res 00000001>      <1> Current_Dir_Drv:   resb 1 ; '?'
    33 00012070 <res 00000001>      <1>                    resb 1 ; ':'
    34 00012071 <res 00000001>      <1> Current_Dir_Root:  resb 1 ; '/' 
    35 00012072 <res 0000005A>      <1> Current_Directory: resb 90
    36 000120CC <res 00000001>      <1> End_Of_Current_Dir_Str: resb 1
    37 000120CD <res 00000001>      <1> Current_Dir_StrLen: resb 1   
    38                              <1> 
    39 000120CE <res 00000001>      <1> CursorColumn: 	resb 1
    40 000120CF <res 00000001>      <1> CmdArgStart:    resb 1
    41                              <1> 
    42                              <1> ; 03/02/2016
    43 000120D0 <res 0000004E>      <1> Remark:		resb 78
    44                              <1> 
    45 0001211E <res 00000050>      <1> CommandBuffer: 	resb 80
    46                              <1> 
    47 0001216E <res 00000100>      <1> TextBuffer:	resb 256
    48                              <1> 
    49                              <1> MasterBootBuff:
    50 0001226E <res 000001BE>      <1> MasterBootCode: resb 1BEh
    51 0001242C <res 00000040>      <1> PartitionTable: resb 64
    52 0001246C <res 00000002>      <1> MBIDCode: resw 1
    53                              <1> 
    54                              <1> PTable_Buffer:
    55 0001246E <res 00000040>      <1> PTable_hd0: resb 64
    56 000124AE <res 00000040>      <1> PTable_hd1: resb 64
    57 000124EE <res 00000040>      <1> PTable_hd2: resb 64
    58 0001252E <res 00000040>      <1> PTable_hd3: resb 64
    59 0001256E <res 00000040>      <1> PTable_ep0: resb 64
    60 000125AE <res 00000040>      <1> PTable_ep1: resb 64
    61 000125EE <res 00000040>      <1> PTable_ep2: resb 64
    62 0001262E <res 00000040>      <1> PTable_ep3: resb 64
    63                              <1> 
    64 0001266E <res 00000001>      <1> scount:	resb 1 ; 16/05/2016 (diskio.s, 'int33h:')	
    65 0001266F <res 00000001>      <1> HD_LBA_yes: resb 1
    66 00012670 <res 00000001>      <1> PP_Counter: resb 1
    67 00012671 <res 00000001>      <1> EP_Counter: resb 1
    68                              <1> 
    69 00012672 <res 00000004>      <1> EP_StartSector: resd 1
    70 00012676 <res 00000004>      <1>                 resd 1
    71 0001267A <res 00000004>      <1>                 resd 1
    72 0001267E <res 00000004>      <1>                 resd 1
    73                              <1> 
    74 00012682 <res 00000200>      <1> DOSBootSectorBuff: resb 512
    75                              <1> 
    76                              <1> FAT_BuffDescriptor:
    77 00012882 <res 00000004>      <1> FAT_CurrentCluster: resd 1
    78 00012886 <res 00000001>      <1> FAT_BuffValidData: resb 1
    79 00012887 <res 00000001>      <1> FAT_BuffDrvName: resb 1
    80 00012888 <res 00000002>      <1> FAT_BuffOffset: resw 1
    81 0001288A <res 00000004>      <1> FAT_BuffSector: resd 1
    82                              <1> 
    83 0001288E <res 00000004>      <1> FAT_ClusterCounter: resd 1
    84 00012892 <res 00000004>      <1> LastCluster: resd 1
    85                              <1> 
    86                              <1> ; 16/05/2016
    87                              <1> ;; 18/03/2016 (TRDOS v2.0)
    88                              <1> ;ClusterBuffer_Valid: resb 1
    89                              <1> 
    90                              <1> Dir_BuffDescriptor:
    91 00012896 <res 00000001>      <1> DirBuff_DRV: resb 1
    92 00012897 <res 00000001>      <1> DirBuff_FATType: resb 1
    93 00012898 <res 00000001>      <1> DirBuff_ValidData: resb 1
    94 00012899 <res 00000002>      <1> DirBuff_CurrentEntry: resw 1
    95 0001289B <res 00000002>      <1> DirBuff_LastEntry: resw 1
    96 0001289D <res 00000004>      <1> DirBuff_Cluster: resd 1 
    97 000128A1 <res 00000002>      <1> DirBuffer_Size: resw 1
    98                              <1> ;DirBuff_EntryCounter: resw 1
    99                              <1> 
   100                              <1> ; 01/02/2016
   101                              <1> ; these are on (real mode) segment 8000h and later
   102                              <1> ; FAT_Buffer:	resb 1536 ; 3 sectors
   103                              <1> ; Dir_Buffer:	resb 512*32
   104                              <1> ; Logical_DOSDisks:  resb 6656 ; 26 * 256 bytes
   105                              <1> 
   106                              <1> ; 18/01/2016
   107                              <1> 
   108 000128A3 <res 00000004>      <1> FreeClusterCount: resd 1
   109                              <1> 
   110 000128A7 <res 00000004>      <1> VolSize_Unit1:   resd 1
   111 000128AB <res 00000004>      <1> VolSize_Unit2:   resd 1
   112                              <1> 
   113 000128AF <res 00000004>      <1> Vol_Tot_Sec_Str_Start:	    resd 1
   114 000128B3 <res 0000000A>      <1> Vol_Tot_Sec_Str: 	    resb 10
   115 000128BD <res 00000001>      <1> Vol_Tot_Sec_Str_End:	    resb 1
   116 000128BE <res 00000001>      <1> resb 1
   117 000128BF <res 00000004>      <1> Vol_Free_Sectors_Str_Start: resd 1
   118 000128C3 <res 0000000A>      <1> Vol_Free_Sectors_Str:	    resb 10				
   119 000128CD <res 00000001>      <1> Vol_Free_Sectors_Str_End:   resb 1
   120                              <1> 
   121                              <1> ; 10/02/2016
   122 000128CE <res 00000001>      <1> RUN_CDRV: resb 1 ; CMD_INTR.ASM  ; 09/11/2011
   123                              <1> 
   124                              <1> ; 24/01/2016
   125 000128CF <res 00000080>      <1> PATH_Array:     resb 128 ; DIR.ASM ; 09/10/2011
   126                              <1> ; 06/02/2016
   127 0001294F <res 00000004>      <1> CCD_DriveDT:	resd 1 ; DIR.ASM ; (word)
   128 00012953 <res 00000001>      <1> CCD_Level:	resb 1 ; DIR.ASM
   129 00012954 <res 00000001>      <1> Last_Dir_Level:	resb 1 ; DIR.ASM
   130                              <1> ;
   131 00012955 <res 00000002>      <1> CDLF_AttributesMask: resw 1 ; DIR.ASM
   132 00012957 <res 00000004>      <1> CDLF_FNAddress:	resd 1 ; DIR.ASM (word)
   133 0001295B <res 00000002>      <1> CDLF_DEType:	resw 1 ; DIR.ASM
   134                              <1> ;
   135 0001295D <res 00000001>      <1> CD_COMMAND:	resb 1 ; DIR.ASM
   136                              <1> 
   137 0001295E <res 00000002>      <1> alignb 4
   138                              <1> 
   139                              <1> ; 29/01/2016
   140 00012960 <res 00000001>      <1> Program_Exit:	resb 1 ; CMD_INTR.ASM  ; 09/11/2011
   141                              <1> 
   142                              <1> ;alignb 4
   143                              <1> ; 23/02/2016
   144 00012961 <res 00000001>      <1> disk_rw_op:	resb 1 ;  0 = disk read, 1 = disk write
   145                              <1> ;disk_rw_spt:	resb 1 ; sectors per track (<= 63) /// (<256)
   146                              <1> ; 31/01/2016
   147 00012962 <res 00000001>      <1> retry_count: 	resb 1 ; DISK_IO.ASM ; 20/07/2011 (CHS_RetryCount)
   148 00012963 <res 00000001>      <1> disk_rw_err: 	resb 1 ; DISK_IO.ASM ; (Disk_IO_err_code)
   149 00012964 <res 00000004>      <1> sector_count:	resd 1 ; DISK_IO.ASM ; (Disk_RW_SectorCount)
   150                              <1> 
   151                              <1> ; 06/02/2016 (long name)
   152 00012968 <res 00000002>      <1> FDE_AttrMask:	   resw 1 ; DIR.ASM
   153 0001296A <res 00000002>      <1> AmbiguousFileName: resw 1 ; DIR.ASM
   154 0001296C <res 00000001>      <1> PreviousAttr:	   resb 1 ; DIR.ASM
   155                              <1> ;	
   156 0001296D <res 00000001>      <1> LongNameFound:   resb 1	  ; DIR.ASM
   157 0001296E <res 00000001>      <1> LFN_EntryLength: resb 1   ; DIR.ASM
   158 0001296F <res 00000001>      <1> LFN_CheckSum:    resb 1   ; DIR.ASM
   159 00012970 <res 00000084>      <1> LongFileName:    resb 132 ; DIR.ASM
   160                              <1> 
   161                              <1> ;PATH_Array_Ptr: resw 1 ; DIR.ASM
   162 000129F4 <res 00000001>      <1> PATH_CDLevel:	 resb 1 ; DIR.ASM
   163 000129F5 <res 00000001>      <1> PATH_Level:	 resb 1 ; DIR.ASM
   164                              <1> 
   165                              <1> ; 07/02/2016
   166 000129F6 <res 0000000D>      <1> Dir_File_Name:	resb 13 ; DIR.ASM ; 09/10/2011
   167                              <1> 
   168                              <1> ; 10/02/2016
   169 00012A03 <res 0000000D>      <1> Dir_Entry_Name:	resb 13 ; DIR.ASM
   170                              <1> 
   171                              <1> alignb 2
   172                              <1> 
   173 00012A10 <res 00000002>      <1> AttributesMask: resw 1 ; CMD_INTR.ASM ; 09/11/2011
   174                              <1> 
   175                              <1> ; 10/02/2016 (128 bytes -> 126 bytes)
   176                              <1> ; 08/02/2016
   177                              <1> ;FFF Structure (128 bytes) ; DIR.ASM ; 09/10/2011
   178 00012A12 <res 00000001>      <1> FindFile_Drv:		  resb 1
   179 00012A13 <res 00000041>      <1> FindFile_Directory:	  resb 65
   180 00012A54 <res 0000000D>      <1> FindFile_Name:		  resb 13
   181                              <1> FindFile_LongNameEntryLength:
   182 00012A61 <res 00000001>      <1> FindFile_LongNameYes: 	  resb 1 ; Sign for longname procedures
   183                              <1> ;Above 80 bytes form
   184                              <1> ;TR-DOS Source/Destination File FullName Format/Structure
   185 00012A62 <res 00000002>      <1> FindFile_AttributesMask:  resw 1
   186 00012A64 <res 00000020>      <1> FindFile_DirEntry:	  resb 32
   187 00012A84 <res 00000004>      <1> FindFile_DirFirstCluster: resd 1
   188 00012A88 <res 00000004>      <1> FindFile_DirCluster:	  resd 1
   189 00012A8C <res 00000002>      <1> FindFile_DirEntryNumber:  resw 1
   190 00012A8E <res 00000002>      <1> FindFile_MatchCounter:	  resw 1
   191 00012A90 <res 00000002>      <1> FindFile_Reserved:	  resw 1 ; 06/03/2016
   192                              <1> 
   193 00012A92 <res 00000004>      <1> First_Path_Pos: resd 1	; DIR.ASM ; 09/10/2011
   194 00012A96 <res 00000004>      <1> Last_Slash_Pos: resd 1	; DIR.ASM 
   195                              <1> 
   196                              <1> ; 10/02/2016
   197 00012A9A <res 00000002>      <1> File_Count:     resw 1 	; DIR.ASM ; 09/10/2011
   198 00012A9C <res 00000002>      <1> Dir_Count:      resw 1
   199 00012A9E <res 00000004>      <1> Total_FSize:    resd 1
   200 00012AA2 <res 00000004>      <1> TFS_Dec_Begin:  resd 1
   201 00012AA6 <res 0000000A>      <1>                 resb 10
   202 00012AB0 <res 00000001>      <1> TFS_Dec_End:    resb 1
   203                              <1> 
   204 00012AB1 <res 00000001>      <1> PrintDir_RowCounter: resb 1
   205                              <1> 
   206 00012AB2 <res 00000002>      <1> alignb 4
   207                              <1> ; 15/02/2015 ('show' command variables)
   208 00012AB4 <res 00000004>      <1> Show_FDT:	resd 1
   209 00012AB8 <res 00000004>      <1> Show_LDDDT:	resd 1
   210 00012ABC <res 00000004>      <1> Show_Cluster:	resd 1
   211 00012AC0 <res 00000004>      <1> Show_FileSize:	resd 1
   212 00012AC4 <res 00000004>      <1> Show_FilePointer: resd 1
   213 00012AC8 <res 00000002>      <1> Show_ClusterPointer: resw 1
   214 00012ACA <res 00000002>      <1> Show_ClusterSize: resw 1
   215 00012ACC <res 00000001>      <1> Show_RowCount:	resb 1
   216                              <1> 
   217 00012ACD <res 00000003>      <1> alignb 4
   218                              <1> ; 21/02/2016
   219 00012AD0 <res 00000004>      <1> DelFile_FNPointer:	resd 1 ; ; CMD_INTR.ASM (word) ; 09/11/2011
   220                              <1> ; 27/02/2016
   221                              <1> ; DIR.ASM (09/10/2011)
   222 00012AD4 <res 00000004>      <1> DelFile_FCluster:	resd 1
   223 00012AD8 <res 00000002>      <1> DelFile_EntryCounter:	resw 1
   224 00012ADA <res 00000001>      <1> DelFile_LNEL:		resb 1
   225 00012ADB <res 00000001>      <1> resb 1
   226                              <1> 
   227                              <1> ; DIR.ASM
   228 00012ADC <res 00000004>      <1> mkdir_DirName_Offset: 	resd 1
   229 00012AE0 <res 00000004>      <1> mkdir_FFCluster:	resd 1
   230 00012AE4 <res 00000004>      <1> mkdir_LastDirCluster:	resd 1
   231 00012AE8 <res 00000004>      <1> mkdir_FreeSectors:	resd 1
   232 00012AEC <res 00000002>      <1> mkdir_attrib:		resw 1 
   233 00012AEE <res 00000001>      <1> mkdir_SecPerClust:	resb 1
   234 00012AEF <res 00000001>      <1> mkdir_add_new_cluster:	resb 1
   235 00012AF0 <res 0000000D>      <1> mkdir_Name:		resb 13
   236 00012AFD <res 00000002>      <1> resw 1 ; 01/03/2016
   237                              <1> ; 27/02/2016
   238 00012AFF <res 00000001>      <1> RmDir_MultiClusters:	resb 1  
   239 00012B00 <res 00000004>      <1> RmDir_DirEntryOffset:	resd 1 ; 01/03/2016 (word -> dword)
   240 00012B04 <res 00000004>      <1> RmDir_ParentDirCluster: resd 1
   241 00012B08 <res 00000004>      <1> RmDir_DirLastCluster:   resd 1
   242 00012B0C <res 00000004>      <1> RmDir_PreviousCluster:  resd 1
   243                              <1> ; 22/02/2016
   244 00012B10 <res 00000001>      <1> UPDLMDT_CDirLevel:	resb 1
   245 00012B11 <res 00000004>      <1> UPDLMDT_CDirFCluster:	resd 1
   246                              <1> 	
   247 00012B15 <res 00000003>      <1> alignb 4
   248                              <1> ; DRV_FAT.ASM ; 21/08/2011
   249 00012B18 <res 00000004>      <1> gffc_next_free_cluster:  resd 1
   250 00012B1C <res 00000004>      <1> gffc_first_free_cluster: resd 1
   251 00012B20 <res 00000004>      <1> gffc_last_free_cluster:  resd 1
   252                              <1> 
   253                              <1> ;29/04/2016
   254                              <1> Cluster_Index: ; resd 1
   255                              <1> ; 22/02/2016
   256 00012B24 <res 00000004>      <1> ClusterValue:	resd 1
   257                              <1> ; 04/03/2016
   258 00012B28 <res 00000001>      <1> Attributes:	resb 1 
   259                              <1> ;;CFS_error:  resb 1 ;; 01/03/2016
   260 00012B29 <res 00000001>      <1> resb 1
   261 00012B2A <res 00000001>      <1> CFS_OPType: resb 1
   262 00012B2B <res 00000001>      <1> CFS_Drv:    resb 1
   263 00012B2C <res 00000004>      <1> CFS_CC:	    resd 1
   264 00012B30 <res 00000004>      <1> CFS_FAT32FSINFOSEC: resd 1
   265 00012B34 <res 00000004>      <1> CFS_FAT32FC: resd 1
   266                              <1> 
   267                              <1> ; 27/02/2016
   268                              <1> ;alignb 4
   269 00012B38 <res 00000004>      <1> glc_prevcluster: resd 1 ; DRV_FAT.ASM (21/08/2011)
   270                              <1> 
   271                              <1> ; DIR.ASM
   272 00012B3C <res 00000002>      <1> DLN_EntryNumber: resw 1
   273 00012B3E <res 00000001>      <1> DLN_40h:	 resb 1
   274                              <1> ; 28/02/2016
   275 00012B3F <res 00000001>      <1> TCC_FATErr:	 resb 1 ; DRV_FAT.ASM
   276                              <1> 
   277                              <1> alignb 4
   278                              <1> ; DIR.ASM (09/10/2011)
   279 00012B40 <res 00000002>      <1> LCDE_EntryIndex: resw 1 ; LCDE_EntryOffset
   280 00012B42 <res 00000002>      <1> LCDE_ClusterSN:  resw 1
   281 00012B44 <res 00000004>      <1> LCDE_Cluster: 	 resd 1
   282 00012B48 <res 00000004>      <1> LCDE_ByteOffset: resd 1
   283                              <1> 
   284                              <1> ;alignb4
   285                              <1> ; 06/03/2016 (word -> dword)
   286                              <1> ; CMD_INTR.ASM (01/08/2010)
   287 00012B4C <res 00000004>      <1> SourceFilePath:	     resd 1
   288 00012B50 <res 00000004>      <1> DestinationFilePath: resd 1
   289                              <1> 
   290                              <1> ;alignb 4
   291                              <1> ; 06/03/2016
   292                              <1> ; FILE.ASM (09/10/2011)
   293                              <1> ;Source File Structure (same with 'Find File' Structure)
   294 00012B54 <res 00000001>      <1> SourceFile_Drv:			resb 1
   295 00012B55 <res 00000041>      <1> SourceFile_Directory:		resb 65
   296 00012B96 <res 0000000D>      <1> SourceFile_Name:		resb 13
   297                              <1> SourceFile_LongNameEntryLength: 
   298 00012BA3 <res 00000001>      <1> SourceFile_LongNameYes:		resb 1 ; Sign for longname procedures
   299                              <1> ;Above 80 bytes
   300                              <1> ;is TR-DOS Source File FullName Format/Structure
   301 00012BA4 <res 00000002>      <1> SourceFile_AttributesMask:	resw 1
   302 00012BA6 <res 00000020>      <1> SourceFile_DirEntry:		resb 32
   303 00012BC6 <res 00000004>      <1> SourceFile_DirFirstCluster:	resd 1
   304 00012BCA <res 00000004>      <1> SourceFile_DirCluster:		resd 1
   305 00012BCE <res 00000002>      <1> SourceFile_DirEntryNumber:	resw 1
   306 00012BD0 <res 00000002>      <1> SourceFile_MatchCounter:	resw 1
   307                              <1> ; 16/03/2016
   308 00012BD2 <res 00000001>      <1> SourceFile_SecPerClust:		resb 1
   309 00012BD3 <res 00000001>      <1> SourceFile_Reserved:		resb 1
   310                              <1> ; Above is 128 bytes
   311                              <1> 
   312                              <1> ;Destination File Structure (same with 'Find File' Structure)
   313 00012BD4 <res 00000001>      <1> DestinationFile_Drv:		resb 1
   314 00012BD5 <res 00000041>      <1> DestinationFile_Directory: 	resb 65
   315 00012C16 <res 0000000D>      <1> DestinationFile_Name:		resb 13
   316                              <1> DestinationFile_LongNameEntryLength:
   317 00012C23 <res 00000001>      <1> DestinationFile_LongNameYes:	resb 1 ; Sign for longname procedures
   318                              <1> ;Above 80 bytes
   319                              <1> ;is TR-DOS Destination File FullName Format/Structure
   320 00012C24 <res 00000002>      <1> DestinationFile_AttributesMask: resw 1
   321 00012C26 <res 00000020>      <1> DestinationFile_DirEntry:	resb 32
   322 00012C46 <res 00000004>      <1> DestinationFile_DirFirstCluster: resd 1
   323 00012C4A <res 00000004>      <1> DestinationFile_DirCluster:	resd 1
   324 00012C4E <res 00000002>      <1> DestinationFile_DirEntryNumber: resw 1
   325 00012C50 <res 00000002>      <1> DestinationFile_MatchCounter:	resw 1
   326                              <1> ; 16/03/2016
   327 00012C52 <res 00000001>      <1> DestinationFile_SecPerClust:	resb 1
   328 00012C53 <res 00000001>      <1> DestinationFile_Reserved:	resb 1
   329                              <1> ; Above is 128 bytes
   330                              <1> 
   331                              <1> ; 24/04/2016
   332 00012C54 <res 00000002>      <1> resw 1
   333                              <1> 
   334                              <1> ; 10/03/2016
   335                              <1> ; FILE.ASM
   336 00012C56 <res 00000001>      <1> move_cmd_phase:	   resb 1
   337 00012C57 <res 00000001>      <1> msftdf_sf_df_drv:  resb 1
   338 00012C58 <res 00000004>      <1> msftdf_drv_offset: resd 1
   339                              <1> 
   340                              <1> ; 11/03/2016
   341                              <1> ; DRV_FAT.ASM (21/08/2011)
   342 00012C5C <res 00000004>      <1> FAT_anc_LCluster:  resd 1
   343 00012C60 <res 00000004>      <1> FAT_anc_FFCluster: resd 1
   344                              <1> 
   345                              <1> ;alignb 4
   346                              <1> 
   347                              <1> ; 14/03/2016
   348                              <1> ; TRDOS 386 = TRDOS v2.0 feature only !
   349                              <1> ; 'allocate_memory_block' in 'memory.s'
   350 00012C64 <res 00000004>      <1> mem_ipg_count:	resd 1 ; page count (for contiguous allocation)
   351 00012C68 <res 00000004>      <1> mem_pg_count:	resd 1 ; page count (for count down)
   352 00012C6C <res 00000004>      <1> mem_aperture:	resd 1 ; contiguous free pages (current)
   353 00012C70 <res 00000004>      <1> mem_max_aperture: resd 1 ; maximum value of contiguous free pages
   354 00012C74 <res 00000004>      <1> mem_pg_pos:	resd 1 ; mem. position (page #) of current aperture
   355 00012C78 <res 00000004>      <1> mem_max_pg_pos: resd 1 ; mem. position (page #) of max. aperture
   356                              <1> 
   357                              <1> ; 15/03/2016
   358                              <1> ; FILE.ASM ('copy_source_file_to_destination_file')
   359 00012C7C <res 00000001>      <1> copy_cmd_phase:       resb 1
   360 00012C7D <res 00000001>      <1> csftdf_rw_err:	      resb 1
   361 00012C7E <res 00000001>      <1> DestinationFileFound: resb 1
   362 00012C7F <res 00000001>      <1> csftdf_cdrv: 	      resb 1
   363 00012C80 <res 00000004>      <1> csftdf_filesize:      resd 1
   364                              <1> ; TRDOS386 (TRDOS v2.0)
   365 00012C84 <res 00000004>      <1> csftdf_sf_mem_addr:   resd 1
   366 00012C88 <res 00000004>      <1> csftdf_sf_mem_bsize:  resd 1
   367                              <1> ;
   368                              <1> 
   369 00012C8C <res 00000004>      <1> csftdf_sf_cluster:    resd 1 ; 16/03/2016
   370 00012C90 <res 00000004>      <1> csftdf_df_cluster:    resd 1
   371                              <1> ; 16/03/2016
   372 00012C94 <res 00000004>      <1> csftdf_r_size:        resd 1
   373 00012C98 <res 00000004>      <1> csftdf_w_size:        resd 1
   374 00012C9C <res 00000004>      <1> csftdf_sf_rbytes:     resd 1
   375 00012CA0 <res 00000004>      <1> csftdf_df_wbytes:     resd 1
   376 00012CA4 <res 00000001>      <1> csftdf_percentage:    resb 1
   377                              <1> ; 17/03/2016
   378 00012CA5 <res 00000001>      <1> csftdf_videopage:     resb 1
   379 00012CA6 <res 00000002>      <1> csftdf_cursorpos:     resw 1
   380 00012CA8 <res 00000004>      <1> csftdf_sf_drv_dt:     resd 1
   381 00012CAC <res 00000004>      <1> csftdf_df_drv_dt:     resd 1
   382                              <1> 
   383                              <1> ; 21/03/2016
   384                              <1> ; 20/03/2016
   385                              <1> ; FILE.ASM
   386 00012CB0 <res 00000004>      <1> createfile_Name_Offset:  resd 1
   387 00012CB4 <res 00000004>      <1> createfile_FreeSectors:  resd 1 
   388 00012CB8 <res 00000004>      <1> createfile_size:         resd 1
   389 00012CBC <res 00000004>      <1> createfile_FFCluster:    resd 1 ; 11/03/2016
   390 00012CC0 <res 00000004>      <1> createfile_LastDirCluster: resd 1
   391 00012CC4 <res 00000004>      <1> createfile_Cluster:      resd 1
   392 00012CC8 <res 00000004>      <1> createfile_PCluster:     resd 1
   393 00012CCC <res 00000001>      <1> createfile_attrib:	 resb 1
   394 00012CCD <res 00000001>      <1> createfile_SecPerClust:  resb 1
   395 00012CCE <res 00000002>      <1> createfile_DirIndex:     resw 1
   396 00012CD0 <res 00000004>      <1> createfile_CCount:	 resd 1
   397 00012CD4 <res 00000002>      <1> createfile_BytesPerSec:	 resw 1 ; 23/03/2016
   398 00012CD6 <res 00000001>      <1> createfile_wfc:	         resb 1
   399 00012CD7 <res 00000001>      <1> createfile_UpdatePDir:	 resb 1 ; 31/03/2016
   400                              <1> 
   401                              <1> ;alignb 4
   402                              <1> 
   403                              <1> ; 11/04/2016
   404 00012CD8 <res 00000002>      <1> env_var_length:	   resw 1
   405                              <1> 
   406 00012CDA <res 00000002>      <1> alignb 4
   407                              <1> 
   408                              <1> ; 25/04/2016
   409 00012CDC <res 00000001>      <1> readi.valid:	resb 1 ; valid data (>0 = valid for readi)
   410 00012CDD <res 00000001>      <1> readi.drv:	resb 1 ; drive number (0, 1,2,3,4..)
   411 00012CDE <res 00000001>      <1> readi.spc:	resb 1 ; sectors per cluster for 'readi' drive
   412 00012CDF <res 00000001>      <1> readi.s_index:  resb 1 ; sector index in current cluster (buffer)
   413 00012CE0 <res 00000004>      <1> readi.sector:	resd 1 ; current disk sector
   414 00012CE4 <res 00000002>      <1> readi.bpc:	resw 1 ; bytes per cluster - 1
   415 00012CE6 <res 00000002>      <1> readi.offset:	resw 1 ; byte offset in cluster buffer
   416 00012CE8 <res 00000004>      <1> readi.cluster:  resd 1 ; current cluster number
   417 00012CEC <res 00000004>      <1> readi.c_index:	resd 1 ; cluster index of the current cluster (0,1,2,3..)
   418 00012CF0 <res 00000004>      <1> readi.fclust:	resd 1 ; first cluster of the current cluster
   419 00012CF4 <res 00000004>      <1> readi.fs_index: resd 1 ; sector index in disk/file section (for Singlix FS)
   420                              <1> ;readi.buffer:	resd 1 ; readi sector buffer address
   421                              <1> 
   422 00012CF8 <res 00000001>      <1> writei.valid:	resb 1 ; valid data (>0 = valid for writei)
   423 00012CF9 <res 00000001>      <1> writei.drv:	resb 1 ; drive number (0, 1,2,3,4..)
   424 00012CFA <res 00000001>      <1> writei.spc:	resb 1 ; sectors per cluster for 'writei' drive
   425 00012CFB <res 00000001>      <1> writei.s_index: resb 1 ; sector index in current cluster (buffer)
   426 00012CFC <res 00000004>      <1> writei.sector:	resd 1 ; current disk sector
   427 00012D00 <res 00000002>      <1> writei.bpc:	resw 1 ; bytes per cluster - 1
   428 00012D02 <res 00000002>      <1> writei.offset:	resw 1 ; byte offset in cluster buffer
   429 00012D04 <res 00000004>      <1> writei.cluster: resd 1 ; current cluster number
   430 00012D08 <res 00000004>      <1> writei.c_index:	resd 1 ; cluster index of the current cluster (0,1,2,3..)
   431 00012D0C <res 00000004>      <1> writei.fclust:  resd 1 ; first cluster of the current cluster
   432 00012D10 <res 00000004>      <1> writei.fs_index: resd 1 ; sector index in disk/file section (for Singlix FS)
   433                              <1> ;writei.buffer:	resd 1 ; writei sector buffer address
   434                              <1> 
   435                              <1> ; 29/04/2016
   436 00012D14 <res 00000004>      <1> Run_CDirFC:	resd 1
   437 00012D18 <res 00000001>      <1> Run_Auto_Path:	resb 1
   438 00012D19 <res 00000001>      <1> Run_Manual_Path: resb 1 ; 0 -> auto path sequence needed
   439 00012D1A <res 00000001>      <1> EXE_ID:		resb 1	
   440 00012D1B <res 00000001>      <1> EXE_dot:	resb 1
   441                              <1> 
   442                              <1> ; 06/05/2016
   443 00012D1C <res 00000004>      <1> mainprog_return_addr: resd 1
   444 00012D20 <res 00000004>      <1> last_error:	resd 1  ; this will be used to return error code to MainProg
   445                              <1> 			; 'lasterror' keyword will be used later to get the
   446                              <1> 			; last error code/number/status.
   447                              <1> ; 12/05/2016
   448 00012D24 <res 00000004>      <1> video_eax:	resd 1  ; eax return value of video function
   449                              <1> 
   450                              <1> ; 01/06/2016
   451 00012D28 <res 00000004>      <1> user_buffer:	resd 1  ; 'diskio.s' (INT 33h, Function 08h, floppy disk type)
   452                              <1> 
   453                              <1> ; 21/05/2016 - TRDOS 386 ('swap/switch', 'rswap', [u.pri])
   454 00012D2C <res 00000001>      <1> priority:	resb 1  ; running priority level of process (0,1,2)
   455                              <1> 			; (run queue which is process comes from)
   456                              <1> ; 22/05/2016 - TRDOS 386 ('set_run_sequence', 'rtc_int', 'u_timer')
   457 00012D2D <res 00000001>      <1> p_change:	resb 1  ; process change status (for timer events)
   458                              <1> ; 23/05/2016 - TRDOS 386 ('clock')
   459 00012D2E <res 00000001>      <1> multi_tasking:	resb 1   ; Multi Tasking status (0 = disabled, >0 = enabled)
   460                              <1> 			; (EBX will return with user buffer addr or disk type)
   461                              <1> ; 07/06/2016
   462 00012D2F <res 00000001>      <1> timer_events:	resb 1  ; number of (active) timer events, <= 16		
   463                              <1> 
   464                              <1> ; 24/06/2016
   465 00012D30 <res 00000001>      <1> w_str_cmd:	resb 1	; WRITE_STRING command (0,1,2,3) ; video.s
   466 00012D31 <res 00000001>      <1> p_crt_mode:	resb 1  ; previous video mode (=3 or 0), backup mark/sign
   467                              <1> ; 26/06/2016
   468 00012D32 <res 00000001>      <1> p_crt_page:	resb 1  ; previous active page (for 'set_mode')
   469                              <1> ; 04/07/2016
   470 00012D33 <res 00000001>      <1> noclearmem:	resb 1  ; if set, 'SET MODE' (INT 31h) function (AH = 4)
   471                              <1> 			; will not clear the video memory
   472                              <1> 			; (usable for graphics modes only)
   473                              <1> alignb 2
   474 00012D34 <res 00000002>      <1> CRT_LEN:	resw 1  ; length of regen buffer in bytes
   475 00012D36 <res 00000010>      <1> cursor_pposn:	resw 8  ; cursor positions backup
   476                              <1> 
   477                              <1> ; 10/07/2016 ('VGA_FONT_SETUP', INT 43H address for x86 real mode bios)
   478 00012D46 <res 00000004>      <1> VGA_INT43H:	resd 1	; 0 = default (not configured by user)
   479                              <1> 			; 0FFFFFFFFh = user defined fonts
   480                              <1> 			; address:
   481                              <1> 			; 	vgafont8
   482                              <1> 			; 	vgafont16
   483                              <1> 			; 	vgafont14
   484                              <1> 
   485                              <1> ; 25/07/2016
   486 00012D4A <res 00000001>      <1> VGA_MTYPE:	resb 1  ; 0=CTEXT,1=MTEXT,2=CGA,3=PLANAR1,4=PLANAR4,5=LINEAR 
  2571                                  ; 24/01/2016
  2572                                  %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: 21/05/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 '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 00012D4B <res 00000001>      <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 00012D4C <res 00000002>      <1> 	i.flgs:	 resw 1
    37 00012D4E <res 00000001>      <1> 	i.nlks:	 resb 1
    38 00012D4F <res 00000001>      <1> 	i.uid:	 resb 1
    39                              <1>         ;i.size:  resw 1 ; size
    40 00012D50 <res 00000002>      <1> 	resw 1 ; 29/04/2016
    41 00012D52 <res 00000010>      <1> 	i.dskp:	 resw 8 ; 16 bytes
    42 00012D62 <res 00000004>      <1> 	i.ctim:	 resd 1
    43 00012D66 <res 00000004>      <1> 	i.mtim:	 resd 1
    44 00012D6A <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> 	; 21/05/2016
    50                              <1> 	; 19/05/2016 - TRDOS 386 (TRDOS v2.0)
    51                              <1> 	; 06/05/2015 - Retro UNIX 386 v1
    52                              <1> 	; 11/03/2013 - 05/02/2014 (Retro UNIX 8086 v1)
    53                              <1> 	;Derived from UNIX v1 source code 'proc' structure (ux).
    54                              <1> 	;p.
    55                              <1> 	
    56 00012D6C <res 00000020>      <1>         p.pid:   resw nproc
    57 00012D8C <res 00000020>      <1>         p.ppid:  resw nproc
    58 00012DAC <res 00000020>      <1>         p.break: resw nproc
    59 00012DCC <res 00000010>      <1>         p.ttyc:  resb nproc ; console tty in Retro UNIX 8086 v1.
    60 00012DDC <res 00000010>      <1> 	p.waitc: resb nproc ; waiting channel in Retro UNIX 8086 v1.
    61 00012DEC <res 00000010>      <1> 	p.link:	 resb nproc
    62 00012DFC <res 00000010>      <1> 	p.stat:	 resb nproc
    63                              <1> 
    64                              <1> 	; 06/05/2015 (Retro UNIX 386 v1 feature only !) 
    65 00012E0C <res 00000040>      <1> 	p.upage: resd nproc ; Physical address of the process's
    66                              <1> 			    ; 'user' structure
    67                              <1> 	; 21/05/2016	
    68                              <1> 	; 19/05/2016 (TRDOS 386 feature only!)
    69 00012E4C <res 00000010>      <1> 	p.timer: resb nproc ; number of timer events of the processs
    70                              <1> 			  		 			 	  
    71                              <1> P_SIZE	equ $ - process
    72                              <1> 
    73                              <1> 
    74                              <1> ; fsp table (original UNIX v1)
    75                              <1> ;
    76                              <1> ;Entry
    77                              <1> ;          15                                      0
    78                              <1> ;  1     |---|---------------------------------------|
    79                              <1> ;        |r/w|       i-number of open file           |
    80                              <1> ;        |---|---------------------------------------| 
    81                              <1> ;        |               device number               |
    82                              <1> ;        |-------------------------------------------|
    83                              <1> ;    (*) | offset pointer, i.e., r/w pointer to file |
    84                              <1> ;        |-------------------------------------------| 
    85                              <1> ;        |  flag that says    | number of processes  |
    86                              <1> ;        |   file deleted     | that have file open  |
    87                              <1> ;        |-------------------------------------------| 
    88                              <1> ;  2     |                                           |
    89                              <1> ;        |-------------------------------------------| 
    90                              <1> ;        |                                           |
    91                              <1> ;        |-------------------------------------------|
    92                              <1> ;        |                                           |
    93                              <1> ;        |-------------------------------------------|
    94                              <1> ;        |                                           |
    95                              <1> ;        |-------------------------------------------| 
    96                              <1> ;  3     |                                           | 
    97                              <1> ;        |                                           |  
    98                              <1> ;
    99                              <1> ; (*) Retro UNIX 386 v1 modification: 32 bit offset pointer 
   100                              <1> 
   101                              <1> 
   102                              <1> ; 15/04/2015
   103 00012E5C <res 000001F4>      <1> fsp:	 resb nfiles * 10 ; 11/05/2015 (8 -> 10)
   104 00013050 <res 00000018>      <1> bufp:	 resd (nbuf+2) ; will be initialized 
   105 00013068 <res 00000002>      <1> idev:	 resw 1 ; device number is 1 byte in Retro UNIX 8086 v1 !
   106 0001306A <res 00000002>      <1> cdev:    resw 1 ; device number is 1 byte in Retro UNIX 8086 v1 !
   107                              <1> ; 18/05/2015
   108                              <1> ; 26/04/2013 device/drive parameters (Retro UNIX 8086 v1 feature only!)
   109                              <1> ; 'UNIX' device numbers (as in 'cdev' and 'u.cdrv')
   110                              <1> ;	0 -> root device (which has Retro UNIX 8086 v1 file system)
   111                              <1> ; 	1 -> mounted device (which has Retro UNIX 8086 v1 file system)
   112                              <1> ; 'Retro UNIX 8086 v1' device numbers: (for disk I/O procedures)
   113                              <1> ;	0 -> fd0 (physical drive, floppy disk 1), physical drive number = 0
   114                              <1> ;	1 -> fd1 (physical drive, floppy disk 2), physical drive number = 1
   115                              <1> ;	2 -> hd0 (physical drive, hard disk 1), physical drive number = 80h
   116                              <1> ;	3 -> hd1 (physical drive, hard disk 2), physical drive number = 81h
   117                              <1> ;	4 -> hd2 (physical drive, hard disk 3), physical drive number = 82h
   118                              <1> ;	5 -> hd3 (physical drive, hard disk 4), physical drive number = 83h
   119 0001306C <res 00000001>      <1> rdev:	 resb 1 ; root device number ; Retro UNIX 8086 v1 feature only!
   120                              <1> 	        ; as above, for physical drives numbers in following table
   121 0001306D <res 00000001>      <1> mdev:	 resb 1 ; mounted device number ; Retro UNIX 8086 v1 feature only!
   122                              <1> ; 15/04/2015
   123 0001306E <res 00000001>      <1> active:	 resb 1 
   124 0001306F <res 00000001>      <1> 	 resb 1 ; 09/06/2015
   125 00013070 <res 00000002>      <1> mnti:	 resw 1
   126 00013072 <res 00000002>      <1> mpid:	 resw 1
   127 00013074 <res 00000002>      <1> rootdir: resw 1
   128                              <1> 
   129                              <1> ; 21/05/2016 - TRDOS 386 (TRDOS v2.0) - priority levels, 3 run queues 
   130                              <1> runq:
   131 00013076 <res 00000002>      <1> runq_event:	 resw 1 ; high priority, 'run for event'            ; 2
   132 00013078 <res 00000002>      <1> runq_normal:	 resw 1 ; normal/regular priority, 'run as reqular' ; 1
   133 0001307A <res 00000002>      <1> runq_background: resw 1 ; low priority, 'run on background'         ; 0
   134                              <1> ;
   135 0001307C <res 00000001>      <1> imod:	 resb 1
   136 0001307D <res 00000001>      <1> smod:	 resb 1
   137 0001307E <res 00000001>      <1> mmod:	 resb 1
   138 0001307F <res 00000001>      <1> sysflg:	 resb 1
   139                              <1> 
   140                              <1> alignb 4
   141                              <1> 
   142                              <1> user:
   143                              <1> 	; 21/05/2016 - TRDOS 386 (TRDOS v2.0) 
   144                              <1> 	; 	       [u.pri] usage method modification
   145                              <1> 	; 04/12/2015 
   146                              <1> 	; 18/10/2015
   147                              <1> 	; 12/10/2015
   148                              <1> 	; 21/09/2015
   149                              <1> 	; 24/07/2015
   150                              <1> 	; 16/06/2015
   151                              <1> 	; 09/06/2015
   152                              <1> 	; 11/05/2015
   153                              <1> 	; 16/04/2015 (Retro UNIX 386 v1 - 32 bit modifications)
   154                              <1> 	; 10/10/2013
   155                              <1> 	; 11/03/2013. 
   156                              <1> 	;Derived from UNIX v1 source code 'user' structure (ux).
   157                              <1> 	;u.
   158                              <1> 
   159 00013080 <res 00000004>      <1> 	u.sp:	  resd 1 ; esp (kernel stack at the beginning of 'sysent')
   160 00013084 <res 00000004>      <1> 	u.usp:	  resd 1 ; esp (kernel stack points to user's registers)
   161 00013088 <res 00000004>      <1> 	u.r0:	  resd 1 ; eax
   162 0001308C <res 00000002>      <1> 	u.cdir:	  resw 1
   163 0001308E <res 0000000A>      <1> 	u.fp:	  resb 10
   164 00013098 <res 00000004>      <1> 	u.fofp:	  resd 1
   165 0001309C <res 00000004>      <1> 	u.dirp:	  resd 1
   166 000130A0 <res 00000004>      <1> 	u.namep:  resd 1
   167 000130A4 <res 00000004>      <1> 	u.off:	  resd 1
   168 000130A8 <res 00000004>      <1> 	u.base:	  resd 1
   169 000130AC <res 00000004>      <1> 	u.count:  resd 1
   170 000130B0 <res 00000004>      <1> 	u.nread:  resd 1
   171 000130B4 <res 00000004>      <1> 	u.break:  resd 1 ; break
   172 000130B8 <res 00000002>      <1> 	u.ttyp:	  resw 1 
   173 000130BA <res 00000010>      <1> 	u.dirbuf: resb 16 ; 04/12/2015 (10 -> 16) 
   174                              <1> 	;u.pri:	  resw 1 ; 14/02/2014
   175 000130CA <res 00000001>      <1> 	u.quant:  resb 1 ; Retro UNIX 8086 v1 Feature only ! (uquant)
   176 000130CB <res 00000001>      <1> 	u.pri:	  resb 1 ; Modification: 21/05/2016 (priority levels: 0, 1, 2)
   177 000130CC <res 00000002>      <1> 	u.intr:	  resw 1
   178 000130CE <res 00000002>      <1> 	u.quit:	  resw 1
   179                              <1> 	;u.emt:	  resw 1 ; 10/10/2013
   180 000130D0 <res 00000002>      <1> 	u.ilgins: resw 1
   181 000130D2 <res 00000002>      <1> 	u.cdrv:	  resw 1 ; cdev
   182 000130D4 <res 00000001>      <1> 	u.uid:	  resb 1 ; uid
   183 000130D5 <res 00000001>      <1> 	u.ruid:	  resb 1
   184 000130D6 <res 00000001>      <1> 	u.bsys:	  resb 1
   185 000130D7 <res 00000001>      <1> 	u.uno:	  resb 1
   186 000130D8 <res 00000004>      <1>         u.upage:  resd 1 ; 16/04/2015 - Retro Unix 386 v1 feature only !
   187                              <1> 	; tty number (rtty, rcvt, wtty)
   188 000130DC <res 00000001>      <1> 	u.ttyn:	  resb 1 ; 28/07/2013 - Retro Unix 8086 v1 feature only !
   189                              <1> 	; last error number
   190 000130DD <res 00000004>      <1> 	u.error:  resd 1 ; 28/07/2013 - 09/03/2015 
   191                              <1> 		        ; Retro UNIX 8086/386 v1 feature only!
   192 000130E1 <res 00000004>      <1> 	u.pgdir:  resd 1 ; 09/03/2015 (page dir addr of process)
   193 000130E5 <res 00000004>      <1> 	u.ppgdir: resd 1 ; 06/05/2015 (page dir addr of the parent process)
   194 000130E9 <res 00000004>      <1> 	u.pbase:  resd 1 ; 20/05/2015 (physical base/transfer address)
   195 000130ED <res 00000002>      <1> 	u.pcount: resw 1 ; 20/05/2015 (byte -transfer- count for page)
   196                              <1> 	;u.pncount: resw 1 
   197                              <1> 		; 16/06/2015 (byte -transfer- count for page, 'namei', 'mkdir')
   198                              <1> 	;u.pnbase:  resd 1 
   199                              <1> 		; 16/06/2015 (physical base/transfer address, 'namei', 'mkdir')
   200                              <1> 			 ; 09/06/2015
   201 000130EF <res 00000001>      <1> 	u.kcall:  resb 1 ; The caller is 'namei' (dskr) or 'mkdir' (dskw) sign		
   202 000130F0 <res 00000001>      <1> 	u.brwdev: resb 1 ; Block device number for direct I/O (bread & bwrite)
   203                              <1> 			 ; 24/07/2015 - 24/06/2015
   204                              <1> 	;u.args:  resd 1 ; arguments list (line) offset from start of [u.upage]
   205                              <1> 			 ; (arg list/line is from offset [u.args] to 4096 in [u.upage])
   206                              <1> 			 ; ([u.args] points to argument count -argc- address offset)
   207                              <1>  			 ; 24/06/2015	  	
   208                              <1> 	;u.core:  resd 1 ; physical start address of user's memory space (for sys exec)
   209                              <1> 	;u.ecore: resd 1 ; physical end address of user's memory space (for sys exec)
   210                              <1> 			 ; 21/09/2015 (debugging - page fault analyze)
   211 000130F1 <res 00000004>      <1> 	u.pfcount: resd 1 ; page fault count for (this) process (for sys geterr)
   212                              <1> 
   213 000130F5 <res 00000003>      <1> alignb 4
   214                              <1> 
   215                              <1> U_SIZE	equ $ - user
   216                              <1> 
   217                              <1> ; 18/10/2015 - Retro UNIX 386 v1 (local variables for 'namei' and 'sysexec')
   218 000130F8 <res 00000004>      <1> pcore:  resd 1 ; physical start address of user's memory space (for sys exec)
   219 000130FC <res 00000004>      <1> ecore:  resd 1 ; physical start address of user's memory space (for sys exec)
   220 00013100 <res 00000004>      <1> nbase:	resd 1	; physical base address for 'namei' & 'sysexec'
   221 00013104 <res 00000002>      <1> ncount: resw 1	; remain byte count in page for 'namei' & 'sysexec'
   222 00013106 <res 00000002>      <1> argc:	resw 1	; argument count for 'sysexec'
   223 00013108 <res 00000004>      <1> argv:	resd 1	; argument list (recent) address for 'sysexec'
   224                              <1> 
   225                              <1> ; 03/06/2015 - Retro UNIX 386 v1 Beginning
   226                              <1> ; 07/04/2013 - 31/07/2013 - Retro UNIX 8086 v1
   227 0001310C <res 00000001>      <1> rw: 	 resb 1 ;; Read/Write sign (iget)
   228                              <1> 
   229                              <1> ;alignb 4
   230                              <1> 
   231                              <1> ; 24/04/2016
   232 0001310D <res 00000004>      <1> ii:		resd 1 ; first cluster of the program file
   233 00013111 <res 00000004>      <1> i.size:		resd 1 ; size of the program file
   234                              <1> 
   235                              <1> ; 29/04/2016 (TRDOS 386 = TRDOS v2.0)
   236                              <1> ; 22/08/2015 (Retro UNIX 386 v1)
   237                              <1> buffer: 
   238 00013115 <res 00000008>      <1> 	resb	8 
   239                              <1> readi_buffer:
   240 0001311D <res 00000200>      <1> 	resb 	512
   241 0001331D <res 00000008>      <1> 	resb	8
   242                              <1> writei_buffer:
   243 00013325 <res 00000200>      <1> 	resb	512	
   244 00013525 <res 00000410>      <1> 	resb (nbuf-2) * 520
   245                              <1> 
   246 00013935 <res 00000008>      <1> sb0:	resd 2
   247                              <1> ;s:
   248                              <1> ; (root disk) super block buffer
   249                              <1> systm:
   250                              <1> 	; 13/11/2015 (Retro UNIX 386 v1)	
   251                              <1> 	; 11/03/2013. 
   252                              <1> 	;Derived from UNIX v1 source code 'systm' structure (ux).
   253                              <1> 	;s.
   254                              <1> 
   255 0001393D <res 00000002>      <1> 	resw 1
   256 0001393F <res 00000168>      <1> 	resb 360 ; 2880 sectors ; original UNIX v1 value: 128
   257 00013AA7 <res 00000002>      <1> 	resw 1
   258 00013AA9 <res 00000020>      <1> 	resb 32	 ; 256+40 inodes ; original UNIX v1 value: 64
   259 00013AC9 <res 00000004>      <1> 	s.time:	 resd 1
   260 00013ACD <res 00000004>      <1> 	s.syst:	 resd 1
   261 00013AD1 <res 00000004>      <1>         s.wait_: resd 1 ; wait
   262 00013AD5 <res 00000004>      <1> 	s.idlet: resd 1
   263 00013AD9 <res 00000004>      <1> 	s.chrgt: resd 1
   264 00013ADD <res 00000002>      <1> 	s.drerr: resw 1
   265                              <1> 
   266                              <1> S_SIZE	equ $ - systm
   267                              <1> 
   268 00013ADF <res 0000005E>      <1> 	resb 512-S_SIZE ; 03/06/2015	 
   269                              <1> 
   270 00013B3D <res 00000008>      <1> sb1:	resd 2
   271                              <1> ; (mounted disk) super block buffer
   272                              <1> mount:	
   273 00013B45 <res 00000200>      <1> 	resb 512  ; 03/06/2015
  2573                                  
  2574 00013D45 <res 00000003>          alignb 4
  2575                                  
  2576                                  ; 23/05/2016 (TRDOS 386)
  2577                                  ; 14/10/2015 (Retro UNIX 386 v1, 'unix386.s')
  2578 00013D48 <res 00000004>          cr3reg:	 resd 1  ; cr3 register content at the beginning of the timer
  2579                                  		 ; (or RTC) interrupt handler.
  2580                                  ; 10/06/2016
  2581                                  ; 19/05/2016
  2582                                  ; 18/05/2016 - TRDOS 386 feature only !
  2583 00013D4C <res 00000100>          timer_set: resd 16*4   ; 256 bytes memory space for 16 timer events
  2584                                  	; Timer Event Structure: (max. 16 timer events, 16*16 bytes)
  2585                                  	;       Owner:	        resb 1 ; 0 = free
  2586                                  	;		  	       ;>0 = process number (p.pid)
  2587                                  	;	Reserved:	resb 1 ; = 0		
  2588                                  	;	Interrupt:      resb 1 ; 0 = Timer interrupt (or none)
  2589                                  	;		   	       ; 1 = Real Time Clock interrupt 
  2590                                  	;	Response:       resb 1 ; 0 to 255, signal return value
  2591                                  	;	Count Limit:	resd 1 ; count of ticks (total/set)
  2592                                  	;	Current Count: 	resd 1 ; count of ticks (current)
  2593                                  	;	Response Addr:  resd 1 ; response byte (pointer) address
  2594                                  
  2595                                  ;; Memory (swap) Data (11/03/2015)
  2596                                  ; 09/03/2015
  2597 00013E4C <res 00000002>          swpq_count: resw 1 ; count of pages on the swap queue
  2598 00013E4E <res 00000004>          swp_drv:    resd 1 ; logical drive description table address of the swap drive/disk
  2599 00013E52 <res 00000004>          swpd_size:  resd 1 ; size of swap drive/disk (volume) in sectors (512 bytes). 		  				
  2600 00013E56 <res 00000004>          swpd_free:  resd 1 ; free page blocks (4096 bytes) on swap disk/drive (logical)
  2601 00013E5A <res 00000004>          swpd_next:  resd 1 ; next free page block
  2602 00013E5E <res 00000004>          swpd_last:  resd 1 ; last swap page block	
  2603                                  
  2604 00013E62 <res 00000002>          alignb 4
  2605                                  
  2606                                  ; 10/07/2015
  2607                                  ; 28/08/2014
  2608 00013E64 <res 00000004>          error_code:	resd 1
  2609                                  ; 29/08/2014
  2610 00013E68 <res 00000004>          FaultOffset: 	resd 1
  2611                                  ; 21/09/2015
  2612 00013E6C <res 00000004>          PF_Count:	resd 1	; total page fault count
  2613                                  		       	; (for debugging - page fault analyze)
  2614                                  		 	; 'page_fault_handler' (memory.inc)
  2615                                  			; 'sysgeterr' (u9.s)
  2616                                  ;; 21/08/2015
  2617                                  ;;buffer: resb (nbuf*520) ;; sysdefs.inc, ux.s
  2618                                  ;; ((NOTE: nbuf = 6, buffer r/w problem/bug here !? when nbuf > 4))
  2619                                  
  2620                                  bss_end:
  2621                                  
  2622                                  ; 27/12/2013
  2623                                  _end:  ; end of kernel code
