; $Id: bs3-cpu-basic-2-template.mac 60679 2016-04-24 15:55:00Z vboxsync $ ;; @file ; BS3Kit - bs3-cpu-basic-2 assembly template. ; ; ; 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. ; %include "bs3kit-template-header.mac" ; setup environment ;********************************************************************************************************************************* ;* External Symbols * ;********************************************************************************************************************************* %undef Bs3Printf BS3_EXTERN_CMN Bs3Printf TMPL_BEGIN_TEXT ; ; Code that is instantiated for every possible CPU mode ; %ifdef BS3_INSTANTIATING_MODE %if 0 ; Will be doing the testing in C, I think. BS3_PROC_BEGIN_MODE bs3CpuBasic2_iret, BS3_PBC_FAR BS3_CALL_CONV_PROLOG 1 push xBP mov xBP, xSP sub xSP, 20h %if TMPL_BITS == 64 %if TMPL_BITS == 16 xor ax, ax mov al, [xBP + xCB*2] push ax push cs push .szMsg wrt BS3TEXT16 call Bs3Printf add sp, 6 %else movzx xDX, byte [xBP + xCB*2] push xDX push .szMsg wrt FLAT BS3_CALL Bs3Printf, 2 add xSP, xCB * 2 %endif %endif ; Return xor al, al ;mov al, TMPL_MODE ; remove me mov xSP, xBP pop xBP BS3_CALL_CONV_EPILOG 1 ret .szMsg: db 'hello world %#x!', 13, 10, 0 BS3_PROC_END_MODE bs3CpuBasic2_iret %endif %endif ; BS3_INSTANTIATING_MODE ; ; Test code snippets containing code which differs between 16-bit, 32-bit ; and 64-bit CPUs modes. ; %ifdef BS3_INSTANTIATING_CMN ; ; SIDT ; BS3_PROC_BEGIN_CMN bs3CpuBasic2_sidt_bx_ud2, BS3_PBC_NEAR sidt [xBX] .again: ud2 jmp .again AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_sidt_bx_ud2) == 3) BS3_PROC_END_CMN bs3CpuBasic2_sidt_bx_ud2 BS3_PROC_BEGIN_CMN bs3CpuBasic2_sidt_opsize_bx_ud2, BS3_PBC_NEAR db X86_OP_PRF_SIZE_OP sidt [xBX] .again: ud2 jmp .again AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_sidt_opsize_bx_ud2) == 4) BS3_PROC_END_CMN bs3CpuBasic2_sidt_opsize_bx_ud2 %if TMPL_BITS == 64 BS3_PROC_BEGIN_CMN bs3CpuBasic2_sidt_rexw_bx_ud2, BS3_PBC_NEAR db X86_OP_REX_W sidt [xBX] .again: ud2 jmp .again AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_sidt_rexw_bx_ud2) == 4) BS3_PROC_END_CMN bs3CpuBasic2_sidt_rexw_bx_ud2 BS3_PROC_BEGIN_CMN bs3CpuBasic2_sidt_opsize_rexw_bx_ud2, BS3_PBC_NEAR db X86_OP_PRF_SIZE_OP db X86_OP_REX_W sidt [xBX] .again: ud2 jmp .again AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_sidt_opsize_rexw_bx_ud2) == 5) BS3_PROC_END_CMN bs3CpuBasic2_sidt_opsize_rexw_bx_ud2 %endif %if TMPL_BITS != 64 BS3_PROC_BEGIN_CMN bs3CpuBasic2_sidt_ss_bx_ud2, BS3_PBC_NEAR sidt [ss:xBX] .again: ud2 jmp .again AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_sidt_ss_bx_ud2) == 4) BS3_PROC_END_CMN bs3CpuBasic2_sidt_ss_bx_ud2 BS3_PROC_BEGIN_CMN bs3CpuBasic2_sidt_opsize_ss_bx_ud2, BS3_PBC_NEAR db X86_OP_PRF_SIZE_OP sidt [ss:xBX] .again: ud2 jmp .again AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_sidt_opsize_ss_bx_ud2) == 5) BS3_PROC_END_CMN bs3CpuBasic2_sidt_opsize_ss_bx_ud2 %endif ; ; SGDT ; BS3_PROC_BEGIN_CMN bs3CpuBasic2_sgdt_bx_ud2, BS3_PBC_NEAR sgdt [xBX] .again: ud2 jmp .again AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_sgdt_bx_ud2) == 3) BS3_PROC_END_CMN bs3CpuBasic2_sgdt_bx_ud2 BS3_PROC_BEGIN_CMN bs3CpuBasic2_sgdt_opsize_bx_ud2, BS3_PBC_NEAR db X86_OP_PRF_SIZE_OP sgdt [xBX] .again: ud2 jmp .again AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_sgdt_opsize_bx_ud2) == 4) BS3_PROC_END_CMN bs3CpuBasic2_sgdt_opsize_bx_ud2 %if TMPL_BITS == 64 BS3_PROC_BEGIN_CMN bs3CpuBasic2_sgdt_rexw_bx_ud2, BS3_PBC_NEAR db X86_OP_REX_W sgdt [xBX] .again: ud2 jmp .again AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_sgdt_rexw_bx_ud2) == 4) BS3_PROC_END_CMN bs3CpuBasic2_sgdt_rexw_bx_ud2 BS3_PROC_BEGIN_CMN bs3CpuBasic2_sgdt_opsize_rexw_bx_ud2, BS3_PBC_NEAR db X86_OP_PRF_SIZE_OP db X86_OP_REX_W sgdt [xBX] .again: ud2 jmp .again AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_sgdt_opsize_rexw_bx_ud2) == 5) BS3_PROC_END_CMN bs3CpuBasic2_sgdt_opsize_rexw_bx_ud2 %endif %if TMPL_BITS != 64 BS3_PROC_BEGIN_CMN bs3CpuBasic2_sgdt_ss_bx_ud2, BS3_PBC_NEAR sgdt [ss:xBX] .again: ud2 jmp .again AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_sgdt_ss_bx_ud2) == 4) BS3_PROC_END_CMN bs3CpuBasic2_sgdt_ss_bx_ud2 BS3_PROC_BEGIN_CMN bs3CpuBasic2_sgdt_opsize_ss_bx_ud2, BS3_PBC_NEAR db X86_OP_PRF_SIZE_OP sgdt [ss:xBX] .again: ud2 jmp .again AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_sgdt_opsize_ss_bx_ud2) == 5) BS3_PROC_END_CMN bs3CpuBasic2_sgdt_opsize_ss_bx_ud2 %endif ; ; ; BS3_PROC_BEGIN_CMN bs3CpuBasic2_lidt_bx_ud2, BS3_PBC_NEAR lidt [xBX] .again: ud2 jmp .again AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_lidt_bx_ud2) == 3) BS3_PROC_END_CMN bs3CpuBasic2_lidt_bx_ud2 %endif ; BS3_INSTANTIATING_CMN %include "bs3kit-template-footer.mac" ; reset environment