Index: trunk/XTIDE_Universal_BIOS/Src/Libraries/keys.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Libraries/keys.asm	(revision 76)
+++ trunk/XTIDE_Universal_BIOS/Src/Libraries/keys.asm	(revision 77)
@@ -2,6 +2,7 @@
 ; Project name	:	Keyboard library
 ; Created date	:	17.11.2009
-; Last update	:	31.12.2009
-; Author		:	Tomi Tilli
+; Last update	:	4.1.2011
+; Author		:	Tomi Tilli,
+;				:	Krister Nordvall (optimizations)
 ; Description	:	ASM library to for keyboard related functions.		
 
@@ -311,7 +312,7 @@
 ALIGN JUMP_ALIGN
 Keys_Backspace:
-	push	dx
 	test	si, si				; At the beginning?
 	jz		.Return				;  If so, return
+	push	dx					; Save DX
 	dec		si					; Decrement char counter
 	dec		di					; Decrement offset to buffer
@@ -322,7 +323,7 @@
 	mov		dl, BS				; Back again
 	PRINT_CHAR
+	pop		dx					; Restore DX
 ALIGN JUMP_ALIGN
 .Return:
-	pop		dx
-	ret
-%endif
+	ret
+%endif
Index: trunk/XTIDE_Universal_BIOS/Src/Libraries/math.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Libraries/math.asm	(revision 76)
+++ trunk/XTIDE_Universal_BIOS/Src/Libraries/math.asm	(revision 77)
@@ -2,6 +2,7 @@
 ; Project name	:	Math library
 ; Created date	:	7.10.2009
-; Last update	:	1.1.2010
-; Author		:	Tomi Tilli
+; Last update	:	4.1.2011
+; Author		:	Tomi Tilli,
+;				:	Krister Nordvall (optimizations)
 ; Description	:	ASM library to for math related functions.		
 
@@ -122,5 +123,5 @@
 .RetZero:						; Return 0 in DX:AX
 	xor		ax, ax
-	xor		dx, dx
+	cwd
 	ret
 %endif
@@ -143,7 +144,7 @@
 ALIGN JUMP_ALIGN
 Math_DivDWbyW:
-	mov		bx, ax
-	mov		ax, dx
-	xor		dx, dx
+	xor		bx, bx
+	xchg	bx, ax
+	xchg	dx, ax
 	div		cx
 	xchg	ax, bx
@@ -171,6 +172,6 @@
 	push	cx
 	push	ax
-	mov		ax, cx				; Copy divisor to AX
-	mov		cl, 10				; Load 10 to CL
+	mov		al, 10				; Load 10 to AL
+	xchg	cx, ax				; AX = Divisor CL = 10
 	div		cl					; AL = Divisor divided by 10
 	inc		ax					; Increment to compensate new remainder
Index: trunk/XTIDE_Universal_BIOS/Src/Libraries/menu/menudraw.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Libraries/menu/menudraw.asm	(revision 76)
+++ trunk/XTIDE_Universal_BIOS/Src/Libraries/menu/menudraw.asm	(revision 77)
@@ -2,6 +2,7 @@
 ; Project name	:	Menu library
 ; Created date	:	9.11.2009
-; Last update	:	25.5.2010
-; Author		:	Tomi Tilli
+; Last update	:	4.1.2011
+; Author		:	Tomi Tilli,
+;				:	Krister Nordvall (optimizations)
 ; Description	:	ASM library to menu system.
 ;					Contains menu drawing functions.
@@ -41,7 +42,7 @@
 	mov		al, CNT_SCRN_ROW			; Load row count
 	mul		ah							; AX=Column count * row count
-	mov		cx, ax						; Copy char count to CX
+	mov		cx, 0920h					; Write Char and attr, space char
 	mov		bx, ATTR_MDA_NORMAL			; Page zero, normal attribute
