⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rxdosexe.asm

📁 dos source
💻 ASM
📖 第 1 页 / 共 5 页
字号:
        getarg ax, _requiredParas
        getarg dx, _maxRequestedParas
        call _allocateMinMaxMemBlock                    ; return seg pointer to avail memory
        jc _loaderAllocMemory_50                        ; if insufficient space to load -->
        storarg _programPSP, es                         ; save PSP seg address
        storarg _allocatedSize, cx                      ; allocated size

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  create child PSP
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

        getdarg dx, ax, _ExecBlock                      ; load exec structure
        call createPSP                                  ; build PSP (cx contains alloc size)
        storarg _StartSegment, es                       ; PSP here

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  set Env Block in PSP
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

        getarg es, _programPSP
        getarg ax, _AllocEnv                            ; alloc environment
        mov word ptr es:[ pspEnvironment ], ax          ; environment block

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  insure parent's handle are set for both blocks
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

        mov dx, es                                      ; PSP address
        mov ax, es
        sub ax, (sizeMEMBLOCK/ PARAGRAPH)
        mov es, ax                                      ; point to allocation block
        mov word ptr es:[ _memParent ], dx              ; assign parent

        getarg ax, _AllocEnv
        or ax, ax                                       ; none required ?
        jz _loaderAllocMemory_56                        ; no -->

        sub ax, (sizeMEMBLOCK/ PARAGRAPH)
        mov es, ax                                      ; point to allocation block
        mov word ptr es:[ _memParent ], dx              ; assign parent
        jmp short _loaderAllocMemory_56                 ; if everything is ok -->

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  free env block if error
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

_loaderAllocMemory_50:
        getarg ax, _AllocEnv
        or ax, ax                                       ; Env allocated ?
        jz _loaderAllocMemory_54                        ; no -->

        mov es, ax
        call _freeMemBlock

_loaderAllocMemory_54:
        SetError pexterrNotEnoughMemory, _loaderAllocMemory_56

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  return 
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

_loaderAllocMemory_56:
        getarg ax, _programPSP
        getarg es, _StartSegment
        getarg cx, _allocatedSize

_loaderAllocMemory_66:
        Return

        ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
        ;  Compute Checksum                                             ;
        ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
        ;                                                               ;
        ;  Input:                                                       ;
        ;   es:di  start address of block                               ;
        ;   cx     number of bytes in block                             ;
        ;                                                               ;
        ;  Output:                                                      ;
        ;   ax     sum, ignoring carry, of all words in block           ;
        ;...............................................................;

computeChecksum:
        push di
        push cx
        shr cx, 1
        xor ax, ax

computeChecksum_04:
        add ax, word ptr es:[ di ]
        add di, 2
        loop computeChecksum_04

        pop cx
        pop di
        ret

        ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
        ;  Set Execution State                                          ;
        ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
        ;                                                               ;
        ;  Usage:                                                       ;
        ;   ds:dx  address of SETEXEC block                             ;
        ;                                                               ;
        ;...............................................................;

_SetExecuteMode:

        clc
        ret  

        ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
        ;  Append Program Name to Environment Block                     ;
        ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
        ;                                                               ;
        ;  Usage:                                                       ;
        ;   es     environment block                                    ;
        ;   ds:dx  program name                                         ;
        ;                                                               ;
        ;...............................................................;

appendProgramNametoEnv:

        mov si, dx                                      ; save name to program

        xor al, al                                      ; byte to search for
        xor di, di                                      ; byte offset
        mov cx, 0FFFFh                                  ; maximum length

appendPgmName_10:
        repnz scasb                                     ; scan for end of string
        scasb                                           ; test if double null
        jne appendPgmName_10                            ;

        mov ax, 0001                                    ; # strings to append
        stosw                                           ;

appendPgmName_14:
        lodsb
        stosb
        or al, al                                       ; null byte copied ?
        jnz appendPgmName_14                            ; not yet -->

        ret

        ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
        ;  Get Size of Envirnment String                                ;
        ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
        ;                                                               ;
        ;  Input:                                                       ;
        ;   es     environment block string (must be non-zero)          ;
        ;                                                               ;
        ;  Output:                                                      ;
        ;   cx     # paragraphs requested. (if zero, allocate none).    ;
        ;                                                               ;
        ;...............................................................;

_getSizeOfEnvString:

        push di

        xor al, al                                      ; byte to search for
        xor di, di                                      ; byte offset
        mov cx, 0FFFFh                                  ; maximum length

getSizeEnv_10:
        repnz scasb                                     ; scan for end of string
        scasb                                           ; test if double null
        jne getSizeEnv_10                               ;

        mov cx, di                                      ; get length
        add cx, (sizeEXPANDNAME + sizeParagraph - 1)/2  ; include size of trailing filename
        add cx, 2                                       ; include count word
        shr cx, 1                                       ; size to paragraphs
        shr cx, 1
        shr cx, 1
        shr cx, 1
        or cx, cx

        pop di
        ret

        ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
        ;  Set Program Name in Memory Block                             ;
        ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
        ;                                                               ;
        ;  Input:                                                       ;
        ;   es     block to change (not header address)                 ;
        ;   dx     full or partial filename (null terminated)           ;
        ;                                                               ;
        ;...............................................................;

_setProgramNameInMemBlock:

        SaveSegments
        mov ax, es
        or ax, ax                                       ; no destination mem block ?
        jz _setProgName_22                              ; ignore set name -->

        sub ax, (sizeMEMBLOCK/ PARAGRAPH)
        push ax                                         ; save seg address

        mov ax, ss
        mov ds, ax                                      ; just in case it's not
        mov es, ax                                      ; scan expanded name

        xor ax, ax
        mov cx, -1
        mov di, dx                                      ; scan name for null terminator
        repnz scasb                                     ; scan name
        not cx                                          ; valid count

_setProgName_08:
        cmp byte ptr es:[ di - 1 ], '\'
        jz _setProgName_12                              ; we have start of name -->
        dec di
        loop _setProgName_08

        mov di, dx                                      ; name contained no path

_setProgName_12:
        mov si, di                                      ; save filename 
        mov dx, di                                      ; save filename 
        pop es                                          ; restore memblock seg address

        mov ax, 2020h
        mov di, offset _memPgmName                      ; where to init
        mov cx, sizefnName / 2                          ; size filename in words
        rep stosw                                       ; initialize to blanks

        mov di, offset _memPgmName                      ; where to init
        mov cx, sizefnName                              ; size filename in bytes

_setProgName_16:
        lodsb                                           ; get byte
        or al, al                                       ; end of name ?
        jz _setProgName_22                              ; if end of name -->
        cmp al, '.'                                     ; extension ?
        jz _setProgName_22                              ; if end of name -->

        stosb                                           ; save character in mem block
        loop _setProgName_16

_setProgName_22:
        RestoreSegments
        ret

        ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
        ;  If Overlay Loader, return size                               ;
        ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
        ;                                                               ;
        ;  Input:                                                       ;
        ;   al     mode flag                                            ;
        ;   cx:dx  file size to return                                  ;
        ;                                                               ;
        ;...............................................................;

ifOverlayLoader:
        push es
        push si
        RetCallersStackFrame es, si                     ; save size only if non-Overlay
        mov word ptr es:[ _CX           ][ si ], dx
        mov word ptr es:[ _BX           ][ si ], cx
        mov word ptr es:[ _AX           ][ si ], 0000
        pop si
        pop es

        cmp al, execLoadOverlay                         ; load overlay ?
        clc
        ret

RxDOS   ENDS
        END


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -