     1                                  	;
     2                                  	;SOS Kernal Full 
     3                                  	;(C) Stephen Gray 2017
     4                                  	;All rights reserved
     5                                  	;
     6                                  	%define PIC1		0x20		;IO base address for master PIC */
     7                                  	%define PIC2		0xA0		; IO base address for slave PIC */
     8                                  	%define PIC1_COMMAND	PIC1
     9                                  	%define PIC1_DATA	(PIC1+1)
    10                                  	%define PIC2_COMMAND	PIC2
    11                                  	%define PIC2_DATA	(PIC2+1)
    12                                  	%define PIC_EOI		0x20		;End-of-interrupt command code */
    13                                  	%define PIC_MO		0x20		;Offset for master
    14                                  	%define PIC_SO		0x28		;Offset for slave
    15                                  	%define ICW1_ICW4	0x01		; ICW4 (not) needed */
    16                                  	%define ICW1_SINGLE	0x02		;Single (cascade) mode */	
    17                                  	%define ICW1_INTERVAL4	0x04		; Call address interval 4 (8) */
    18                                  	%define ICW1_LEVEL	0x08		; Level triggered (edge) mode */
    19                                  	%define ICW1_INIT	0x10		; Initialization - required! */
    20                                   
    21                                  	%define ICW4_8086	0x01		; 8086/88 (MCS-80/85) mode */
    22                                  	%define ICW4_AUTO	0x02		; Auto (normal) EOI */
    23                                  	%define ICW4_BUF_SLAVE	0x08		; Buffered mode/slave */
    24                                  	%define ICW4_BUF_MASTER	0x0C		; Buffered mode/master */
    25                                  	%define ICW4_SFNM	0x10		; Special fully nested (not) */
    26                                  	
    27                                  	[BITS 64]
    28                                  	org 0x1000000
    29                                  	
    30 00000000 E9CB040000              	jmp Kern_Start
    31                                  	
    32                                  	;Messages
    33 00000005 2020476F2061776179-     		db '  Go away please hackers  '
    33 0000000E 20706C656173652068-
    33 00000017 61636B6572732020   
    34 0000001F 0000                    STK:	dw 0
    35 00000021 4B4900                  		db 'KI',0
    36 00000024 496E74657272757074-     PINT	db 'Interrupt!',0
    36 0000002D 2100               
    37 0000002F 0400                    DIV0	dw 4
    38 00000031 446976696465206572-     		db 'Divide error  ',0
    38 0000003A 726F72202000       
    39 00000040 0500                    Deb_Exc	dw 5
    40 00000042 446562756720457863-     		db 'Debug Exception  ' ,0
    40 0000004B 657074696F6E202000 
    41 00000054 0600                    Breakp	dw 6
    42 00000056 427265616B706F696E-     		db 'Breakpoint  ',0 
    42 0000005F 74202000           
    43 00000063 0700                    Overf	dw 7
    44 00000065 4F766572666C6F7720-     		db 'Overflow  ',0
    44 0000006E 2000               
    45 00000070 0800                    Bounds	dw 8
    46 00000072 426F756E6473204368-     		db 'Bounds Check  ',0
    46 0000007B 65636B202000       
    47 00000081 0900                    Inv_Op   dw 9
    48 00000083 496E76616C6964204F-     		db 'Invalid Opcode  ',0
    48 0000008C 70636F6465202000   
    49 00000094 0A00                    Copr_No 	dw 10
    50 00000096 436F70726F63657373-     		db 'Coprocessor not available  ',0
    50 0000009F 6F72206E6F74206176-
    50 000000A8 61696C61626C652020-
    50 000000B1 00                 
    51 000000B2 0B00                    Sys_Err	dw 11
    52 000000B4 53797374656D206572-     		db 'System error Double Fault ',0
    52 000000BD 726F7220446F75626C-
    52 000000C6 65204661756C742000 
    53 000000CF 0C00                    Cop_Seg	dw 12
    54 000000D1 436F70726F63657373-     		db 'Coprocessor Segment Overrun  ',0
    54 000000DA 6F72205365676D656E-
    54 000000E3 74204F76657272756E-
    54 000000EC 202000             
    55 000000EF 0D00                    Inv_Tss	dw 13
    56 000000F1 496E76616C69642054-     		db 'Invalid TSS  ',0
    56 000000FA 5353202000         
    57 000000FF 0E00                    Seg_Not  dw 14
    58 00000101 5365676D656E74206E-     		db 'Segment not present  ',0
    58 0000010A 6F742070726573656E-
    58 00000113 74202000           
    59 00000117 0F00                    Stac_Ex	dw 15
    60 00000119 537461636B20657863-     		db 'Stack exception  ',0
    60 00000122 657074696F6E202000 
    61 0000012B 1000                    Gen_Pro	dw 16
    62 0000012D 47656E6572616C2070-     		db 'General protection fault  ',0
    62 00000136 726F74656374696F6E-
    62 0000013F 206661756C74202000 
    63 00000148 1100                    P_Fault	dw 17
    64 0000014A 50616765206661756C-     		db 'Page fault  ',0
    64 00000153 74202000           
    65 00000157 1200                    Cop_Err	dw 18
    66 00000159 436F70726F63657373-     		db 'Coprocessor Error  ',0
    66 00000162 6F72204572726F7220-
    66 0000016B 2000               
    67 0000016D 506C65617365205265-     Turn_O	db 'Please Reboot and if the error persists, call support  ',0
    67 00000176 626F6F7420616E6420-
    67 0000017F 696620746865206572-
    67 00000188 726F72207065727369-
    67 00000191 7374732C2063616C6C-
    67 0000019A 20737570706F727420-
    67 000001A3 2000               
    68                                  		
    69                                  
    70 000001A5 90<rept>                	align 8
    71                                  	%include "C:\Users\Stephen\Documents\NASM\cls.asm"			;include clear screen
     1                              <1> 			;
     2                              <1> 			;Clear screen text mode
     3                              <1> 			;
     4                              <1> 	[BITS 64]
     5                              <1> 		cls:
     6 000001A8 57                  <1> 	push rdi
     7 000001A9 50                  <1> 	push rax
     8 000001AA 51                  <1> 	push rcx
     9 000001AB BF00800B00          <1> 	mov rdi, 0xB8000              ; Set the destination index to 0xB8000.
    10 000001B0 48B820002000200020- <1> 	mov rax, 0x0020002000200020   ; Set the A-register to 0x1F201F201F201F20  i.e. black space
    10 000001B9 00                  <1>
    11 000001BA B9F4010000          <1> 	mov rcx, 500                  ; Set the C-register to 500 i.e. ((80*25)*2)/8
    12 000001BF F348AB              <1> 	rep stosq                     ; Clear the screen.
    13 000001C2 59                  <1> 	pop rcx
    14 000001C3 58                  <1> 	pop rax
    15 000001C4 5F                  <1> 	pop rdi
    16 000001C5 C3                  <1> 	ret
    72                                  	%include "C:\Users\Stephen\Documents\NASM\printc.asm"		;include print character at x,y r8,r9 r10=colour r11=string address
     1                              <1> 	;	
     2                              <1> 	;printc
     3                              <1> 	;prints a string ending in 0 at position r8,r9 from r11 r10=colour
     4                              <1> 	;
     5                              <1> 	;
     6                              <1> 	;Dec	Hex	Binary	Color
     7                              <1> 	;0	0	0000	Black	 
     8                              <1> 	;1	1	0001	Blue	
     9                              <1> 	;2	2	0010	Green	
    10                              <1> 	;3	3	0011	Cyan	
    11                              <1> 	;4	4	0100	Red	
    12                              <1> 	;5	5	0101	Magenta	
    13                              <1> 	;6	6	0110	Brown	
    14                              <1> 	;7	7	0111	Light Gray	
    15                              <1> 	;8	8	1000	Dark Gray	
    16                              <1> 	;9	9	1001	Light Blue	
    17                              <1> 	;10	A	1010	Light Green	
    18                              <1> 	;11	B	1011	Light Cyan	
    19                              <1> 	;12	C	1100	Light Red	
    20                              <1> 	;13	D	1101	Light Magenta	
    21                              <1> 	;14	E	1110	Yellow	
    22                              <1> 	;15	F	1111	White	
    23                              <1> 
    24                              <1> 	[bits 64]
    25                              <1> 	;rdi contains address of string
    26                              <1> 	printc:
    27                              <1> 	
    28 000001C6 4152                <1> 	push r10				;save colour;
    29 000001C8 B8A0000000          <1> 	mov rax,160			;one line of bytes
    30 000001CD 49F7E1              <1> 	mul r9				;get line on screen
    31 000001D0 49D1E0              <1> 	shl r8,1				;multiply r8*2
    32 000001D3 4C01C0              <1> 	add rax,r8			;add the x amount
    33 000001D6 480500800B00        <1> 	add rax,0xb8000			;memory position
    34 000001DC 49C1E208            <1> 	shl r10,8			;attribute in top half of word
    35                              <1> 	nxtchr:
    36 000001E0 490FBE1B            <1> 	movsx rbx, byte [r11]	;text chr
    37 000001E4 4883FB00            <1> 	cmp rbx,0			;string ended?
    38 000001E8 740F                <1> 	jz ender
    39 000001EA 4C09D3              <1> 	or rbx,r10				;add text colour
    40                              <1> 	;shl rbx,8				;move text color
    41 000001ED 668918              <1> 	mov [rax],bx			;store chr+attribute
    42 000001F0 4883C002            <1> 	add rax,2
    43 000001F4 49FFC3              <1> 	inc r11
    44 000001F7 EBE7                <1> 	jmp nxtchr			;back for the next one
    45                              <1> 	ender:
    46 000001F9 415A                <1> 	pop r10
    47 000001FB C3                  <1> 	ret
    48                              <1> 	
    73                                  	%include "C:\Users\Stephen\Documents\NASM\hd.asm"			;include read hd functions
     1                              <1> 	;DexOS HD functions
     2                              <1> 	;(c) Craig Bamford
     3                              <1> 	;
     4                              <1> 
     5                              <1> 	;
     6                              <1> 	;push rax - rdi macro
     7                              <1> 	;
     8                              <1> %macro pushraxrdi 0
     9                              <1> 
    10                              <1> 	push rax
    11                              <1> 	push rcx
    12                              <1> 	push rdx
    13                              <1> 	push rbx
    14                              <1> 	push rsp
    15                              <1> 	push rbp
    16                              <1> 	push rsi
    17                              <1> 	push rdi
    18                              <1> 
    19                              <1> %endmacro
    20                              <1> 
    21                              <1> 	;
    22                              <1> 	;pop rax - rdi macro
    23                              <1> 	;
    24                              <1> %macro popraxrdi 0
    25                              <1> 
    26                              <1> 	pop rdi
    27                              <1> 	pop rsi
    28                              <1> 	pop rbp
    29                              <1> 	pop rsp
    30                              <1> 	pop rbx
    31                              <1> 	pop rdx
    32                              <1> 	pop rcx
    33                              <1> 	pop rax
    34                              <1> 	
    35                              <1> %endmacro
    36                              <1> 
    37 000001FC BE010000            <1>  PartitionTable dd 446
    38 00000200 202053746F70206B6E- <1> 	db '  Stop knicking my code Hackers !!!!  '
    38 00000209 69636B696E67206D79- <1>
    38 00000212 20636F646520486163- <1>
    38 0000021B 6B6572732021212121- <1>
    38 00000224 2020                <1>
    39                              <1>  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    40 00000226 00000000            <1> LbaFirstSecOfPartition		dd 0			    ; Lba of First Sector Of Partition
    41 0000022A 00000000            <1> NumBlocksInPartition		dd 0			    ; Number of Blocks In Partition
    42 0000022E 00                  <1> FileSysType			db 0			    ; File sys type
    43 0000022F 00                  <1> ActiveByte			db 0			    ; Is this partition bootable
    44 00000230 00                  <1> FS_GetPartionNumber		db 0			    ; Partion number
    45                              <1> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    46 00000231 90<rept>            <1> align 4
    47 00000234 00000000F0010000F0- <1> BaseTable			dd 0x000, 0x1f0, 0x1f0, 0x170, 0x170, 0x1e8, 0x1e8, 0x168, 0x168
    47 0000023D 010000700100007001- <1>
    47 00000246 0000E8010000E80100- <1>
    47 0000024F 006801000068010000  <1>
    48 00000258 E0010000E001000060- <1> 				dd 0x1e0, 0x1e0, 0x160, 0x160
    48 00000261 01000060010000      <1>
    49                              <1> 
    50                              <1> align 4
    51 00000268 00000000            <1> HddBaseFS			dd 0			    ; First device =0x1f0 for primary, second =0x170 for secondary device.
    52 0000026C 00                  <1> MasterSlave			db 0			    ; Master = 0x00 Slave = 0x10.
    53 0000026D 00                  <1> FS_RW_SectorErrorNum		db 0			    ; Store the error number in.
    54 0000026E 00000000            <1> HddScratchBuffer		dd 0			    ; Place to store sector buffer address.
    55 00000272 00000000            <1> FS_RW_Sector			dd 0			    ; Sector size var.
    56 00000276 00000000            <1> FS_RW_Count			dd 0			    ; Count, var for sectors to read/write.
    57                              <1> 
    58                              <1>  ;=======================================================;
    59                              <1>  ; FS_ReadWriteSectorSetUp                               ;
    60                              <1>  ;-------------------------------------------------------;
    61                              <1>  ;   Input:                                              ;
    62                              <1>  ;         EAX  = Unit (drive)                           ;
    63                              <1>  ;           0  = Floppy                                 ;
    64                              <1>  ;           1  = primary device (0x1f0), master(0x00)   ;
    65                              <1>  ;           2  = primary device (0x1f0), slave(0x10)    ;
    66                              <1>  ;           3  = secondary device (0x170), master(0x00) ;
    67                              <1>  ;           4  = secondary device (0x170), slave(0x10)  ;
    68                              <1>  ;                                                       ;
    69                              <1>  ;         EDI  = Buffer                                 ;
    70                              <1>  ;         ECX  = Count  (just one for now)              ;
    71                              <1>  ;                                                       ;
    72                              <1>  ;  Output:                                              ;
    73                              <1>  ;          AH  = 0  for success                         ;
    74                              <1>  ;          AH  = Nonzero for failure                    ;
    75                              <1>  ;           1  = Not implemented yet                    ;
    76                              <1>  ;           2  = Unit to high                           ;
    77                              <1>  ;                                                (100%) ;
    78                              <1>  ;.......................................................;
    79                              <1> 
    80                              <1> FS_ReadWriteSectorSetUp:
    81                              <1> 	pushraxrdi					; Save the regs
    81                              <2> 
    81 0000027A 50                  <2>  push rax
    81 0000027B 51                  <2>  push rcx
    81 0000027C 52                  <2>  push rdx
    81 0000027D 53                  <2>  push rbx
    81 0000027E 54                  <2>  push rsp
    81 0000027F 55                  <2>  push rbp
    81 00000280 56                  <2>  push rsi
    81 00000281 57                  <2>  push rdi
    81                              <2> 
    82 00000282 893C25[6E020000]    <1> 	mov  dword[HddScratchBuffer],edi			; Save the buffer address
    83 00000289 891425[72020000]    <1> 	mov  dword[FS_RW_Sector],edx				; Save the sector size (In the current implementation, Sector size will always be 512).
    84 00000290 890C25[76020000]    <1> 	mov  dword[FS_RW_Count],ecx				; Count (In the current implementation, count will always be 1).
    85 00000297 C60425[6D020000]01  <1> 	mov  byte[FS_RW_SectorErrorNum],1			; Set the error flag for Not implemented yet (1)
    86 0000029F 83F800              <1> 	cmp  eax,0						; cmp if floppy
    87 000002A2 7438                <1> 	je   FS_ReadWriteSectorSetUpError			; If so error as not done yet
    88 000002A4 FE0425[6D020000]    <1> 	inc  byte [FS_RW_SectorErrorNum]				; Put the error code to 2
    89 000002AB 83F808              <1> 	cmp  eax,8						; Check if it more then 8
    90 000002AE 772C                <1> 	ja   FS_ReadWriteSectorSetUpError			; if so exit with error
    91 000002B0 50                  <1> 	push rax						; Save whats in eax
    92 000002B1 C1E002              <1> 	shl  eax,2						; times it by 4
    93 000002B4 678B98[34020000]    <1> 	mov  ebx,dword[BaseTable+eax]				; Use the look up table to find the base
    94 000002BB 891C25[68020000]    <1> 	mov  dword[HddBaseFS],ebx				  ; Store it
    95 000002C2 58                  <1> 	pop  rax						; get the saved eax
    96 000002C3 2401                <1> 	and  al,00000001b					; See if its odd or even number
    97 000002C5 3401                <1> 	xor  al,00000001b					; Flip bit 1 round
    98 000002C7 C0E004              <1> 	shl  al,4						; Multiply by 16
    99 000002CA 880425[6C020000]    <1> 	mov  byte[MasterSlave],al				; Store it as master or slave
   100                              <1> 	popraxrdi							; restore the regs
   100                              <2> 
   100 000002D1 5F                  <2>  pop rdi
   100 000002D2 5E                  <2>  pop rsi
   100 000002D3 5D                  <2>  pop rbp
   100 000002D4 5C                  <2>  pop rsp
   100 000002D5 5B                  <2>  pop rbx
   100 000002D6 5A                  <2>  pop rdx
   100 000002D7 59                  <2>  pop rcx
   100 000002D8 58                  <2>  pop rax
   100                              <2> 
   101 000002D9 30E4                <1> 	xor  ah,ah						; post success
   102 000002DB C3                  <1> 	ret							; Return
   103                              <1> 
   104                              <1> FS_ReadWriteSectorSetUpError:
   105                              <1> 	popraxrdi							; restore the regs
   105                              <2> 
   105 000002DC 5F                  <2>  pop rdi
   105 000002DD 5E                  <2>  pop rsi
   105 000002DE 5D                  <2>  pop rbp
   105 000002DF 5C                  <2>  pop rsp
   105 000002E0 5B                  <2>  pop rbx
   105 000002E1 5A                  <2>  pop rdx
   105 000002E2 59                  <2>  pop rcx
   105 000002E3 58                  <2>  pop rax
   105                              <2> 
   106 000002E4 8A2425[6D020000]    <1> 	mov   ah,byte[FS_RW_SectorErrorNum]			; post error number
   107 000002EB C3                  <1> 	ret							; Return
   108                              <1> 
   109                              <1> 
   110                              <1>  ;=======================================================;
   111                              <1>  ; FS_ReadSector                                         ;
   112                              <1>  ;-------------------------------------------------------;
   113                              <1>  ;   Input:                                              ;
   114                              <1>  ;         EAX  = Unit (drive)                           ;
   115                              <1>  ;           0  = Floppy                                 ;
   116                              <1>  ;           1  = primary device (0x1f0), master(0x00)   ;
   117                              <1>  ;           2  = primary device (0x1f0), slave(0x10)    ;
   118                              <1>  ;           3  = secondary device (0x170), master(0x00) ;
   119                              <1>  ;           4  = secondary device (0x170), slave(0x10)  ;
   120                              <1>  ;                                                       ;
   121                              <1>  ;           (upto 8 devices)                            ;
   122                              <1>  ;                                                       ;
   123                              <1>  ;         EDI  = Buffer to write the data               ;
   124                              <1>  ;         EDX  = Sector number to read from             ;
   125                              <1>  ;         ECX  = Count  Nunmber of sectors (just 1)     ;
   126                              <1>  ;                                                       ;
   127                              <1>  ;  Output:                                              ;
   128                              <1>  ;          AH  = 0  for success                         ;
   129                              <1>  ;          AH  = Nonzero for failure                    ;
   130                              <1>  ;           1  = Not implemented yet                    ;
   131                              <1>  ;           2  = Unit to high                           ;
   132                              <1>  ;           3  = TimeOut                                ;
   133                              <1>  ;                                                (100%) ;
   134                              <1>  ;.......................................................;
   135                              <1> 
   136                              <1> FS_ReadSector:
   137                              <1> 	pushraxrdi							; Save the regs
   137                              <2> 
   137 000002EC 50                  <2>  push rax
   137 000002ED 51                  <2>  push rcx
   137 000002EE 52                  <2>  push rdx
   137 000002EF 53                  <2>  push rbx
   137 000002F0 54                  <2>  push rsp
   137 000002F1 55                  <2>  push rbp
   137 000002F2 56                  <2>  push rsi
   137 000002F3 57                  <2>  push rdi
   137                              <2> 
   138 000002F4 893C25[6E020000]    <1> 	mov  dword[HddScratchBuffer],edi			; Save the buffer address
   139 000002FB 891425[72020000]    <1> 	mov  dword[FS_RW_Sector],edx				; Save the sector size (In the current implementation, Sector size will always be 512).
   140 00000302 890C25[76020000]    <1> 	mov  dword[FS_RW_Count],ecx				; Count (In the current implementation, count will always be 1).
   141 00000309 C60425[6D020000]01  <1> 	mov  byte[FS_RW_SectorErrorNum],1			; Set the error flag for Not implemented yet (1)
   142 00000311 83F800              <1> 	cmp  eax,0						; cmp if floppy
   143 00000314 7444                <1> 	je   FS_ReadSectorError 				; If so error as not done yet
   144 00000316 FE0425[6D020000]    <1> 	inc  byte [FS_RW_SectorErrorNum]				; Put the error code to 2
   145 0000031D 83F808              <1> 	cmp  eax,8						; Check if it more then 8
   146 00000320 7738                <1> 	ja   FS_ReadSectorError 				; if so exit with error
   147 00000322 50                  <1> 	push rax						; Save whats in eax
   148 00000323 C1E002              <1> 	shl  eax,2						; times it by 4
   149 00000326 678B98[34020000]    <1> 	mov  ebx,dword[BaseTable+eax]				; Use the look up table to find the base
   150 0000032D 891C25[68020000]    <1> 	mov  dword[HddBaseFS],ebx				  ; Store it
   151 00000334 58                  <1> 	pop  rax						; get the saved eax
   152 00000335 2401                <1> 	and  al,00000001b					; See if its odd or even number
   153 00000337 3401                <1> 	xor  al,00000001b					; Flip bit 1 round
   154 00000339 C0E004              <1> 	shl  al,4						; Multiply by 16
   155 0000033C 880425[6C020000]    <1> 	mov  byte[MasterSlave],al				; Store it as master or slave
   156 00000343 8B0425[72020000]    <1> 	mov  eax,dword[FS_RW_Sector]				; move sector number in to eax
   157 0000034A E899000000          <1> 	call FS_Read_Sector					; call the hdd read function
   158                              <1> 	popraxrdi							; restore the regs
   158                              <2> 
   158 0000034F 5F                  <2>  pop rdi
   158 00000350 5E                  <2>  pop rsi
   158 00000351 5D                  <2>  pop rbp
   158 00000352 5C                  <2>  pop rsp
   158 00000353 5B                  <2>  pop rbx
   158 00000354 5A                  <2>  pop rdx
   158 00000355 59                  <2>  pop rcx
   158 00000356 58                  <2>  pop rax
   158                              <2> 
   159 00000357 30E4                <1> 	xor  ah,ah						; post success
   160 00000359 C3                  <1> 	ret							; Return
   161                              <1> 
   162                              <1> FS_ReadSectorError:
   163                              <1> 	popraxrdi							; restore the regs
   163                              <2> 
   163 0000035A 5F                  <2>  pop rdi
   163 0000035B 5E                  <2>  pop rsi
   163 0000035C 5D                  <2>  pop rbp
   163 0000035D 5C                  <2>  pop rsp
   163 0000035E 5B                  <2>  pop rbx
   163 0000035F 5A                  <2>  pop rdx
   163 00000360 59                  <2>  pop rcx
   163 00000361 58                  <2>  pop rax
   163                              <2> 
   164 00000362 8A2425[6D020000]    <1> 	mov   ah,byte[FS_RW_SectorErrorNum]			; post error number
   165 00000369 C3                  <1> 	ret							; Return
   166                              <1> 
   167                              <1>  ;=======================================================;
   168                              <1>  ; FS_WriteSector                                        ;
   169                              <1>  ;-------------------------------------------------------;
   170                              <1>  ;   Input:                                              ;
   171                              <1>  ;         EAX  = Unit (drive)                           ;
   172                              <1>  ;           0  = Floppy                                 ;
   173                              <1>  ;           1  = primary device (0x1f0), master(0x00)   ;
   174                              <1>  ;           2  = primary device (0x1f0), slave(0x10)    ;
   175                              <1>  ;           3  = secondary device (0x170), master(0x00) ;
   176                              <1>  ;           4  = secondary device (0x170), slave(0x10)  ;
   177                              <1>  ;                                                       ;
   178                              <1>  ;           (upto 8 devices)                            ;
   179                              <1>  ;                                                       ;
   180                              <1>  ;         EDI  = Buffer to write the data               ;
   181                              <1>  ;         EDX  = Sector number to read from             ;
   182                              <1>  ;         ECX  = Count  Nunmber of sectors (just 1)     ;
   183                              <1>  ;                                                       ;
   184                              <1>  ;  Output:                                              ;
   185                              <1>  ;          AH  = 0  for success                         ;
   186                              <1>  ;          AH  = Nonzero for failure                    ;
   187                              <1>  ;           1  = Not implemented yet                    ;
   188                              <1>  ;           2  = Unit to high                           ;
   189                              <1>  ;           3  = TimeOut                                ;
   190                              <1>  ;                                                (100%) ;
   191                              <1>  ;.......................................................;
   192                              <1> 
   193                              <1> FS_WriteSector:
   194                              <1> 	pushraxrdi							; Save the regs
   194                              <2> 
   194 0000036A 50                  <2>  push rax
   194 0000036B 51                  <2>  push rcx
   194 0000036C 52                  <2>  push rdx
   194 0000036D 53                  <2>  push rbx
   194 0000036E 54                  <2>  push rsp
   194 0000036F 55                  <2>  push rbp
   194 00000370 56                  <2>  push rsi
   194 00000371 57                  <2>  push rdi
   194                              <2> 
   195 00000372 893C25[6E020000]    <1> 	mov  dword[HddScratchBuffer],edi			; Save the buffer address
   196 00000379 891425[72020000]    <1> 	mov  dword[FS_RW_Sector],edx				; Save the sector size (In the current implementation, Sector size will always be 512).
   197 00000380 890C25[76020000]    <1> 	mov  dword[FS_RW_Count],ecx				; Count (In the current implementation, count will always be 1).
   198 00000387 C60425[6D020000]01  <1> 	mov  byte[FS_RW_SectorErrorNum],1			; Set the error flag for Not implemented yet (1)
   199 0000038F 83F800              <1> 	cmp  eax,0						; cmp if floppy
   200 00000392 7444                <1> 	je   FS_WriteSectorError				; If so error as not done yet
   201 00000394 FE0425[6D020000]    <1> 	inc  byte [FS_RW_SectorErrorNum]				; Put the error code to 2
   202 0000039B 83F808              <1> 	cmp  eax,8						; Check if it more then 8
   203 0000039E 7738                <1> 	ja   FS_WriteSectorError				; if so exit with error
   204 000003A0 50                  <1> 	push rax						; Save whats in eax
   205 000003A1 C1E002              <1> 	shl  eax,2						; times it by 4
   206 000003A4 678B98[34020000]    <1> 	mov  ebx,dword[BaseTable+eax]				; Use the look up table to find the base
   207 000003AB 891C25[68020000]    <1> 	mov  dword[HddBaseFS],ebx				  ; Store it
   208 000003B2 58                  <1> 	pop  rax						; get the saved eax
   209 000003B3 2401                <1> 	and  al,00000001b					; See if its odd or even number
   210 000003B5 3401                <1> 	xor  al,00000001b					; Flip bit 1 round
   211 000003B7 C0E004              <1> 	shl  al,4						; Multiply by 16
   212 000003BA 880425[6C020000]    <1> 	mov  byte[MasterSlave],al				; Store it as master or slave
   213 000003C1 8B0425[72020000]    <1> 	mov  eax,dword[FS_RW_Sector]				; move sector number in to eax
   214 000003C8 E821000000          <1> 	call FS_Write_Sector					; call the hdd read function
   215                              <1> 	popraxrdi							; restore the regs
   215                              <2> 
   215 000003CD 5F                  <2>  pop rdi
   215 000003CE 5E                  <2>  pop rsi
   215 000003CF 5D                  <2>  pop rbp
   215 000003D0 5C                  <2>  pop rsp
   215 000003D1 5B                  <2>  pop rbx
   215 000003D2 5A                  <2>  pop rdx
   215 000003D3 59                  <2>  pop rcx
   215 000003D4 58                  <2>  pop rax
   215                              <2> 
   216 000003D5 30E4                <1> 	xor  ah,ah						; post success
   217 000003D7 C3                  <1> 	ret							; Return
   218                              <1> 
   219                              <1> FS_WriteSectorError:
   220                              <1> 	popraxrdi							; restore the regs
   220                              <2> 
   220 000003D8 5F                  <2>  pop rdi
   220 000003D9 5E                  <2>  pop rsi
   220 000003DA 5D                  <2>  pop rbp
   220 000003DB 5C                  <2>  pop rsp
   220 000003DC 5B                  <2>  pop rbx
   220 000003DD 5A                  <2>  pop rdx
   220 000003DE 59                  <2>  pop rcx
   220 000003DF 58                  <2>  pop rax
   220                              <2> 
   221 000003E0 8A2425[6D020000]    <1> 	mov   ah,byte[FS_RW_SectorErrorNum]			; post error number
   222 000003E7 C3                  <1> 	ret							; Return
   223                              <1> 
   224                              <1> 
   225                              <1>  ;=======================================================;
   226                              <1>  ; FS_ReadSector.                                        ;
   227                              <1>  ;-------------------------------------------------------;
   228                              <1>  ;   Input:                                              ;
   229                              <1>  ;         EAX  = Block to read                          ;
   230                              <1>  ;                                                       ;
   231                              <1>  ; NOTE: You should call FS_ReadWriteSectorSetUp         ;
   232                              <1>  ;       on before the first time you call this function ;
   233                              <1>  ;                                                (100%) ;
   234                              <1>  ;.......................................................;
   235                              <1> 
   236                              <1> FS_Read_Sector:
   237 000003E8 E807000000          <1> 	call HddReadFS						  ; Call the function
   238 000003ED C3                  <1> 	ret							; Return
   239                              <1> 
   240                              <1> 
   241                              <1>  ;=======================================================;
   242                              <1>  ; FS_WriteSector.                                       ;
   243                              <1>  ;-------------------------------------------------------;
   244                              <1>  ;   Input:                                              ;
   245                              <1>  ;         EAX  = Block to write                         ;
   246                              <1>  ;                                                       ;
   247                              <1>  ; NOTE: You should call FS_ReadWriteSectorSetUp         ;
   248                              <1>  ;       on before the first time you call this function ;
   249                              <1>  ;                                                (100%) ;
   250                              <1>  ;.......................................................;
   251                              <1> 
   252                              <1> FS_Write_Sector:
   253 000003EE E86C000000          <1> 	call HddWriteFS 					  ; Call the function
   254 000003F3 C3                  <1> 	ret							; Return
   255                              <1> 
   256                              <1>  ;=======================================================;
   257                              <1>  ; hd_read.                                              ;
   258                              <1>  ;            ;  eax = block to read                     ;
   259                              <1>  ;            ; [HddScratchBuffer] = buffer to write too ;
   260                              <1>  ;=======================================================;
   261                              <1> HddReadFS:
   262                              <1> 	pushraxrdi
   262                              <2> 
   262 000003F4 50                  <2>  push rax
   262 000003F5 51                  <2>  push rcx
   262 000003F6 52                  <2>  push rdx
   262 000003F7 53                  <2>  push rbx
   262 000003F8 54                  <2>  push rsp
   262 000003F9 55                  <2>  push rbp
   262 000003FA 56                  <2>  push rsi
   262 000003FB 57                  <2>  push rdi
   262                              <2> 
   263 000003FC 50                  <1> 	push  rax
   264                              <1> newhdreadFS:
   265 000003FD 8B1425[68020000]    <1> 	mov edx,[HddBaseFS]
   266 00000404 FFC2                <1> 	inc   edx
   267 00000406 B000                <1> 	mov   al,0
   268 00000408 EE                  <1> 	out   dx,al
   269                              <1> 
   270 00000409 FFC2                <1> 	inc   edx
   271 0000040B B001                <1> 	mov   al,1
   272 0000040D EE                  <1> 	out   dx,al
   273                              <1> 
   274 0000040E FFC2                <1> 	inc   edx
   275                              <1> 	;pop   ax
   276                              <1> 	;pop   ax
   277 00000410 6658                <1> 	pop   ax
   278 00000412 EE                  <1> 	out   dx,al
   279                              <1> 
   280 00000413 FFC2                <1> 	inc   edx
   281 00000415 66C1E808            <1> 	shr   ax,8
   282 00000419 EE                  <1> 	out   dx,al
   283                              <1> 
   284 0000041A FFC2                <1> 	inc   edx
   285 0000041C 6658                <1> 	pop   ax
   286 0000041E EE                  <1> 	out   dx,al
   287                              <1> 
   288 0000041F FFC2                <1> 	inc   edx
   289 00000421 66C1E808            <1> 	shr   ax,8
   290 00000425 240F                <1> 	and   al,1+2+4+8
   291 00000427 020425[6C020000]    <1> 	add   al,[MasterSlave]
   292 0000042E 04E0                <1> 	add   al,128+64+32
   293 00000430 EE                  <1> 	out   dx,al
   294                              <1> 
   295 00000431 FFC2                <1> 	inc   edx
   296 00000433 B020                <1> 	mov   al,20h
   297 00000435 EE                  <1> 	out   dx,al
   298                              <1> hddwaitFS:
   299 00000436 EC                  <1> 	in    al,dx
   300 00000437 A880                <1> 	test  al,128
   301 00000439 75FB                <1> 	jnz   hddwaitFS
   302                              <1> 
   303 0000043B 8B3C25[6E020000]    <1> 	mov   edi,dword[HddScratchBuffer]
   304 00000442 B900010000          <1> 	mov   ecx,256
   305 00000447 8B1425[68020000]    <1> 	mov edx,[HddBaseFS]
   306 0000044E FC                  <1> 	cld
   307 0000044F F3666D              <1> 	rep   insw
   308                              <1> 
   309 00000452 6658                <1> 	pop ax
   310 00000454 6658                <1> 	pop ax
   311                              <1> 	popraxrdi
   311                              <2> 
   311 00000456 5F                  <2>  pop rdi
   311 00000457 5E                  <2>  pop rsi
   311 00000458 5D                  <2>  pop rbp
   311 00000459 5C                  <2>  pop rsp
   311 0000045A 5B                  <2>  pop rbx
   311 0000045B 5A                  <2>  pop rdx
   311 0000045C 59                  <2>  pop rcx
   311 0000045D 58                  <2>  pop rax
   311                              <2> 
   312 0000045E C3                  <1> 	ret
   313                              <1> 
   314                              <1> 
   315                              <1> 
   316                              <1>  ;=======================================================;
   317                              <1>  ; hd_write.    ; eax = block to write                   ;
   318                              <1>  ;              ; HddScratchBuffer = buffer to read from ;
   319                              <1>  ;=======================================================;
   320                              <1> HddWriteFS:
   321                              <1> 	pushraxrdi 
   321                              <2> 
   321 0000045F 50                  <2>  push rax
   321 00000460 51                  <2>  push rcx
   321 00000461 52                  <2>  push rdx
   321 00000462 53                  <2>  push rbx
   321 00000463 54                  <2>  push rsp
   321 00000464 55                  <2>  push rbp
   321 00000465 56                  <2>  push rsi
   321 00000466 57                  <2>  push rdi
   321                              <2> 
   322 00000467 50                  <1> 	push  rax
   323                              <1> newhdwrite:
   324 00000468 8B1425[68020000]    <1> 	mov edx,[HddBaseFS]
   325 0000046F FFC2                <1> 	inc   edx
   326 00000471 B000                <1> 	mov   al,0
   327 00000473 EE                  <1> 	out   dx,al
   328                              <1> 
   329 00000474 FFC2                <1> 	inc   edx
   330 00000476 B001                <1> 	mov   al,1
   331 00000478 EE                  <1> 	out   dx,al
   332                              <1> 
   333 00000479 FFC2                <1> 	inc   edx
   334 0000047B 6658                <1> 	pop   ax
   335 0000047D 6658                <1> 	pop ax
   336 0000047F 6658                <1> 	pop ax
   337 00000481 EE                  <1> 	out   dx,al
   338                              <1> 
   339 00000482 FFC2                <1> 	inc   edx
   340 00000484 66C1E808            <1> 	shr   ax,8
   341 00000488 EE                  <1> 	out   dx,al
   342                              <1> 
   343 00000489 FFC2                <1> 	inc   edx
   344 0000048B 6658                <1> 	pop   ax
   345 0000048D EE                  <1> 	out   dx,al
   346                              <1> 
   347 0000048E FFC2                <1> 	inc   edx
   348 00000490 66C1E808            <1> 	shr   ax,8
   349 00000494 240F                <1> 	and   al,1+2+4+8
   350 00000496 020425[6C020000]    <1> 	add   al,[MasterSlave]
   351 0000049D 04E0                <1> 	add   al,128+64+32
   352 0000049F EE                  <1> 	out   dx,al
   353                              <1> 
   354 000004A0 FFC2                <1> 	inc   edx
   355 000004A2 B030                <1> 	mov   al,30h					; write with retry (without = 0x31)
   356 000004A4 EE                  <1> 	out   dx,al
   357                              <1> hddwaitWrite:
   358 000004A5 EC                  <1> 	in    al,dx
   359 000004A6 A880                <1> 	test  al,128
   360 000004A8 75FB                <1> 	jnz   hddwaitWrite
   361                              <1> 
   362 000004AA 8B3425[6E020000]    <1> 	mov   esi,dword[HddScratchBuffer]
   363 000004B1 B900010000          <1> 	mov   ecx,256
   364 000004B6 8B1425[68020000]    <1> 	mov   edx,[HddBaseFS]
   365 000004BD FC                  <1> 	cld
   366 000004BE F3666F              <1> 	rep outsw
   367                              <1> 	popraxrdi
   367                              <2> 
   367 000004C1 5F                  <2>  pop rdi
   367 000004C2 5E                  <2>  pop rsi
   367 000004C3 5D                  <2>  pop rbp
   367 000004C4 5C                  <2>  pop rsp
   367 000004C5 5B                  <2>  pop rbx
   367 000004C6 5A                  <2>  pop rdx
   367 000004C7 59                  <2>  pop rcx
   367 000004C8 58                  <2>  pop rax
   367                              <2> 
   368 000004C9 C3                  <1> 	ret
   369                              <1> 
   370                              <1> 
   371                              <1> 
   372                              <1> 
   373                              <1>  
    74                                  	%include "C:\Users\Stephen\Documents\NASM\pushpopraxtordi.inc" 	;include pusha popa 64
     1                              <1> 	;
     2                              <1> 	;push rax - rdi macro
     3                              <1> 	;
     4                              <1> %macro pushraxrdi 0
     4          ******************  <1>  warning: redefining multi-line macro `pushraxrdi'
     5                              <1> 
     6                              <1> 	push rax
     7                              <1> 	push rcx
     8                              <1> 	push rdx
     9                              <1> 	push rbx
    10                              <1> 	push rsp
    11                              <1> 	push rbp
    12                              <1> 	push rsi
    13                              <1> 	push rdi
    14                              <1> 
    15                              <1> %endmacro
    16                              <1> 
    17                              <1> 	;
    18                              <1> 	;pop rax - rdi macro
    19                              <1> 	;
    20                              <1> %macro popraxrdi 0
    20          ******************  <1>  warning: redefining multi-line macro `popraxrdi'
    21                              <1> 
    22                              <1> 	pop rdi
    23                              <1> 	pop rsi
    24                              <1> 	pop rbp
    25                              <1> 	pop rsp
    26                              <1> 	pop rbp
    27                              <1> 	pop rdx
    28                              <1> 	pop rcx
    29                              <1> 	pop rax
    30                              <1> 	
    31                              <1> %endmacro
    75                                  	
    76                                  	
    77                                  	
    78                                  	;Kernal code start
    79 000004CA 90<rept>                	align 8
    80                                  	
    81                                  	Kern_Start:
    82 000004D0 41B800000000            	mov r8,0					;x=0
    83 000004D6 66448B0C25-             	mov r9w,word [STK]		;y=0
    83 000004DB [1F000000]         
    84 000004DF 49BB-                   	mov r11,STK+2			;string to print
    84 000004E1 [2100000000000000] 
    85 000004E9 41BAF4000000            	mov r10,0xf4				;Red on white
    86 000004EF E8D2FCFFFF              	call printc
    87 000004F4 B800000000              	mov rax,0
    88 000004F9 B900020000              	mov rcx,512
    89 000004FE BF00000040              	mov rdi,IDTRK
    90 00000503 F348AB                  	rep stosq				;clear IDT table
    91 00000506 B800200040              	mov rax,idt_info
    92 0000050B 482D00000040            	sub rax,IDTRK
    93 00000511 48FFC8                  	dec rax					;Size of table-1
    94 00000514 6689042500200040        	mov [IDTS],ax			;16 bit size of table
    95 0000051C 48C704250220004000-     	mov qword [IDTST],IDTRK	;start of interrupt table
    95 00000525 000040             
    96 00000528 0F011C2500200040        	lidt [idt_info]			;load interrupt table info into IDTR register
    97                                  	;
    98                                  	;Re-map PIC offsets	
    99                                  	;
   100 00000530 E421                    	in al,PIC1_DATA			;Save mask for master
   101 00000532 4188C0                  	mov r8b,al
   102 00000535 E4A1                    	in al,PIC2_DATA			;Save mask for slave
   103 00000537 4188C1                  	mov r9b,al
   104 0000053A B011                    	mov al,ICW1_INIT+ICW1_ICW4
   105 0000053C E620                    	out PIC1_COMMAND,al			;starts the initialization sequence (in cascade mode)
   106 0000053E E6A0                    	out PIC2_COMMAND,al			;
   107 00000540 B020                    	mov al,0x20
   108 00000542 E621                    	out PIC1_DATA,al				;ICW2: Master PIC vector offset
   109 00000544 B028                    	mov al,0x28
   110 00000546 E6A1                    	out PIC2_DATA,al				;ICW2: Slave PIC vector offset
   111 00000548 B004                    	mov al,4
   112 0000054A E621                    	out PIC1_DATA,al				;ICW3: tell Master PIC that there is a slave PIC at IRQ2 (0000 0100)
   113 0000054C B002                    	mov al,2
   114 0000054E E6A1                    	out PIC2_DATA,al				;ICW3: tell Slave PIC its cascade identity (0000 0010)
   115 00000550 B001                    	mov al,ICW4_8086
   116 00000552 E621                    	out PIC1_DATA,al
   117 00000554 E6A1                    	out PIC2_DATA,al
   118 00000556 4488C0                  	mov al,r8b					;Restore saved masks
   119 00000559 E621                    	out PIC1_DATA ,al			;
   120 0000055B 4488C8                  	mov al,r9b					;
   121 0000055E E6A1                    	out PIC2_DATA,al				;
   122                                  								;
   123                                  								;initialise interrupt table to the default for now
   124                                  								;
   125 00000560 BF00000040              	mov rdi,IDTRK				;start of interrupt table
   126 00000565 48B8-                   	mov rax,Default_Int			;start of the default interrupt
   126 00000567 [0406000000000000] 
   127 0000056F B900010000              	mov rcx,256					;256 entries
   128 00000574 668907                  	mov word [rdi],ax			;First offset for interrupt
   129 00000577 66C747020800            	mov word [rdi+2],8			;Selector = 8
   130 0000057D C6470400                	mov byte [rdi+4],0			;
   131 00000581 C647058E                	mov byte [rdi+5],0x8e		;Interrupt gate and present plus ring 0 only
   132 00000585 48C1C810                	ror rax,16					;get middle bits
   133 00000589 66894706                	mov [rdi+6],ax	
   134 0000058D 48C1C810                	ror rax,16					;get high bits
   135 00000591 894708                  	mov [rdi+8],eax
   136 00000594 C7470C00000000          	mov dword [rdi+12],0			;first entry done
   137 0000059B 4883C710                	add rdi,16					;next entry
   138 0000059F B9FF000000              	mov rcx,255					;count of qword entries
   139 000005A4 FC                      	cld
   140                                  	L1:
   141 000005A5 BE00000040              	mov rsi,IDTRK				;source
   142 000005AA 48A5                    	movsq 						;store qword from rsi to rdi
   143 000005AC 48A5                    	movsq						;16 bytes copied for one entry
   144 000005AE E2F5                    	loop L1						;until done
   145 000005B0 BF00000040              	mov rdi,IDTRK
   146 000005B5 4881C780000000          	add rdi,8*16					;8th entry
   147 000005BC 48B8-                   	mov rax,ISR_Sys_Er
   147 000005BE [6F06000000000000] 
   148 000005C6 668907                  	mov [rdi],ax
   149 000005C9 48C1C810                	ror rax,16
   150 000005CD 66894706                	mov [rdi+6],ax
   151 000005D1 48C1C810                	ror rax,16
   152 000005D5 894708                  	mov [rdi+8],eax
   153 000005D8 BF00000040              	mov rdi,IDTRK
   154 000005DD 4881C7D0000000          	add rdi,13*16					;13th entry
   155 000005E4 48B8-                   	mov rax,Gen_Pro_Er
   155 000005E6 [8006000000000000] 
   156 000005EE 668907                  	mov [rdi],ax
   157 000005F1 48C1C810                	ror rax,16
   158 000005F5 66894706                	mov [rdi+6],ax
   159 000005F9 48C1C810                	ror rax,16
   160 000005FD 894708                  	mov [rdi+8],eax
   161                                  
   162                                  	;sti
   163 00000600 CD28                    	int 40
   164                                  
   165 00000602 EBFE                    	jmp $
   166                                  	
   167                                  	
   168                                  	Default_Int:					;Default interrupt
   169 00000604 EBFE                    	jmp $
   170                                  	pushraxrdi						;pusha macro
   170                              <1> 
   170 00000606 50                  <1>  push rax
   170 00000607 51                  <1>  push rcx
   170 00000608 52                  <1>  push rdx
   170 00000609 53                  <1>  push rbx
   170 0000060A 54                  <1>  push rsp
   170 0000060B 55                  <1>  push rbp
   170 0000060C 56                  <1>  push rsi
   170 0000060D 57                  <1>  push rdi
   170                              <1> 
   171 0000060E 41B800000000            	mov r8,0
   172 00000614 41B903000000            	mov r9,3
   173 0000061A 49BB-                   	mov r11,PINT						;print 'Interrupt!'
   173 0000061C [2400000000000000] 
   174 00000624 41BAF0000000            	mov r10,0xf0
   175 0000062A E897FBFFFF              	call printc
   176                                  	popraxrdi						;popa macro
   176                              <1> 
   176 0000062F 5F                  <1>  pop rdi
   176 00000630 5E                  <1>  pop rsi
   176 00000631 5D                  <1>  pop rbp
   176 00000632 5C                  <1>  pop rsp
   176 00000633 5D                  <1>  pop rbp
   176 00000634 5A                  <1>  pop rdx
   176 00000635 59                  <1>  pop rcx
   176 00000636 58                  <1>  pop rax
   176                              <1> 
   177                                  	;jmp $
   178 00000637 48CF                    	iretq
   179                                  	
   180                                  	Pr_Except:					;Print exception Sub_Routine
   181 00000639 66448B08                	mov r9w,[rax]				;y 
   182 0000063D 4D31C0                  	xor r8,r8					;x = 0
   183 00000640 4989C3                  	mov r11,rax
   184 00000643 4983C302                	add r11,2					;string
   185 00000647 41BAF0000000            	mov r10,0xf0					;colour
   186 0000064D E874FBFFFF              	call printc					;Print exception warning
   187 00000652 41B90C000000            	mov r9,12
   188 00000658 41B80A000000            	mov r8,10
   189 0000065E 49BB-                   	mov r11,Turn_O
   189 00000660 [6D01000000000000] 
   190 00000668 E859FBFFFF              	call printc
   191 0000066D FA                      	cli
   192 0000066E F4                      	hlt							;turn off or reboot
   193                                  	
   194                                  	ISR_Sys_Er:					;Double Exception Int 8
   195 0000066F 48B8-                   	mov rax,Sys_Err
   195 00000671 [B200000000000000] 
   196 00000679 E8BBFFFFFF              	call Pr_Except
   197 0000067E FA                      	cli
   198 0000067F F4                      	hlt
   199                                  	
   200                                  	Gen_Pro_Er:					;General protection fault
   201 00000680 48B8-                   	mov rax,Gen_Pro
   201 00000682 [2B01000000000000] 
   202 0000068A E8AAFFFFFF              	call Pr_Except
   203 0000068F FA                      	cli
   204 00000690 F4                      	hlt
   205                                  	
   206 00000691 5555555555555555        	dq 0x5555555555555555			;end of code marker
   207                                  	
   208                                  	absolute 0x40000000					;1GB start of data
   209                                  	
   210                                  	IDTRK:							;IDT descriptor table
   211 40000000 <res 00002000>          	resw	0x1000					;256*16 byte table
   212                                  	idt_info:
   213 40002000 <res 00000002>          IDTS:	resw 1
   214 40002002 <res 00000008>          IDTST:	resq 1
