Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/Makefile.kmk
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/Makefile.kmk	(revision 64693)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/Makefile.kmk	(revision 64694)
@@ -283,4 +283,5 @@
 	bs3-mode-SwitchToLM32.asm \
 	bs3-mode-SwitchToLM16.asm \
+	bs3-mode-SwitchTo32BitAndCallC.asm \
 	bs3-mode-EnteredMode.asm \
 	bs3-mode-PagingGetRootForPP16.asm \
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchTo16Bit.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchTo16Bit.asm	(revision 64693)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchTo16Bit.asm	(revision 64694)
@@ -75,5 +75,5 @@
 
 BS3_BEGIN_TEXT16
-.sixteen_bit:
+BS3_GLOBAL_LOCAL_LABEL .sixteen_bit
 
         ; Load 16-bit segment registers.
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestDoModesByOneHlp.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestDoModesByOneHlp.asm	(revision 64693)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestDoModesByOneHlp.asm	(revision 64694)
@@ -87,5 +87,5 @@
 
         ; Assuming real mode far pointer, convert protected mode before calling it.
-        push    word [BS3_CMN_NM(g_pfnBs3TestDoModesByOneCurrent) + 2]
+        push    word [2 + BS3_DATA16_WRT(BS3_CMN_NM(g_pfnBs3TestDoModesByOneCurrent))]
         call    _Bs3SelRealModeCodeToProtMode_c16
         add     sp, 2
@@ -95,5 +95,5 @@
 
         push    ax                                                  ; call converted selector
-        push    word [BS3_CMN_NM(g_pfnBs3TestDoModesByOneCurrent)]  ; call offset
+        push    word [BS3_DATA16_WRT(BS3_CMN_NM(g_pfnBs3TestDoModesByOneCurrent))]  ; call offset
         retf
 
@@ -130,5 +130,5 @@
 
         ; Assuming real mode far pointer, convert protected mode before calling it.
-        push    word [BS3_CMN_NM(g_pfnBs3TestDoModesByOneCurrent) + 2]
+        push    word [2 + BS3_DATA16_WRT(BS3_CMN_NM(g_pfnBs3TestDoModesByOneCurrent))]
         call    _Bs3SelRealModeCodeToProtMode_c16
         add     sp, 2
@@ -137,5 +137,5 @@
         push    word .return                                        ; return address
         push    ax                                                  ; call converted selector
-        push    word [BS3_CMN_NM(g_pfnBs3TestDoModesByOneCurrent)]  ; call offset
+        push    word [BS3_DATA16_WRT(BS3_CMN_NM(g_pfnBs3TestDoModesByOneCurrent))] ; call offset
         retf
 
@@ -157,5 +157,5 @@
 
 BS3_BEGIN_TEXT16
-BS3_SET_BITS 32
+BS3_SET_BITS 16
 BS3_PROC_BEGIN _Bs3TestCallDoerTo32_f16
         push    xBP
@@ -180,5 +180,5 @@
         jnz     .return_to_v86          ; Need to figure this while we still have the mode value.
 
-        call    [BS3_CMN_NM(g_pfnBs3TestDoModesByOneCurrent)]
+        call    [BS3_DATA16_WRT(BS3_CMN_NM(g_pfnBs3TestDoModesByOneCurrent))]
 
         ; Switch back to 16-bit mode.
@@ -192,5 +192,5 @@
         BS3_SET_BITS 32
 .return_to_v86:
-        call    [BS3_CMN_NM(g_pfnBs3TestDoModesByOneCurrent)]
+        call    [BS3_DATA16_WRT(BS3_CMN_NM(g_pfnBs3TestDoModesByOneCurrent))]
 
         ; Switch back to v8086 mode.
@@ -222,5 +222,5 @@
 
         push    eax                     ; Worker bMode argument.