-	mov		ax, 0920h					; Write Char and attr, space char
+	xchg	cx, ax						; CX=Char count AX=Space char and attr
 	int		10h
 	ret
@@ -354,6 +355,5 @@
 ALIGN JUMP_ALIGN
 MenuDraw_TopBorder:
-	mov		bh, B_TL
-	mov		bl, B_H
+	mov		bx, (B_TL << 8) + B_H
 	mov		dh, B_TR
 	jmp		SHORT MenuDraw_BorderChars
@@ -361,6 +361,5 @@
 ALIGN JUMP_ALIGN
 MenuDraw_StringBorder:
-	mov		bh, B_V
-	mov		bl, ' '
+	mov		bx, (B_V << 8) + ' '
 	mov		dh, B_V
 	jmp		SHORT MenuDraw_BorderChars
@@ -369,12 +368,10 @@
 MenuDraw_ScrollBorder:
 	call	MenuDraw_GetScrollChar			; Load scroll char to DH
-	mov		bh, B_V
-	mov		bl, ' '
+	mov		bx, (B_V << 8) + ' '
 	jmp		SHORT MenuDraw_BorderChars
 
 ALIGN JUMP_ALIGN
 MenuDraw_MiddleBorder:
-	mov		bh, BVL_THR
-	mov		bl, T_H
+	mov		bx, (BVL_THR << 8) + T_H
 	mov		dh, THL_BVR
 
@@ -393,6 +390,5 @@
 ALIGN JUMP_ALIGN
 MenuDraw_BottomBorder:
-	mov		bh, B_LL
-	mov		bl, B_H
+	mov		bx, (B_LL << 8) + B_H
 	mov		dh, B_LR
 	cmp		WORD [bp+MENUVARS.wTimeInit], 0	; Timeout enabled?
Index: trunk/XTIDE_Universal_BIOS/Src/Libraries/print.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Libraries/print.asm	(revision 76)
+++ trunk/XTIDE_Universal_BIOS/Src/Libraries/print.asm	(revision 77)
@@ -2,7 +2,8 @@
 ; Project name	:	Print library
 ; Created date	:	6.10.2009
-; Last update	:	31.12.2009
-; Author		:	Tomi Tilli
-; Description	:	ASM library to for character and string
+; Last update	:	4.1.2011
+; Author		:	Tomi Tilli,
+;				:	Krister Nordvall (optimizations)
+; Description	:	ASM library for character and string
 ;					printing related functions.
 
@@ -467,7 +468,7 @@
 ALIGN JUMP_ALIGN
 Print_IntSW:
+	test	ax, ax				; Positive integer?
+	jns		Print_IntUW			;  If so, jump to print it
 	push	di					; Store DI
-	cmp		ax, 0				; Positive integer?
-	jge		Print_IntUW			;  If so, jump to print it
 	push	ax					; Store word
 	mov		dl, '-'				; Print '-'
Index: trunk/XTIDE_Universal_BIOS/Src/Libraries/string.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Libraries/string.asm	(revision 76)
+++ trunk/XTIDE_Universal_BIOS/Src/Libraries/string.asm	(revision 77)
@@ -2,7 +2,7 @@
 ; Project name	:	String library
 ; Created date	:	7.10.2009
-; Last update	:	20.12.2009
+; Last update	:	4.1.2011
 ; Author		:	Tomi Tilli,
-;				:	Krille (optimizations)
+;				:	Krister Nordvall (optimizations)
 ; Description	:	ASM library to work as Standard C String and Character.
 
@@ -130,11 +130,11 @@
 String_IsHexDigit:
 	call	String_IsAlphaNum	; Is alphabetic letter or digit?
-	jc		.CheckHex			;  If so, jump to check A...F
-	ret
-.CheckHex:
+	jnc		.ExitStrIsHexDigit	; If it is, check A...F. If not, exit
 	push	ax					; Store character
 	call	String_ToLower		; Convert to lower case letter
 	cmp		al, 'f'+1			; Last valid hex alphanumeric?
 	pop		ax					; Restore character
