Index: trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectDrives.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectDrives.asm	(revision 39)
+++ trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectDrives.asm	(revision 86)
@@ -1,9 +1,4 @@
-; File name		:	DetectDrives.asm
 ; Project name	:	IDE BIOS
-; Created date	:	17.3.2010
-; Last update	:	23.8.2010
-; Author		:	Tomi Tilli
 ; Description	:	Functions for detecting drive for the BIOS.
-
 
 ; Section containing code
@@ -80,6 +75,5 @@
 DetectDrives_DetectMasterDrive:
 	mov		bh, MASK_IDE_DRVHD_SET		; Select Master drive
-	jmp		SHORT DetectDrives_StartDetection
-ALIGN JUMP_ALIGN
+	SKIP2B	ax							; mov ax, <next instruction>
 DetectDrives_DetectSlaveDrive:
 	mov		bh, MASK_IDE_DRVHD_SET | FLG_IDE_DRVHD_DRV
@@ -134,26 +128,4 @@
 	call	AH25h_GetDriveInfo
 	mov		si, di						; ES:SI now points to ATA information
-	ret
-
-
-;--------------------------------------------------------------------
-; Reads ATAPI information from the drive (for CD/DVD-ROMs).
-;
-; DetectDrives_ReadAtapiInfoFromDrive
-;	Parameters:
-;		BH:		Drive Select byte for Drive and Head Register
-;		CS:BP:	Ptr to IDEVARS for the drive
-;		DS:		RAMVARS segment
-;		ES:		Zero (BDA segment)
-;	Returns:
-;		ES:SI	Ptr to ATAPI information (read with IDENTIFY PACKET DEVICE command)
-;		CF:		Cleared if ATAPI-information read successfully
-;				Set if any error
-;	Corrupts registers:
-;		AX, BL, CX, DX, DI
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-DetectDrives_ReadAtapiInfoFromDrive:
-	stc
 	ret
 
@@ -188,4 +160,27 @@
 
 ;--------------------------------------------------------------------
+; Reads ATAPI information from the drive (for CD/DVD-ROMs).
+;
+; DetectDrives_ReadAtapiInfoFromDrive
+;	Parameters:
+;		BH:		Drive Select byte for Drive and Head Register
+;		CS:BP:	Ptr to IDEVARS for the drive
+;		DS:		RAMVARS segment
+;		ES:		Zero (BDA segment)
+;	Returns:
+;		ES:SI	Ptr to ATAPI information (read with IDENTIFY PACKET DEVICE command)
+;		CF:		Cleared if ATAPI-information read successfully
+;				Set if any error
+;	Corrupts registers:
+;		AX, BL, CX, DX, DI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+DetectDrives_ReadAtapiInfoFromDrive:
+	;stc
+	;ret
+	; Fall through to DetectDrives_CreateBiosTablesForCDROM
+
+
+;--------------------------------------------------------------------
 ; Creates all BIOS tables for detected CD/DVD-ROM.
 ;
Index: trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectPrint.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectPrint.asm	(revision 39)
+++ trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectPrint.asm	(revision 86)
@@ -1,7 +1,3 @@
-; File name		:	DetectPrint.asm
 ; Project name	:	IDE BIOS
-; Created date	:	28.3.2010
-; Last update	:	9.4.2010
-; Author		:	Tomi Tilli
 ; Description	:	Functions for printing drive detection strings.
 
@@ -25,6 +21,5 @@
 	ePUSH_T	ax, ROMVARS.szTitle
 	mov		si, g_szRomAt
-	mov		dh, 4						; 4 bytes pushed to stack
-	jmp		PrintString_JumpToFormat
+	jmp		SHORT DetectPrint_4BytesPushedToStack
 
 
@@ -67,4 +62,5 @@
 	push	ax
 	mov		si, g_szDetect
+DetectPrint_4BytesPushedToStack:
 	mov		dh, 4						; 4 bytes pushed to stack
 	jmp		PrintString_JumpToFormat
Index: trunk/XTIDE_Universal_BIOS/Src/Initialization/FloppyDrive.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Initialization/FloppyDrive.asm	(revision 39)
+++ trunk/XTIDE_Universal_BIOS/Src/Initialization/FloppyDrive.asm	(revision 86)
@@ -1,7 +1,3 @@
-; File name		:	FloppyDrive.asm
 ; Project name	:	IDE BIOS