-        call    [BS3_CMN_NM(g_pfnBs3TestDoModesByOneCurrent)]
+        call    [BS3_DATA16_WRT(BS3_CMN_NM(g_pfnBs3TestDoModesByOneCurrent))]
 
         ; Switch back to 64-bit mode.
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchTo32BitAndCallC.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchTo32BitAndCallC.asm	(revision 64694)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchTo32BitAndCallC.asm	(revision 64694)
@@ -0,0 +1,154 @@
+; $Id$
+;; @file
+; BS3Kit - bs3SwitchTo32BitAndCallC
+;
+
+;
+; Copyright (C) 2007-2016 Oracle Corporation
+;
+; This file is part of VirtualBox Open Source Edition (OSE), as
+; available from http://www.virtualbox.org. This file is free software;
+; you can redistribute it and/or modify it under the terms of the GNU
+; General Public License (GPL) as published by the Free Software
+; Foundation, in version 2 as it comes in the "COPYING" file of the
+; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+;
+; The contents of this file may alternatively be used under the terms
+; of the Common Development and Distribution License Version 1.0
+; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+; VirtualBox OSE distribution, in which case the provisions of the
+; CDDL are applicable instead of those of the GPL.
+;
+; You may elect to license modified versions of this file under the
+; terms and conditions of either the GPL or the CDDL or both.
+;
+
+;*********************************************************************************************************************************
+;*  Header Files                                                                                                                 *
+;*********************************************************************************************************************************
+%include "bs3kit-template-header.mac"
+
+
+;*********************************************************************************************************************************
+;*  External Symbols                                                                                                             *
+;*********************************************************************************************************************************
+BS3_EXTERN_DATA16   g_bBs3CurrentMode
+TMPL_BEGIN_TEXT
+
+%ifdef BS3_STRICT
+BS3_EXTERN_CMN      Bs3Panic
+%endif
+
+%if BS3_MODE_IS_RM_OR_V86(TMPL_MODE)
+BS3_EXTERN_CMN      Bs3SelRealModeCodeToFlat
+%endif
+
+%if TMPL_MODE == BS3_MODE_RM
+extern              NAME(Bs3SwitchToPE32_rm)
+extern              NAME(Bs3SwitchToRM_pe32)
+%elif !BS3_MODE_IS_32BIT_CODE(TMPL_MODE)
+BS3_EXTERN_CMN      Bs3SwitchTo32Bit
+ %if BS3_MODE_IS_16BIT_CODE_NO_V86(TMPL_MODE)
+extern              _Bs3SwitchTo16Bit_c32
+ %elif BS3_MODE_IS_32BIT_CODE_NO_V86(TMPL_MODE)
+extern              _Bs3SwitchTo16BitV86_c32
+ %elif !BS3_MODE_IS_32BIT_CODE(TMPL_MODE)
+extern              _Bs3SwitchTo64_c32
+ %endif
+%endif
+
+
+
+;;
+; @cproto   BS3_MODE_PROTO_STUB(int, Bs3SwitchTo32BitAndCallC,(PFNBS3FARADDRCONV fpfnCall, unsigned cbParams, ...));
+;
+BS3_PROC_BEGIN_MODE Bs3SwitchTo32BitAndCallC, BS3_PBC_HYBRID
+        BS3_CALL_CONV_PROLOG 4
+TONLY16 inc     xBP
+        push    xBP
+        mov     xBP, xSP
+        push    xSI
+
+        ;
+        ; Push the arguments first.
+        ;
+TONLY16 mov     si,  [xBP + xCB + cbCurRetAddr + sCB]
+TNOT16  mov     esi, [xBP + xCB + cbCurRetAddr + sCB]
+%ifdef BS3_STRICT
+        test    xSI, 3
+        jz      .cbParams_ok
+        call    Bs3Panic
+.cbParams_ok:
+        cmp     byte [BS3_DATA16_WRT(g_bBs3CurrentMode)], TMPL_MODE
+        je      .mode_ok
+        call    Bs3Panic
+.mode_ok:
+%endif
+        add     xSI, sCB - 1            ; round it up to nearest push size / dword.
+        and     xSI, ~(sCB - 1)
+        jz      .done_pushing           ; skip if zero
+.push_more:
+        push    xPRE [xBP + xCB + cbCurRetAddr + sCB + xCB + xSI - xCB]
+        sub     xSI, xCB
+        jnz     .push_more
+        mov     xSI, xAX                ; restore xSI
+.done_pushing:
+
+        ;
+        ; Load fpfnCall into eax.
+        ;
+%if BS3_MODE_IS_RM_OR_V86(TMPL_MODE)
+        push    sPRE [xBP + xCB + cbCurRetAddr]
+        BS3_CALL Bs3SelRealModeCodeToFlat, 1
+        add     xSP, sCB
+        rol     eax, 16
+        mov     ax, dx
+        rol     eax, 16
+%else
+        mov     eax, [xBP + xCB + cbCurRetAddr]
+%endif
+
+        ;
+        ; Switch to 32-bit mode, if this is real mode pick PE32.
+        ;
+%if TMPL_MODE == BS3_MODE_RM
+        call    NAME(Bs3SwitchToPE32_rm)
+        BS3_SET_BITS 32
+%elif !BS3_MODE_IS_32BIT_CODE(TMPL_MODE)
+        call    Bs3SwitchTo32Bit
+        BS3_SET_BITS 32
+%endif
+
+        ;
+        ; Make the call.
+        ;
+        call    eax
+
+        ;
+        ; Return, preserving xAX.
+        ;
+%if BS3_MODE_IS_RM_OR_V86(TMPL_MODE)
+        mov     edx, eax
+        shr     edx, 16
+%endif
+%if TMPL_MODE == BS3_MODE_RM
+        call    NAME(Bs3SwitchToRM_pe32)
+%elif BS3_MODE_IS_16BIT_CODE_NO_V86(TMPL_MODE)
+        call    _Bs3SwitchTo16Bit_c32
+%elif BS3_MODE_IS_32BIT_CODE_NO_V86(TMPL_MODE)
+        call    _Bs3SwitchTo16BitV86_c32
+%elif !BS3_MODE_IS_32BIT_CODE(TMPL_MODE)
+        call    _Bs3SwitchTo64_c32
+%endif
+        BS3_SET_BITS TMPL_BITS
+
+        ; Epilog.
+        lea     xSP, [xBP - xCB]
+        pop     xSI
+        pop     xBP
+TONLY16 dec     xBP
+        BS3_CALL_CONV_EPILOG 4
+        BS3_HYBRID_RET
+BS3_PROC_END_MODE   Bs3SwitchTo32BitAndCallC
+
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToLM32.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToLM32.asm	(revision 64693)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToLM32.asm	(revision 64694)
@@ -79,5 +79,5 @@
         jmp     .thirty_two_bit_segment
 BS3_BEGIN_TEXT32
-.thirty_two_bit_segment:
+BS3_GLOBAL_LOCAL_LABEL .thirty_two_bit_segment
  %endif
 
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPAE16.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPAE16.asm	(revision 64693)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPAE16.asm	(revision 64694)
@@ -25,13 +25,22 @@
 ;
 
+;*********************************************************************************************************************************
+;*  Header Files                                                                                                                 *
+;*********************************************************************************************************************************
 %include "bs3kit-template-header.mac"
 
+
+;*********************************************************************************************************************************
+;*  External Symbols                                                                                                             *
+;*********************************************************************************************************************************
 %ifndef TMPL_PAE16
+BS3_BEGIN_TEXT16
 extern  NAME(Bs3EnteredMode_pae16)
  %ifdef TMPL_PAE32
  BS3_EXTERN_CMN Bs3SwitchTo16Bit
