TESTHMA


TESTHMA ( 11.1) .

11.1. testhma\testhma.asm

; =====================================================

; API HIMEM.SYS

;

; (C) A. Frolov, 1997

;

; E-mail: frolov@glas.apc.org

; WWW: http://www.glasnet.ru/~frolov

; or

; http://www.dials.ccas.ru/frolov

; =====================================================

@@out_ch MACRO c1,c2,c3,c4,c5,c6,c7,c8,c9,c10

mov ah,02h

IRP chr,<c1,c2,c3,c4,c5,c6,c7,c8,c9,c10>

IFB <chr>

EXITM

ENDIF

mov dl,chr

int 21h

ENDM

ENDM

@@out_str MACRO

mov ah,9

int 21h

ENDM

BEEP MACRO

mov bx,0

mov ax, 0E07h

int 10h

ENDM

.model small

.STACK 100h

.DATA

msg DB 13,10,"HIMEM.SYSAPI Demo", 13, 10

DB "(C) Frolov A., 1997",13,10,13,10

DB "$"

noHMM DB 13,10

DB "HIMEM.SYSnot installed",13,10,"$"

yesHMM DB 13,10,"HIMEM.SYSistalled, ", "$"

ver1 DB "version: ", "$"

ver2 DB ", modification: ", "$"

errmsg DB 13,10,"Error code ", "$"

okmsg DB 13,10,"Success!", "$"

hmareq DB 13,10,"Request HMA", "$"

hmarel DB 13,10,"Release HMA", "$"

enA20 DB 13,10,"Open A20", "$"

dsA20 DB 13,10,"Close A20", "$"

loc_enA20 DB 13,10,"Local open A20","$"

loc_dsA20 DB 13,10,"Local close A20", "$"

check_A20 DB 13,10,"Check A20", "$"

free_ext_mem DB 13,10,"Extended memory, Kbyte: ", "$"

max_ext_block DB 13,10,"Max free Extended memory block, Kbyte: ", "$"


HMMEntry dd ?

.CODE

begin:

mov ax, DGROUP

mov ds, ax

mov ah, 9h ;

mov dx, OFFSET msg

int 21h

; , HIMEM.SYS

mov ax, 4300h

int 2fh

cmp al, 80h

je HMM_installed

; ,

;

mov ah, 9h

mov dx, OFFSET noHMM

int 21h

jmp terminate

HMM_installed:

mov ah, 9h

mov dx, OFFSET yesHMM

int 21h

;

mov ax, 4310h

int 2fh

mov word ptr cs:[HMMEntry][0], bx

mov word ptr cs:[HMMEntry][2], es

;

mov ah, 9h

mov dx, OFFSET ver1

int 21h

mov ax,0

call cs:[HMMEntry]

;

call Print_word

mov ah, 9h

mov dx, OFFSET ver2

int 21h

mov ax, bx

call Print_word

; HMA

mov ah, 9h

mov dx, OFFSET hmareq

int 21h

mov ax,0100h

mov dx,0ffffh

call cs:[HMMEntry]

or ax, ax

jnz hmareq_ok

jmp error

hmareq_ok:

mov ah, 9h

mov dx, OFFSET okmsg

int 21h

; A20

mov ah, 9h

mov dx, OFFSET enA20

int 21h

mov ax,0300h

call cs:[HMMEntry]

or ax, ax

jnz enA20_ok

jmp error

enA20_ok:

mov ah, 9h

mov dx, OFFSET okmsg

int 21h

; A20

mov ah, 9h

mov dx, OFFSET dsA20

int 21h

mov ax,0400h

call cs:[HMMEntry]

or ax, ax

jnz dsA20_ok

jmp error

dsA20_ok:

mov ah, 9h

mov dx, OFFSET okmsg

int 21h

; HMA

mov ah, 9h

mov dx, OFFSET hmarel

int 21h

mov ax,0200h

call cs:[HMMEntry]





or ax, ax

jz error

mov ah, 9h

mov dx, OFFSET okmsg

int 21h

; A20

mov ah, 9h

mov dx, OFFSET loc_enA20

int 21h

mov ax,0500h

call cs:[HMMEntry]

or ax, ax

jz error

mov ah, 9h

mov dx, OFFSET okmsg

int 21h

; A20

mov ah, 9h

mov dx, OFFSET check_A20

int 21h

mov ax,0700h

call cs:[HMMEntry]

or ax, ax

jz error

mov ah, 9h

mov dx, OFFSET okmsg

int 21h

;

mov ah, 9h

mov dx, OFFSET free_ext_mem

int 21h

mov ax,0800h

call cs:[HMMEntry]

push ax

mov ax, dx

call Print_word

mov ah, 9h

mov dx, OFFSET max_ext_block

int 21h

pop ax

call Print_word

; A20

mov ah, 9h

mov dx, OFFSET loc_dsA20

int 21h

mov ax,0600h

call cs:[HMMEntry]

or ax, ax

jz error

mov ah, 9h

mov dx, OFFSET okmsg

int 21h

jmp terminate

error:

push bx

mov ah, 9h

mov dx, OFFSET errmsg

int 21h

pop ax

call Print_word

terminate:

;

;

mov ax, 4C00h

int 21h

; AX

Print_word proc near

;--------------------

push ax

push bx

push dx

push ax

mov cl,8

rol ax,cl

call Byte_to_hex

mov bx,dx

@@out_ch bh

@@out_ch bl

pop ax

call Byte_to_hex

mov bx,dx

@@out_ch bh

@@out_ch bl

pop dx

pop bx

pop ax

ret

Print_word endp

Byte_to_hex proc near

;--------------------

; al - input byte

; dx - output hex

;--------------------

push ds

push cx

push bx

lea bx,tabl

mov dx,cs

mov ds,dx

push ax

and al,0fh

xlat

mov dl,al

pop ax

mov cl,4

shr al,cl

xlat

mov dh,al

pop bx

pop cx

pop ds

ret

tabl db '0123456789ABCDEF'

Byte_to_hex endp



END begin










Forekc.ru
, , , , , , , , , ,