; Sample TR-CENTRAL (INT 18h) program
; PRINT TR-CENTRAL FREE MEMORY COUNT
; ¸ ERDOGAN TAN (30/12/2000)

;ÄÄÄÄÄÄÄÄÄÄ CODE_SEG_1  ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ

CODE_SEG_1	segment para public
		assume  CS:CODE_SEG_1, DS:CODE_SEG_1, SS:CODE_SEG_1, ES:CODE_SEG_1

		org	100h

proc_start	proc	far

start:
                push cs
                pop ds

                mov ah, 0Fh               ; CLS
                int 10h
                mov ah, 0
                int 10h

                mov ax, 01A1h
                mov bx, 0704h
                int 18h

                push ax
                xchg ah, al
                call proc_hex
                mov word ptr [FFMEM_Block], ax
                pop ax
                call proc_hex
                mov word ptr [FFMEM_Block]+2, ax

                mov ax, dx
                push ax
                xchg ah, al
                call proc_hex
                mov word ptr [FFMEM_BCount], ax
                pop ax
                call proc_hex
                mov word ptr [FFMEM_BCount]+2, ax

                mov ax, bx
                push ax
                xchg ah, al
                call proc_hex
                mov word ptr [FMEM_Count], ax
                pop ax
                call proc_hex
                mov word ptr [FMEM_Count]+2, ax

                mov ax, 01A1h
                mov bx, 0705h
                int 18h

                push ax
                xchg ah, al
                call proc_hex
                mov word ptr [MFMEM_Block], ax
                pop ax
                call proc_hex
                mov word ptr [MFMEM_Block]+2, ax

                mov ax, dx
                push ax
                xchg ah, al
                call proc_hex
                mov word ptr [MFMEM_BCount], ax
                pop ax
                call proc_hex
                mov word ptr [MFMEM_BCount]+2, ax

                mov ax, bx
                push ax
                xchg ah, al
                call proc_hex
                mov word ptr [MFMEM_Count], ax
                pop ax
                call proc_hex
                mov word ptr [MFMEM_Count]+2, ax

                mov si, offset FMEM_Info
                call proc_print_msg

                xor ah, ah
                int 16h

                int 20h

proc_hex:
               db 0D4h, 10h             ; AAM 
                                        ; output : AH = AL / 10h
                                        ;          AL = AL mod 10h
               or ax, '00'

               xchg ah, al

               cmp al, '9'
               jna short pass_cc_al
               add al, 7
pass_cc_al:
               cmp ah, '9'
               jna short end_of_proc_hex
               add ah, 7
end_of_proc_hex:
               retn

proc_print_msg  proc near

loc_print:
                lodsb                           ; Load byte at DS:SI to AL
		and     AL,AL            
                je      short end_of_print      ; If AL = 00h then return
		mov     AH,0Eh                  
		mov     BX,07h             
                int     10h                     
		jmp     short loc_print           
end_of_print:
                retn

proc_print_msg  endp

FMEM_Info:
                db 7
                db "TR-CENTRAL FREE MEMORY INFORMATION"
                db 0Dh, 0Ah, 0Dh, 0Ah
                db 'First Free Memory Block   : '
FFMEM_Block:    dd 30303030h
                db 'h'
                db 0Dh, 0Ah
                db 'F. Free Mem. Block Count  : '
FFMEM_BCount:   dd 30303030h
                db 'h'
                db 0Dh, 0Ah
                db 'Free Memory Block Count   : '
FMEM_Count:     dd 30303030h
                db 'h'
                db 0Dh, 0Ah
                db 'Maximum C. F. M. Block    : '
MFMEM_Block:    dd 30303030h
                db 'h'
                db 0Dh, 0Ah
                db 'Max. C. F. M. Block Count : '
MFMEM_BCount:   dd 30303030h
                db 'h'
                db 0Dh, 0Ah
                db 'Free Memory Block Count   : '
MFMEM_Count:    dd 30303030h
                db 'h'
                db 0Dh, 0Ah, 0

proc_start	endp

CODE_SEG_1	ends

		end	start