- %else
- %endif
-%endif
+ %endif
+TMPL_BEGIN_TEXT
+%endif
+
 
 ;;
@@ -75,5 +84,5 @@
         ;
  %if TMPL_BITS != 16
-        shl     xPRE [xSP + xCB], TMPL_BITS - 16    ; Adjust the return address.
+        shl     xPRE [xSP], TMPL_BITS - 16  ; Adjust the return address.
         add     xSP, xCB - 2
 
@@ -82,5 +91,5 @@
 BS3_BEGIN_TEXT16
         BS3_SET_BITS TMPL_BITS
-.sixteen_bit_segment:
+BS3_GLOBAL_LOCAL_LABEL .sixteen_bit_segment
  %endif
 
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPAE16_32.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPAE16_32.asm	(revision 64693)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPAE16_32.asm	(revision 64694)
@@ -53,5 +53,5 @@
 BS3_BEGIN_TEXT16
         BS3_SET_BITS TMPL_BITS
-.sixteen_bit_segment:
+BS3_GLOBAL_LOCAL_LABEL .sixteen_bit_segment
  %endif
         extern  TMPL_NM(Bs3SwitchToPAE16)
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPAE16_V86.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPAE16_V86.asm	(revision 64693)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPAE16_V86.asm	(revision 64694)
@@ -57,5 +57,5 @@
 BS3_BEGIN_TEXT16
         BS3_SET_BITS TMPL_BITS
-.sixteen_bit_segment:
+BS3_GLOBAL_LOCAL_LABEL .sixteen_bit_segment
  %endif
 
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPAE32.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPAE32.asm	(revision 64693)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPAE32.asm	(revision 64694)
@@ -62,14 +62,16 @@
  %if TMPL_BITS != 32
   %if TMPL_BITS > 32
-        shl     xPRE [xSP + xCB], 32    ; Adjust the return address from 64-bit to 32-bit.
+        shl     xPRE [xSP], 32          ; Adjust the return address from 64-bit to 32-bit.
         add     rsp, xCB - 4
   %else
         push    word 0                  ; Reserve space to expand the return address.
   %endif
+ %endif
+ %if TMPL_BITS != 16
         ; Must be in 16-bit segment when calling Bs3SwitchTo16Bit.
         jmp     .sixteen_bit_segment
 BS3_BEGIN_TEXT16
         BS3_SET_BITS TMPL_BITS
-.sixteen_bit_segment:
+BS3_GLOBAL_LOCAL_LABEL .sixteen_bit_segment
  %endif
 
@@ -121,5 +123,5 @@
         jmp     BS3_SEL_R0_CS32:dword .thirty_two_bit wrt FLAT
 BS3_BEGIN_TEXT32
-.thirty_two_bit:
+BS3_GLOBAL_LOCAL_LABEL .thirty_two_bit
 
         ;
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPAE32_16.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPAE32_16.asm	(revision 64693)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPAE32_16.asm	(revision 64694)
@@ -48,6 +48,6 @@
 
 %elif TMPL_MODE == BS3_MODE_PAE32
-        extern  BS3_CMN_NM(Bs3SwitchTo32Bit)
-        jmp     BS3_CMN_NM(Bs3SwitchTo32Bit)
+        extern  BS3_CMN_NM(Bs3SwitchTo16Bit)
+        jmp     BS3_CMN_NM(Bs3SwitchTo16Bit)
 
 %else
@@ -66,5 +66,5 @@
 BS3_BEGIN_TEXT16
         BS3_SET_BITS TMPL_BITS
-.sixteen_bit_segment:
+BS3_GLOBAL_LOCAL_LABEL .sixteen_bit_segment
  %endif
         extern  _Bs3SwitchTo16Bit_c32
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPE16.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPE16.asm	(revision 64693)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPE16.asm	(revision 64694)
@@ -68,5 +68,5 @@
         ;
  %if TMPL_BITS != 16
-        shl     xPRE [xSP + xCB], TMPL_BITS - 16    ; Adjust the return address.
+        shl     xPRE [xSP], TMPL_BITS - 16    ; Adjust the return address.
         add     xSP, xCB - 2
 
@@ -75,5 +75,5 @@
 BS3_BEGIN_TEXT16
         BS3_SET_BITS TMPL_BITS
-.sixteen_bit_segment:
+BS3_GLOBAL_LOCAL_LABEL .sixteen_bit_segment
  %endif
 
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPE16_32.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPE16_32.asm	(revision 64693)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPE16_32.asm	(revision 64694)
@@ -53,5 +53,5 @@
 BS3_BEGIN_TEXT16
         BS3_SET_BITS TMPL_BITS
-.sixteen_bit_segment:
+BS3_GLOBAL_LOCAL_LABEL .sixteen_bit_segment
  %endif
         extern  TMPL_NM(Bs3SwitchToPE16)
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPE16_V86.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPE16_V86.asm	(revision 64693)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPE16_V86.asm	(revision 64694)
@@ -57,5 +57,5 @@
 BS3_BEGIN_TEXT16
         BS3_SET_BITS TMPL_BITS
-.sixteen_bit_segment:
+BS3_GLOBAL_LOCAL_LABEL .sixteen_bit_segment
  %endif
 
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPE32.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPE32.asm	(revision 64693)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPE32.asm	(revision 64694)
@@ -61,16 +61,17 @@
  %if TMPL_BITS != 32
   %if TMPL_BITS > 32
-        shl     xPRE [xSP + xCB], 32    ; Adjust the return address from 64-bit to 32-bit.
+        shl     xPRE [xSP], 32          ; Adjust the return address from 64-bit to 32-bit.
         add     rsp, xCB - 4
   %else
         push    word 0                  ; Reserve space to expand the return address.
   %endif
