VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SelRealModeDataToProtFar16.asm@ 77922

Last change on this file since 77922 was 76553, checked in by vboxsync, 6 years ago

scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.3 KB
Line 
1; $Id: bs3-cmn-SelRealModeDataToProtFar16.asm 76553 2019-01-01 01:45:53Z vboxsync $
2;; @file
3; BS3Kit - Bs3SelRealModeDataToProtFar16.
4;
5
6;
7; Copyright (C) 2007-2019 Oracle Corporation
8;
9; This file is part of VirtualBox Open Source Edition (OSE), as
10; available from http://www.virtualbox.org. This file is free software;
11; you can redistribute it and/or modify it under the terms of the GNU
12; General Public License (GPL) as published by the Free Software
13; Foundation, in version 2 as it comes in the "COPYING" file of the
14; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16;
17; The contents of this file may alternatively be used under the terms
18; of the Common Development and Distribution License Version 1.0
19; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20; VirtualBox OSE distribution, in which case the provisions of the
21; CDDL are applicable instead of those of the GPL.
22;
23; You may elect to license modified versions of this file under the
24; terms and conditions of either the GPL or the CDDL or both.
25;
26
27
28;*********************************************************************************************************************************
29;* Header Files *
30;*********************************************************************************************************************************
31%include "bs3kit-template-header.mac"
32
33
34;*********************************************************************************************************************************
35;* External Symbols *
36;*********************************************************************************************************************************
37BS3_BEGIN_DATA16 ; For real mode segment value.
38BS3_BEGIN_SYSTEM16 ; Ditto.
39
40TMPL_BEGIN_TEXT
41%if TMPL_BITS == 16
42CPU 8086
43%endif
44
45
46;;
47; @cproto BS3_CMN_PROTO_NOSB(uint32_t, Bs3SelRealModeDataToProtFar16,(uint32_t uFar1616));
48;
49; @uses Only return registers (ax:dx, eax, eax)
50; @remarks No 20h scratch area requirements.
51;
52BS3_PROC_BEGIN_CMN Bs3SelRealModeDataToProtFar16, BS3_PBC_NEAR ; Far stub generated by the makefile/bs3kit.h.
53 push xBP
54 mov xBP, xSP
55
56 ;
57 ; See if it's our default 16-bit data, stack or system data segment.
58 ;
59%if TMPL_BITS == 16
60 mov ax, [xBP + xCB + cbCurRetAddr + 2]
61%elif TMPL_BITS == 32
62 movzx eax, word [xBP + xCB + cbCurRetAddr + 2]
63%else
64 mov eax, ecx
65 shr eax, 16
66%endif
67 cmp ax, 0
68 jnz .not_stack
69 mov ax, BS3_SEL_R0_SS16
70
71.quick_return:
72%if TMPL_BITS == 16
73 mov dx, ax
74 mov ax, [xBP + xCB + cbCurRetAddr]
75%elif TMPL_BITS == 32
76 shl eax, 16
77 mov ax, word [xBP + xCB + cbCurRetAddr]
78%else
79 shl eax, 16
80 mov ax, cx
81%endif
82
83.return:
84 pop xBP
85 BS3_HYBRID_RET
86
87.not_stack:
88 cmp ax, BS3KIT_GRPNM_DATA16
89 jne .not_dgroup
90 mov ax, BS3_SEL_R0_DS16
91 jmp .quick_return
92
93.not_dgroup:
94 cmp ax, BS3SYSTEM16
95 jne .not_system16
96 mov ax, BS3_SEL_SYSTEM16
97 jmp .quick_return
98
99 ;
100 ; Compute flat address and translate it to tiled.
101 ;
102.not_system16:
103%if TMPL_BITS == 16
104 push cx
105
106 ; Calc flat address.
107 mov dx, ax
108 mov cl, 12
109 shr dx, cl
110 mov cl, 4
111 shl ax, cl
112 add ax, [xBP + xCB + cbCurRetAddr]
113 adc dx, 0
114
115 ; Convert upper 16-bit to tiled selector.
116 mov cl, X86_SEL_SHIFT
117 shl dx, cl
118 add dx, BS3_SEL_TILED
119
120 pop cx
121%else
122 ; Calc flat address.
123 shl eax, 4
124 %if TMPL_BITS == 32
125 add ax, [xBP + xCB + cbCurRetAddr]
126 %else
127 add ax, cx
128 %endif
129 jnc .no_carry
130 add eax, 10000h
131.no_carry:
132
133 ; Convert upper 16-bit to tiled selector.
134 rol eax, 16
135 shl ax, X86_SEL_SHIFT
136 add ax, BS3_SEL_TILED
137 ror eax, 16
138%endif
139 jmp .return
140BS3_PROC_END_CMN Bs3SelRealModeDataToProtFar16
141
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette