Index: /trunk/Assembly_Library/Inc/CgaSnow.inc
===================================================================
--- /trunk/Assembly_Library/Inc/CgaSnow.inc	(revision 623)
+++ /trunk/Assembly_Library/Inc/CgaSnow.inc	(revision 624)
@@ -8,5 +8,5 @@
 ; JMP_WAIT_FOR_RETRACE_IF_NECESSARY_THEN
 ;	Parameters:
-;		%1:		Instruction that accessed CGA memory
+;		%1:		Instruction that accesses CGA memory
 ;		AL:		Character to output
 ;		AH:		Attribute to output (stosw only)
Index: /trunk/Assembly_Library/Inc/Emulate.inc
===================================================================
--- /trunk/Assembly_Library/Inc/Emulate.inc	(revision 623)
+++ /trunk/Assembly_Library/Inc/Emulate.inc	(revision 624)
@@ -188,4 +188,64 @@
 ;		%2:		Source WORD operand where to search bit (not CX or same as %1!)
 ;	Returns:
+;		%1:		Index of lowest order bit from %2
+;		ZF:		Set if %2 is zero
+;				Cleared if %2 is non-zero
+;	Corrupts registers:
+;		Nothing
+;--------------------------------------------------------------------
+%macro eBSF 2
+%ifndef USE_386
+	FSIS	], %2				; %2 is a memory operand?
+	%if strpos
+		cmp		WORD %2, BYTE 0	; Source operand is zero?
+		je		SHORT %%Return	;  If so, return with ZF set
+	%else						; No, %2 is a register
+		test	%2, %2
+		jz		SHORT %%Return
+	%endif
+
+	push	cx
+
+%ifdef USE_NEC_V
+	mov		cx, -1
+
+ALIGN JUMP_ALIGN
+%%BitLoop:
+	inc		cx
+	eTEST1	%2, cl
+	jz		SHORT %%BitLoop
+	mov		%1, cx
+
+%else ; ~USE_NEC_V
+	mov		cx, 1<<15
+	mov		%1, -1
+
+ALIGN JUMP_ALIGN
+%%BitLoop:
+	rol		cx, 1				; Prepare to test next bit
+	inc		%1					; Increment bit index
+	test	%2, cx				; Bit set?
+	jz		SHORT %%BitLoop
+%endif
+
+	pop		cx
+
+%%Return:
+;-----------------------------------
+%else ; USE_386
+	bsf		%1, %2
+%endif
+%endmacro
+
+
+;--------------------------------------------------------------------
+; Emulates BSR (Bit Scan Reverse) instruction when necessary.
+; BSR is used to find index of most significant bit.
+;
+; eBSR
+;	Parameters:
+;		%1:		Destination WORD Register for bit index (not CX or same as %2!)
+;		%2:		Source WORD operand where to search bit (not CX or same as %1!)
+;	Returns:
 ;		%1:		Index of highest order bit from %2
 ;		ZF:		Set if %2 is zero
@@ -194,68 +254,44 @@
 ;		Nothing
 ;--------------------------------------------------------------------
-%macro eBSF 2
+%macro eBSR 2
 %ifndef USE_386
-	cmp		WORD %2, BYTE 0		; Source operand is zero?
-	je		SHORT %%Return		;  If so, return with ZF set
-
-	; Set destination to zero and load mask for bit 0
+	FSIS	], %2				; %2 is a memory operand?
+	%if strpos
+		cmp		WORD %2, BYTE 0	; Source operand is zero?
+		je		SHORT %%Return	;  If so, return with ZF set
+	%else						; No, %2 is a register
+		test	%2, %2
+		jz		SHORT %%Return
+	%endif
+
 	push	cx
-	xor		%1, %1
-	mov		cx, 1
+
+%ifdef USE_NEC_V
+	mov		cx, 16
 
 ALIGN JUMP_ALIGN
 %%BitLoop:
-	test	%2, cx				; Bit set?
-	jnz		SHORT %%PopAndReturn;  If so, return with ZF cleared
-	shl		cx, 1				; Prepare to test next bit
-	inc		%1					; Increment bit index
-	jmp		SHORT %%BitLoop		; Loop until bit found
-%%PopAndReturn:
-	pop		cx
-%%Return:
-;-----------------------------------
-%else
-	bsf		%1, %2
-%endif
-%endmacro
-
-
-;--------------------------------------------------------------------
-; Emulates BSR (Bit Scan Reverse) instruction when necessary.
-; BSR is used to find index of most significant bit.
-;
-; eBSR
-;	Parameters:
-;		%1:		Destination WORD Register for bit index (not CX or same as %2!)
-;		%2:		Source WORD operand where to search bit (not CX or same as %1!)
-;	Returns:
-;		%1:		Index of highest order bit from %2
-;		ZF:		Set if %2 is zero
-;				Cleared if %2 is non-zero
-;	Corrupts registers:
-;		Nothing
-;--------------------------------------------------------------------
-%macro eBSR 2
-%ifndef USE_386
-	cmp		WORD %2, BYTE 0		; Source operand is zero?
-	je		SHORT %%Return		;  If so, return with ZF set
-
-	; Load mask for highest order bit
-	push	cx
-	mov		cx, 1<<15
-	mov		%1, 15
+	dec		cx
+	eTEST1	%2, cl
+	jz		SHORT %%BitLoop
+	mov		%1, cx
+
+%else ; ~USE_NEC_V
+	mov		cx, 1
+	mov		%1, 16
 
 ALIGN JUMP_ALIGN
 %%BitLoop:
+	ror		cx, 1				; Prepare to test next bit
+	dec		%1					; Decrement bit index
 	test	%2, cx				; Bit set?
-	jnz		SHORT %%PopAndReturn;  If so, return with ZF cleared
-	shr		cx, 1				; Prepare to test next bit
-	dec		%1					; Decrement bit index
-	jmp		SHORT %%BitLoop		; Loop until bit found
-%%PopAndReturn:
+	jz		SHORT %%BitLoop
+%endif
+
 	pop		cx
-%%Return:
-;-----------------------------------
-%else
+
+%%Return:
+;-----------------------------------
+%else ; USE_386
 	bsr		%1, %2
 %endif
@@ -539,29 +575,38 @@
 ;		%2:		Source segment override (destination is always ES)
 ;		%3:		String instruction
+;		%4:		An exclamation mark (!) if the state of the IF must
+;				be preserved (can not be used together with CMPS or
+;				SCAS instructions), otherwise it will be set on
+;				return from the macro (i.e. interrupts will be on)
 ;		CX:		Repeat count
 ;	Returns:
-;		FLAGS for cmps and scas only
+;		FLAGS for CMPS and SCAS only
 ;	Corrupts registers:
 ;		FLAGS
 ;--------------------------------------------------------------------
-%macro eSEG_STR 3
-%ifndef USE_186	; 8088/8086 has string instruction restart bug when more than one prefix
-	%%Loop:
-		%1						; REP is the prefix that can be lost
-		%2						; SEG is the prefix that won't be lost
-		%3						; String instruction
-FSIS	cmps, %3
+%macro eSEG_STR 3-4
+%ifndef USE_186	; 8088/8086 has string instruction restart bug when using more than one prefix
+%ifidn %4, !				; Preserve the IF
+	FSIS	cmps, %3
 %ifn strpos
 	FSIS	scas, %3
 %endif
-%if strpos						; Must preserve FLAGS
-		jcxz	%%End			; Jump to end if no repeats left (preserves FLAGS)
-		jmp		SHORT %%Loop	; Loop while repeats left
-	%%End:
-%else							; No need to preserve FLAGS
-		inc		cx
-		loop	%%Loop
-%endif
-%else	; No bug on V20/V30 and later, don't know about 188/186
+%if strpos
+	%error "The state of the IF can not be preserved when using CMPS or SCAS!"
+%endif
+	pushf
+	cli
+	%1						; REP is the prefix that can be lost
+	%2						; SEG is the prefix that won't be lost
+	%3						; String instruction
+	popf
+%else						; No need to preserve the IF
+	cli
+	%1
+	%2
+	%3
+	sti
+%endif
+%else	; No bug on V20/V30/188/186 and later
 	%2
 	%1 %3
Index: /trunk/Assembly_Library/Src/Display/DisplayFormat.asm
===================================================================
--- /trunk/Assembly_Library/Src/Display/DisplayFormat.asm	(revision 623)
+++ /trunk/Assembly_Library/Src/Display/DisplayFormat.asm	(revision 624)
@@ -366,5 +366,5 @@
 
 	cmp		si, BYTE 7Fh		; well within the boundaries of ROMVARS_size
-	jb		.notFormatted
+	jb		SHORT .notFormatted
 
 	dec		bp
@@ -373,5 +373,5 @@
 	inc		bp					; will be decremented after the call is done
 	inc		bp
-	jmp		.done
+	jmp		SHORT .done
 
 .notFormatted:
Index: /trunk/BIOS_Drive_Information_Tool/Src/Strings.asm
===================================================================
--- /trunk/BIOS_Drive_Information_Tool/Src/Strings.asm	(revision 623)
+++ /trunk/BIOS_Drive_Information_Tool/Src/Strings.asm	(revision 624)
@@ -22,5 +22,5 @@
 
 g_szProgramName:	db	"BIOS Drive Information Tool v1.0.3",CR,LF
-					db	"(C) 2012-2021 by XTIDE Universal BIOS Team",CR,LF
+					db	"(C) 2012-2022 by XTIDE Universal BIOS Team",CR,LF
 					db	"Released under GNU GPL v2",CR,LF
 					db	"http://xtideuniversalbios.org/",CR,LF,NULL
@@ -37,5 +37,5 @@
 g_szLBA:			db	"LBA   ",NULL
 g_szFormatCHS:		db	" Cylinders    : %5u, Heads: %3u, Sectors: %2u",NULL
-g_szWillBeModified:	db	"Will be modified to:",CR,LF,NULL		
+g_szWillBeModified:	db	"Will be modified to:",CR,LF,NULL
 g_szChsSectors:		db	" CHS   sectors: ",NULL
 g_szLBA28:			db	" LBA28 sectors: ",NULL
@@ -44,5 +44,7 @@
 g_szPIO:			db	" PIO mode     : Max %u, Min cycle times: %u ns, with IORDY %d ns",CR,LF,NULL
 g_szXUB:			db	"XTIDE Universal BIOS %s generates following L-CHS...",CR,LF,NULL
-g_szXUBversion:		db	ROM_VERSION_STRING	; This one is NULL terminated
+g_szXUBversion:		db	"r"
+					db	ROM_VERSION_STRING
+					db	BUILD_DATE_STRING,NULL
 
 g_szOldInfoHeader:	db	"Old INT 13h information from AH=08h and AH=15h...",CR,LF,NULL
Index: /trunk/Serial_Server/win32/Win32.cpp
===================================================================
--- /trunk/Serial_Server/win32/Win32.cpp	(revision 623)
+++ /trunk/Serial_Server/win32/Win32.cpp	(revision 624)
@@ -33,11 +33,8 @@
 #include "../library/FlatImage.h"
 
-#include "../../XTIDE_Universal_BIOS/Inc/Version.inc"
-
 char *bannerStrings[] = {
 	"SerDrive - XTIDE Universal BIOS Serial Drive Server",
-	"Copyright (C) 2012-2019 by XTIDE Universal BIOS Team",
+	"Copyright (C) 2012-2022 by XTIDE Universal BIOS Team",
 	"Released under GNU GPL v2, with ABSOLUTELY NO WARRANTY",
-	ROM_VERSION_STRING,
 	"",
 	NULL };