+ %endif
+ %if TMPL_BITS != 16
         ; Must be in 16-bit segment when calling Bs3SwitchTo16Bit.
         jmp     .sixteen_bit_segment
 BS3_BEGIN_TEXT16
         BS3_SET_BITS TMPL_BITS
-.sixteen_bit_segment:
+BS3_GLOBAL_LOCAL_LABEL .sixteen_bit_segment
  %endif
-
         ;
         ; Switch to real mode.
@@ -99,5 +100,5 @@
         jmp     BS3_SEL_R0_CS32:dword .thirty_two_bit wrt FLAT
 BS3_BEGIN_TEXT32
-.thirty_two_bit:
+BS3_GLOBAL_LOCAL_LABEL .thirty_two_bit
 
         ;
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPE32_16.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPE32_16.asm	(revision 64693)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPE32_16.asm	(revision 64694)
@@ -48,6 +48,6 @@
 
 %elif TMPL_MODE == BS3_MODE_PE32
-        extern  BS3_CMN_NM(Bs3SwitchTo32Bit)
-        jmp     BS3_CMN_NM(Bs3SwitchTo32Bit)
+        extern  BS3_CMN_NM(Bs3SwitchTo16Bit)
+        jmp     BS3_CMN_NM(Bs3SwitchTo16Bit)
 
 %else
@@ -66,5 +66,5 @@
 BS3_BEGIN_TEXT16
         BS3_SET_BITS TMPL_BITS
-.sixteen_bit_segment:
+BS3_GLOBAL_LOCAL_LABEL .sixteen_bit_segment
  %endif
         extern  _Bs3SwitchTo16Bit_c32
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPP16.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPP16.asm	(revision 64693)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPP16.asm	(revision 64694)
@@ -25,13 +25,21 @@
 ;
 
+;*********************************************************************************************************************************
+;*  Header Files                                                                                                                 *
+;*********************************************************************************************************************************
 %include "bs3kit-template-header.mac"
 
+;*********************************************************************************************************************************
+;*  External Symbols                                                                                                             *
+;*********************************************************************************************************************************
 %ifndef TMPL_PP16
+BS3_BEGIN_TEXT16
 extern  NAME(Bs3EnteredMode_pp16)
  %ifdef TMPL_PP32
  BS3_EXTERN_CMN Bs3SwitchTo16Bit
- %else
- %endif
-%endif
+ %endif
+TMPL_BEGIN_TEXT
+%endif
+
 
 ;;
@@ -76,5 +84,5 @@
         ;
  %if TMPL_BITS != 16
-        shl     xPRE [xSP + xCB], TMPL_BITS - 16    ; Adjust the return address.
+        shl     xPRE [xSP], TMPL_BITS - 16    ; Adjust the return address.
         add     xSP, xCB - 2
 
@@ -83,5 +91,5 @@
 BS3_BEGIN_TEXT16
         BS3_SET_BITS TMPL_BITS
-.sixteen_bit_segment:
+BS3_GLOBAL_LOCAL_LABEL .sixteen_bit_segment
  %endif
 
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPP16_32.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPP16_32.asm	(revision 64693)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPP16_32.asm	(revision 64694)
@@ -53,5 +53,5 @@
 BS3_BEGIN_TEXT16
         BS3_SET_BITS TMPL_BITS
-.sixteen_bit_segment:
+BS3_GLOBAL_LOCAL_LABEL .sixteen_bit_segment
  %endif
         extern  TMPL_NM(Bs3SwitchToPP16)
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPP16_V86.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPP16_V86.asm	(revision 64693)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPP16_V86.asm	(revision 64694)
@@ -57,5 +57,5 @@
 BS3_BEGIN_TEXT16
         BS3_SET_BITS TMPL_BITS
-.sixteen_bit_segment:
+BS3_GLOBAL_LOCAL_LABEL .sixteen_bit_segment
  %endif
 
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPP32.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPP32.asm	(revision 64693)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPP32.asm	(revision 64694)
@@ -62,14 +62,16 @@
  %if TMPL_BITS != 32
   %if TMPL_BITS > 32
-        shl     xPRE [xSP + xCB], 32    ; Adjust the return address from 64-bit to 32-bit.
+        shl     xPRE [xSP], 32          ; Adjust the return address from 64-bit to 32-bit.
         add     rsp, xCB - 4
   %else
         push    word 0                  ; Reserve space to expand the return address.
   %endif
+ %endif
+ %if TMPL_BITS != 16
         ; Must be in 16-bit segment when calling Bs3SwitchTo16Bit.
         jmp     .sixteen_bit_segment
 BS3_BEGIN_TEXT16
         BS3_SET_BITS TMPL_BITS
-.sixteen_bit_segment:
+BS3_GLOBAL_LOCAL_LABEL .sixteen_bit_segment
  %endif
 
@@ -129,5 +131,5 @@
         jmp     BS3_SEL_R0_CS32:dword .thirty_two_bit wrt FLAT
 BS3_BEGIN_TEXT32
-.thirty_two_bit:
+BS3_GLOBAL_LOCAL_LABEL .thirty_two_bit
         ;
         ; Convert the (now) real mode stack pointer to 32-bit flat.
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPP32_16.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPP32_16.asm	(revision 64693)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToPP32_16.asm	(revision 64694)
@@ -48,6 +48,6 @@
 
 %elif TMPL_MODE == BS3_MODE_PP32
