home *** CD-ROM | disk | FTP | other *** search
- ;void assemble_path(return_string,array_position,tree_array);
- ; char *tree_array,*return_string;
- ; unsigned short array_position;
-
- EXTRN _memory_model:byte
- EXTRN _error_code:byte
- EXTRN _tree_array_size:word
-
- _TEXT SEGMENT BYTE PUBLIC 'CODE'
- ASSUME CS:_TEXT
- PUBLIC _assemble_path
- _assemble_path proc near
- push bp ;
- mov bp,sp ;
- push di ;
- push si ;
- cmp _memory_model,0 ;near or far?
- jle begin ;jump if near
- inc bp ;else add 2 to BP
- inc bp ;
- begin: push ds ;
- jmp short start ;jump over local data
- mem_model db ? ;keep copy, since DS changed
- start: mov al,_memory_model ;
- mov cs:mem_model,al ;
- cmp _memory_model,2 ;data near or far?
- jb L0 ;jump if near
- les di,dword ptr[bp+4] ;ES:DI pts to return string
- inc bp ;add 2 to BP since dword ptr
- inc bp ;
- jmp short L00 ;
- L0: mov ax,ds ;ES = DS
- mov es,ax ;
- mov di,[bp+4] ;
- L00: mov byte ptr es:[di],0 ;null string if error
- mov _error_code,1 ;1 = _tree_array_size out of range
- mov ax,_tree_array_size ;ArrayPosition OK?
- mov bx,[bp+6] ;
- or bx,bx ;
- jz L9 ;
- cmp bx,ax ;
- ja L9 ;quit if not
- dec _error_code ;0 = no error
- sub bx,bx ;counts return strg length
- L1: mov ax,[bp+6] ;fetch ArrayPosition
- L2: cmp cs:mem_model,2 ;
- jb L3 ;
- lds si,dword ptr[bp+8] ;DS:SI pts to TreeArray
- jmp short L4 ;
- L3: mov si,[bp+8] ;near case
- L4: add si,21 ;start at array element 1
- dec ax ;offset from 0
- mov dl,21 ;bytes per record
- mul dl ;offset
- add si,ax ;add to ptr
- sub cx,cx ;get string length
- push si ;
- L5: cmp byte ptr[si],0 ;
- je L6 ;
- inc cx ;
- inc si ;
- jmp short L5 ;
- L6: pop si ;
- add bl,cl ;add to tally
- inc bl ;plus one for backslash
- or bh,bh ;first pass?
- jz L7 ;don't copy string if so
- add si,cx ;pt SI to end of string
- dec si ;
- std ;
- rep movsb ;copy chars to return strg
- mov byte ptr es:[di],'\' ;write in the slash
- dec di ;
- inc si ;adjust for terminator
- L7: cmp word ptr [si+13],0 ;check Parent field
- jz L8 ;
- mov ax,[si+13] ;get ptr to Parent element
- jmp short L2 ;
- L8: or bh,bh ;first pass?
- jnz L9 ;quit if not
- add di,bx ;forward strg ptr
- mov byte ptr es:[di],0 ;set terminating null
- dec di ;minus one for terminator byte
- inc bh ;flag that second pass
- jmp short L1 ;this time, copy over strings
- L9: pop ds ;
- pop si ;
- pop di ;
- pop bp ;
- cld ;
- cmp _memory_model,0 ;quit
- jle quit ;
- db 0CBh ;RET far
- quit: ret ;RET near
- _assemble_path endp
- _TEXT ENDS
- END