Index: /trunk/Tools/PostCommitHook.cmd
===================================================================
--- /trunk/Tools/PostCommitHook.cmd	(revision 624)
+++ /trunk/Tools/PostCommitHook.cmd	(revision 624)
@@ -0,0 +1,9 @@
+@echo off
+if exist ..\CommitInProgress goto NoError1
+echo PostCommitHook was called but no CommitInProgress file could be found!>con
+echo Something is very wrong as this should not happen!>con
+pause<con>con
+exit 1
+:NoError1
+del ..\CommitInProgress
+exit 0
Index: /trunk/Tools/StartCommitHook.cmd
===================================================================
--- /trunk/Tools/StartCommitHook.cmd	(revision 624)
+++ /trunk/Tools/StartCommitHook.cmd	(revision 624)
@@ -0,0 +1,16 @@
+@echo off
+if exist XTIDE_Universal_BIOS\Inc\Revision.inc goto NoError1
+echo Couldn't find Revision.inc! Make sure to commit from the working copy root!>con
+pause<con>con
+exit 1
+:NoError1
+if not exist CommitInProgress goto NoError2
+echo Revision.inc has already been updated but not yet successfully committed!>con
+pause<con>con
+exit 0
+:NoError2
+set /p XUB_REV=<XTIDE_Universal_BIOS\Inc\Revision.inc
+set /a XUB_REV+=1
+echo|set /p=%XUB_REV%>XTIDE_Universal_BIOS\Inc\Revision.inc
+echo.>CommitInProgress
+exit 0
Index: /trunk/XTIDE_Universal_BIOS/Inc/Revision.inc
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Inc/Revision.inc	(revision 624)
+++ /trunk/XTIDE_Universal_BIOS/Inc/Revision.inc	(revision 624)
@@ -0,0 +1,1 @@
+624 
Index: /trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc	(revision 623)
+++ /trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc	(revision 624)
@@ -142,5 +142,5 @@
 	.rgbSign			resb	6	; Signature for XTIDE Configurator Program (must be even length)
 	.szTitle			resb	31	; BIOS title string
-	.szVersion			resb	25	; BIOS version string
+	.szVersion			resb	19	; BIOS version string (supports up to r9999)
 
 	.wFlags				resb	2	; Word for ROM flags
@@ -154,4 +154,5 @@
 	.bIdleTimeout		resb	1	; Standby timer value
 
+						alignb	2	; WORD align the IDEVARS structures
 	.ideVarsBegin:
 	.ideVars0			resb	IDEVARS_size
Index: /trunk/XTIDE_Universal_BIOS/Inc/Version.inc
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Inc/Version.inc	(revision 623)
+++ /trunk/XTIDE_Universal_BIOS/Inc/Version.inc	(revision 624)
@@ -1,3 +1,2 @@
-; /*
 ; Project name	:	XTIDE Universal BIOS
 ; Description	:	Version information.
@@ -20,4 +19,5 @@
 
 ; Flash signature revisions:
+; XUB209	Shortened the BIOS version string (ROMVARS.szVersion) and WORD aligned the IDEVARS structures
 ; XUB208	Added option to skip slave drive detection
 ; XTIDE207	Added device type DEVICE_8BIT_XTIDE_REV2_OLIVETTI
@@ -27,46 +27,30 @@
 ;
 
-;--------------------------------------------------------------------------------
-;
-; Assembler Version
-;
-
 %ifndef VERSION_INC
 %define VERSION_INC
 
 
-%define TITLE_STRING_START	"-=XTIDE Universal BIOS "
+%define TITLE_STRING_START		"-=XTIDE Universal BIOS "
 %ifdef USE_AT
 	%ifdef USE_386
-		%define	TITLE_STRING_END	"(386)=-",NULL
+		%define TITLE_STRING_END	"(386)=-"
 	%else
-		%define	TITLE_STRING_END	"(AT)=-",NULL
+		%define TITLE_STRING_END	"(AT)=-"
 	%endif
 %elifdef USE_186
-	%define	TITLE_STRING_END	"(XT+)=-",NULL
+	%define TITLE_STRING_END	"(XT+)=-"
 %else
-	%define	TITLE_STRING_END	"(XT)=-",NULL
+	%define TITLE_STRING_END	"(XT)=-"
 %endif
 
-%define	TITLE_STRING			TITLE_STRING_START, TITLE_STRING_END
-%define	ROM_VERSION_STRING		"v2.0.0",BETA,"3+ (",__DATE__,")",NULL
-%define	FLASH_SIGNATURE			"XUB208"	; Do not terminate with NULL
+%define TITLE_STRING			TITLE_STRING_START,TITLE_STRING_END,NULL
+%define ROM_VERSION_STRING		incbin "Revision.inc"	; This file must include a trailing space
+; Note!
+; NASM will throw weird errors when using ROM_VERSION_STRING if it's not a single statement on its own line.
+; This is likely due to the "unusual" way it is defined above. Make sure to not have any additional strings
+; on the same line, either before or after. In fact, do not even put a preceding label on the same line!
+%define BUILD_DATE_STRING		"(",__DATE__,")"
+%define FLASH_SIGNATURE			"XUB209"	; Do not terminate with NULL
 
 
 %endif ; VERSION_INC
-
-%if 0			; equivalent of a NASM comment block
-;*/
-
-//--------------------------------------------------------------------------------
-//
-// C/C++ Version
-//
-
-#define BETA " Beta "
-
-#define ROM_VERSION_STRING		"v2.0.0" BETA "3 (" __DATE__ ")"
-
-/*
-%endif
-;*/
Index: /trunk/XTIDE_Universal_BIOS/Src/Main.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Main.asm	(revision 623)
+++ /trunk/XTIDE_Universal_BIOS/Src/Main.asm	(revision 624)
@@ -71,5 +71,7 @@
 	at	ROMVARS.rgbSign,	db	FLASH_SIGNATURE
 	at	ROMVARS.szTitle,	db	TITLE_STRING