-        extern  BS3_CMN_NM(Bs3SwitchTo32Bit)
-        jmp     BS3_CMN_NM(Bs3SwitchTo32Bit)
+        extern  BS3_CMN_NM(Bs3SwitchTo16Bit)
+        jmp     BS3_CMN_NM(Bs3SwitchTo16Bit)
 
 %else
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToRM.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToRM.asm	(revision 64693)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToRM.asm	(revision 64694)
@@ -242,5 +242,5 @@
 BS3_BEGIN_TEXT16
         BS3_SET_BITS TMPL_BITS
-.sixteen_bit_segment:
+BS3_GLOBAL_LOCAL_LABEL .sixteen_bit_segment
 
         extern  BS3_CMN_NM(Bs3SwitchTo16Bit)
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-TestDoModesByOne.c
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-TestDoModesByOne.c	(revision 64693)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-TestDoModesByOne.c	(revision 64694)
@@ -112,4 +112,5 @@
 extern PFNBS3TESTDOMODE g_pfnBs3TestDoModesByOneCurrent;
 
+#include <iprt/asm-amd64-x86.h>
 
 
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-TestDoModesHlp.asm
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-TestDoModesHlp.asm	(revision 64693)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-TestDoModesHlp.asm	(revision 64694)
@@ -38,9 +38,11 @@
 ;
 %if TMPL_MODE == BS3_MODE_RM
- %define MY_BEGIN_TEXT   BS3_BEGIN_RMTEXT16
- %define MY_BEGIN_TEXT16 BS3_BEGIN_RMTEXT16
-%else
- %define MY_BEGIN_TEXT   TMPL_BEGIN_TEXT
- %define MY_BEGIN_TEXT16 BS3_BEGIN_TEXT16
+ %define MY_BEGIN_TEXT          BS3_BEGIN_RMTEXT16
+ %define MY_BEGIN_TEXT16        BS3_BEGIN_RMTEXT16
+ %define MY_TEXT16_WRT(a_Label) a_Label wrt BS3GROUPRMTEXT16
+%else
+ %define MY_BEGIN_TEXT          TMPL_BEGIN_TEXT
+ %define MY_BEGIN_TEXT16        BS3_BEGIN_TEXT16
+ %define MY_TEXT16_WRT(a_Label) BS3_TEXT16_WRT(a_Label)
 %endif
 
@@ -137,5 +139,5 @@
 
 
-
+MY_BEGIN_TEXT16                         ; need the group definition
 MY_BEGIN_TEXT
 
@@ -277,9 +279,9 @@
 ; @uses     rax
 BS3_PROC_BEGIN_MODE Bs3TestCallDoerInRM, BS3_PBC_NEAR
-        BS3_LEA_MOV_WRT_RIP(xAX, .doit)
-        jmp     TMPL_NM(bs3TestCallDoerPrologue)
-MY_BEGIN_TEXT16
-BS3_SET_BITS TMPL_BITS
-.doit:
+        BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
+        jmp     TMPL_NM(bs3TestCallDoerPrologue)
+MY_BEGIN_TEXT16
+BS3_SET_BITS TMPL_BITS
+BS3_GLOBAL_LOCAL_LABEL .doit
         mov     ax, [xBP + xCB + cbCurRetAddr]      ; Load far function pointer.
         mov     dx, [xBP + xCB + cbCurRetAddr + 2]
@@ -326,9 +328,9 @@
 ; @uses     rax
 BS3_PROC_BEGIN_MODE Bs3TestCallDoerInPE16, BS3_PBC_NEAR
-        BS3_LEA_MOV_WRT_RIP(xAX, .doit)
-        jmp     TMPL_NM(bs3TestCallDoerPrologue)
-MY_BEGIN_TEXT16
-BS3_SET_BITS TMPL_BITS
-.doit:
+        BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
+        jmp     TMPL_NM(bs3TestCallDoerPrologue)
+MY_BEGIN_TEXT16
+BS3_SET_BITS TMPL_BITS
+BS3_GLOBAL_LOCAL_LABEL .doit
         mov     ax, [xBP + xCB + cbCurRetAddr]      ; Load far function pointer.
         mov     dx, [xBP + xCB + cbCurRetAddr + 2]
@@ -367,5 +369,5 @@
 ; @uses     rax
 BS3_PROC_BEGIN_MODE Bs3TestCallDoerInPE16_32, BS3_PBC_NEAR
-        BS3_LEA_MOV_WRT_RIP(xAX, .doit)
+        BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
         jmp     TMPL_NM(bs3TestCallDoerPrologue)
 .doit:
@@ -396,7 +398,9 @@
 ; @uses     rax
 BS3_PROC_BEGIN_MODE Bs3TestCallDoerInPE16_V86, BS3_PBC_NEAR
-        BS3_LEA_MOV_WRT_RIP(xAX, .doit)
-        jmp     TMPL_NM(bs3TestCallDoerPrologue)
-.doit:
+        BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
+        jmp     TMPL_NM(bs3TestCallDoerPrologue)
+MY_BEGIN_TEXT16
+BS3_SET_BITS TMPL_BITS
+BS3_GLOBAL_LOCAL_LABEL .doit
         mov     ax, [xBP + xCB + cbCurRetAddr]      ; Load far function pointer.
         mov     dx, [xBP + xCB + cbCurRetAddr + 2]
@@ -429,4 +433,5 @@
         STRICT_CHECK_REGS
         jmp     TMPL_NM(bs3TestCallDoerEpilogue)
+MY_BEGIN_TEXT
 BS3_PROC_END_MODE   Bs3TestCallDoerInPE16_V86
 
@@ -435,5 +440,5 @@
 ; @uses     rax
 BS3_PROC_BEGIN_MODE Bs3TestCallDoerInPE32, BS3_PBC_NEAR
-        BS3_LEA_MOV_WRT_RIP(xAX, .doit)
+        BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
         jmp     TMPL_NM(bs3TestCallDoerPrologue)
 .doit:
