summaryrefslogtreecommitdiff
path: root/v4.0/src/CMD/EXE2BIN
diff options
context:
space:
mode:
authorGravatar Mark Zbikowski2024-04-25 21:24:10 +0100
committerGravatar Microsoft Open Source2024-04-25 22:32:27 +0000
commit2d04cacc5322951f187bb17e017c12920ac8ebe2 (patch)
tree80ee017efa878dfd5344b44249e6a241f2a7f6e2 /v4.0/src/CMD/EXE2BIN
parentMerge pull request #430 from jpbaltazar/typoptbr (diff)
downloadms-dos-main.tar.gz
ms-dos-main.tar.xz
ms-dos-main.zip
MZ is back!HEADmain
Diffstat (limited to 'v4.0/src/CMD/EXE2BIN')
-rw-r--r--v4.0/src/CMD/EXE2BIN/DISPLAY.ASM110
-rw-r--r--v4.0/src/CMD/EXE2BIN/E2BCHNG.INC21
-rw-r--r--v4.0/src/CMD/EXE2BIN/E2BEQU.INC50
-rw-r--r--v4.0/src/CMD/EXE2BIN/E2BINIT.ASM1123
-rw-r--r--v4.0/src/CMD/EXE2BIN/E2BMACRO.INC80
-rw-r--r--v4.0/src/CMD/EXE2BIN/E2BPARSE.INC180
-rw-r--r--v4.0/src/CMD/EXE2BIN/E2BTABLE.INC189
-rw-r--r--v4.0/src/CMD/EXE2BIN/EXE2BIN.LNK5
-rw-r--r--v4.0/src/CMD/EXE2BIN/EXE2BIN.SKL71
-rw-r--r--v4.0/src/CMD/EXE2BIN/LOCATE.ASM592
-rw-r--r--v4.0/src/CMD/EXE2BIN/LOCMES.ASM55
-rw-r--r--v4.0/src/CMD/EXE2BIN/MAKEFILE30
12 files changed, 2506 insertions, 0 deletions
diff --git a/v4.0/src/CMD/EXE2BIN/DISPLAY.ASM b/v4.0/src/CMD/EXE2BIN/DISPLAY.ASM
new file mode 100644
index 0000000..4c4bae7
--- /dev/null
+++ b/v4.0/src/CMD/EXE2BIN/DISPLAY.ASM
@@ -0,0 +1,110 @@
1
2
3CODE SEGMENT PARA PUBLIC 'CODE'
4CODE ENDS
5DATA SEGMENT PARA PUBLIC 'DATA'
6DATA ENDS
7STACK SEGMENT PARA STACK 'STACK'
8STACK ENDS
9ZLOAD SEGMENT PARA PUBLIC 'ZLOAD'
10ZLOAD ENDS
11
12CODE SEGMENT PARA PUBLIC 'CODE'
13 assume cs:code,ds:data
14;
15;*****************************************************************************
16; External Declarations
17;*****************************************************************************
18;
19
20 extrn SysDispMsg:near
21
22;
23;***************************************************************************
24; Message Structures
25;***************************************************************************
26;
27
28
29Message_Table struc ; ;AN000;
30 ;
31Entry1 dw 0 ; ;AN000;
32Entry2 dw 0 ; ;AN000;
33Entry3 dw 0 ; ;AN000;
34Entry4 dw 0 ; ;AN000;
35Entry5 db 0 ; ;AN000;
36Entry6 db 0 ; ;AN000;
37Entry7 dw 0 ; ;AN000;
38 ;
39Message_Table ends ; ;AN000;
40
41
42
43;*****************************************************************************
44;Routine name&gml Display_Interface
45;*****************************************************************************
46;
47;DescriptioN&gml Save all registers, set up registers required for SysDispMsg
48; routine. This information is contained in a message description
49; table pointed to by the DX register. Call SysDispMsg, then
50; restore registers. This routine assumes that the only time an
51; error will be returned is if an extended error message was
52; requested, so it will ignore error returns
53;
54;Called Procedures: Message (macro)
55;
56;Change History&gml Created 4/22/87 MT
57;
58;Input&gml ES&gmlDX = pointer to message description
59;
60;Output&gml None
61;
62;Psuedocode
63;----------
64;
65; Save all registers
66; Setup registers for SysDispMsg from Message Description Tables
67; CALL SysDispMsg
68; Restore registers
69; ret
70;*****************************************************************************
71
72Public Display_Interface
73Display_Interface proc ; ;AN000;
74
75 push ds ; ;AN000;
76 push es ; ;AN000;
77 push ax ;Save registers ;AN000;
78 push bx ; " " " " ;AN000;
79 push cx ; " " " " ;AN000;
80 push dx ; " " " " ;AN000;
81 push si ; " " " " ;AN000;
82 push di ; " " " " ;AN000;
83 mov di,dx ;Change pointer to table ;AN000;
84 mov dx,SEG data ;Point to data segment
85 mov ds,dx ;
86 mov es,dx
87 mov ax,[di].Entry1 ;Message number ;AN000;
88 mov bx,[di].Entry2 ;Handle ;AN000;
89 mov si,[di].Entry3 ;Sublist ;AN000;
90 mov cx,[di].Entry4 ;Count ;AN000;
91 mov dh,[di].Entry5 ;Class ;AN000;
92 mov dl,[di].Entry6 ;Function ;AN000;
93 mov di,[di].Entry7 ;Input ;AN000;
94 call SysDispMsg ;Display the message ;AN000;
95 pop di ;Restore registers ;AN000;
96 pop si ; " " " " ;AN000;
97 pop dx ; " " " " ;AN000;
98 pop cx ; " " " " ;AN000;
99 pop bx ; " " " " ;AN000;
100 pop ax ; " " " " ;AN000;
101 pop es ; ;AN000;
102 pop ds ; ;AN000;
103 ret ;All done ;AN000;
104
105Display_Interface endp ; ;AN000;
106code ends
107
108
109 end
110 \ No newline at end of file
diff --git a/v4.0/src/CMD/EXE2BIN/E2BCHNG.INC b/v4.0/src/CMD/EXE2BIN/E2BCHNG.INC
new file mode 100644
index 0000000..560618d
--- /dev/null
+++ b/v4.0/src/CMD/EXE2BIN/E2BCHNG.INC
@@ -0,0 +1,21 @@
1.xlist
2;
3;
4;*****************************************************************************
5;* *
6;* Change list to EXE2BIN modules *
7;* *
8;* Lines are tagged ANxxx for new, ACxxx for changed *
9;* --------------------------------------------------------------------------*
10;* 000 - DOS 4.00 Spec additions and DCR's thru unit/function test *
11;* Date: 12/31/87 Developer: Dennis M *
12;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
13;* 001 - DOS 4.00 PTM P3964 Pass invalid parameter to message retriever for *
14;* replacement in error message. *
15;* Date: 03/24/88 Developer: Dennis M *
16;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
17;*****************************************************************************
18;* Note: This is file E2BCHNG.INC for updating purposes *
19;*****************************************************************************
20.list
21
diff --git a/v4.0/src/CMD/EXE2BIN/E2BEQU.INC b/v4.0/src/CMD/EXE2BIN/E2BEQU.INC
new file mode 100644
index 0000000..d127c92
--- /dev/null
+++ b/v4.0/src/CMD/EXE2BIN/E2BEQU.INC
@@ -0,0 +1,50 @@
1 ; ; ;
2
3NO equ 0
4YES equ not NO
5
6
7DOS_Found equ 0
8
9INIT equ 0
10
11
12Net_Check equ 1200h
13Assign_Check equ 8000h
14
15Found_Yes equ 1
16Found_No equ 0
17
18Asciiz_End equ 0
19;DBCS equ 81h
20DBCS_Blank equ 40h
21DBCS_Vector_Size equ 2
22End_Of_Vector equ 0
23
24
25Blank equ " "
26
27Label_Length equ 11
28CR equ 13
29
30DBCS_VECTOR equ NO
31
32;-------------------------------------------------------------------------------
33
34
35
36
37
38DRNUM EQU 5CH
39
40
41
42; Exit status defines
43ExitOK equ 0
44
45
46;-------------------------------------------------------------------------------
47; These are the data structures which we will need
48
49
50 \ No newline at end of file
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
diff --git a/v4.0/src/CMD/EXE2BIN/E2BMACRO.INC b/v4.0/src/CMD/EXE2BIN/E2BMACRO.INC
new file mode 100644
index 0000000..c01206d
--- /dev/null
+++ b/v4.0/src/CMD/EXE2BIN/E2BMACRO.INC
@@ -0,0 +1,80 @@
1
2
3
4
5
6
7
8;
9;******************************************************************************
10; Message Macro Definitions
11;******************************************************************************
12;
13
14 EXTRN Display_Interface:near
15
16
17;-----------------------------------------------------------------------------
18
19MESSAGE macro Message_Name ; ;AN000;
20 ;
21 mov dx,offset Message_Name ; ;AN000;
22 call Display_Interface ; ;AN000;
23 ;
24 endm ; ;AN000;
25
26
27;
28;*****************************************************************************
29; General Macro's
30;*****************************************************************************
31;
32
33Procedure macro Proc_Name
34
35Public Proc_Name
36Proc_Name proc
37
38 endm
39;-----------------------------------------------------------------------------
40
41DOS_Call macro Function
42
43 mov ah,Function
44 int 21h
45
46 endm
47;-----------------------------------------------------------------------------
48
49Parse_Message macro ;AN000;
50
51
52 push ds ;AN000;
53 mov dx,SEG parse_ptr ;AN000;
54 mov ds,dx ;AN000;
55 ASSUME DS:DATA ;AN000;
56 ASSUME ES:DATA ;AN000;
57 mov word ptr Parse_Error_Msg,ax ;AN000;
58 mov dx,offset Parse_Error_Msg ; ;AN000;
59 call Display_Interface ; ;AN000;
60 pop ds
61 endm ; ;AN000;
62
63;-----------------------------------------------------------------------------
64
65Extend_Message macro ; ;AN001;
66
67 ;
68 push ds ;AN001;
69 mov dx,SEG parse_ptr ;AN001;
70 mov ds,dx ;AN001;
71 ASSUME DS:DATA ;AN001;
72 ASSUME ES:DATA ;AN001;
73 mov word ptr Extend_Error_Msg,ax ; ;AN001;
74 mov dx,offset Extend_Error_Msg ; ;AN001;
75 call Display_Interface ; ;AN001;
76 pop ds ;AN001;
77 endm ; ;AN001;
78
79;-----------------------------------------------------------------------------
80
diff --git a/v4.0/src/CMD/EXE2BIN/E2BPARSE.INC b/v4.0/src/CMD/EXE2BIN/E2BPARSE.INC
new file mode 100644
index 0000000..9867a46
--- /dev/null
+++ b/v4.0/src/CMD/EXE2BIN/E2BPARSE.INC
@@ -0,0 +1,180 @@
1
2
3
4data segment public 'DATA'
5
6
7
8;
9;***************************************************************************
10; Equates
11;***************************************************************************
12;
13
14;Match Flags
15
16Numeric_Value equ 8000h ; ;AN000;
17Signed_Numeric_Value equ 4000h ; ;AN000;
18Simple_String equ 2000h ; ;AN000;
19Date_String equ 1000h ; ;AN000;
20Time_String equ 0800h ; ;AN000;
21Complex_List equ 0400h ; ;AN000;
22Filespec equ 0200h ; ;AN000;
23Drive_Only equ 0100h ; ;AN000;
24Quoted_String equ 0080h ; ;AN000;
25Ignore_Colon equ 0010h ; ;AN000;
26Repeats_Allowed equ 0002h ; ;AN000;
27Optional equ 0001h ; ;AN000;
28
29;Function_Flags
30
31File_Table_Capitalize equ 1 ; ;AN000;
32
33;Result buffer type returned
34rb_Number equ 1
35rb_List_Index equ 2
36rb_String equ 3
37rb_Complex equ 4
38rb_Filespec equ 5
39rb_Drive equ 6
40rb_Date equ 7
41rb_Time equ 8
42rb_Quoted_String equ 9
43
44
45;Extra delimeters and EOL
46
47Delimiters_Only equ 1 ; ;AN000;
48EOL_Or_Delimiters equ 2 ; ;AN000;
49
50Semi_Colon equ ";" ; ;AN000;
51Tab equ 09h ; ;AN000;
52Colon1 equ ":" ; ;AN000;
53NUL equ "0"
54
55;Parse Errors
56
57No_Error equ 0 ; ;AN000;
58Too_Many_Operands equ 1 ; ;AN000;
59Operand_Missing equ 2 ; ;AN000;
60Not_In_Switch_List equ 3 ; ;AN000;
61Not_In_Keyword_List equ 4 ; ;AN000;
62Out_Of_Range equ 6 ; ;AN000;
63Not_In_Value_List equ 7 ; ;AN000;
64Not_In_String_List equ 8 ; ;AN000;
65Syntax_Error equ 9 ; ;AN000;
66End_Of_Parse equ -1 ; ;AN000;
67
68;Other
69
70None equ 0 ; ;AN000;
71No_Error equ 0 ; ;AN000;
72Switch_Found equ 0FFFFh ; ;AN000;
73Range_Ok equ 1 ; ;AN000;
74Command_Line_Parms equ 81h ; ;AN000;
75
76;
77;*****************************************************************************
78; Parse Structures
79;*****************************************************************************
80;
81
82Control struc
83
84Match_Flags dw ?
85Function_Flags dw ?
86Result dw ?
87Values dw ?
88Num_Keywords db ?
89Keyword db ?
90
91Control ends
92
93File_Name_Return struc ; ;AN000;
94
95Drive_Type db 0 ; ;AN000;
96Drive_Item_Tag db 0 ; ;AN000;
97Synonym dw 0 ; ;AN000;
98String_Value_ptr db 0 ;File Name ;AN000;
99
100File_Name_Return ends ; ;AN000;
101
102
103;
104;**************************************************************************
105; Parse tables
106;**************************************************************************
107;
108
109Command_Line_Table label byte ; ;AN000;
110
111 dw Command_Control ;Point to next level ;AN000;
112 db Delimiters_Only ; ;AN000;
113 db 1 ; ;AN000;
114 db Semi_Colon ; ;AN000;
115
116
117;
118;**************************************************************************
119; Define Positionals, Switches and Keywords
120;**************************************************************************
121;
122
123Command_Control label byte ; ;AN000;
124
125 db 1,2 ;File names Positional (1 required) ;AN000;
126 dw Positional_Control1 ;Pointer to control table ;AN000;
127 dw Positional_Control2 ;Pointer to control table ;AN000;
128 db None ;no switches ;AN000;
129 db None ;No Keywords (maxk) ;AN000;
130
131;
132;**************************************************************************
133;Control Tables
134;**************************************************************************
135;
136
137Positional_Control1 label byte ; ;AN000;
138
139 dw Filespec ;Match_Flag ;AN000;
140 dw File_Table_Capitalize ;No function flags ;AN000;
141 dw File_Name_Buffer1 ;Where it will be returned ;AN000;
142 dw No_Value ;No value ranges defined ;AN000;
143 db None ;No defined switches/keywords ;AN000;
144
145Positional_Control2 label byte ; ;AN000;
146
147 dw Filespec+Optional ;Match_Flag ;AN000;
148
149 dw File_Table_Capitalize ;No function flags ;AN000;
150 dw File_Name_Buffer2 ;Where it will be returned ;AN000;
151 dw No_Value ;No value ranges defined ;AN000;
152 db None ;No defined switches/keywords ;AN000;
153
154No_Value label byte ; ;AN000;
155 db 0 ; ;AN000;
156
157;
158;************************************************************************
159; PARSE Return Buffers
160;************************************************************************
161;
162File_name_Buffer1 label byte ; ;AN000;
163
164rb_type1 db 0 ;type returned ;AN000;
165rb_item_tag1 db 0 ;matched item tag ;AN000;
166rb_synonym1 dw 0 ;found synonyms ;AN000;
167rb_string1_off dw 0 ;Offset of string ;AN000;
168rb_string1_seg dw 0 ;Offset of string ;AN000;
169
170File_name_Buffer2 label byte ; ;AN000;
171
172rb_type2 db 0 ;type returned ;AN000;
173rb_item_tag2 db 0 ;matched item tag ;AN000;
174rb_synonym2 dw 0 ;found synonyms ;AN000;
175rb_string2_off dw 0 ;Offset of string ;AN000;
176rb_string2_seg dw 0 ;Offset of string ;AN000;
177
178data ends
179
180 \ No newline at end of file
diff --git a/v4.0/src/CMD/EXE2BIN/E2BTABLE.INC b/v4.0/src/CMD/EXE2BIN/E2BTABLE.INC
new file mode 100644
index 0000000..d163c3b
--- /dev/null
+++ b/v4.0/src/CMD/EXE2BIN/E2BTABLE.INC
@@ -0,0 +1,189 @@
1data segment
2
3;
4;*****************************************************************************
5; Macro's
6;*****************************************************************************
7;
8
9
10Define_Msg macro Message_Name ; ;AN000;
11 ;
12Create_Msg Message_Name,Message_Number,Handle,Sublist,Count,Class,Function,Input;AN000;
13 ;
14 endm ; ;AN000;
15
16;-----------------------------------------------------------------------------
17
18Create_Msg macro Parm1,Parm2,Parm3,Parm4,Parm5,Parm6,Parm7,Parm8; ;AN000;
19
20Parm1 label word ; ;AN000;
21 dw Parm2 ; ;AN000;
22 dw Parm3 ; ;AN000;
23 dw Parm4 ; ;AN000;
24 dw Parm5 ; ;AN000;
25 db Parm6 ; ;AN000;
26 db Parm7 ; ;AN000;
27 dw Parm8 ; ;AN000;
28 endm ; ;AN000;
29
30
31;--------------------------- ; ;AN001;
32Sublist_msg_parserr label dword ; ;AN001;
33 ;AN001;
34 db Sublist_Length ;11 ;AN001;
35 db Reserved ;0 ;AN001;
36parsoff dw ? ;off ;AN001;
37parseg dw ? ; ;AN001;
38 db 0 ;USE PERCENT ZERO ;AN001;
39 db Left_Align+Char_Field_ASCIIZ ;type of data ;AN001;
40 db 128 ;max width ;AN001;
41 db 1 ;min width ;AN001;
42 db Blank ;pad char ;AN001;
43;--------------------------- ; ;AN001;
44
45Sublist_msg_exterror label word ;AN001;
46
47 db Sublist_Length ;AN001;
48 db Reserved ;AN001;
49FileNamePointer label dword ;AN001;
50FileNameOffset dw ? ;AN001;
51FileNameSegment dw ? ;AN001;
52 db 0 ; SPECIAL %0 - Extended Errors only ;AN001;
53 db Left_Align+Char_Field_ASCIIZ ;AN001;
54 db 132 ;AN001;
55 db 0 ;AN001;
56 db Blank ;AN001;
57;-----------------------------------------------------------------------------
58;
59;*****************************************************************************
60; Message Retriever equates
61;*****************************************************************************
62;
63
64Format_Msg equ 'C'
65
66N_A equ 0
67
68Blank equ " "
69No_Function equ 0
70
71No_Input equ 0
72
73
74;
75;*****************************************************************************
76; Message Description Tables
77;*****************************************************************************
78;
79
80;---------------------- ;
81Message_Number = 1 ; ;AN000;
82Handle = No_Handle ; ;AN000;
83Sublist = No_Replace ; ;AN000;
84Count = N_A ; ;AN000;
85Class = Utility_Msg_Class ; ;AN000;
86Function = No_Input ; ;AN000;
87Input = N_A ; ;AN000;
88 Define_Msg msgBadDOSVersion ; ;AN000;
89;---------------------- ;
90Message_Number = 2 ; ;AN000;
91Handle = STDOUT ; ;AN000;
92Sublist = No_Replace ; ;AN000;
93Count = N_A ; ;AN000;
94Class = Utility_Msg_Class ; ;AN000;
95Function = No_Input ; ;AN000;
96Input = N_A ; ;AN000;
97 Define_Msg msgOutOfMemory ; ;AN000;
98;---------------------- ;
99Message_Number = 3 ; ;AN000;
100Handle = STDOUT ; ;AN000;
101Sublist = No_Replace ; ;AN000;
102Count = N_A ; ;AN000;
103Class = Utility_Msg_Class ; ;AN000;
104Function = No_Input ; ;AN000;
105Input = N_A ; ;AN000;
106 Define_Msg msgLoadFailure ; ;AN000;
107;---------------------- ;
108Message_Number = 4 ; ;AN000;
109Handle = STDOUT ; ;AN000;
110Sublist = No_Replace ; ;AN000;
111Count = N_A ; ;AN000;
112Class = Utility_Msg_Class ; ;AN000;
113Function = No_Input ; ;AN000;
114Input = N_A ; ;AN000;
115 Define_Msg msgNoAccess ; ;AN000;
116;---------------------- ;
117Message_Number = 5 ; ;AN000;
118Handle = STDOUT ; ;AN000;
119Sublist = No_Replace ; ;AN000;
120Count = N_A ; ;AN000;
121Class = Utility_Msg_Class ; ;AN000;
122Function = No_Input ; ;AN000;
123Input = N_A ; ;AN000;
124 Define_Msg msgNoConvert ; ;AN000;
125;---------------------- ;
126Message_Number = 6 ; ;AN000;
127Handle = STDOUT ; ;AN000;
128Sublist = No_Replace ; ;AN000;
129Count = N_A ; ;AN000;
130Class = Utility_Msg_Class ; ;AN000;
131Function = No_Input ; ;AN000;
132Input = N_A ; ;AN000;
133 Define_Msg msgNoFile ; ;AN000;
134;---------------------- ;
135Message_Number = 7 ; ;AN000;
136Handle = STDOUT ; ;AN000;
137Sublist = No_Replace ; ;AN000;
138Count = N_A ; ;AN000;
139Class = Utility_Msg_Class ; ;AN000;
140Function = No_Input ; ;AN000;
141Input = N_A ; ;AN000;
142 Define_Msg msgFileCreateError ; ;AN000;
143;---------------------- ;
144Message_Number = 8 ; ;AN000;
145Handle = STDOUT ; ;AN000;
146Sublist = No_Replace ; ;AN000;
147Count = N_A ; ;AN000;
148Class = Utility_Msg_Class ; ;AN000;
149Function = DOS_BUF_KEYB_INP ; ;AN000;
150Input = INBUF ; ;AN000;
151 Define_Msg msgFixUp ; ;AN000;
152;---------------------- ;
153Message_Number = 0 ; ;AN001;
154Handle = STDERR ; ;AN001;
155Sublist = ds:sublist_msg_parserr ; ;AN001;
156Count = 1 ; ;AN001;
157Class = Parse_Err_Class ; ;AN001;
158Function = No_Input ; ;AN001;
159Input = N_A ; ;AN001;
160 Define_Msg parse_error_msg ; ;AN001;
161;---------------------- ;
162Message_Number = 0 ; ;AN001;
163Handle = STDERR ; ;AN001;
164Sublist = ds:sublist_msg_exterror ; ;AN001;
165Count = 1 ; ;AN001;
166Class = ext_Err_Class ; ;AN001;
167Function = No_Input ; ;AN001;
168Input = N_A ; ;AN001;
169 Define_Msg extend_error_msg ; ;AN001;
170;---------------------- ;
171Message_Number = 10 ; ;AN000;
172Handle = STDOUT ; ;AN000;
173Sublist = No_Replace ; ;AN000;
174Count = N_A ; ;AN000;
175Class = Utility_Msg_Class ; ;AN000;
176Function = No_Input ; ;AN000;
177Input = N_A ; ;AN000;
178 Define_Msg msgNoDiskSpace ; ;AN000;
179;---------------------- ;
180Message_Number = 12 ; ;AN000;
181Handle = STDOUT ; ;AN000;
182Sublist = No_Replace ; ;AN000;
183Count = N_A ; ;AN000;
184Class = Utility_Msg_Class ; ;AN000;
185Function = No_Input ; ;AN000;
186Input = N_A ; ;AN000;
187 Define_Msg msgNoFileName ; ;AN000;
188;---------------------- ;
189data ends
diff --git a/v4.0/src/CMD/EXE2BIN/EXE2BIN.LNK b/v4.0/src/CMD/EXE2BIN/EXE2BIN.LNK
new file mode 100644
index 0000000..652fceb
--- /dev/null
+++ b/v4.0/src/CMD/EXE2BIN/EXE2BIN.LNK
@@ -0,0 +1,5 @@
1/DOSSEG /MAP /E+
2E2BINIT.obj+
3DISPLAY.obj
4EXE2BIN.EXE, EXE2BIN.MAP;
5 \ No newline at end of file
diff --git a/v4.0/src/CMD/EXE2BIN/EXE2BIN.SKL b/v4.0/src/CMD/EXE2BIN/EXE2BIN.SKL
new file mode 100644
index 0000000..6a6a0f3
--- /dev/null
+++ b/v4.0/src/CMD/EXE2BIN/EXE2BIN.SKL
@@ -0,0 +1,71 @@
1
2:util EXE2BIN
3
4:class 1
5:use EXTEND2
6:use EXTEND3
7:use EXTEND4
8:use EXTEND5
9:use EXTEND6
10:use EXTEND15
11:use EXTEND18
12
13:class 2
14
15:class A
16;msgBadDosVersion
17;"Incorrect DOS version",CR,LF,"$"
18:use 1 COMMON1
19
20;msgOutOfMemory
21;"Insufficient memory",CR,LF
22:def 2 "Insufficient memory",CR,LF
23
24;msgLoadFailure
25;"Can't find messages"
26:def 3 "Can't find messages",CR,LF
27
28:CLASS B
29
30;msgNoAccess
31;"Access denied ", CR, LF
32:def 4 "Access denied",CR,LF
33
34;msgNoConvert
35;"File cannot be converted", CR, LF
36:def 5 "File cannot be converted",CR,LF
37
38;msgNoFile
39;"File not found ", CR, LF
40:def 6 "File not found",CR,LF
41
42;msgFileCreateError
43;"File creation error", CR, LF
44:def 7 "File creation error",CR,LF
45
46;msgFixUp
47;"Fix-ups needed - base segment (hex):"
48:def 8 "Fix-ups needed - base segment (hex):"
49
50;msgBadParameter
51;"Invalid parameter",CR,LF,0
52:use 9 EXTEND87
53
54;msgNoDiskSpace
55;"Insufficient disk space", CR, LF
56;def 10 "Insufficient disk space",CR,LF
57:use 10 COMMON20
58
59;msgNoFileName
60;"File name must be specified ", CR, LF
61:def 12 "File name must be specified",CR,LF
62
63:end
64
65
66
67
68
69
70
71 \ No newline at end of file
diff --git a/v4.0/src/CMD/EXE2BIN/LOCATE.ASM b/v4.0/src/CMD/EXE2BIN/LOCATE.ASM
new file mode 100644
index 0000000..a2d44f4
--- /dev/null
+++ b/v4.0/src/CMD/EXE2BIN/LOCATE.ASM
@@ -0,0 +1,592 @@
1; SCCSID = @(#)locate.asm 4.3 85/09/13
2Title LOCATE (EXE2BIN)
3
4; Loader for EXE files under 86-DOS
5; VER 1.5
6; 05/21/82 Added rev number
7; VER 1.6
8; 07/01/82 A little less choosy about size matches
9; VER 2.0 M.A.U
10; 10/08/82 Modified to use new 2.0 system calls for file i/o
11; Ver 2.1 M.A.U
12; 10/27/82 Added the DOS version check
13; Ver 2.2 MZ
14; 8/30/83 Fixed command line parsing
15; Ver 2.3 EE
16; 10-12-83 More fixes to command line parsing
17; Ver 2.4 NP
18; 10/17/83 Use Printf for messages
19; Ver 2.5 MZ Fix LOCATE sss D: problem
20; 04/09/87 Add PARSER and MESSAGE RETRIEVER
21; Ver 4.00 DRM
22
23; The following switch allows use with the "old linker", which put a version
24; number where the new linker puts the number of bytes used in the last page.
25; If enabled, this will cause a test for 0004 at this location (the old linker
26; version number), and if equal, change it to 200H so all of the last page
27; will be used.
28
29
30OLDLINK EQU 0 ;1 to enable, 0 to disable
31
32 .xlist
33
34; INCLUDE DOSSYM.INC ; also versiona.inc
35; INCLUDE E2BMACRO.INC
36
37 .list
38
39 subttl Main Code Area
40 page
41
42DATA SEGMENT PUBLIC BYTE
43
44rev db "2.4"
45
46
47file1_ext db ".EXE",00h
48file2_ext db ".BIN",00h
49
50per1 dW 0
51per2 db 0
52
53file1 db (64+13) dup(?)
54fnptr dw offset file1 ; Ptr to filename in file1
55handle1 dw 1 dup(?)
56
57file2 db (64+13) dup(?)
58f2cspot dw offset file2 ; Ptr to spot in file2, file1 maybe added
59handle2 dw 1 dup(?)
60
61dma_buf db 80h dup(0) ; DMA transfer buffer
62
63INBUF DB 5,0
64 DB 5 DUP(?)
65
66;The following locations must be defined for storing the header:
67
68RUNVAR LABEL BYTE ;Start of RUN variables
69RELPT DW ?
70LASTP LABEL WORD
71RELSEG DW ?
72SIZ LABEL WORD ;Share these locations
73PAGES DW ?
74RELCNT DW ?
75HEADSIZ DW ?
76 DW ?
77LOADLOW DW ?
78INITSS DW ?
79INITSP DW ?
80 DW ?
81INITIP DW ?
82INITCS DW ?
83RELTAB DW ?
84RUNVARSIZ EQU $-RUNVAR
85
86DATA ENDS
87
88STACK SEGMENT WORD STACK
89 DB (362 - 80h) + 80H DUP (?) ; (362 - 80h) is IBMs ROM requirement
90 ; (New - Old) == size of growth
91STACK ENDS
92
93
94ZLOAD SEGMENT
95ZLOAD ENDS
96LOAD EQU ZLOAD
97
98
99CODE SEGMENT BYTE
100
101 ASSUME CS:CODE,SS:STACK
102
103LOCATE PROC NEAR
104
105LOCSTRT:
106 PUSH DS
107 XOR AX,AX
108 PUSH AX ;Push return address to DS:0
109
110
111 MOV SI,81H
112 MOV BX,DATA
113 MOV ES,BX
114 MOV BX,WORD PTR DS:[2] ;Get size of memory
115
116 assume es:data
117
118
119
120
121
122
123;-----------------------------------------------------------------------;
124
125;
126; The rules for the arguments are:
127; File 1:
128; If no extention is present, .EXE is used.
129; File 2:
130; If no drive is present in file2, use the one from file1
131; If no path is specified, then use current dir
132; If no filename is specified, use the filename from file1
133; If no extention is present in file2, .BIN is used
134;
135
136
137;----- Get the first file name
138 call kill_bl ; p = skipblanks (p);
139 jnc sj01 ; if (p == NULL)
140 push es
141 pop ds
142 MESSAGE msgNoFile ;AC000;
143sj01:
144 mov di,offset file1 ; d = file1;
145sj0:
146 lodsb ; while (!IsBlank(c=*p++)) {
147 CALL IsBlank
148 JZ SJ2
149 mov DX,per1
150 cmp al,'\' ; if (c == '\\' || c == ':') {
151 jz sj05
152 cmp al,':'
153 jnz checkper1
154sj05:
155 mov fnptr,di ; fnptr = ptr to slash
156 inc fnptr ; fnptr advanced past slash to fname
157 xor DX,DX ; per1 = NULL;
158checkper1:
159 cmp al,'.' ; if (c == '.')
160 jne sj1
161 mov DX,DI ; per1 = p-1;
162 DEC DX ;
163sj1:
164 mov per1,DX
165 stosb ; *d++ = c;
166 jmp short sj0 ; }
167sj2:
168 dec si ; p--;
169 mov byte ptr es:[di],00h ; *d = 0;
170 call kill_bl ; if (End(p))
171 jnc get_second
172 cmp byte ptr [file1+1],':' ; Drive spec on first file?
173 jnz nsja ; no
174 mov ax,word ptr file1 ; get drive stuff
175 mov word ptr file2,ax
176 inc f2cspot
177 inc f2cspot
178nsja:
179 jmp no_second ; goto No_second;
180
181
182get_second:
183;----- Get the second file name
184 mov di,offset file2 ; d = file2
185 cmp byte ptr [si+1],':' ; Drive spec on second file?
186 jz sj3 ; yes
187 cmp byte ptr [file1+1],':' ; Drive spec on first file?
188 jnz sj3 ; no
189 push ax ; Suck drive spec from file1
190 mov ax,word ptr file1
191 stosw
192 mov f2cspot,di
193 pop ax
194sj3:
195 lodsb ; while (!IsBlank(c=*p++)) {
196 CALL IsBlank
197 JZ SJ5
198 mov ah,per2
199 cmp al,'\' ; if (c == '\\')
200 jnz checkper2
201 xor ah,ah ; per2 = FALSE;
202checkper2:
203 cmp al,'.' ; if (c == '.')
204 jne sj4
205 mov ah,-1 ; per2 = TRUE;
206sj4:
207 mov per2,ah
208 stosb ; *d++ = c;
209 jmp short sj3 ; }
210sj5:
211 mov byte ptr es:[di],00h ; *d = 0;
212 mov ah,Set_DMA ; Use find_first to see if file2 is
213 mov dx,offset dma_buf ; a directory. If it isn't, go to
214 push es ; chex_ext. If it is, put a back-
215 pop ds ; slash on the end of the string,
216 int 21h ; set f2cspot to point to the spot
217 mov ah,Find_First ; right after the backslash, and
218 mov dx,offset file2 ; fall through to no_second so that
219 mov cx,-1 ; file1's name will be added to file2.
220 int 21h
221 jc checkDrive
222 test dma_buf+21,00010000b
223 jNZ DoDirectory
224 jmp Check_Ext
225CheckDrive:
226 CMP BYTE PTR ES:[DI-1],':'
227 JNZ Check_Ext ; if char is not a : then skip
228 JMP SetSecond ; presume drive:
229DoDirectory:
230 mov AL,5ch
231 stosb
232SetSecond:
233 mov per2,FALSE
234 mov f2cspot,di
235
236;----- Copy file1 to file2
237no_second:
238 PUSH ES
239 POP DS
240 assume ds:data
241
242 mov si,fnptr ; s = ptr to fname in file1;
243 mov di,f2cspot ; d = spot in file2 to cat file1;
244 mov dx,per1 ; dx = ptr to ext dot in file1;
245 inc dx
246
247sj6: ; while (TRUE) {
248 cmp SI,dx ; if (s == per1)
249 je sj7 ; break;
250 lodsb ; c = *s++;
251 cmp al,00h ; if (!c)
252 je sj7 ; break;
253 stosb ; *d++ = c;
254 jmp short sj6 ; }
255sj7:
256 mov byte ptr [di],00h ; *d = 0;
257
258;----- Check that files have an extension, otherwise set default
259check_ext:
260 PUSH ES
261 POP DS
262 assume ds:data
263
264 cmp per1,0 ; if (per1 == NULL) {
265 jNZ file1_ok
266 mov di,offset file1 ; d = file1;
267 mov si,offset file1_ext ; s = ".EXE";
268 call strcat ; strcat (d, s);
269file1_ok: ; }
270 cmp per2,-1 ; if (per2 != NULL) {
271 je file2_ok
272 mov di,offset file2 ; d = file2;
273 mov si,offset file2_ext ; s = ".BIN";
274 call strcat ; strcap (d, s);
275 jmp short file2_ok ; }
276
277;-----------------------------------------------------------------------;
278file2_ok:
279 mov dx,offset file1
280 mov ax,(open SHL 8) + 0 ;for reading only
281 INT 21H ;Open input file
282 jc bad_file
283 mov [handle1],ax
284 jmp exeload
285
286bad_file:
287 MESSAGE msgNoFile ;AC000;
288 call TriageError
289BADEXE:
290 MESSAGE msgNoConvert ;AC000;
291TOOBIG:
292 MESSAGE msgOutOfMemory ;AC000;
293
294EXELOAD:
295 MOV DX,OFFSET RUNVAR ;Read header in here
296 MOV CX,RUNVARSIZ ;Amount of header info we need
297 push bx
298 mov bx,[handle1]
299 MOV AH,read
300 INT 21H ;Read in header
301 pop bx
302 CMP [RELPT],5A4DH ;Check signature word
303 JNZ BADEXE
304 MOV AX,[HEADSIZ] ;size of header in paragraphs
305 ADD AX,31 ;Round up first
306 CMP AX,1000H ;Must not be >=64K
307 JAE TOOBIG
308 AND AX,NOT 31
309 MOV CL,4
310 SHL AX,CL ;Header size in bytes
311
312 push dx
313 push cx
314 push ax
315 push bx
316 mov dx,ax
317 xor cx,cx
318 mov al,0
319 mov bx,[handle1]
320 mov ah,lseek
321 int 21h
322 pop bx
323 pop ax
324 pop cx
325 pop dx
326
327 XCHG AL,AH
328 SHR AX,1 ;Convert to pages
329 MOV DX,[PAGES] ;Total size of file in 512-byte pages
330 SUB DX,AX ;Size of program in pages
331 CMP DX,80H ;Fit in 64K?
332 JAE TOOBIG
333 XCHG DH,DL
334 SHL DX,1 ;Convert pages to bytes
335 MOV AX,[LASTP] ;Get count of bytes in last page
336 OR AX,AX ;If zero, use all of last page
337 JZ WHOLEP
338
339 IF OLDLINK
340 CMP AX,4 ;Produced by old linker?
341 JZ WHOLEP ;If so, use all of last page too
342 ENDIF
343
344 SUB DX,200H ;Subtract last page
345 ADD DX,AX ;Add in byte count for last page
346WHOLEP:
347 MOV [SIZ],DX
348 ADD DX,15
349 SHR DX,CL ;Convert bytes to paragraphs
350 MOV BP,LOAD
351 ADD DX,BP ;Size + start = minimum memory (paragr.)
352 CMP DX,BX ;Enough memory?
353 JA TOOBIG
354 MESSAGE msgNoConvert ;AC000;
355 MOV AX,[INITSS]
356 OR AX,[INITSP]
357 OR AX,[INITCS]
358ERRORNZ:
359 jz xj
360 JMP WRTERR ;Must not have SS, SP, or CS to init.
361xj: MOV AX,[INITIP]
362 OR AX,AX ;If IP=0, do binary fix
363 JZ BINFIX
364 CMP AX,100H ;COM file must be set up for CS:100
365 JNZ ERRORNZ
366
367 push dx
368 push cx
369 push ax
370 push bx
371 mov dx,100h ;chop off first 100h
372 xor cx,cx
373 mov al,1 ;seek from current position
374 mov bx,[handle1]
375 mov ah,lseek
376 int 21h
377 pop bx
378 pop ax
379 pop cx
380 pop dx
381
382 SUB [SIZ],AX ;And count decreased size
383 CMP [RELCNT],0 ;Must have no fixups
384 JNZ ERRORNZ
385BINFIX:
386 XOR BX,BX ;Initialize fixup segment
387;See if segment fixups needed
388 CMP [RELCNT],0
389 JZ LOADEXE
390GETSEG:
391 MESSAGE msgFixUp ;AC000;
392 MOV AH,STD_CON_STRING_INPUT
393 MOV DX,OFFSET INBUF
394 INT 21H ;Get user response
395 MOV SI,OFFSET INBUF+2
396 MOV BYTE PTR [SI-1],0 ;Any digits?
397 JZ GETSEG
398DIGLP:
399 LODSB
400 SUB AL,"0"
401 JC DIGERR
402 CMP AL,10
403 JB HAVDIG
404 AND AL,5FH ;Convert to upper case
405 SUB AL,7
406 CMP AL,10
407 JB DIGERR
408 CMP AL,10H
409 JAE DIGERR
410HAVDIG:
411 SHL BX,1
412 SHL BX,1
413 SHL BX,1
414 SHL BX,1
415 OR BL,AL
416 JMP DIGLP
417
418DIGERR:
419 CMP BYTE PTR [SI-1],0DH ;Is last char. a CR?
420 JNZ GETSEG
421LOADEXE:
422 XCHG BX,BP ;BX has LOAD, BP has fixup
423
424 MOV CX,[SIZ]
425 MOV AH,read
426 push di
427 mov di,[handle1]
428 PUSH DS
429 MOV DS,BX
430 XOR DX,DX
431 push bx
432 mov bx,di
433 INT 21H ;Read in up to 64K
434 pop bx
435 POP DS
436 pop di
437 Jnc HAVEXE ;Did we get it all?
438 MESSAGE msgReadError ;AC000;
439HAVEXE:
440 CMP [RELCNT],0 ;Any fixups to do?
441 JZ STORE
442 MOV AX,[RELTAB] ;Get position of table
443
444 push dx
445 push cx
446 push ax
447 push bx
448 mov dx,ax
449 xor cx,cx
450 mov al,0
451 mov bx,[handle1]
452 mov ah,lseek
453 int 21h
454 pop bx
455 pop ax
456 pop cx
457 pop dx
458
459 MOV DX,OFFSET RELPT ;4-byte buffer for relocation address
460RELOC:
461 MOV DX,OFFSET RELPT ;4-byte buffer for relocation address
462 MOV CX,4
463 MOV AH,read
464 push bx
465 mov bx,[handle1]
466 INT 21H ;Read in one relocation pointer
467 pop bx
468 Jnc RDCMP
469 JMP BADEXE
470RDCMP:
471 MOV DI,[RELPT] ;Get offset of relocation pointer
472 MOV AX,[RELSEG] ;Get segment
473 ADD AX,BX ;Bias segment with actual load segment
474 MOV ES,AX
475 ADD ES:[DI],BP ;Relocate
476 DEC [RELCNT] ;Count off
477 JNZ RELOC
478STORE:
479 MOV AH,CREAT
480 MOV DX,OFFSET file2
481 xor cx,cx
482 INT 21H
483 Jc MKERR
484 mov [handle2],ax
485 MOV CX,[SIZ]
486 MOV AH,write
487 push di
488 mov di,[handle2]
489 PUSH DS
490 MOV DS,BX
491 XOR DX,DX ;Address 0 in segment
492 push bx
493 mov bx,di
494 INT 21H
495 pop bx
496 POP DS
497 pop di
498 Jc WRTERR ;Must be zero if more to come
499 MOV AH,CLOSE
500 push bx
501 mov bx,[handle2]
502 INT 21H
503 pop bx
504 RET
505
506WRTERR:
507 MESSAGE msgOutOfMemory ;AC000;
508
509MKERR:
510 MESSAGE msgFileCreateError ;AC000;
511 Call TriageError
512
513
514LOCATE ENDP
515
516;----- concatenate two strings
517strcat proc near ; while (*d)
518 cmp byte ptr [di],0
519 jz atend
520 inc di ; d++;
521 jmp strcat
522atend: ; while (*d++ = *s++)
523 lodsb
524 stosb
525 or al,al ; ;
526 jnz atend
527 ret
528strcat endp
529
530;----- Find the first non-ignorable char, return carry if CR found
531kill_bl proc near
532 cld
533sj10: ; while ( *p != 13 &&
534 lodsb
535 CMP AL,13 ; IsBlank (*p++))
536 JZ BreakOut
537 CALL IsBlank
538 JZ SJ10 ; ;
539BreakOut:
540 dec si ; p--;
541 cmp al,0dh ; return *p == 13;
542 clc
543 jne sj11
544 stc
545sj11:
546 ret
547kill_bl endp
548
549IsBlank proc near
550 cmp al,13
551 retz
552 cmp al,' ' ; space
553 retz
554 cmp al,9 ; tab
555 retz
556 cmp al,',' ; comma
557 retz
558 cmp al,';' ; semicolon
559 retz
560 cmp al,'+' ; plus
561 retz
562 cmp al,10 ; line feed
563 retz
564 cmp al,'=' ; equal sign
565 return
566IsBlank Endp
567
568;
569; Take a default message pointer in DX and convert it to access-denied iff
570; the extended error indicates so. Leave all other registers (except AX)
571; alone.
572;
573Procedure TriageError,near
574 retnc ; no carry => do nothing...
575 PUSHF
576 SaveReg <BX,CX,SI,DI,BP,ES,DS,AX,DX>
577 MOV AH,GetExtendedError
578 INT 21h
579 RestoreReg <CX,BX> ; restore original AX
580 MESSAGE msgNoAccess ;AC000;
581 CMP AX,65 ; network access denied?
582 JZ NoMove ; Yes, return it.
583 MOV AX,BX
584 MOV DX,CX
585NoMove:
586 RestoreReg <DS,ES,BP,DI,SI,CX,BX>
587 popf
588 return
589TriageError ENDP
590
591CODE ENDS
592 END LOCATE
diff --git a/v4.0/src/CMD/EXE2BIN/LOCMES.ASM b/v4.0/src/CMD/EXE2BIN/LOCMES.ASM
new file mode 100644
index 0000000..1e87615
--- /dev/null
+++ b/v4.0/src/CMD/EXE2BIN/LOCMES.ASM
@@ -0,0 +1,55 @@
1; SCCSID = @(#)locmes.asm 1.1 85/06/13
2 title LOCATE (EXE2BIN) Messages
3
4FALSE EQU 0
5TRUE EQU NOT FALSE
6
7addr macro sym,name
8 public name
9 ifidn <name>,<>
10 dw offset sym
11 else
12 public name
13name dw offset sym
14 endif
15endm
16
17
18DATA SEGMENT PUBLIC BYTE
19
20 PUBLIC bad_vers
21
22bad_vers db "Incorrect DOS version$"
23
24AccDen db "Access denied",0
25 addr AccDen,AccDen_ptr
26
27notfnd db "File not found",0
28 addr notfnd,notfnd_ptr
29
30NOROOM db "Insufficient memory",0
31 addr noroom,noroom_ptr
32
33DIRFULL db "File creation error",0
34 addr dirfull,dirfull_ptr
35
36FULL db "Insufficient disk space",0
37 addr full,full_ptr
38
39CANTFIX db "File cannot be converted",0
40 addr cantfix,cantfix_ptr
41
42PROMPT db "Fix-ups needed - base segment (hex): ",0
43 addr prompt,prompt_ptr
44
45
46crlf db 13,10,0
47 addr crlf,crlf_ptr
48
49rdbad db "WARNING - Read error on EXE file.",13,10
50 db " Amount read less than size in header.",0
51 addr rdbad,rdbad_ptr
52
53
54DATA ENDS
55 END
diff --git a/v4.0/src/CMD/EXE2BIN/MAKEFILE b/v4.0/src/CMD/EXE2BIN/MAKEFILE
new file mode 100644
index 0000000..0c0910b
--- /dev/null
+++ b/v4.0/src/CMD/EXE2BIN/MAKEFILE
@@ -0,0 +1,30 @@
1#************************** makefile for cmd\... ***************************
2
3msg =..\..\messages
4dos =..\..\dos
5inc =..\..\inc
6hinc =..\..\h
7
8#
9####################### dependencies begin here. #########################
10#
11
12all: exe2bin.exe
13
14exe2bin.ctl : exe2bin.skl makefile \
15 $(msg)\$(COUNTRY).msg
16
17e2binit.obj : e2binit.asm $(inc)\syscall.inc e2bparse.inc e2bmacro.inc \
18 e2bequ.inc $(inc)\sysmsg.inc e2btable.inc exe2bin.ctl \
19 locate.asm $(inc)\dossym.inc $(inc)\dosmac.inc \
20 $(inc)\bpb.inc $(inc)\buffer.inc $(inc)\sysvar.inc \
21 $(inc)\mult.inc $(inc)\dirent.inc $(inc)\dpb.inc \
22 $(inc)\curdir.inc $(inc)\cpmfcb.inc $(inc)\find.inc \
23 $(inc)\pdb.inc $(inc)\sf.inc $(inc)\arena.inc $(inc)\intnat.inc \
24 $(inc)\error.inc $(inc)\syscall.inc $(inc)\parse.asm \
25 $(inc)\psdata.inc makefile
26
27display.obj : display.asm makefile
28
29exe2bin.exe : display.obj e2binit.obj exe2bin.ctl makefile exe2bin.lnk
30 link @exe2bin.lnk