汇编源码系列之fxn

这个都是过去DOS时代的汇编源码,虽然已经过去了,但是对于学习汇编还是有帮助的,汇编语言只是程序员一门基础语言,大多人掌握即可,不一定要深入研究.......

     name   FXN4BH
     page   55,132
     title   'FXN4BH --- demo PC-DOS EXEC function'
;
; FXN4BH --- demonstrate use of the
; PC-DOS 2.0 EXEC function call 4BH
;
; Copyright (c) 1983 by Ray Duncan
;
cr    equ    0dh    ;ASCII carriage return
lf    equ    0ah    ;ASCII line feed
               ;
cseg   segment  para public 'CODE'
               ;
     assume  cs:cseg,ds:data,ss:stack
               ;
demo   proc   far
               ;at entry DS & ES = PSP
     push   ds    ;Save address for final
     xor    ax,ax   ;FAR RET to PC-DOS on stack
     push   ax
               ;save copy of SS:SP for use
               ;after return from overlay
     mov    cs:STK_SEG,ss
     mov    cs:STK_PTR,sp
               ;
               ;Reserve 1000H bytes for
               ;this loader and release
               ;the rest of memory for
               ;use by the overlayed program.
     mov    bx,100h  ;ES=segment of PSP of loader
     mov    ah,4ah  ;BX=paragraphs to reserve
     int    21h
               ;make the messages in data
               ;segment addressable
     mov    ax,seg DATA
     mov    ds,ax
     mov    es,ax
               ;jump if memory
               ;de-allocation failed
     jc    ALLOC_ERR
               ;print memory successfully
               ;released
     mov    dx,offset MSG2
     mov    ah,9
     int    21h
               ;
               ;now load and execute
               ;the overlaid program.
     mov    dx,offset PGM_NAME
     mov    bx,offset PAR_BLK
     mov    al,0
     mov    ah,4bh
     int    21h
               ;restore stack pointers
               ;to state before EXEC call
     mov    ss,cs:STK_SEG
     mov    sp,cs:STK_PTR
               ;Make data segment
               ;addressable again
     mov    ax,seg DATA
     mov    ds,ax
               ;print message that loader
               ;successfully regained control
     mov    dx,offset MSG3
     mov    ah,9
     int    21h
               ;now exit to PC-DOS
     ret
alloc_err:          ;come here if memory
               ;cannot be released
     mov    dx,offset MSG1
     mov    ah,9
     int    21h    ;print error message and
     ret         ;exit to PC-DOS
               ;
demo   endp
               ;
               ;these two variables must
               ;reside in Code Segment so
               ;that they are addressable
               ;after return from overlay.
stk_seg dw    0     ;original SS contents
stk_ptr dw    0     ;original SP contents
               ;
cseg   ends
               ;declare a stack area
               ;for use by this loader
stack  segment  para stack 'STACK'
               ;allow 64 bytes in this case
     db    64 dup (?)
stack  ends
               ;declare data segment to
               ;contain variables and tables
data   segment  para public 'DATA'
;
msg1   db    cr,lf
     db    'Unable to release memory.'
     db    cr,lf,'$'
msg2   db    cr,lf
     db    'Memory above loader released.'
     db    cr,lf,'Now loading CHKDSK.COM.'
     db    cr,lf,'$'
msg3   db    cr,lf
     db    'Loader regained control from CHKDSK,'
     db    cr,lf
     db    'now making final exit to PC-DOS.'
     db    cr,lf,'$'
;
               ;drive, path, and name of program
               ;to be loaded and executed.
pgm_name db    'CHKDSK.COM',0
;
par_blk dw    ENVIR   ;segment address of
               ;environment descriptor
               ;
               ;full address of command line
               ;to be passed at offset 80H
     dw    offset CMD_LINE   ;in overlaid
     dw    seg CMD_LINE    ;program's PSP
               ;
               ;full address of default
               ;File Control Block to be
               ;passed at offset 5CH in
     dw    offset FCB1     ;overlaid
     dw    seg FCB1      ;program's PSP
               ;
               ;full address of default
               ;File Control Block to be
               ;passed at offset 6CH in
     dw    offset FCB2     ;overlaid
     dw    seg FCB2      ;program's PSP
;
               ;actual command line tail
               ;to be passed to overlay
cmd_line db    4,' *.*',cr,0
;
               ;first default FCB to
fcb1   db    0     ;be passed to overlay
     db    11 dup ('?')
     db    25 dup (0)
               ;second default FCB to
fcb2   db    0     ;be passed to overlay
     db    11 dup (' ')
     db    25 dup (0)
;
data   ends
               ;declare separate data
               ;segment to contain
               ;environment descriptor