@@ -464,9 +469,9 @@
 ; @uses     rax
 BS3_PROC_BEGIN_MODE Bs3TestCallDoerInPE32_16, BS3_PBC_NEAR
-        BS3_LEA_MOV_WRT_RIP(xAX, .doit)
-        jmp     TMPL_NM(bs3TestCallDoerPrologue)
-MY_BEGIN_TEXT16
-BS3_SET_BITS TMPL_BITS
-.doit:
+        BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
+        jmp     TMPL_NM(bs3TestCallDoerPrologue)
+MY_BEGIN_TEXT16
+BS3_SET_BITS TMPL_BITS
+BS3_GLOBAL_LOCAL_LABEL .doit
         mov     ax, [xBP + xCB + cbCurRetAddr]      ; Load far function pointer.
         mov     dx, [xBP + xCB + cbCurRetAddr + 2]
@@ -506,9 +511,9 @@
 ; @uses     rax
 BS3_PROC_BEGIN_MODE Bs3TestCallDoerInPEV86, BS3_PBC_NEAR
-        BS3_LEA_MOV_WRT_RIP(xAX, .doit)
-        jmp     TMPL_NM(bs3TestCallDoerPrologue)
-MY_BEGIN_TEXT16
-BS3_SET_BITS TMPL_BITS
-.doit:
+        BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
+        jmp     TMPL_NM(bs3TestCallDoerPrologue)
+MY_BEGIN_TEXT16
+BS3_SET_BITS TMPL_BITS
+BS3_GLOBAL_LOCAL_LABEL .doit
         mov     ax, [xBP + xCB + cbCurRetAddr]      ; Load far function pointer.
         mov     dx, [xBP + xCB + cbCurRetAddr + 2]
@@ -554,9 +559,9 @@
 ; @uses     rax
 BS3_PROC_BEGIN_MODE Bs3TestCallDoerInPP16, BS3_PBC_NEAR
-        BS3_LEA_MOV_WRT_RIP(xAX, .doit)
-        jmp     TMPL_NM(bs3TestCallDoerPrologue)
-MY_BEGIN_TEXT16
-BS3_SET_BITS TMPL_BITS
-.doit:
+        BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
+        jmp     TMPL_NM(bs3TestCallDoerPrologue)
+MY_BEGIN_TEXT16
+BS3_SET_BITS TMPL_BITS
+BS3_GLOBAL_LOCAL_LABEL .doit
         mov     ax, [xBP + xCB + cbCurRetAddr]      ; Load far function pointer.
         mov     dx, [xBP + xCB + cbCurRetAddr + 2]
@@ -596,5 +601,5 @@
 ; @uses     rax
 BS3_PROC_BEGIN_MODE Bs3TestCallDoerInPP16_32, BS3_PBC_NEAR
-        BS3_LEA_MOV_WRT_RIP(xAX, .doit)
+        BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
         jmp     TMPL_NM(bs3TestCallDoerPrologue)
 .doit:
@@ -625,7 +630,9 @@
 ; @uses     rax
 BS3_PROC_BEGIN_MODE Bs3TestCallDoerInPP16_V86, BS3_PBC_NEAR
-        BS3_LEA_MOV_WRT_RIP(xAX, .doit)
-        jmp     TMPL_NM(bs3TestCallDoerPrologue)
-.doit:
+        BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
+        jmp     TMPL_NM(bs3TestCallDoerPrologue)
+MY_BEGIN_TEXT16
+BS3_SET_BITS TMPL_BITS
+BS3_GLOBAL_LOCAL_LABEL .doit
         mov     ax, [xBP + xCB + cbCurRetAddr]      ; Load far function pointer.
         mov     dx, [xBP + xCB + cbCurRetAddr + 2]
@@ -658,4 +665,5 @@
         STRICT_CHECK_REGS
         jmp     TMPL_NM(bs3TestCallDoerEpilogue)
+MY_BEGIN_TEXT
 BS3_PROC_END_MODE   Bs3TestCallDoerInPP16_V86
 
@@ -664,5 +672,5 @@
 ; @uses     rax
 BS3_PROC_BEGIN_MODE Bs3TestCallDoerInPP32, BS3_PBC_NEAR
-        BS3_LEA_MOV_WRT_RIP(xAX, .doit)
+        BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
         jmp     TMPL_NM(bs3TestCallDoerPrologue)
 .doit:
@@ -693,9 +701,9 @@
 ; @uses     rax
 BS3_PROC_BEGIN_MODE Bs3TestCallDoerInPP32_16, BS3_PBC_NEAR
-        BS3_LEA_MOV_WRT_RIP(xAX, .doit)
-        jmp     TMPL_NM(bs3TestCallDoerPrologue)
-MY_BEGIN_TEXT16
-BS3_SET_BITS TMPL_BITS
-.doit:
+        BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
+        jmp     TMPL_NM(bs3TestCallDoerPrologue)
+MY_BEGIN_TEXT16
+BS3_SET_BITS TMPL_BITS
+BS3_GLOBAL_LOCAL_LABEL .doit
         mov     ax, [xBP + xCB + cbCurRetAddr]      ; Load far function pointer.
         mov     dx, [xBP + xCB + cbCurRetAddr + 2]
@@ -735,9 +743,9 @@
 ; @uses     rax
 BS3_PROC_BEGIN_MODE Bs3TestCallDoerInPPV86, BS3_PBC_NEAR
-        BS3_LEA_MOV_WRT_RIP(xAX, .doit)
-        jmp     TMPL_NM(bs3TestCallDoerPrologue)
-MY_BEGIN_TEXT16
-BS3_SET_BITS TMPL_BITS
-.doit:
+        BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
+        jmp     TMPL_NM(bs3TestCallDoerPrologue)
+MY_BEGIN_TEXT16
+BS3_SET_BITS TMPL_BITS
+BS3_GLOBAL_LOCAL_LABEL .doit
         mov     ax, [xBP + xCB + cbCurRetAddr]      ; Load far function pointer.
         mov     dx, [xBP + xCB + cbCurRetAddr + 2]