-; Created date	:	25.3.2010
-; Last update	:	13.9.2010
-; Author		:	Tomi Tilli
 ; Description	:	Various floppy drive related functions that
 ;					Boot Menu uses.
@@ -21,5 +17,5 @@
 ;	Corrupts registers:
 ;		BX, CX, DI
-;--------------------------------------------------------------------	
+;--------------------------------------------------------------------
 ;ALIGN JUMP_ALIGN
 FloppyDrive_IsInt40hInstalled:
@@ -40,5 +36,5 @@
 ;	Corrupts registers:
 ;		BX, CX, DI
-;--------------------------------------------------------------------	
+;--------------------------------------------------------------------
 ;ALIGN JUMP_ALIGN
 .VerifyInt40hHandlerSinceSomeBiosesSimplyReturnFromInt40h:
@@ -84,11 +80,11 @@
 ;	Corrupts registers:
 ;		DH
-;--------------------------------------------------------------------	
+;--------------------------------------------------------------------
 ;ALIGN JUMP_ALIGN
 .LoadInt40hVerifyParameters:
-	xor		dx, dx				; Floppy drive 0
+	mov		ah, 08h				; Get Drive Parameters
+	cwd							; Floppy drive 0
 	mov		di, dx
 	mov		es, dx				; ES:DI = 0000:0000h to guard against BIOS bugs
-	mov		ah, 08h				; Get Drive Parameters
 	ret
 
@@ -171,5 +167,5 @@
 
 	mov		ah, 08h					; Get Drive Parameters
-	xor		dx, dx					; Floppy Drive 00h
+	cwd								; Floppy Drive 00h
 	int		INTV_FLOPPY_FUNC
 	mov		cl, dl					; Number of Floppy Drives to CL
Index: trunk/XTIDE_Universal_BIOS/Src/Initialization/Interrupts.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Initialization/Interrupts.asm	(revision 39)
+++ trunk/XTIDE_Universal_BIOS/Src/Initialization/Interrupts.asm	(revision 86)
@@ -1,7 +1,3 @@
-; File name		:	Interrupts.asm
 ; Project name	:	IDE BIOS
-; Created date	:	23.8.2010
-; Last update	:	23.8.2010
-; Author		:	Tomi Tilli
 ; Description	:	Functions for initializing the BIOS.
 
@@ -18,5 +14,5 @@
 ;	Corrupts registers:
 ;		All except segments
-;--------------------------------------------------------------------	
+;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
 Interrupts_InitializeInterruptVectors:
@@ -24,4 +20,5 @@
 	call	Interrupts_InitializeInt19h
 	jmp		SHORT Interrupts_InitializeHardwareIrqHandlers
+	; Maybe all this should be inlined?
 
 
@@ -35,5 +32,5 @@
 ;	Corrupts registers:
 ;		AX, BX, CX, DX, SI, DI
-;--------------------------------------------------------------------	
+;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
 Interrupts_InitializeInt13hAnd40h:
@@ -50,21 +47,8 @@
 	; 40h from 13h. That system locks to infinite loop if we copy 13h to 40h.
 	call	FloppyDrive_IsInt40hInstalled
-	jnc		SHORT .InitializeInt40h
-	ret
-
-;--------------------------------------------------------------------
-; .InitializeInt40h
-;	Parameters:
-;		DX:AX:	Ptr to old INT 13h handler
-;		ES:		BDA and Interrupt Vector segment (zero)
-;	Returns:
-;		Nothing
-;	Corrupts registers:
-;		Nothing
-;--------------------------------------------------------------------	
-ALIGN JUMP_ALIGN
-.InitializeInt40h:
+	jc		SHORT .Return
 	mov		[es:INTV_FLOPPY_FUNC*4], ax		; Store offset
 	mov		[es:INTV_FLOPPY_FUNC*4+2], dx	; Store segment
+.Return:
 	ret
 
@@ -79,5 +63,5 @@
 ;	Corrupts registers:
 ;		BX, SI
-;--------------------------------------------------------------------	
+;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
 Interrupts_InitializeInt19h:
@@ -116,5 +100,5 @@
 ;	Corrupts registers:
 ;		BX, CX, DX, SI, DI
-;--------------------------------------------------------------------		
+;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
 Interrupts_InitializeHardwareIrqHandlers:
@@ -127,5 +111,6 @@
 	call	.InstallLowOrHighIrqHandler
 	loop	.IdeControllerLoop
