!**************************************************************************
!*
!* Boot-ROM-Code to load an operating system across a TCP/IP network.
!*
!* Module: general.inc
!* Purpose: General assembler definitions. This has to be the first
!* file to be included into any assembler file.
!* Entries: None
!*
!**************************************************************************
!*
!* Copyright (C) 1998-2003 Gero Kuhlmann <gero@gkminix.han.de>
!*
!* This program is free software; you can redistribute it and/or modify
!* it under the terms of the GNU General Public License as published by
!* the Free Software Foundation; either version 2 of the License, or
!* any later version.
!*
!* This program is distributed in the hope that it will be useful,
!* but WITHOUT ANY WARRANTY; without even the implied warranty of
!* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
!* GNU General Public License for more details.
!*
!* You should have received a copy of the GNU General Public License
!* along with this program; if not, write to the Free Software
!* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
!*
!* $Id: general.inc,v 1.4 2003/01/25 23:29:40 gkminix Exp $
!*
#ifndef _GENERAL_INC
#define _GENERAL_INC
!
!**************************************************************************
!
! With the following definition all further include files switch to
! assembler definitions. Therefore, this file has to come before any
! other assembler include file.
!
#define _USE_ASSEMBLER 1
!
!**************************************************************************
!
! Define the processor type to use. We define the assembler use
! instruction as a preprocessor macro so that we can easily change
! to 386 instructions when required.
!
#define USE386 use16 386 ! use 386 instructions
#ifdef P86
# define USETYPE use16 86 ! use only 8086 instructions
#else
# ifdef P186
# define USETYPE use16 186 ! may also use 80186 special instructions
# define IS186
# else
# ifdef P286
# define USETYPE use16 286 ! may also use 80286 special instructions
# define IS186
# define IS286
# else
# define USETYPE use16 386 ! this is the default
# define IS186
# define IS286
# define IS386
# endif
# endif
#endif
!
! Check if are using the optimizer. This check is required because the
! optimizer uses a different register layout for procedure returns then
! the compiler would normally use.
!
#if defined(IS386) && defined(OPTIMIZE)
# define OPT386
#endif
!
! Now set the processor type for the assembler
!
USETYPE
!
!**************************************************************************
!
! Macros to make things easier with different processors
!
! Standard shift and rotate instructions
!
macro shift
#ifdef IS186
?1 ?2,#?3
#else
if ?3 > 1
push cx
mov cl,#?3
?1 ?2,cl
pop cx
else
?1 ?2,#1
endif
#endif
mend
!
! Push all registers onto stack (except segment registers)
!
macro pushall
#ifdef IS386
pushad
PUSHA_AX set $001C
PUSHA_CX set $0018
PUSHA_DX set $0014
PUSHA_BX set $0010
PUSHA_SP set $000C
PUSHA_BP set $0008
PUSHA_SI set $0004
PUSHA_DI set $0000
PUSHA_SIZE set $0020
#else
# ifdef IS186
pusha
# else
push ax
push cx
push dx
push bx
push sp
push bp
push si
push di
# endif
PUSHA_AX set $000E
PUSHA_CX set $000C
PUSHA_DX set $000A
PUSHA_BX set $0008
PUSHA_SP set $0006
PUSHA_BP set $0004
PUSHA_SI set $0002
PUSHA_DI set $0000
PUSHA_SIZE set $0010
#endif
mend
!
! Pop all registers from stack (except segment registers)
!
macro popall
#ifdef IS386
popad
#else
# ifdef IS186
popa
# else
pop di
pop si
pop bp
pop ax ! SP is discarded
pop bx
pop dx
pop cx
pop ax
# endif
#endif
mend
!
! Setup standard stackframe
!
__last_args set 0
macro penter
#ifdef IS286
if ?1 > 0
enter ?1,0
else
push bp
mov bp,sp
endif
#else
push bp
mov bp,sp
if ?1 > 0
sub sp,#?1
endif
#endif
__last_args set ?1
mend
!
! Terminate standard stackframe
!
macro pleave
#ifdef IS286
leave
#else
if __last_args > 0
mov sp,bp
endif
pop bp
#endif
mend
!
! Get an argument from the stack using a constant argument number
!
macro getcarg
mov ?1,[bp + (?2 * 2) + 4]
mend
#ifdef IS386
!
! Get an argument into a 386 32-bit register
!
macro getlarg
ifc (?3,dword)
mov ?1,?3 ptr [bp + (?2 * 2) + 4]
else
movzx ?1,?3 ptr [bp + (?2 * 2) + 4]
endif
mend
#endif
!
! Get an argument from the stack using an argument number in a register
!
macro getrarg
ifc (?1,si)
mov si,?2
shl si,#1
mov si,[bp + si + 4]
else
push si
mov si,?2
shl si,#1
mov ?1,[bp + si + 4]
pop si
endif
mend
!
!**************************************************************************
!
! Include the corresponding C header file. Due to the _USE_ASSEMBLER
! definition, this will automatically include only those definitions
! which are necessary for assembler modules.
!
#include <general.h>
!
!**************************************************************************
!
! BIOS interrupt vectors:
!
INT_VIDEO equ $10 ! BIOS screen vector
INT_EQUIP equ $11 ! BIOS equipment flags
INT_MEMORY equ $12 ! BIOS determine amount of base memory
INT_DISK equ $13 ! BIOS disk vector
INT_AUX equ $14 ! BIOS aux I/O vector
INT_MISC equ $15 ! BIOS misc function vector
INT_KBD equ $16 ! BIOS keyboard vector
INT_PRINT equ $17 ! BIOS printer output vector
INT_BOOTROM equ $18 ! ROM entry interrupt
INT_BOOTFAIL equ $18 ! PnP BIOS boot fail interrupt
INT_BOOTSTRAP equ $19 ! Bootstrap interrupt
INT_PXE equ $1A ! PXE interface interrupt
INT_TIME equ $1A ! BIOS time/date vector
INT_PCI equ $1A ! PCI BIOS vector
!
!**************************************************************************
!
! Size of processor interrupt descriptor table
!
IDT_NUM equ 256 ! number of interrupt vectors in IDT
IDT_SIZE equ (IDT_NUM * 4) ! size of IDT
!
!**************************************************************************
!
#endif
syntax highlighted by Code2HTML, v. 0.9.1