@@ -772,5 +780,4 @@
 MY_BEGIN_TEXT
 BS3_PROC_END_MODE   Bs3TestCallDoerInPPV86
-
 
 
@@ -783,9 +790,9 @@
 ; @uses     rax
 BS3_PROC_BEGIN_MODE Bs3TestCallDoerInPAE16, BS3_PBC_NEAR
-        BS3_LEA_MOV_WRT_RIP(xAX, .doit)
-        jmp     TMPL_NM(bs3TestCallDoerPrologue)
-MY_BEGIN_TEXT16
-BS3_SET_BITS TMPL_BITS
-.doit:
+        BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
+        jmp     TMPL_NM(bs3TestCallDoerPrologue)
+MY_BEGIN_TEXT16
+BS3_SET_BITS TMPL_BITS
+BS3_GLOBAL_LOCAL_LABEL .doit
         mov     ax, [xBP + xCB + cbCurRetAddr]      ; Load far function pointer.
         mov     dx, [xBP + xCB + cbCurRetAddr + 2]
@@ -825,5 +832,5 @@
 ; @uses     rax
 BS3_PROC_BEGIN_MODE Bs3TestCallDoerInPAE16_32, BS3_PBC_NEAR
-        BS3_LEA_MOV_WRT_RIP(xAX, .doit)
+        BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
         jmp     TMPL_NM(bs3TestCallDoerPrologue)
 .doit:
@@ -854,7 +861,9 @@
 ; @uses     rax
 BS3_PROC_BEGIN_MODE Bs3TestCallDoerInPAE16_V86, BS3_PBC_NEAR
-        BS3_LEA_MOV_WRT_RIP(xAX, .doit)
-        jmp     TMPL_NM(bs3TestCallDoerPrologue)
-.doit:
+        BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
+        jmp     TMPL_NM(bs3TestCallDoerPrologue)
+MY_BEGIN_TEXT16
+BS3_SET_BITS TMPL_BITS
+BS3_GLOBAL_LOCAL_LABEL .doit
         mov     ax, [xBP + xCB + cbCurRetAddr]      ; Load far function pointer.
         mov     dx, [xBP + xCB + cbCurRetAddr + 2]
@@ -887,4 +896,5 @@
         STRICT_CHECK_REGS
         jmp     TMPL_NM(bs3TestCallDoerEpilogue)
+MY_BEGIN_TEXT
 BS3_PROC_END_MODE   Bs3TestCallDoerInPAE16_V86
 
@@ -893,5 +903,5 @@
 ; @uses     rax
 BS3_PROC_BEGIN_MODE Bs3TestCallDoerInPAE32, BS3_PBC_NEAR
-        BS3_LEA_MOV_WRT_RIP(xAX, .doit)
+        BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
         jmp     TMPL_NM(bs3TestCallDoerPrologue)
 .doit:
@@ -922,9 +932,9 @@
 ; @uses     rax
 BS3_PROC_BEGIN_MODE Bs3TestCallDoerInPAE32_16, BS3_PBC_NEAR
-        BS3_LEA_MOV_WRT_RIP(xAX, .doit)
-        jmp     TMPL_NM(bs3TestCallDoerPrologue)
-MY_BEGIN_TEXT16
-BS3_SET_BITS TMPL_BITS
-.doit:
+        BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
+        jmp     TMPL_NM(bs3TestCallDoerPrologue)
+MY_BEGIN_TEXT16
+BS3_SET_BITS TMPL_BITS
+BS3_GLOBAL_LOCAL_LABEL .doit
         mov     ax, [xBP + xCB + cbCurRetAddr]      ; Load far function pointer.
         mov     dx, [xBP + xCB + cbCurRetAddr + 2]
@@ -964,9 +974,9 @@
 ; @uses     rax
 BS3_PROC_BEGIN_MODE Bs3TestCallDoerInPAEV86, BS3_PBC_NEAR
-        BS3_LEA_MOV_WRT_RIP(xAX, .doit)
-        jmp     TMPL_NM(bs3TestCallDoerPrologue)
-MY_BEGIN_TEXT16
-BS3_SET_BITS TMPL_BITS
-.doit:
+        BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
+        jmp     TMPL_NM(bs3TestCallDoerPrologue)
+MY_BEGIN_TEXT16
+BS3_SET_BITS TMPL_BITS
+BS3_GLOBAL_LOCAL_LABEL .doit
         mov     ax, [xBP + xCB + cbCurRetAddr]      ; Load far function pointer.
         mov     dx, [xBP + xCB + cbCurRetAddr + 2]
@@ -1012,9 +1022,9 @@
 ; @uses     rax
 BS3_PROC_BEGIN_MODE Bs3TestCallDoerInLM16, BS3_PBC_NEAR
-        BS3_LEA_MOV_WRT_RIP(xAX, .doit)
-        jmp     TMPL_NM(bs3TestCallDoerPrologue)
-MY_BEGIN_TEXT16
-BS3_SET_BITS TMPL_BITS
-.doit:
+        BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
+        jmp     TMPL_NM(bs3TestCallDoerPrologue)
+MY_BEGIN_TEXT16
+BS3_SET_BITS TMPL_BITS
+BS3_GLOBAL_LOCAL_LABEL .doit
         mov     ax, [xBP + xCB + cbCurRetAddr]      ; Load far function pointer.
         mov     dx, [xBP + xCB + cbCurRetAddr + 2]