-	ret
+.Return:
+	ret		; This ret is shared with .InstallLowOrHighIrqHandler
 
 ;--------------------------------------------------------------------
@@ -138,12 +123,12 @@
 ;	Corrupts registers:
 ;		BX, SI
-;--------------------------------------------------------------------		
+;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
 .InstallLowOrHighIrqHandler:
+	test	bl, bl
+	jz		SHORT .Return	; IRQ not used
 	cmp		bl, 8
-	jae		SHORT .InstallHighIrqHandler
-	test	bl, bl
-	jnz		SHORT .InstallLowIrqHandler
-	ret		; IRQ not used
+	jb		SHORT .InstallLowIrqHandler
+	; Fall through to .InstallHighIrqHandler
 
 ;--------------------------------------------------------------------
@@ -156,7 +141,7 @@
 ;	Corrupts registers:
 ;		BX, SI
-;--------------------------------------------------------------------		
-ALIGN JUMP_ALIGN
-.InstallHighIrqHandler:
+;--------------------------------------------------------------------
+;ALIGN JUMP_ALIGN
+;.InstallHighIrqHandler:
 	add		bx, BYTE INTV_IRQ8 - 8			; Interrupt vector number
 	mov		si, HIRQ_InterruptServiceRoutineForIrqs8to15
@@ -172,5 +157,5 @@
 ;	Corrupts registers:
 ;		BX, SI
-;--------------------------------------------------------------------		
+;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
 .InstallLowIrqHandler:
@@ -190,5 +175,5 @@
 ;	Corrupts registers:
 ;		BX
-;--------------------------------------------------------------------	
+;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
 Interrupts_InstallHandlerToVectorInBXFromCSSI:
@@ -212,9 +197,9 @@
 	eMOVZX	bx, BYTE [di+DPT.bIdeOff]
 	mov		al, [cs:bx+IDEVARS.bIRQ]
+	test	al, al
+	jz		SHORT .Return	; Interrupts disabled
 	cmp		al, 8
-	jae		SHORT .UnmaskHighIrqController
-	test	al, al
-	jnz		SHORT .UnmaskLowIrqController
-	ret		; Interrupts disabled
+	jb		SHORT .UnmaskLowIrqController
+	; Fall through to .UnmaskHighIrqController
 
 ;--------------------------------------------------------------------
@@ -227,6 +212,6 @@
 ;		AX, DX
 ;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-.UnmaskHighIrqController:
+;ALIGN JUMP_ALIGN
+;.UnmaskHighIrqController:
 	sub		al, 8				; Slave interrupt number
 	mov		dx, PORT_8259SL_IMR	; Load Slave Mask Register address
@@ -270,3 +255,4 @@
 	out		dx, al				; Write modified Interrupt Mask Register
 	pop		cx
-	ret
+.Return:
+	ret
Index: trunk/XTIDE_Universal_BIOS/Src/Initialization/PrintString.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Initialization/PrintString.asm	(revision 39)
+++ trunk/XTIDE_Universal_BIOS/Src/Initialization/PrintString.asm	(revision 86)
@@ -1,9 +1,4 @@
-; File name		:	PrintString.asm
 ; Project name	:	IDE BIOS
-; Created date	:	19.3.2010
-; Last update	:	31.3.2010
-; Author		:	Tomi Tilli
 ; Description	:	Functions for printing strings used in this IDE BIOS.
-
 
 ; Section containing code
@@ -13,5 +8,5 @@
 ; Prints string with formatting parameters.
 ; Do not call PrintString_JumpToFormat!!! Jump there only!
-; 
+;
 ; PrintString_JumpToFormat
 ;	Parameters:
@@ -42,5 +37,5 @@
 ;--------------------------------------------------------------------
 ; Prints STOP terminated string from wanted segment.
-; 
+;
 ; PrintString_FromCS
 ; PrintString_FromES
@@ -56,14 +51,9 @@
 PrintString_FromCS:
 	push	ds
-	push	cs					; Push string segment...
-	pop		ds					; ...and pop it to DS
-	call	PrintString_FromDS
-	pop		ds
-	ret
-
-ALIGN JUMP_ALIGN
+	push	cs					; Push string segment here...
+	SKIP2B	ax					; mov ax, <next 2 bytes/instructions>
 PrintString_FromES:
 	push	ds
-	push	es					; Push string segment...
+	push	es					; ...or here...
 	pop		ds					; ...and pop it to DS
 	call	PrintString_FromDS
