;******************************************************************************* ;* TIPC Scheme '84 Runtime Support - Assembler Macros * ;* * ;* (C) Copyright 1984,1985 by Texas Instruments Incorporated. * ;* All rights reserved. * ;* * ;* Memory and Machine specific macros to aid in the building specific * ;* of PC Scheme. There are four versions of the PC Scheme system: * ;* 1. Conventional Memory Scheme * ;* 2. Expanded Memory Scheme * ;* 3. Extended Memory Scheme * ;* 4. Protected Mode Scheme * ;* These macros create version specific code for each of the above schemes. * ;* The Macro assembler symbols REGMEM, EXPMEM, EXTMEM, and PROMEM are used * ;* to conditionally define the correct macros. It can be (and must be) * ;* specified on the MASM command line during the assembly phase as follows: * ;* MASM /DREGMEM srcfile,objfile,... * ;* * ;* Date Written: 29 July 1987 * ;* * ;* * ;******************************************************************************* ;;; ;;; Macros for conventional memory version - default ;;; ; The LoadPage macros should be used to obtain the address of a given page ; from the pagetable. This must be done in order to access any given heap ; allocated object. For conventional memory, this just means indexing into ; the pagetable and accessing the paragraph address, however for extended ; and expanded memories, it is quite different. See the macro definitions ; for EXPMEM and EXTMEM for definitions for expanded and extended memorys. LoadPage MACRO dst,src ; Get Page address from page table IFIDN , mov dst,[SS:pagetabl+src] ELSE IFIDN , mov dst,[SS:pagetabl+src] ELSE IFIDN , mov dst,[SS:pagetabl+src] ELSE IFIDN , mov dst,[SS:pagetabl+src] ELSE IFIDN , mov dst,[SS:pagetabl+src] ELSE IFIDN , mov dst,[SS:pagetabl+src] ELSE IFIDN , mov dst,[SS:pagetabl+src] ELSE push BX mov BX,src mov dst,[SS:pagetabl+BX] pop BX ENDIF ENDIF ENDIF ENDIF ENDIF ENDIF ENDIF ENDM %LoadPage MACRO dst,src LoadPage dst,src ENDM %LoadPage0 MACRO dst,src LoadPage dst,src ENDM %LoadPage1 MACRO dst,src LoadPage dst,src ENDM LoadCode MACRO dst,src LoadPage dst,src ENDM ; The following macros should be used whenever saving some value in a ; location within the code segment. For real mode, you may store anything ; within the code segment, however in protected mode, this causes a ; protection violation. See the macro expansions for PROMEM to see how ; this may be accomplished in protected mode. STORE_WORD_IN_CS MACRO SEG,OFFSET,VALUE mov word ptr CS:OFFSET,VALUE ENDM STORE_BYTE_IN_CS MACRO SEG,OFFSET,VALUE mov byte ptr CS:OFFSET,VALUE ENDM XCHG_WORD_IN_CS MACRO SEG,OFFSET,VALUE xchg word ptr CS:OFFSET,VALUE ENDM IFDEF REGMEM ; Access to pagetabl for LoadPage macros extrn pagetabl:word ENDIF ;;; ;;; Macros for expanded memory version ;;; IFDEF EXPMEM ; get rid of default conventional memory definitions purge LoadPage,%LoadPage,%LoadPage0,%LoadPage1,LoadCode ; Load page address extrn _MMU:near LoadPage MACRO dst,src push src call _MMU pop dst ENDM ; Load code block extrn _MMUCB:near LoadCode MACRO dst,src push src call _MMUCB pop dst ENDM ; SAME AS LoadPage EXCEPT CALLABLE FROM PROGX SEGMENT extrn _%MMU:far %LoadPage MACRO dst,src IF1 IFIDN , %OUT *AX as destination of %LoadPage not recommended* ELSE IFIDN , %OUT *AX as destination of %LoadPage not recommended* ENDIF ENDIF ENDIF push AX mov AX,src call _%MMU mov dst,AX pop AX ENDM ; Loads only Emm page 0 extrn _%MMU0:far %LoadPage0 MACRO dst,src IF1 IFIDN , %OUT *AX as destination of %LoadPage0 not recommended* ELSE IFIDN , %OUT *AX as destination of %LoadPage0 not recommended* ENDIF ENDIF ENDIF push AX mov AX,src call _%MMU0 mov dst,AX pop AX ENDM ; Loads only Emm page 1 extrn _%MMU1:far %LoadPage1 MACRO dst,src IF1 IFIDN , %OUT *AX as destination of %LoadPage1 not recommended* ELSE IFIDN , %OUT *AX as destination of %LoadPage1 not recommended* ENDIF ENDIF ENDIF push AX mov AX,src call _%MMU1 mov dst,AX pop AX ENDM ENDIF ;;; ;;; Macros for extended memory version ;;; IFDEF EXTMEM ; get rid of default conventional memory definitions purge LoadPage,%LoadPage,%LoadPage0,%LoadPage1,LoadCode ; Load page address extrn _MMU:near LoadPage MACRO dst,src push src call _MMU pop dst ENDM ; SAME AS LoadPage EXCEPT CALLABLE FROM PROGX SEGMENT extrn _%MMU:far %LoadPage MACRO dst,src IF1 IFIDN , %OUT *AX as destination of %LoadPage not recommended* ELSE IFIDN , %OUT *AX as destination of %LoadPage not recommended* ENDIF ENDIF ENDIF push AX mov AX,src call _%MMU mov dst,AX pop AX ENDM ; The following macros are provided for comatibility with the ; Expanded memory version. They just perform a LoadPage. ; Load code block LoadCode MACRO dst,src LoadPage dst,src ENDM %LoadPage0 MACRO dst,src %LoadPage dst,src ENDM %LoadPage1 MACRO dst,src %LoadPage dst,src ENDM ENDIF ;;; ;;; Macros for protected mode version ;;; IFDEF PROMEM ; get rid of default real mode definitions purge STORE_WORD_IN_CS,STORE_BYTE_IN_CS,XCHG_WORD_IN_CS ; Access to pagetabl for LoadPage macros extrn pagetabl:word STORE_WORD_IN_CS MACRO SEG,OFFSET,VALUE push DS push AX mov AX,CS and AX,0FFF7H mov DS,AX pop AX assume DS:SEG mov word ptr DS:OFFSET,VALUE assume DS:DGROUP pop DS ENDM STORE_BYTE_IN_CS MACRO SEG,OFFSET,VALUE push DS push AX mov AX,CS and AX,0FFF7H mov DS,AX pop AX assume DS:SEG mov byte ptr DS:OFFSET,VALUE assume DS:DGROUP pop DS ENDM XCHG_WORD_IN_CS MACRO SEG,OFFSET,VALUE push DS push AX mov AX,CS and AX,0FFF7H mov DS,AX pop AX assume DS:SEG xchg word ptr DS:OFFSET,VALUE assume DS:DGROUP pop DS ENDM ENDIF