;----------------------------------------------------------------------------- ; ; MACROS.INC ; ; Copyright (c) 1991, 1995-Present Robert Collins ; ; You have my permission to copy and distribute this software for ; non-commercial purposes. Any commercial use of this software or ; source code is allowed, so long as the appropriate copyright ; attributions (to me) are intact, *AND* my email address is properly ; displayed. ; ; Basically, give me credit, where credit is due, and show my email ; address. ; ;----------------------------------------------------------------------------- ; ; Robert R. Collins email: rcollins@x86.org ; ;----------------------------------------------------------------------------- ;----------------------------------------------------------------------------- ; Macro definitions ;----------------------------------------------------------------------------- Init_descriptor macro segment,offset,desc_name push ax push dx push si push es mov ax,&segment ;; get segment name mov es,ax ;; to form 24 bit address mov si,&offset ;; mov ax,es ; point to control block xor dh,dh ; clear upper register mov dl,ah ; build high byte of 32-bit address shr dl,4 ; use only high nibble from (AX) shl ax,4 ; strip high nibble from segment add ax,si ; add the GDT offset to develop low word adc dx,0 ; adjust high byte if carry from low mov &desc_name.Base_A15_A00,ax ;; low word of address mov &desc_name.Base_A23_A16,dl ;; high byte of address mov &desc_name.Base_A31_A24,dh ;; high byte of linear address pop es pop si pop dx pop ax endm Farjmp macro destination,selector ; dynamic JMP FAR SEG:OFF db 0eah ;; jmp instruction dw offset destination ;; offset word dw selector ;; segment selector word endm Farcall macro destination,selector ; dynamic CALL FAR SEG:OFF db 09ah ;; jmp instruction dw offset destination ;; offset word dw selector ;; segment selector word endm Farjmp32 macro destination,selector ; dynamic JMP FAR SEG:OFF db 0eah ;; jmp instruction dd offset destination ;; offset word dw selector ;; segment selector word endm Farcall32 macro destination,selector ; dynamic CALL FAR SEG:OFF db 09ah ;; jmp instruction dd offset destination ;; offset word dw selector ;; segment selector word endm Enter_PM MACRO Local L1 mov ebx,cr0 or bl,1 mov cr0,ebx jmp short L1 L1: ENDM Exit_PM MACRO Local L1 mov ebx,cr0 and bl,not 1 mov cr0,ebx farjmp L1, L1: ENDM LOADALL MACRO db 0fh,07h ENDM IO_Delay MACRO out 0edh,ax ENDM CMOS_Write2 MACRO CMOS_Addr,CMOS_Value mov al,CMOS_Addr out 70h,al IO_DELAY mov al,CMOS_Value out 71h,al ENDM Print_String MACRO Str_Addr mov ah,9 mov dx,Str_Addr int 21h ENDM Pass_Fail MACRO Expected Local @L1 mov dx,offset Passed cmp al,Expected je short @L1 mov dx,offset Failed @L1: Print_String dx ENDM