envir  segment  para 'ENVIR'
               ;
               ;Search path used by PC-DOS
               ;to look for commands or
               ;batch files not found in
     db    'PATH=',0 ;the current directory
               ;
               ;Search path used by PC-DOS
               ;to locate COMMAND.COM
     db    'COMSPEC=A:COMMAND.COM',0
     db    0     ;extra 0 byte designates
               ;end of environment
envir  ends
     end    demo

时间: 2024-12-31 02:25:07

汇编源码系列之fxn的相关文章

汇编源码系列之clear

这个都是过去DOS时代的汇编源码,虽然已经过去了,但是对于学习汇编还是有帮助的,汇编语言只是程序员一门基础语言,大多人掌握即可,不一定要深入研究....... name clear page 55,132 title 'CLEAR --- control PC display';; CLEAR Utility to clear display; and set character attributes;; Ray Duncan, Uncopyright (u) August 1983; This

汇编源码系列之clock

这个都是过去DOS时代的汇编源码,虽然已经过去了,但是对于学习汇编还是有帮助的,汇编语言只是程序员一门基础语言,大多人掌握即可,不一定要深入研究....... CGROUP GROUP VECTOR,CODESEGVECTOR SEGMENT AT 0H DB 6CH DUP(?) ;FILLERTIME_LO DW ? ;DOS TIMETIME_HI DW ? ;DOS TIMEVEC_IP DW ;CLOCK UPDATE VECTOR IPVEC_CS DW ;CLOCK UPDATE

汇编源码系列之charop

这个都是过去DOS时代的汇编源码,虽然已经过去了,但是对于学习汇编还是有帮助的,汇编语言只是程序员一门基础语言,大多人掌握即可,不一定要深入研究....... title MSDOS 2.00 Function Library for Lattice Csubttl -;;;;FUNCTION: Sets and returns switch char-;; acter and device availability.;;;;;;CALL:;;;; ret= _charop(al,dl);; i

汇编源码系列之clean

这个都是过去DOS时代的汇编源码,虽然已经过去了,但是对于学习汇编还是有帮助的,汇编语言只是程序员一门基础语言,大多人掌握即可,不一定要深入研究....... name clean page 55,132 title 'CLEAN --- Filter text file';; CLEAN --- a utility to filter text files.; This program removes all control codes except; for line feeds, carr

汇编源码系列之cleanf

这个都是过去DOS时代的汇编源码,虽然已经过去了,但是对于学习汇编还是有帮助的,汇编语言只是程序员一门基础语言,大多人掌握即可,不一定要深入研究....... name cleanf page 55,132 title 'CLEANF - Filter text file';; CLEANF - a DOS 2.0 filter for word processing document files.;; CLEAN.ASM Originally written by Ray Duncan; Co

汇编源码系列之burnout

这个都是过去DOS时代的汇编源码,虽然已经过去了,但是对于学习汇编还是有帮助的,汇编语言只是程序员一门基础语言,大多人掌握即可,不一定要深入研究....... COMMENT * Demo (and semi-useful) program to read/set burnout device parameters. Usage: burnout [ticks] [C+-] [V+-] [H+-] Parameters can be separated by almost anything. W

汇编源码系列之calc

这个都是过去DOS时代的汇编源码,虽然已经过去了,但是对于学习汇编还是有帮助的,汇编语言只是程序员一门基础语言,大多人掌握即可,不一定要深入研究....... PAGE ,132 TITLE CALCCGROUP GROUP CODESEGCODESEG SEGMENT PARA PUBLIC 'CODE' ASSUME CS:CGROUP,DS:CGROUP,ES:CGROUP PUBLIC CALC ORG 100HCALC PROC FAR JMP START;--------------

汇编源码系列之char

这个都是过去DOS时代的汇编源码,虽然已经过去了,但是对于学习汇编还是有帮助的,汇编语言只是程序员一门基础语言,大多人掌握即可,不一定要深入研究....... ctable segment para public 'DATA db 9 dup(' ') db 9,10,' ',12,13 db 13 dup(' ') db 27 db 4 dup(' ') db ' !"#$%&',39,'()*+,-./0123456789:;<=>?@' db 'ABCDEFGHIJKL

汇编源码系列之brk

这个都是过去DOS时代的汇编源码,虽然已经过去了,但是对于学习汇编还是有帮助的,汇编语言只是程序员一门基础语言,大多人掌握即可,不一定要深入研究....... PGROUP Group PROGDGROUP Group DATADATA Segment Public 'DATA'public brkflagbrkflag DW 0DATA endsPROG Segment Para Public 'PROG'public TrapBreaassume cs:PGROUP,DS:DGROUPTra