summaryrefslogtreecommitdiff
path: root/v4.0/src/CMD/EXE2BIN/E2BINIT.ASM
diff options
context:
space:
mode:
Diffstat (limited to 'v4.0/src/CMD/EXE2BIN/E2BINIT.ASM')
-rw-r--r--v4.0/src/CMD/EXE2BIN/E2BINIT.ASM1123
1 files changed, 1123 insertions, 0 deletions
diff --git a/v4.0/src/CMD/EXE2BIN/E2BINIT.ASM b/v4.0/src/CMD/EXE2BIN/E2BINIT.ASM
new file mode 100644
index 0000000..60422d4
--- /dev/null
+++ b/v4.0/src/CMD/EXE2BIN/E2BINIT.ASM
@@ -0,0 +1,1123 @@
1
2Title E2BINIT(EXE2BIN)
3
4;*****************************************************************************
5; Loader for EXE files under 86-DOS
6; VER 1.5
7; 05/21/82 Added rev number
8; VER 1.6
9; 07/01/82 A little less choosy about size matches
10; VER 2.0 M.A.U
11; 10/08/82 Modified to use new 2.0 system calls for file i/o
12; Ver 2.1 M.A.U
13; 10/27/82 Added the DOS version check
14; Ver 2.2 MZ
15; 8/30/83 Fixed command line parsing
16; Ver 2.3 EE
17; 10-12-83 More fixes to command line parsing
18; Ver 2.4 NP
19; 10/17/83 Use Printf for messages
20; Ver 2.5 MZ Fix LOCATE sss D: problem
21; 04/09/87 Add PARSER and MESSAGE RETRIEVER
22; Ver 4.00 DRM
23;*****************************************************************************
24
25
26INCLUDE SYSMSG.INC
27MSG_UTILNAME <EXE2BIN> ;AN000;
28
29 subttl Main Code Area ;AN000;
30 page
31
32
33; The following switch allows use with the "old linker", which put a version
34; number where the new linker puts the number of bytes used in the last page.
35; If enabled, this will cause a test for 0004 at this location (the old linker
36; version number), and if equal, change it to 200H so all of the last page
37; will be used.
38
39OLDLINK EQU 0 ;1 to enable, 0 to disable
40
41CODE SEGMENT PARA PUBLIC 'CODE' ;AN000;
42CODE ENDS ;AN000;
43DATA SEGMENT PARA PUBLIC 'DATA' ;AN000;
44DATA ENDS ;AN000;
45STACK SEGMENT PARA PUBLIC 'STACK' ;AN000;
46STACK ENDS ;AN000;
47ZLOAD SEGMENT PARA PUBLIC 'ZLOAD' ;AN000;
48ZLOAD ENDS ;AN000;
49
50DATA SEGMENT PARA PUBLIC 'DATA' ;AN000;
51
52MSG_SERVICES <MSGDATA> ;AN000;
53
54Command_Line_Buffer db 128 dup(0) ;AN000;
55Command_Line_Length equ $ - Command_Line_Buffer ;AN000;
56
57Fatal_Error db 0 ;AN000;
58
59Command_Line db NO
60
61
62
63rev db "2.4"
64
65
66file1_ext db ".EXE",00h
67file2_ext db ".BIN",00h
68
69per11 db 0 ;AN000;
70per2 db 0
71per22 db 0 ;AN000;
72
73update equ 0 ;AN000;
74noupdate equ -1 ;AN000;
75
76file1 db (64+13) dup(?)
77fnptr dw offset file1 ; Ptr to filename in file1
78handle1 dw 1 dup(?)
79
80file2 db (64+13) dup(?)
81f2cspot dw offset file2 ; Ptr to spot in file2, file1 maybe added
82handle2 dw 1 dup(?)
83
84dma_buf db 80h dup(0) ; DMA transfer buffer
85
86INBUF DB 5,0
87 DB 5 DUP(?)
88
89;The following locations must be defined for storing the header:
90
91RUNVAR LABEL BYTE ;Start of RUN variables
92RELPT DW ?
93LASTP LABEL WORD
94RELSEG DW ?
95SIZ LABEL WORD ;Share these locations
96PAGES DW ?
97RELCNT DW ?
98HEADSIZ DW ?
99 DW ?
100LOADLOW DW ?
101INITSS DW ?
102INITSP DW ?
103 DW ?
104INITIP DW ?
105INITCS DW ?
106RELTAB DW ?
107RUNVARSIZ EQU $-RUNVAR
108
109DBCS_Vector_Off dw 0 ;AN000;
110DBCS_Vector_Seg dw 0 ;AN000;
111
112parse_ptr DW ?
113
114DATA ENDS
115
116
117STACK SEGMENT PARA PUBLIC 'STACK'
118 DB (362 - 80h) + 80H DUP (?) ; (362 - 80h) is IBMs ROM requirement
119 ; (New - Old) == size of growth
120STACK ENDS
121;
122
123
124
125ZLOAD SEGMENT PARA PUBLIC 'ZLOAD'
126 db ?
127ZLOAD ENDS
128LOAD EQU ZLOAD
129;
130
131
132
133;
134;*****************************************************************************
135; Include files
136;*****************************************************************************
137;
138
139.xlist
140INCLUDE DOSSYM.INC ; also versiona.inc ;AN000;
141INCLUDE SYSCALL.INC ;AN000;
142INCLUDE E2BMACRO.INC ;AN000;
143INCLUDE E2BEQU.INC ;AN000;
144INCLUDE E2BTABLE.INC ;AN000;
145INCLUDE E2BPARSE.INC ;AN000;
146include version.inc
147.list
148
149
150
151CODE SEGMENT PARA PUBLIC 'CODE'
152 assume cs:CODE,ds:DATA,es:NOTHING,SS:STACK ;AN000;
153
154psp_ptr dw 1 dup(?) ;AN000;
155;
156;*****************************************************************************
157; SysDisplayMsg Declarations
158;*****************************************************************************
159;
160.xlist
161MSG_SERVICES <LOADmsg> ;AN000;
162MSG_SERVICES <DISPLAYmsg,CHARmsg> ;AN000;
163MSG_SERVICES <EXE2BIN.CLA,EXE2BIN.CLB> ;AN000;
164MSG_SERVICES <EXE2BIN.CL1,EXE2BIN.CL2> ;AN000;
165MSG_SERVICES <EXE2BIN.CTL> ;AN000;
166
167
168.list
169
170;
171;*****************************************************************************
172; External Routine Declarations
173;*****************************************************************************
174;
175
176 public SysDispMsg ;AN000;
177 public SysLoadMsg ;AN000;
178
179
180;*****************************************************************************
181;Routine name: Main_Init
182;*****************************************************************************
183;
184;Description: Main control routine for init section
185;
186;Called Procedures: Message (macro)
187; Check_DOS_Version
188; Init_Input_Output
189; Validate_Target_Drive
190; Hook_CNTRL_C
191;
192;Input: None
193;
194;Output: None
195;
196;Change History: Created 6/22/87 DM
197;
198;*****************************************************************************
199
200procedure Main_Init near ; ;AN000;
201
202 ASSUME DS:NOTHING ; THIS IS WHAT dos GIVES YOU ;AN000;
203 ASSUME ES:NOTHING ;AN000;
204
205 PUSH DS ;AN000;
206 mov psp_ptr,ds ;AN000;
207 XOR AX,AX ;AN000;
208 PUSH AX ;Push return address to DS:0 ;AN000;
209
210 MOV AX,SEG DATA ;SET UP ADDRESSABILITY TO ;AN000;
211 MOV DS,AX ; THE DATA SEGMENT ;AN000;
212 ASSUME DS:DATA ;TELL ASSEMBLER WHAT I JUST DID ;AN000;
213
214 mov Fatal_Error,No ;Init the error flag ;AN000;
215 call Init_Input_Output ;Setup messages and parse ;AN000;
216 cmp Fatal_Error,Yes ;Error occur? ;AN000;
217; $IF NE ;Nope, keep going ;AN000;
218 JE $$IF1
219 call LOCATE ;Go do the real program ;AN000;
220; $ENDIF ;AN000;
221$$IF1:
222 xor al,al ;AN000;
223 Dos_call Exit ;AN000;
224 int 20h ;If other exit fails ;AN000;
225
226Main_Init endp ;AN000;
227
228;*****************************************************************************
229;Routine name: Init_Input_Output
230;*****************************************************************************
231;
232;Description: Initialize messages, Parse command line, allocate memory as
233; needed. If there is a /FS switch, go handle it first as
234; syntax of IFS format may be different from FAT format.
235;
236;Called Procedures: Preload_Messages
237; Parse_For_FS_Switch
238; Parse_Command_Line
239; Interpret_Parse
240;
241;Change History: Created 6/22/87 DM
242;
243;Input: PSP command line at 81h and length at 80h
244; Fatal_Error = No
245;
246;Output: Fatal_Error = YES/NO
247;
248;*****************************************************************************
249
250procedure Init_Input_Output near ;AN000;
251
252 call Preload_Messages ;Load up message retriever ;AN000;
253 cmp Fatal_Error,YES ;Quit? ;AN000;
254; $IF NE ;Nope, keep going ;AN000;
255 JE $$IF3
256 call Parse_Command_Line ;Parse in command line input ;AN000;
257; $ENDIF ;AN000;
258$$IF3:
259 ret ;AN000;
260
261Init_Input_Output endp ;AN000;
262
263;*****************************************************************************
264;Routine name: Preload_Messages
265;*****************************************************************************
266;
267;Description: Preload messages using common message retriever routines.
268;
269;Called Procedures: SysLoadMsg
270;
271;
272;Change History: Created 6/22/87 DM
273;
274;Input: Fatal_Error = NO
275;
276;Output: Fatal_Error = YES/NO
277;
278;*****************************************************************************
279
280procedure Preload_Messages near ;AN000;
281
282 call SYSLOADMSG ;Preload the messages ;AN000;
283; $IF C ;Error? ;AN000;
284 JNC $$IF5
285 call SYSDISPMSG ;AN000;
286 mov fatal_error, YES ;AN000;
287; $ENDIF ;AN000;
288$$IF5:
289 ret ;AN000;
290Preload_Messages endp ;AN000;
291
292
293;*****************************************************************************
294;Routine name: Parse_Command_Line
295;*****************************************************************************
296;
297;Description: Parses command line.
298;
299;Called Procedures: Message (macro)
300; Sysparse
301;
302;Change History: Created 6/22/87 DM
303;
304;Input: Fatal_Error = NO
305;
306;Output: Fatal_Error = YES/NO
307;
308;*****************************************************************************
309
310
311Procedure Parse_Command_Line ;AN000;
312
313 push ds ;AN000;
314 mov ds,psp_ptr ;AN000;
315 ASSUME DS:NOTHING ;AN000;
316 mov si,Command_Line_Parms ;AN000;
317 mov ax,seg command_line_table ;AN000;
318 push es ;AN000;
319 mov es,ax ;AN000;
320 ASSUME ES:NOTHING ;AN000;
321 mov di,offset Command_Line_Table ;AN000;
322 xor cx,cx ;AN000;
323
324; $DO ;AN000;
325$$DO7:
326 xor dx,dx ;AN000;
327 mov es:parse_ptr,si
328 call Sysparse ;AN000;
329 cmp ax,No_Error ;AN000;
330
331; $IF E ;AN000;
332 JNE $$IF8
333
334 push ax ;AN000;
335 push bx ;AN000;
336 push ds ;AN000;
337 push es ;AN000;
338 push si ;AN000;
339 push di ;AN000;
340
341 cmp cx,1 ;AN000;
342
343; $IF E ;AN000;
344 JNE $$IF9
345
346 mov ax,seg rb_string1_off ;AN000;
347 mov ds,ax ;AN000;
348 ASSUME DS:NOTHING ;AN000;
349 mov si,offset rb_string1_off ;AN000;
350 mov ax,ds:[si] ;AN000;
351 mov bx,ax ;AN000;
352
353
354 mov ax,ds:[si+2] ;AN000;
355 mov ds,ax ;AN000;
356 ASSUME DS:NOTHING ;AN000;
357 mov si,bx ;AN000;
358
359 mov ax,seg file1 ;AN000;
360 mov es,ax ;AN000;
361 ASSUME ES:NOTHING ;AN000;
362 mov di,offset file1 ;AN000;
363 call copyfs ;AN000;
364
365; $ELSE ;AN000;
366 JMP SHORT $$EN9
367$$IF9:
368
369 mov ax,seg rb_string2_off ;AN000;
370 mov ds,ax ;AN000;
371 ASSUME DS:NOTHING ;AN000;
372 mov si,offset rb_string2_off ;AN000;
373 mov ax,ds:[si] ;AN000;
374 mov bx,ax ;AN000;
375
376
377 mov ax,ds:[si+2] ;AN000;
378 mov ds,ax ;AN000;
379 ASSUME DS:NOTHING ;AN000;
380 mov si,bx ;AN000;
381
382 mov ax,seg file2 ;AN000;
383 mov es,ax ;AN000;
384 ASSUME ES:NOTHING ;AN000;
385 mov di,offset file2 ;AN000;
386 call copyfs ;AN000;
387
388; $ENDIF ;AN000;
389$$EN9:
390
391 pop di ;AN000;
392 pop si ;AN000;
393 pop es ;AN000;
394 ASSUME ES:NOTHING ;AN000;
395 pop ds ;AN000;
396 ASSUME DS:NOTHING ;AN000;
397 pop bx ;AN000;
398 pop ax ;AN000;
399
400; $ENDIF ;AN000;
401$$IF8:
402
403 cmp ax,No_Error ;AN000;
404
405; $ENDDO NE ;AN000;
406 JE $$DO7
407
408 cmp ax,End_of_Parse ;Check for parse error ;AN000;
409; $IF NE ;AN000;
410 JE $$IF14
411 push ax ;AN001;
412 mov ax,es:parse_ptr ;AN001;
413 mov es:parsoff,ax ;AN001;
414 mov es:parseg,ds ;AN001;
415 mov byte ptr ds:[si],0 ;AN001;
416 pop ax ;AN001;
417 parse_message ;Must enter file name ;AN000;
418 mov es:Fatal_Error,YES ;Indicate death! ;AN000;
419; $ENDIF ;AN000;
420$$IF14:
421
422 pop es ;AN000;
423 ASSUME ES:NOTHING ;AN000;
424 pop ds ;AN000;
425 ASSUME DS:DATA ;AN000;
426
427 ret ;AN000;
428
429Parse_Command_Line endp ;AN000;
430
431;*****************************************************************************
432
433INCLUDE PARSE.ASM
434
435;*****************************************************************************
436
437
438procedure LOCATE near
439
440 push ds ;AN000;
441 ASSUME ES:NOTHING ; THIS IS THE WAY IT GETS HERE! ;AN000;
442 mov ax,es ; ES -> PSP ;AN000;
443 mov ds,ax ; DS -> PSP ;AN000;
444 ASSUME DS:NOTHING ;AN000;
445
446 MOV SI,offset file1
447 MOV BX,SEG DATA
448 MOV ES,BX
449 assume es:data ;AN000;
450
451 MOV BX,WORD PTR DS:[2] ;Get size of memory
452
453
454;-----------------------------------------------------------------------;
455
456;
457; The rules for the arguments are:
458; File 1:
459; If no extention is present, .EXE is used.
460; File 2:
461; If no drive is present in file2, use the one from file1
462; If no path is specified, then use current dir
463; If no filename is specified, use the filename from file1
464; If no extention is present in file2, .BIN is used
465;
466
467
468;----- Get the first file name
469 push ds ;AN000;
470 push es ;AN000;
471 ASSUME ES:DATA ;AN000;
472 pop ds ;AN000;
473 ASSUME DS:DATA ;AN000;
474
475sj01:
476 mov si,offset file1 ; d = file1;
477 mov per11,0 ; assume no extension on file1;AC000;
478
479;******************************************************************************
480
481sj0:
482 lodsb ; while (!IsBlank(c=*p++)) {
483 cmp al,0
484 JE SJ2
485 call dbcs_check ; see if a dbcs character ;AN000;
486 jc dbcs_1 ; dbcs character, go load another char ;AN000;
487 cmp al,'\' ; if (c == '\\' || c == ':') {
488 jnz sj05
489 mov per11,update ;AC000;
490 mov fnptr,si ; fnptr = ptr to slash
491sj05:
492 cmp al,':' ; if (c == '\\' || c == ':') {
493 jnz checkper1
494 mov per11,update ;AC000;
495 mov fnptr,si ; fnptr = ptr to slash
496checkper1:
497 cmp al,'.' ; if (c == '.')
498 jne sj1
499 mov per11,noupdate ; set file1 to have extension ;AN000;
500
501sj1:
502
503IF IBMCOPYRIGHT
504ELSE
505 cmp al,'*'
506 je File1_Err
507 cmp al,'?'
508 je File1_Err
509ENDIF
510
511 jmp short sj0 ; }
512
513IF IBMCOPYRIGHT
514ELSE
515File1_Err:
516 stc
517 mov dx, offset file1
518 jmp DosError
519ENDIF
520
521dbcs_1: ; ;AN000;
522 lodsb ; load another character and got to ;AN000;
523 jmp short sj0 ; the start again. ;AN000;
524
525;******************************************************************************
526
527sj2:
528get_second:
529;----- Get the second file name
530 MOV SI,offset file1
531 mov di,offset file2 ; d = file2
532
533;******************************************************************************
534
535sj3:
536 cmp word ptr [di],00 ; check to see if first character of
537 je sj32 ; file2 is a null. ;AN000;
538 mov si,offset file2 ; set pointer to file2
539
540;******************************************************************************
541
542sj31:
543 lodsb ; If file2 first character is not a
544 mov f2cspot,si
545 cmp al,0 ; null, this loop will check to see
546 JZ maycopy ; the file has an extension assigned;AN000;
547 call dbcs_check ; to it. If not it will set per2 to ;AN000;
548 jc dbcs_2 ; go load another byte ;AN000;
549 mov per22,noupdate ; ;AN000;
550 cmp al,'\' ; 0 so that in check_ext, the .BIN
551 jnz checkper6 ; will be added to the filename.
552 mov per2,update ; ;AC000;
553 mov per22,update ; ;AN000;
554checkper6:
555 cmp al,':' ; if (c == '\\' || c == ':') {
556 jnz checkper4
557 mov per22,update ; ;AN000;
558checkper4: ; there is an extension already.
559 cmp al,'.' ;
560 jne sj33 ;
561 mov per2,noupdate ; ;AC000;
562
563sj33: ;
564
565IF IBMCOPYRIGHT
566ELSE
567 cmp al,'*'
568 je File2_Err
569 cmp al,'?'
570 je File2_Err
571ENDIF
572
573 jmp short sj31 ;
574
575IF IBMCOPYRIGHT
576ELSE
577File2_Err:
578 stc
579 mov dx, offset file2
580 jmp DosError
581ENDIF
582
583
584dbcs_2:
585 lodsb ;load another character and got to ;AN000;
586 jmp short sj31 ;the start again. ;AN000;
587
588;******************************************************************************
589
590maycopy: ; Check to see if the ;AN000;
591 cmp per22,noupdate ; Last thing copied was either a ;AN000;
592 je SJ5 ; driver letter or "\". ;AN000;
593 dec f2cspot ;AN000;
594 mov di,f2cspot ;AN000;
595
596sj32:
597 ; There is no second filename so
598 mov si,fnptr ;AN000;
599 mov per2,update ; set per2 to 0 to get default .BIN ;AN000;
600 ; extension in check_ext.
601
602;******************************************************************************
603
604copy1to2: ;AN000;
605 lodsb ; This loop is executed when there is ;AN000;
606 cmp al,0 ; no file2 specified on the command ;AN000;
607 JZ SJ5 ; line. It will copy the file1 name ;AN000;
608 call dbcs_check ; check for dbcs character ;AN000;
609 jc dbcs_3 ; got a dbcs character, go copy. ;AN000;
610 cmp al,'.' ; extension. The defult extension ;AN000;
611 je sj5 ; of .BIN will be added in check_ext. ;AN000;
612 stosb ;AN000;
613 jmp short copy1to2 ;AN000;
614dbcs_3:
615 stosb ; Got a dbcs character. Copy ;AN000;
616 lodsb ; two characters and then go to ;AN000;
617 stosb ; next character in filename. ;AN000;
618 jmp short copy1to2 ;AN000; ;AN000;
619
620;******************************************************************************
621
622sj5:
623; mov byte ptr es:[di],00h ; *d = 0;
624 mov ah,Set_DMA ; Use find_first to see if file2 is
625 mov dx,offset dma_buf ; a directory. If it isn't, go to
626 int 21h ; set f2cspot to point to the spot
627 mov ah,Find_First ; right after the backslash, and
628 mov dx,offset file2 ; fall through to no_second so that
629 mov cx,-1 ; file1's name will be added to file2.
630 int 21h
631 jc check_ext
632 test dma_buf+21,00010000b
633 jNZ DoDirectory
634 jmp Check_Ext
635DoDirectory:
636 mov AL,'\'
637 mov di,f2cspot
638 dec di
639 stosb
640SetSecond:
641 mov per22,update ;AN000;
642 inc di
643 mov f2cspot,di
644 jmp maycopy
645
646
647;----- Check that files have an extension, otherwise set default
648check_ext:
649 cmp per11,noupdate ; if (per1 == NULL) { ;AC000;
650 jz file1_ok
651 mov di,offset file1 ; d = file1;
652 mov si,offset file1_ext ; s = ".EXE";
653 call strcat ; strcat (d, s);
654file1_ok: ; }
655 cmp per2,noupdate ; if (per2 != NULL) { ;AC000;
656 je file2_ok
657 mov di,offset file2 ; d = file2;
658 mov si,offset file2_ext ; s = ".BIN";
659 call strcat ; strcap (d, s);
660 jmp short file2_ok ; }
661
662;-----------------------------------------------------------------------;
663file2_ok:
664 mov dx,offset file1
665 mov ax,(open SHL 8) + 0 ;for reading only
666 INT 21H ;Open input file
667 jc bad_file
668 mov [handle1],ax
669 jmp exeload
670
671bad_file:
672 jmp DosError
673
674BADEXE:
675 pop ds
676 ASSUME DS:nothing ;AN000;
677 MESSAGE msgNoConvert ;AC000;
678 jmp getout ;AN000;
679
680ReadError:
681 jmp DosError
682
683EXELOAD:
684 ASSUME DS:DATA ;AN000;
685 MOV DX,OFFSET RUNVAR ;Read header in here
686 MOV CX,RUNVARSIZ ;Amount of header info we need
687 push bx
688 mov bx,[handle1]
689 MOV AH,read
690 INT 21H ;Read in header
691 pop bx
692 jc ReadError
693 CMP [RELPT],5A4DH ;Check signature word
694 JNZ BADEXE
695 MOV AX,[HEADSIZ] ;size of header in paragraphs
696 ADD AX,31 ;Round up first
697 CMP AX,1000H ;Must not be >=64K
698 JAE TOOBIG
699 AND AX,NOT 31
700 MOV CL,4
701 SHL AX,CL ;Header size in bytes
702
703 push dx
704 push cx
705 push ax
706 push bx
707 mov dx,ax
708 xor cx,cx
709 mov al,0
710 mov bx,[handle1]
711 mov ah,lseek
712 int 21h
713 jc LseekError
714 pop bx
715 pop ax
716 pop cx
717 pop dx
718
719 XCHG AL,AH
720 SHR AX,1 ;Convert to pages
721 MOV DX,[PAGES] ;Total size of file in 512-byte pages
722 SUB DX,AX ;Size of program in pages
723 CMP DX,80H ;Fit in 64K? (128 * 512 = 64k)
724 JAE TOOBIG
725 XCHG DH,DL
726 SHL DX,1 ;Convert pages to bytes
727 MOV AX,[LASTP] ;Get count of bytes in last page
728 OR AX,AX ;If zero, use all of last page
729 JZ WHOLEP
730
731 IF OLDLINK
732 CMP AX,4 ;Produced by old linker?
733 JZ WHOLEP ;If so, use all of last page too
734 ENDIF
735
736 SUB DX,200H ;Subtract last page
737 ADD DX,AX ;Add in byte count for last page
738WHOLEP:
739 MOV [SIZ],DX
740 ADD DX,15
741 SHR DX,CL ;Convert bytes to paragraphs
742 MOV BP,SEG LOAD
743 ADD DX,BP ;Size + start = minimum memory (paragr.)
744 CMP DX,BX ;Enough memory?
745 JA TOOBIG
746 MOV AX,[INITSS]
747 OR AX,[INITSP]
748 OR AX,[INITCS]
749 JMP ERRORNZ
750
751TOOBIG:
752 pop ds
753 ASSUME DS:NOTHING ;AN000;
754 MESSAGE msgOutOfMemory ;AN000;
755 jmp getout ;AN000;
756
757LseekError:
758 jmp DosError
759
760
761ERRORNZ:
762 ASSUME DS:DATA ;AN000;
763 jz xj
764 JMP BADEXE ;AC000; For ptm P475;
765xj: MOV AX,[INITIP]
766 OR AX,AX ;If IP=0, do binary fix
767 JZ BINFIX
768 CMP AX,100H ;COM file must be set up for CS:100
769 JNZ ERRORNZ
770
771 push dx
772 push cx
773 push ax
774 push bx
775 mov dx,100h ;chop off first 100h
776 xor cx,cx
777 mov al,1 ;seek from current position
778 mov bx,[handle1]
779 mov ah,lseek
780 int 21h
781 jc LseekError
782 pop bx
783 pop ax
784 pop cx
785 pop dx
786
787 SUB [SIZ],AX ;And count decreased size
788 CMP [RELCNT],0 ;Must have no fixups
789 JNZ ERRORNZ
790BINFIX:
791 XOR BX,BX ;Initialize fixup segment
792;See if segment fixups needed
793 CMP [RELCNT],0
794 JZ LOADEXE
795GETSEG:
796 pop ds
797 ASSUME DS:NOTHING ;AN000;
798 MESSAGE msgFixUp ;AN000;
799 PUSH DS
800 PUSH ES
801 POP DS
802 ASSUME DS:DATA ;AN000;
803 MOV AH,STD_CON_STRING_INPUT
804 MOV DX,OFFSET INBUF
805 INT 21H ;Get user response
806 MOV SI,OFFSET INBUF+2
807;;dcl;; MOV BYTE PTR [SI-1],0 ;Any digits?
808 cmp BYTE PTR [SI-1],0 ;Any digits? ;AC000;
809 JZ GETSEG
810DIGLP:
811 LODSB
812 SUB AL,"0"
813 JC DIGERR
814 CMP AL,10
815 JB HAVDIG
816 AND AL,5FH ;Convert to upper case
817 SUB AL,7
818 CMP AL,10
819 JB DIGERR
820 CMP AL,10H
821 JAE DIGERR
822HAVDIG:
823 SHL BX,1
824 SHL BX,1
825 SHL BX,1
826 SHL BX,1
827 OR BL,AL
828 JMP DIGLP
829
830DIGERR:
831 CMP BYTE PTR [SI-1],0DH ;Is last char. a CR?
832 JNZ GETSEG
833LOADEXE:
834 XCHG BX,BP ;BX has LOAD, BP has fixup
835
836 MOV CX,[SIZ]
837 MOV AH,read
838 push di
839 mov di,[handle1]
840 PUSH DS
841 MOV DS,BX
842 ASSUME DS:NOTHING ;AN000;
843 XOR DX,DX
844 push bx
845 mov bx,di
846 INT 21H ;Read in up to 64K
847 pop bx
848 POP DS
849 ASSUME DS:DATA ;AN000;
850 pop di
851 Jnc HAVEXE ;Did we get it all?
852
853 jmp DosError
854
855LseekError2:
856 jmp DosError
857
858HAVEXE:
859 ASSUME DS:DATA ;AN000;
860 CMP [RELCNT],0 ;Any fixups to do?
861 JZ STORE
862 MOV AX,[RELTAB] ;Get position of table
863
864 push dx
865 push cx
866 push ax
867 push bx
868 mov dx,ax
869 xor cx,cx
870 mov al,0
871 mov bx,[handle1]
872 mov ah,lseek
873 int 21h
874 jc LseekError2
875 pop bx
876 pop ax
877 pop cx
878 pop dx
879
880 MOV DX,OFFSET RELPT ;4-byte buffer for relocation address
881RELOC:
882 MOV DX,OFFSET RELPT ;4-byte buffer for relocation address
883 MOV CX,4
884 MOV AH,read
885 push bx
886 mov bx,[handle1]
887 INT 21H ;Read in one relocation pointer
888 pop bx
889 Jnc RDCMP
890 jmp DosError
891RDCMP:
892 MOV DI,[RELPT] ;Get offset of relocation pointer
893 MOV AX,[RELSEG] ;Get segment
894 ADD AX,BX ;Bias segment with actual load segment
895 MOV ES,AX
896 ASSUME ES:NOTHING ;AN000;
897 ADD ES:[DI],BP ;Relocate
898 DEC [RELCNT] ;Count off
899 JNZ RELOC
900STORE:
901 MOV AH,CREAT
902 MOV DX,OFFSET file2
903 xor cx,cx
904 INT 21H
905 Jc MKERR
906 mov [handle2],ax
907 MOV CX,[SIZ]
908 MOV AH,write
909 push di
910 mov di,[handle2]
911 PUSH DS
912 MOV DS,BX
913 ASSUME DS:NOTHING ;AN000;
914 XOR DX,DX ;Address 0 in segment
915 push bx
916 mov bx,di
917 INT 21H
918 pop bx
919 POP DS
920 ASSUME DS:DATA ;AN000;
921 pop di
922 Jc WRTERR ;Must be zero if more to come
923 cmp AX,CX
924 jnz NOROOM
925 MOV AH,CLOSE
926 push bx
927 mov bx,[handle2]
928 INT 21H
929 jc CloseError
930 pop bx
931 pop ds
932 pop ds
933 ASSUME DS:NOTHING ;AN000;
934
935 RET
936
937;*******************************************************************************
938
939NOROOM: ; ;AN000;
940 ASSUME DS:DATA ;AN000;
941 MOV AH,CLOSE ; Close the file here ;AN000;
942 push bx ; ;AN000;
943 mov bx,[handle2] ; ;AN000;
944 INT 21H ; ;AN000;
945 jc CloseError ; If error let extend messages get it;AN000;
946 pop bx ; ;AN000;
947 mov ah,UNLINK ; Delete the file because it did ;AN000;
948 MOV DX,OFFSET file2 ; not get written correctly. ;AN000;
949 INT 21H ; ;AN000;
950 jc CloseError ; If error let extend messages get it;AN000;
951 pop ds ; ;AN000;
952 ASSUME DS:NOTHING ; ;AN000;
953 message msgNoDiskSpace ; Put out insufficient disk space ;AN000;
954 jmp getout ; message ;AN000;
955 RET ; return to main_init ;AN000;
956
957;*******************************************************************************
958
959WRTERR: ;AN000;
960MKERR: ;AN000;
961CloseError: ;AN000;
962
963 public DosError ;AN000;
964DosError: ;AN000;
965 mov es:FileNameSegment,ds ; save for opens, creates, ;AN000;
966 mov es:FileNameOffset,dx ;AN000;
967
968 mov bx,0 ; get the extended error code ;AN000;
969 mov ah,059h ;AN000;
970 int 21h ;AN000;
971
972 mov si,offset ds:Sublist_msg_exterror ;AC001;
973 extend_message ;AN001;
974 pop ds ;AN001;
975
976getout: ;AN000;
977 pop ds ;AN000;
978 ASSUME DS:NOTHING ;AN000;
979
980 ret ;AN000;
981
982
983LOCATE ENDP
984
985;----- concatenate two strings
986strcat proc near ; while (*d)
987 cmp byte ptr [di],0
988 jz atend
989 inc di ; d++;
990 jmp strcat
991atend: ; while (*d++ = *s++)
992 lodsb
993 stosb
994 or al,al ; ;
995 jnz atend
996 ret
997strcat endp
998
999;----- Find the first non-ignorable char, return carry if CR found
1000kill_bl proc near
1001 cld
1002sj10: ; while ( *p != 13 &&
1003 lodsb
1004 CMP AL,13 ; IsBlank (*p++))
1005 JZ BreakOut
1006 CALL IsBlank
1007 JZ SJ10 ; ;
1008BreakOut:
1009 dec si ; p--;
1010 cmp al,0dh ; return *p == 13;
1011 clc
1012 jne sj11
1013 stc
1014sj11:
1015 ret
1016kill_bl endp
1017
1018IsBlank proc near
1019 cmp al,00 ;AN000;
1020 retz ;AN000;
1021 cmp al,13
1022 retz
1023 cmp al,' ' ; space
1024 retz
1025 cmp al,9 ; tab
1026 retz
1027 cmp al,',' ; comma
1028 retz
1029 cmp al,';' ; semicolon
1030 retz
1031 cmp al,'+' ; plus
1032 retz
1033 cmp al,10 ; line feed
1034 retz
1035 cmp al,'=' ; equal sign
1036 return
1037IsBlank Endp
1038
1039
1040procedure copyfs near
1041
1042 push ax ;AN000;
1043
1044; $do ; while we have filespec ;AN000;
1045$$DO16:
1046 lodsb ; move byte to al ;AN000;
1047 cmp al,0 ; see if we are at ;AN000;
1048 ; the end of the
1049 ; filespec
1050; $leave e ; exit while loop ;AN000;
1051 JE $$EN16
1052 stosb ; move byte to path_name ;AN000;
1053; $enddo ; end do while ;AN000;
1054 JMP SHORT $$DO16
1055$$EN16:
1056 stosb ;AN000;
1057 pop ax ;AN000;
1058
1059 ret ;AN000;
1060copyfs endp ;AN000;
1061
1062
1063procedure dbcs_check near
1064
1065 push ds ;Save registers ;AC000;
1066 push si ; " " " " ;AC000;
1067 push ax ; " " " " ;AC000;
1068 push ds ; " " " " ;AC000;
1069 pop es ;Establish addressability;AC000;
1070 cmp byte ptr es:DBCS_VECTOR,Yes ;Have we set this yet? ;AC000;
1071 push ax ;Save input character ;AC000;
1072; $IF NE ;Nope ;AN000;
1073 JE $$IF19
1074 mov al,0 ;Get DBCS environment vectors;AC000;
1075 DOS_Call Hongeul ; " " " " ;AC000;
1076 mov byte ptr es:DBCS_VECTOR,YES ;Indicate we've got vector;AC000;
1077 mov es:DBCS_Vector_Off,si ;Save the vector ;AC000;
1078 mov ax,ds ; ;AC000;
1079 mov es:DBCS_Vector_Seg,ax ; ;AC000;
1080; $ENDIF ; for next time in ;AC000;
1081$$IF19:
1082 pop ax ;Restore input character;AC000;
1083 mov si,es:DBCS_Vector_Seg ;Get saved vector pointer;AC000;
1084 mov ds,si ; ;AC000;
1085 mov si,es:DBCS_Vector_Off ; ;AC000;
1086; $SEARCH ;Check all the vectors ;AC000;
1087$$DO21:
1088 cmp word ptr ds:[si],End_Of_Vector ;End of vector table? ;AC000;
1089; $LEAVE E ;Yes, done ;AC000;
1090 JE $$EN21
1091 cmp al,ds:[si] ;See if char is in vector;AC000;
1092; $EXITIF AE,AND ;If >= to lower, and ;AC000;
1093 JNAE $$IF21
1094 cmp al,ds:[si+1] ; =< than higher range ;AC000;
1095; $EXITIF BE ; then DBCS character ;AC000;
1096 JNBE $$IF21
1097 stc ;Set CY to indicate DBCS;AC000;
1098; $ORELSE ;Not in range, check next;AC000;
1099 JMP SHORT $$SR21
1100$$IF21:
1101 add si,DBCS_Vector_Size ;Get next DBCS vector ;AC000;
1102; $ENDLOOP ;We didn't find DBCS chaR;AC000;
1103 JMP SHORT $$DO21
1104$$EN21:
1105 clc ;Clear CY for exit ;AC000;
1106; $ENDSRCH ; ;AC000;
1107$$SR21:
1108 pop ax ;Restore registers ;AC000;
1109 pop si ; " " " " ;AC000;
1110 pop ds ;Restore data segment ;AC000;
1111 ret ; ;AC000;
1112
1113 ret ;AN000;
1114dbcs_check endp ;AN000;
1115
1116
1117
1118CODE ends
1119
1120
1121 end main_init ;AC000;
1122
1123 \ No newline at end of file