+
+.ExitStrIsHexDigit:
 	ret
 
@@ -165,24 +165,19 @@
 	mov		ah, al				; Copy char to AH
 	call	String_IsDigit		; Is '0'...'9'?
-	jc		.ConvertDigit		;  If so, jump to convert
+	jnc		.CheckForAlpha		; If not, check for alphabetic letter
+	sub		al, '0'				; Convert char to integer
+	jmp		.FinalizeAXAndCheckBase
+
+.CheckForAlpha:
 	call	String_IsAlpha		; Is alphabetic letter?
-	jnc		.RetFalse			;  If not, return FALSE
+	jnc		.JustRet			; If not, return FALSE
 	call	String_ToLower		; Convert to lower case
+	sub		al, 'a'-10			; From char to integer: a=10, b=11...
+
+.FinalizeAXAndCheckBase:
 	xchg	al, ah				; Converted char to AH
-	sub		ah, 'a'-10			; From char to integer: a=10, b=11...
 	cmp		ah, cl				; Belongs to base?
-	jae		.RetFalse			; If not, return FALSE
-	stc							; Set CF since belongs to base
-	ret
-ALIGN JUMP_ALIGN
-.ConvertDigit:
-	sub		ah, '0'				; Convert char to integer
-	cmp		ah, cl				; Belongs to base?
-	jae		.RetFalse			; If not, return FALSE
-	stc							; Set CF since belongs to base
-	ret
-ALIGN JUMP_ALIGN
-.RetFalse:
-	clc							; Clear CF since char doesn't belong to b
+
+.JustRet:						; CF now reflects TRUE/FALSE so just return
 	ret
 %endif
@@ -324,19 +319,11 @@
 	jnz		.CharLoop			; Loop while characters left
 
-	mov		ax, bx				; Copy loword to AX
+	stc							; Set CF since success
+.RetFalse:	; If we jumped to here no CLC is needed to reflect a FALSE condition
+	mov		ax, bx				; Copy loword to AX (may be incomplete)
 	pop		bx					; Restore BX
 	pop		di					; Restore DI
 	pop		si					; Restore SI
 	pop		ds					; Restore DS
-	stc							; Set CF since success
-	ret
-ALIGN JUMP_ALIGN
-.RetFalse:
-	mov		ax, bx				; Copy (likely incomplete) loword to AX
-	pop		bx					; Restore BX
-	pop		di					; Restore DI
-	pop		si					; Restore SI
-	pop		ds					; Restore DS
-	clc							; Clear CF since error
 	ret
 %endif
@@ -448,8 +435,7 @@
 ALIGN JUMP_ALIGN
 .Str2NotFound:
-	xor		bx, bx				; Zero BX
+	xor		bx, bx				; Zero BX and clear CF
 	pop		si					; Restore SI
 	pop		cx					; Restore CX
-	clc							; Clear CF since str2 was not found
 	ret
 %endif
@@ -578,17 +564,11 @@
 ALIGN JUMP_ALIGN
 .ConvComplete:
-	mov		ax, bx				; Copy loword to AX
+	stc							; Set CF since success
+ALIGN JUMP_ALIGN
+.RetFalse:	; If we jumped to here no CLC is needed to reflect a FALSE condition
+	mov		ax, bx				; Copy loword to AX (may be incomplete)
 	pop		bx					; Restore BX
 	pop		si					; Restore SI
 	pop		ds					; Restore DS
-	stc							; Set CF since success
-	ret
-ALIGN JUMP_ALIGN
-.RetFalse:
-	mov		ax, bx				; Copy (likely incomplete) loword to AX
-	pop		bx					; Restore BX
-	pop		si					; Restore SI
-	pop		ds					; Restore DS
-	clc							; Clear CF since error
 	ret
 %endif