@@ -1054,5 +1064,5 @@
 ; @uses     rax
 BS3_PROC_BEGIN_MODE Bs3TestCallDoerInLM32, BS3_PBC_NEAR
-        BS3_LEA_MOV_WRT_RIP(xAX, .doit)
+        BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
         jmp     TMPL_NM(bs3TestCallDoerPrologue)
 .doit:
@@ -1084,5 +1094,5 @@
 ; @uses     rax
 BS3_PROC_BEGIN_MODE Bs3TestCallDoerInLM64, BS3_PBC_NEAR
-        BS3_LEA_MOV_WRT_RIP(xAX, .doit)
+        BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
         jmp     TMPL_NM(bs3TestCallDoerPrologue)
 .doit:
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-template-footer.mac
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-template-footer.mac	(revision 64693)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-template-footer.mac	(revision 64694)
@@ -127,4 +127,6 @@
 %unmacro TONLY32 1+
 %unmacro TONLY64 1+
+%unmacro TNOT16  1+
+%unmacro TNOT32  1+
 %unmacro TNOT64  1+
 
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-template-header.mac
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-template-header.mac	(revision 64693)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-template-header.mac	(revision 64694)
@@ -470,4 +470,28 @@
 %endif
 
+;; @def TNOT16
+; Version of BNOT16 that follows the code template.
+; Like BNOT16 this normally goes in column 1.
+%if TMPL_BITS == 16
+ %macro TNOT16 1+
+ %endmacro
+%else
+ %macro TNOT16 1+
+        %1
+ %endmacro
+%endif
+
+;; @def TNOT32
+; Version of BNOT32 that follows the code template.
+; Like BNOT32 this normally goes in column 1.
+%if TMPL_BITS == 32
+ %macro TNOT32 1+
+ %endmacro
+%else
+ %macro TNOT32 1+
+        %1
+ %endmacro
+%endif
+
 ;; @def TNOT64
 ; Version of BNOT64 that follows the code template.
@@ -481,4 +505,5 @@
  %endmacro
 %endif
+
 
 ;
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.h
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.h	(revision 64693)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.h	(revision 64694)
@@ -2313,8 +2313,9 @@
  * Afterwards it switches back to v8086 mode and returns a 16-bit status code.
  *
- * @returns     16-bit status code if the function returned anything.
- * @param       fpfnCall        Far real mode pointer to the function to call.
- * @param       cbParams        The size of the parameter list, in bytes.
- * @param       ...             The parameters.
+ * @returns 16-bit status code if the function returned anything.
+ * @param   fpfnCall        Far real mode pointer to the function to call.
+ * @param   cbParams        The size of the parameter list, in bytes.
+ * @param   ...             The parameters.
+ * @sa Bs3SwitchTo32BitAndCallC
  */
 BS3_CMN_PROTO_STUB(int, Bs3SwitchFromV86To16BitAndCallC,(FPFNBS3FAR fpfnCall, unsigned cbParams, ...));
@@ -3304,4 +3305,24 @@
 
 /**
+ * Call 32-bit prot mode C function.
+ *
+ * This switches from the current mode and calls the 32-bit @a fpfnCall C code
+ * with @a cbParams on the stack, then returns.
+ *
+ * @returns 32-bit status code if the function returned anything.
+ * @param   fpfnCall        Address of the 32-bit C function to call.  When
+ *                          called from 16-bit code, this is a far real mode
+ *                          function pointer, i.e. as fixed up by the linker.
+ *                          In 32-bit and 64-bit code, this is a flat address.
+ * @param   cbParams        The size of the parameter list, in bytes.
+ * @param   ...             The parameters.
+ * @sa      Bs3SwitchFromV86To16BitAndCallC
+ *
+ * @remarks     WARNING! This probably doesn't work in 64-bit mode yet.
+ *                       Only tested for 16-bit real mode.
+ */
+BS3_MODE_PROTO_STUB(int32_t, Bs3SwitchTo32BitAndCallC,(FPFNBS3FAR fpfnCall, unsigned cbParams, ...));
+
+/**
  * Initializes trap handling for the current system.
  *
@@ -3319,5 +3340,5 @@
 
 /**
- * Executes the array of tests in every possibly mode, unitifed driver.
+ * Executes the array of tests in every possibly mode, unified driver.
  *
  * This requires much less code space than Bs3TestDoModes as there is only one
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.mac
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.mac	(revision 64693)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.mac	(revision 64694)
@@ -213,4 +213,16 @@
  %endif
 
+ ;; @def BS3_TEXT16_WRT
+ ; For accessing BS3DATA16 correctly.
+ ; @param a_Label The BS3TEXT16 label.
+ %undef BS3_TEXT16_WRT
+ %if %1 == 16
+  %define BS3_TEXT16_WRT(a_Label)   a_Label wrt CGROUP16
+ %elif %1 == 32
+  %define BS3_TEXT16_WRT(a_Label)   a_Label wrt FLAT
+ %else
+  %define BS3_TEXT16_WRT(a_Label)   BS3_WRT_RIP(a_Label) wrt FLAT
+ %endif
+
  %undef   BS3_IF_16BIT_OTHERWISE
  %if %1 == 16
@@ -622,4 +634,17 @@
 %macro BS3_GLOBAL_NAME_EX 3
 global %1
+%1:
+%undef  BS3_LAST_LABEL
+%xdefine BS3_LAST_LABEL %1
+%endmacro
+
+;;
+; Global local label.
+;
+; This should be used when switching segments and jumping to it via a local lable.
+; It makes the lable visible to the debugger and map file.
+;
+%macro BS3_GLOBAL_LOCAL_LABEL 1
+global RT_CONCAT(BS3_LAST_LABEL,%1)
 %1:
 %endmacro