-	at	ROMVARS.szVersion,	db	ROM_VERSION_STRING
+	at	ROMVARS.szVersion,	db	"r"
+							db	ROM_VERSION_STRING
+							db	BUILD_DATE_STRING,NULL
 
 ;---------------------------;
Index: /trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Strings.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Strings.asm	(revision 623)
+++ /trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Strings.asm	(revision 624)
@@ -25,5 +25,7 @@
 
 ; Menu title
-g_szProgramTitle:					db	"Configuration and Flashing program for XTIDE Universal BIOS v2.0.0.",LF,CR,NULL
+g_szProgramTitle:					db	"Configuration and Flashing program for XTIDE Universal BIOS r"
+									db	ROM_VERSION_STRING
+									db	LF,CR,NULL
 g_sXtideUniversalBiosSignature:		db	FLASH_SIGNATURE		; No need to terminate with NULL.
 g_szBiosIsNotLoaded:				db	"BIOS is not loaded!",NULL
@@ -96,10 +98,10 @@
 g_szNfoMainFlash:		db	"Flash loaded BIOS image to EEPROM.",NULL
 g_szNfoMainSave:		db	"Save BIOS changes back to original file from which it was loaded.",NULL
-g_szNfoMainLicense:		db	"XTIDE Universal BIOS and XTIDECFG Copyright (C) 2009-2010 by Tomi Tilli, 2011-2021 by XTIDE Universal BIOS Team."
+g_szNfoMainLicense:		db	"XTIDE Universal BIOS and XTIDECFG Copyright (C) 2009-2010 by Tomi Tilli, 2011-2022 by XTIDE Universal BIOS Team."
 						db	" Released under GNU GPL v2, with ABSOLUTELY NO WARRANTY. Press ENTER for more details...",NULL
 g_szNfoMainHomePage:	db	"Visit http://xtideuniversalbios.org (home page) and http://forum.vcfed.org (support)",NULL
 
 g_szHelpMainLicense:	db	"XTIDE Universal BIOS and XTIDECFG Configuration program are Copyright 2009-2010 by Tomi Tilli,"
-						db	" 2011-2021 by XTIDE Universal BIOS Team. Released under GNU GPL v2. This software comes with ABSOLUTELY NO WARRANTY."
+						db	" 2011-2022 by XTIDE Universal BIOS Team. Released under GNU GPL v2. This software comes with ABSOLUTELY NO WARRANTY."
 						db	" This is free software, and you are welcome to redistribute it under certain conditions."
 						db	" See the LICENSE.TXT file that was included with this distribution,"
