2 TITLE DEBEMS
.SAL - EMS DEBUGGER COMMANDS PC DOS
3 ;======================= START OF SPECIFICATIONS =========================
5 ; MODULE NAME: DEBEMS.SAL
7 ; DESCRIPTIVE NAME: DEBUGGING TOOL
9 ; FUNCTION: PROVIDES USERS WITH ACCESS TO RUDIMENTARY EMS FACILITIES.
11 ; ENTRY POINT: ANY CALLED ROUTINE
19 ; INTERNAL REFERENCES:
21 ; EXTERNAL REFERENCES:
23 ; ROUTINE: DEBCOM2 - CONTAINS ROUTINES CALLED BY DEBUG
24 ; DEBCOM3 - CONTAINS ROUTINES CALLED BY DEBUG
25 ; DEBASM - CONTAINS ROUTINES CALLED BY DEBUG
26 ; DEBUASM - CONTAINS ROUTINES CALLED BY DEBUG
27 ; DEBMES - CONTAINS ROUTINES CALLED BY DEBUG
29 ; NOTES: THIS MODULE IS TO BE PREPPED BY SALUT WITH THE "PR" OPTIONS.
30 ; LINK DEBUG+DEBCOM1+DEBCOM2+DEBCOM3+DEBASM+DEBUASM+DEBERR+
31 ; DEBCONST+DEBDATA+DEBMES
35 ; AN000 VERSION 4.00 - REVISIONS MADE RELATE TO THE FOLLOWING:
37 ; - IMPLEMENT EMS FUNCTIONS DSM:6/24/87
39 ; COPYRIGHT: "MS DOS DEBUG UTILITY"
40 ; "VERSION 4.00 (C) COPYRIGHT 1988 Microsoft"
41 ; "LICENSED MATERIAL - PROPERTY OF Microsoft "
43 ;======================= END OF SPECIFICATIONS ===========================
49 CODE SEGMENT PUBLIC BYTE
52 CONST
SEGMENT PUBLIC BYTE
58 DATA SEGMENT PUBLIC BYTE
60 extrn xm_page
:byte ;an000;page count to allocate
61 extrn xm_log
:byte ;an000;log. page to map
62 extrn xm_phy
:byte ;an000;phy. page to map
63 extrn xm_handle
:word ;an000;handle to map
64 extrn xm_handle_ret
:word ;an000;handle created
66 extrn xm_page_cnt
:word ;an000;page count
67 extrn xm_handle_pages_buf
:byte ;an000;holds handles and pages
68 extrn xm_frame
:word ;an000;EMS frame value
69 extrn xm_deall_han
:word ;an000;handle to deallocate
70 extrn xm_alloc_pg
:word ;an000;pages allocated
71 extrn xm_total_pg
:word ;an000;total pages possible
72 extrn xm_han_alloc
:word ;an000;handles allocated
73 extrn xm_han_total
:word ;an000;total handles possible
75 extrn xm_han_ret_ptr
:word ;an000;prints handle created
76 extrn xm_mapped_ptr
:word ;an000;prints log/phy pages
77 extrn xm_page_seg_ptr
:word ;an000;Frame seg status
78 extrn xm_deall_ptr
:word ;an000;Handle deallocation
79 extrn xm_unall_ptr
:word ;an000;prints page status
80 extrn xm_han_alloc_ptr
:word ;an000;print handle status
82 extrn xm_err80_ptr
:word ;an000;ems error message
83 extrn xm_err83_ptr
:word ;an000;ems error message
84 extrn xm_err84_ptr
:word ;an000;ems error message
85 extrn xm_err85_ptr
:word ;an000;ems error message
86 extrn xm_err86_ptr
:word ;an000;ems error message
87 extrn xm_err87_ptr
:word ;an000;ems error message
88 extrn xm_err88_ptr
:word ;an000;ems error message
89 extrn xm_err89_ptr
:word ;an000;ems error message
90 extrn xm_err8a_ptr
:word ;an000;ems error message
91 extrn xm_err8b_ptr
:word ;an000;ems error message
92 extrn xm_err8d_ptr
:word ;an000;ems error message
93 extrn xm_err8e_ptr
:word ;an000;ems error message
94 extrn xm_errff_ptr
:word ;an000;ems error message
95 extrn xm_err_gen_ptr
:word ;an000;ems error message
96 extrn xm_parse_err_ptr
:word ;an000;input error message
97 extrn xm_status_ptr
:word ;an000;prints status of EMS
101 DG GROUP
CODE,CONST
,CSTACK
,DATA
103 CODE SEGMENT PUBLIC BYTE
104 ASSUME
CS:DG
,DS:DG
,ES:DG
,SS:DG
106 public debems
;an000;entry point
107 extrn std_printf
:near ;an000;message retriever
108 extrn gethx
:near ;an000;ASCII to bin conversion
109 extrn inbuf
:near ;an000;input command line
110 extrn scanb
:near ;an000;scan off blanks
111 extrn scanp
:near ;an000;scan for parm
112 extrn perr
:near ;an000;print ^ error
114 extrn crlf
:near ;an000;prints a cr,lf
119 DEBEMS: ;an000;entry to module
121 call SCANP
;an000;scan for M or S parm
122 ; $if z ;an000;no parms found
124 call XM_PARSE_ERROR
;an000;tell user of error
128 mov al,[si] ;an000;grab parm
129 cmp al,"M" ;an000;is it MAP?
132 inc si ;an000;point to next byte
133 call XM_EMS_MAP
;an000;
137 cmp al,"S" ;an000;is it a status check?
140 inc si ;an000;point to next byte
141 call XM_EMS_STATUS
;an000;
145 cmp al,"D" ;an000;Deallocate pages?
148 inc si ;an000;point to next byte
149 call XM_EMS_DEALL
;an000;
153 cmp al,"A" ;an000;Allocate pages?
156 inc si ;an000;point to next byte
157 call XM_EMS_ALLOC
;an000;
161 call GETEOL
;an000;check out parm
173 ret ;an000;return to caller
177 ;=========================================================================
178 ; XM_EMS_ALLOC : This function will provide the user the
179 ; capability to set and change EMS logical and
180 ; physical pages within page frame 0.
184 ; Outputs: EMS page frames set or altered
187 ;=========================================================================
189 XM_EMS_ALLOC proc
near ;an000;XM functions
191 call XM_GET_MAN_STATUS
;an000;see if EMS active
192 ; $if nc ;an000;EMS active
194 call XM_PAGE_PROMPT
;an000;get pages to allocate
195 call XM_GET_HAN_ALLOC
;an000;allocate pages
196 mov dg
:XM_HANDLE_RET
,dx ;an000;save handle returned
197 ; $if z ;an000;good return
199 pushf ;an000;save our flags
200 call XM_DISP1
;an000;tell user results
201 popf ;an000;restore our flags
205 call XM_ERROR
;an000;print error message
208 ; $else ;an000;EMS not active
211 call XM_ERROR
;an000;say why not active
215 ret ;an000;return to caller
217 XM_EMS_ALLOC endp
;an000;
220 ;=========================================================================
221 ; XM_EMS_MAP : This function will provide the user the
222 ; capability to set and change EMS logical and
223 ; physical pages within page frame 0.
227 ; Outputs: EMS page frames set or altered
230 ;=========================================================================
232 XM_EMS_MAP proc
near ;an000;XM functions
234 call XM_GET_MAN_STATUS
;an000;see if EMS active
235 ; $if nc ;an000;EMS active
237 call XM_LOG_PROMPT
;an000;get logical page
238 call XM_PHY_PROMPT
;an000;get physical page
239 call XM_HAN_PROMPT
;an000;get handle
240 call XM_MAP_MEMORY
;an000;map the page
241 ; $if z ;an000;good return
243 pushf ;an000;save our flags
244 call XM_DISP2
;an000;tell user results
245 popf ;an000;restore our flags
249 call XM_ERROR
;an000;tell error
252 ; $else ;an000;EMS not active
255 call XM_ERROR
;an000;say why not active
259 ret ;an000;return to caller
261 XM_EMS_MAP endp
;an000;
263 ;=========================================================================
264 ; XM_GET_MAN_STATUS : This routine will determine if EMS is active for
271 ; Outputs: Z - no error
273 ; AH - error message number
276 ;=========================================================================
278 XM_GET_MAN_STATUS proc
near ;an000;see if EMS active
280 push ds ;an000;save ds - we stomp it
281 mov ax,00h ;an000;set ax to 0
282 mov ds,ax ;an000;set ds to 0
283 cmp ds:word ptr[067h*4+0],0 ;an000;see if int 67h is there
284 pop ds ;an000;restore ds
285 ; $if e ;an000;EMS not installed
287 stc ;an000;flag no ems
288 mov ah,XM_NOT_INST
;an000;signal EMS not installed
292 call XM_INSTALL_CHECK
;an000;see if EMS installed
293 ; $if z ;AN000;IS EMS INSTALLED
295 clc ;AN000;EMS INSTALLED - FLAG IT
299 stc ;AN000;FLAG EMS NOT INSTALLED
300 mov ah,XM_NOT_INST
;an000;signal EMS not installed
306 RET ;AN000;RETURN TO CALLER
309 XM_GET_MAN_STATUS endp
;an000;
313 ;=========================================================================
314 ; XM_PAGE_PROMPT : This routine prompts the user for the number of
315 ; pages to be allocated, if he desires a new handle.
316 ; This routine will determine whether or not the other
317 ; prompt messages will be displayed.
319 ; Called Procs: STD_PRINTF
324 ; Outputs: XM_PAGE_FLAG
329 ;=========================================================================
331 XM_PAGE_PROMPT proc
near ;an000;prompt user for number
332 ; of pages to allocate
333 call SCANB
;an000;see if parm entered
334 ; $if nz ;an000;if parm found
336 mov cx,02 ;an000;bytes to parse
337 call GETHX
;an000;get hex value
338 ; $if c ;an000;no an error occurred
340 call PERR
;an000;display ^ error
344 mov dg
:XM_PAGE
,dl ;an000;save page count
350 call PERR
;an000;display ^ error
354 ret ;an000;return to caller
356 XM_PAGE_PROMPT endp
;an000;
359 ;=========================================================================
360 ; XM_LOG_PROMPT : This routine prompts the user for the number of the
361 ; logical page that is to be mapped in EMS. This
362 ; routine will not be performed if a page count
365 ; Called Procs: STD_PRINTF
370 ; Outputs: XM_LOG_BUF
374 ;=========================================================================
377 XM_LOG_PROMPT proc
near ;an000;prompt user for the
380 call SCANB
;an000;see if parm entered
381 ; $if nz ;an000;parm entered
383 mov cx,02 ;an000;bytes to parse
384 call GETHX
;an000;get hex value
385 ; $if c ;an000;no an error occurred
387 call PERR
;an000;display ^ error
391 mov dg
:XM_LOG
,dl ;an000;save logical page
397 call PERR
;an000;display ^ error
401 ret ;an000;return to caller
403 XM_LOG_PROMPT endp
;an000;
406 ;=========================================================================
407 ; XM_PHY_PROMPT : This routine prompts the user for the number of the
408 ; physical page that is to be mapped in EMS. This
409 ; routine will not be performed if a page count
412 ; Called Procs: STD_PRINTF
417 ; Outputs: XM_PHY_BUF
421 ;=========================================================================
424 XM_PHY_PROMPT proc
near ;an000;prompt user for the
425 ; physical page to be
427 call SCANB
;an000;see if parm entered
428 ; $if nz ;an000;parm found
430 mov cx,02 ;an000;bytes to parse
431 call GETHX
;an000;get hex value
432 ; $if c ;an000;no an error occurred
434 call PERR
;an000;display ^ error
438 mov dg
:XM_PHY
,dl ;an000;save logical page
448 ret ;an000;return to caller
450 XM_PHY_PROMPT endp
;an000;
453 ;=========================================================================
454 ; XM_HAN_PROMPT : This routine prompts the user for the number of the
455 ; handle that the mapping is to occur on. This
456 ; routine will not be performed if a page count
459 ; Called Procs: STD_PRINTF
464 ; Outputs: XM_HAN_BUF
468 ;=========================================================================
471 XM_HAN_PROMPT proc
near ;an000;prompt user for the
472 ; handle to be mapped
473 call SCANB
;an000;see if parm entered
474 ; $if nz ;an000;prompt found
476 mov cx,04 ;an000;bytes to parse
477 call GETHX
;an000;get hex value
478 ; $if c ;an000;no an error occurred
480 call PERR
;an000;display ^ error
484 mov dg
:XM_HANDLE
,dx ;an000;save logical page
490 call PERR
;an000;display ^ error
494 ret ;an000;return to caller
496 XM_HAN_PROMPT endp
;an000;
500 ;=========================================================================
501 ; XM_GET_HAN_ALLOC : This routine will get a handle and allocate the
502 ; requested number of pages to that handle.
506 ; Inputs: XM_PAGE - number of pages to allocate to handle
508 ; Outputs: Z - no error
510 ; DX - handle allocated
513 ;=========================================================================
515 XM_GET_HAN_ALLOC proc
near ;an000;create handle and alloc.
517 push bx ;an000;save regs.
518 mov ah,EMS_HAN_ALLOC
;an000;function 43h
519 xor bh,bh ;an000;clear byte
520 mov bl,dg
:XM_PAGE
;an000;number of pages to
522 int 67h
;an000;call EMS
523 or ah,ah ;an000;was there an error
524 pop bx ;an000;restore regs.
526 ret ;an000;return to caller
528 XM_GET_HAN_ALLOC endp
;an000;
530 ;=========================================================================
531 ; XM_MAP_MEMORY : This routine will map the requested logical page
532 ; to the requested physical page in EMS.
536 ; Inputs: XM_PHY - physical page to map to
537 ; XM_HAN - logical page to map
539 ; Outputs: Z - no error
544 ;=========================================================================
546 XM_MAP_MEMORY proc
near ;an000;map a logical page to
549 push bx ;an000;save regs.
551 mov ah,EMS_MAP_MEMORY
;an000;function 44h
552 mov al,dg
:XM_PHY
;an000;physical page to map
553 xor bh,bh ;an000;zero byte
554 mov bl,dg
:XM_LOG
;an000;logical page to map
555 mov dx,dg
:XM_HANDLE
;an000;handle to map page to
556 int 67h
;an000;call EMS
557 or ah,ah ;an000;was there an error
558 pop dx ;an000;restore regs.
561 ret ;an000;return to caller
563 XM_MAP_MEMORY endp
;an000;
566 ;=========================================================================
567 ; XM_DISP1 : This routine displays the current page frame and
568 ; the handle created as a result of the allocate pages.
570 ; Called Procs: STD_PRINTF
572 ; Inputs: XM_FRAME_SEG - page frame segment
573 ; XM_HANDLE_RET - created handle
574 ; XM_PG_FRAME_PTR - pointer to message
575 ; XM_HAN_RET_PTR - pointer to message
577 ; Outputs: "Page Frame Segment : %1",0d,0a
578 ; "Handle Created : %1",0d,0a
581 ;=========================================================================
583 XM_DISP1 proc
near ;an000;display messages
585 mov dx,offset dg
:XM_HAN_RET_PTR
;an000;"Handle Created : "
586 call STD_PRINTF
;an000;call message ret.
588 ret ;an000;return to caller
590 XM_DISP1 endp
;an000;
593 ;=========================================================================
594 ; XM_DISP2 : This routine displays the logical page mapped and
595 ; the physical page it was mapped to.
597 ; Called Procs: STD_PRINTF
599 ; Inputs: XM_MAPPED_PTR - pointer to message
600 ; XM_LOG - logical page mapped
601 ; XM_PHY - physical page mapped
603 ; Outputs: "Logical page %1 mapped to physical page %2",0d0a
606 ;=========================================================================
608 XM_DISP2 proc
near ;an000;display messages
610 mov dx,offset dg
:XM_MAPPED_PTR
;an000;"Logical page %1 mapped
611 ; to physical page %2"
612 call STD_PRINTF
;an000;call message ret.
614 ret ;an000;return to caller
616 XM_DISP2 endp
;an000;
618 ;=========================================================================
619 ; XM_ERROR: This routine will determine what error we have by
620 ; querying the result in the AH register. It will then
621 ; report the error to the user through STD_PRINTF
623 ; Called Procs: STD_PRINTF
625 ; Inputs: AH - error code
627 ; Outputs: error message
630 ;=========================================================================
632 XM_ERROR proc
near ;an000;error message printer
634 cmp ah,XM_ERR80
;an000;error message
635 ; $if e ;an000;found message
637 mov dx,offset dg
:XM_ERR80_PTR
;an000;point to message
638 jmp XM_ERROR_CONT
;an000;print error
642 cmp ah,XM_ERR83
;an000;error message
643 ; $if e ;an000;found message
645 mov dx,offset dg
:XM_ERR83_PTR
;an000;point to message
646 jmp XM_ERROR_CONT
;an000;print error
650 cmp ah,XM_ERR84
;an000;error message
651 ; $if e ;an000;found message
653 mov dx,offset dg
:XM_ERR84_PTR
;an000;point to message
654 jmp XM_ERROR_CONT
;an000;print error
658 cmp ah,XM_ERR85
;an000;error message
659 ; $if e ;an000;found message
661 mov dx,offset dg
:XM_ERR85_PTR
;an000;point to message
662 jmp XM_ERROR_CONT
;an000;print error
667 cmp ah,XM_ERR86
;an000;error message
668 ; $if e ;an000;found message
670 mov dx,offset dg
:XM_ERR86_PTR
;an000;point to message
671 jmp XM_ERROR_CONT
;an000;print error
675 cmp ah,XM_ERR87
;an000;error message
676 ; $if e ;an000;found message
678 mov dx,offset dg
:XM_ERR87_PTR
;an000;point to message
679 jmp XM_ERROR_CONT
;an000;print error
683 cmp ah,XM_ERR88
;an000;error message
684 ; $if e ;an000;found message
686 mov dx,offset dg
:XM_ERR88_PTR
;an000;point to message
687 jmp XM_ERROR_CONT
;an000;print error
691 cmp ah,XM_ERR89
;an000;error message
692 ; $if e ;an000;found message
694 mov dx,offset dg
:XM_ERR89_PTR
;an000;point to message
695 jmp XM_ERROR_CONT
;an000;print error
699 cmp ah,XM_ERR8A
;an000;error message
700 ; $if e ;an000;found message
702 mov dx,offset dg
:XM_ERR8A_PTR
;an000;point to message
703 jmp XM_ERROR_CONT
;an000;print error
707 cmp ah,XM_ERR8B
;an000;error message
708 ; $if e ;an000;found message
710 mov dx,offset dg
:XM_ERR8B_PTR
;an000;point to message
711 jmp XM_ERROR_CONT
;an000;print error
715 cmp ah,XM_ERR8D
;an000;error message
716 ; $if e ;an000;found message
718 mov dx,offset dg
:XM_ERR8D_PTR
;an000;point to message
719 jmp XM_ERROR_CONT
;an000;print error
723 cmp ah,XM_ERR8E
;an000;error message
724 ; $if e ;an000;found message
726 mov dx,offset dg
:XM_ERR8E_PTR
;an000;point to message
727 jmp XM_ERROR_CONT
;an000;print error
731 cmp ah,XM_NOT_INST
;an000;EMS not installed
732 ; $if e ;an000;found message
734 mov dx,offset dg
:XM_ERRFF_PTR
;an000;point to message
735 jmp XM_ERROR_CONT
;an000;print error
739 mov dx,offset dg
:XM_ERR_GEN_PTR
;an000;general error message
743 call STD_PRINTF
;an000;call message ret.
745 ret ;an000;return to caller
747 XM_ERROR endp
;an000;
749 ;=========================================================================
750 ; XM_PARSE_ERROR : This routine will display that an error has occurred
751 ; on the input of the requested data.
753 ; Called Procs: STD_PRINTF
755 ; Inputs: XM_PARSE_ERR_PTR - error message
757 ; Outputs: "Invalid value for parameter",0d,0a
760 ;=========================================================================
762 XM_PARSE_ERROR proc
near ;an000;input error message
764 mov dx,offset dg
:XM_PARSE_ERR_PTR
;an000;error message
765 call STD_PRINTF
;an000;call message ret.
766 ret ;an000;return to caller
768 XM_PARSE_ERROR endp
;an000;
772 ;=========================================================================
773 ; XM_EMS_STATUS : This function will provide the user with
774 ; a report the the current status of EMS.
778 ; Outputs: EMS page frames set or altered
781 ;=========================================================================
783 XM_EMS_STATUS proc
near ;an000;XM functions
785 call XM_GET_MAN_STATUS
;an000;see if EMS active
786 ; $if nc ;an000;EMS active
788 call XM_CURR_STATUS
;an000;current status of EMS
789 ; $else ;an000;EMS not active
792 call XM_ERROR
;an000;say why not active
796 ret ;an000;return to caller
798 XM_EMS_STATUS endp
;an000;
801 ;=========================================================================
802 ; XM_CURR_STATUS : This routine will display the current status of
803 ; all active EMS handles.
807 ; Outputs : Current status of all active EMS handles
808 ; "Handle %1 has %2 pages allocated"
810 ; Physical page with it associated frame segment
811 ; "Physical page %1 = Frame segment %2"
814 ;=========================================================================
816 XM_CURR_STATUS proc
near ;an000;current EMS status
818 mov ah,EMS_HANDLE_PAGES
;an000;get handle pages
819 mov di,offset dg
:XM_HANDLE_PAGES_BUF
;an000;point to the buffer
822 or ah,ah ;an000;see if an error occurred
823 ; $if z ;an000;no error
825 ; $do ;an000;do while data in buffer
827 cmp bx,0 ;an000;end of buffer?
828 ; $leave e ;an000;yes
830 mov ax,word ptr es:[di] ;an000;page handle
831 mov dg
:XM_HANDLE_RET
,ax ;an000;save in var
832 mov ax,word ptr es:[di+02];an000;page count
833 mov dg
:XM_PAGE_CNT
,ax ;an000;save in var
834 mov dx,offset dg
:XM_STATUS_PTR
;an000;point to message
835 call STD_PRINTF
;an000;print it
836 add di,04h ;an000;next record
837 dec bx ;an000;decrement counter
842 call CRLF
;an000;place a blank line
845 call XM_FRAME_BUFFER
;an000;get frame buffer
846 ;ES:DI points to frame buffer
847 ; $do ;an000;while cx not = 0
849 cmp cx,00 ;an000;at end?
850 ; $leave e ;an000;yes
852 call XM_GET_FRAME_SEG
;an000;obtain page and seg
853 mov dx,offset dg
:XM_PAGE_SEG_PTR
;an000;message
854 call STD_PRINTF
;an000;print it
855 dec cx ;an000;decrease counter
856 add di,04 ;an000;adjust pointer
861 call XM_UNALL_COUNT
;an000;display page status
862 call XM_HANDLE_COUNT
;an000;display handle status
867 call XM_ERROR
;an000;display the error
872 XM_CURR_STATUS endp
;an000;
874 ;=========================================================================
875 ; XM_UNALL_COUNT : This routine generates a line of the status report
876 ; displaying the number of pages allocated out of
881 ; Outputs : Current status of allocated pages
882 ; "%1 of a total %2 EMS pages have been allocated"
885 ;=========================================================================
887 XM_UNALL_COUNT proc
near ;an000;
889 mov ah,EMS_UNALL_PG_CNT
;an000;see how many pages
892 or ah,ah ;an000;see if error
894 ; $if z ;an000;no error
896 push bx ;an000;save bx
897 push dx ;an000;save dx
899 pop dx ;an000;restore dx
900 pop bx ;an000;restore bx
901 mov ax,dx ;an000;total page count
902 sub ax,bx ;an000;get pages allocated
903 mov dg
:XM_ALLOC_PG
,ax ;an000;save allocated pages
904 mov dg
:XM_TOTAL_PG
,dx ;an000;save total page count
905 mov dx,offset dg
:XM_UNALL_PTR
;an000;"%1 of a total %2 EMS
906 ; pages have been allocated",cr,lf
907 call STD_PRINTF
;an000;print it
913 XM_UNALL_COUNT endp
;an000;
916 ;=========================================================================
917 ; XM_HANDLE_COUNT: This routine generates a line of the status report
918 ; displaying the number of handles allocated out of
919 ; the total possible.
923 ; Outputs : Current status of allocated pages
924 ; "%1 of a total %2 EMS handles have been allocated"
927 ;=========================================================================
929 XM_HANDLE_COUNT proc
near ;an000;
931 mov ah,EMS_HANDLE_CNT
;an000;see how many handles
934 or ah,ah ;an000;see if error
936 ; $if z ;an000;no error
938 mov ax,EMS_HANDLE_TOTAL
;an000;total possible handles
939 mov dg
:XM_HAN_TOTAL
,ax ;an000;save total page count
940 mov dg
:XM_HAN_ALLOC
,bx ;an000;save allocated pages
941 mov dx,offset dg
:XM_HAN_ALLOC_PTR
942 ;an000;"%1 of a total %2 EMS
943 ; handles have been allocated",cr,lf
944 call STD_PRINTF
;an000;print it
950 XM_HANDLE_COUNT endp
;an000;
953 ;=========================================================================
954 ; XM_FRAME_SEG : This routine accesses the vector created by
955 ; function 58h, int 67h. It obtains a physical
956 ; page of EMS and its segment from this vector
958 ; Inputs : ES:DI - points to frame buffer
960 ; Outputs : XM_PHY - a physical page in EMS
961 ; XM_FRAME - segment corresponding to the physical page
964 ;=========================================================================
967 XM_GET_FRAME_SEG proc
near ;an000;find the frame segment
969 mov al,byte ptr es:[di+2] ;an000;get physical page
970 mov dg
:XM_PHY
,al ;an000;place in print var
971 mov ax,word ptr es:[di] ;an000;get frame segment
972 mov dg
:XM_FRAME
,ax ;an000;place in print var
976 XM_GET_FRAME_SEG endp
;an000;
978 ;=========================================================================
979 ; XM_INSTALL_CHECK: This routine performs function 51h, int 67h to
980 ; determine if EMS is indeed active.
982 ; Inputs : XM_FRAME_BUFFER - used to receive physical page
983 ; and segment data for EMS.
985 ; Outputs : XM_FRAME_BUFFER - buffer holds physical page
986 ; and segment data for EMS.
989 ;=========================================================================
991 XM_INSTALL_CHECK proc
near ;an000;see if EMS installed
993 MOV AH,EMS_GET_MAN_STAT
;AN000;GET EMS STATUS
994 XOR AL,AL ;an000;clear low byte
996 OR AH,AH ;an000;check for error
997 ; $IF Z ;an000;no error
999 MOV AH,EMS_VERSION
;an000;get version number
1001 CMP AL,EMS_LIM_40
;an000;LIM 4.0 ?
1002 ; $IF AE ;an000;4.0 or greater
1004 MOV AH,00h ;an000;set up for flag pass
1005 OR AH,AH ;an000;set flag to ZR
1006 ; $ELSE ;an000;below 4.0
1009 MOV AH,01h ;an000;set up for flag pass
1010 OR AH,AH ;an000;set flag to NZ
1018 XM_INSTALL_CHECK endp
;an000;
1023 ;=========================================================================
1024 ; XM_EMS_DEALL : This routine deallocates handles from EMS.
1026 ; Inputs : DX - Handle supplied by XM_DEALL_PROMPT
1028 ; Outputs : Good return - "Handle %1 deallocated"
1029 ; Bad return - message describing error
1032 ;=========================================================================
1034 XM_EMS_DEALL proc
near ;an000;deallocate EMS pages
1036 call XM_GET_MAN_STATUS
;an000;see if EMS installed
1037 ; $if nc ;an000;error?
1039 call XM_DEALL_PROMPT
;an000;prompt user for handle
1040 mov ah,EMS_PAGE_DEALL
;an000;function 45h, int 67h
1043 or ah,ah ;an000;error?
1046 call XM_ERROR
;an000;say why
1050 mov dx,offset dg
:XM_DEALL_PTR
;an000;"Handle %1 deallocated"
1051 call STD_PRINTF
;an000;print message
1057 call XM_ERROR
;an000;print type of error
1063 XM_EMS_DEALL endp
;an000;
1065 ;=========================================================================
1066 ; XM_DEALL_PROMPT : This routine prompts the user for the handle to be
1067 ; deallocated. It converts the handle entered to
1068 ; binary and passes it back to the caller in DX.
1072 ; Outputs : DX - Handle to be deallocated.
1075 ;=========================================================================
1077 XM_DEALL_PROMPT proc
near ;an000;prompt user for handle
1079 call SCANB
;an000;see if parm entered
1080 ; $if nz ;an000;parm found
1082 mov cx,04 ;an000;bytes to parse
1083 call GETHX
;an000;get hex value
1084 ; $if c ;an000;no an error occurred
1086 call PERR
;an000;display ^ error
1090 mov dg
:XM_DEALL_HAN
,dx ;an000;save handle to deallocate
1096 call PERR
;an000;display ^ error
1100 ret ;an000;return to caller
1102 XM_DEALL_PROMPT endp
;an000;
1105 ;=========================================================================
1106 ; XM_FRAME_BUFFER : This routine obtains the frame buffer
1111 ; Outputs : ES:DI - Pointer to frame array
1112 ; CX - Number of elements in array
1113 ;=========================================================================
1115 XM_FRAME_BUFFER proc
near ;an000;
1117 mov ax,EMS_PG_FRAME
;an000;get frame buffer
1122 XM_FRAME_BUFFER endp
;an000;