 The IBM Personal Computer MACRO Assembler 01-20-85    	PAGE	1-1



1	 0000	 	 	 	RED segment para public 'code'
2	 	 	 	 	 	assume cs:red, ds:red, es:red, 
	 	 	 	ss:nothing
3	 0100	 	 	 	 	org 100h	 	;.com f
	 	 	 	ormat
4	 0100	 	 	 	begin:	
5	 0100  E9 0362 R	 	 	jmp	code_start	; jump 
	 	 	 	around data declarations
6	 	 	 	 	;
7	 0103	 	 	 	declare:	; messages, storage are
	 	 	 	as, equates
8	 0103  52 45 44 69 72 65	 	copyright	db	'REDire
	 	 	 	ct (C) 1985, Dickinson Associates Inc.'
9	       63 74 20 28 43 29	
10	       20 31 39 38 35 2C	
11	       20 44 69 63 6B 69	
12	       6E 73 6F 6E 20 41	
13	       73 73 6F 63 69 61	
14	       74 65 73 20 49 6E	
15	       63 2E	 	 	
16	 012F  0D 0A 24	 	 	 	 	 	db	13,10,'
	 	 	 	$'
17	 = 004D	 	 	 	 	path_file_len	equ	77  ;le
	 	 	 	ngth=1, path=63, filename=12, 0=1
18	 0132     4D [	 	 	 	source_file	db	path_fi
	 	 	 	le_len dup (0)
19	                00	 	
20	                    ]	 	
21	 	 	 	 	
22	 017F     4D [	 	 	 	target_path	db	path_fi
	 	 	 	le_len dup (0)
23	                00	 	
24	                    ]	 	
25	 	 	 	 	
26	 01CC  0000	 	 	 	source_end	dw	0
27	 01CE  0000	 	 	 	target_end	dw	0
28	 01D0  00	 	 	 	pc_dos_ver	db	0
29	 01D1  61 62 63 64 65 66	 	valid_in	db	'abcdef
	 	 	 	ghijklmnopqrstuvwxyz,;=',9
30	       67 68 69 6A 6B 6C	
31	       6D 6E 6F 70 71 72	
32	       73 74 75 76 77 78	
33	       79 7A 2C 3B 3D 09	
34	 01EF  41 42 43 44 45 46	 	valid_out	db	'ABCDEF
	 	 	 	GHIJKLMNOPQRSTUVWXYZ',4 DUP(32)
35	       47 48 49 4A 4B 4C	
36	       4D 4E 4F 50 51 52	
37	       53 54 55 56 57 58	
38	       59 04 [	 	 	
39	                20	 	
40	                    ]	 	
41	 	 	 	 	
42	 = 001F	 	 	 	 	valid_num	equ	$ - val
 The IBM Personal Computer MACRO Assembler 01-20-85    	PAGE	1-2



	 	 	 	id_out + 1
43	 020D  00	 	 	 	err_flag	db	0
44	 020E  0A 0D 52 45 44 69	 	err_head	db	10,13,'
	 	 	 	REDirect Error - $'
45	       72 65 63 74 20 45	
46	       72 72 6F 72 20 2D	
47	       20 24	 	 	
48	 0222  49 6E 63 6F 72 72	 	bad_version	db	'Incorr
	 	 	 	ect PC-DOS Version$'
49	       65 63 74 20 50 43	
50	       2D 44 4F 53 20 56	
51	       65 72 73 69 6F 6E	
52	       24	 	 	
53	 023B  43 6F 72 72 65 63	 	no_parms	db	'Correc
	 	 	 	t Syntax is:',13,10,10
54	       74 20 53 79 6E 74	
55	       61 78 20 69 73 3A	
56	       0D 0A 0A	 	 	
57	 0250  52 45 44 20 5B 64	 	db	'RED [d:][source_path]s
	 	 	 	ource_filename[.ext] [d:][target_path]$'
58	       3A 5D 5B 73 6F 75	
59	       72 63 65 5F 70 61	
60	       74 68 5D 73 6F 75	
61	       72 63 65 5F 66 69	
62	       6C 65 6E 61 6D 65	
63	       5B 2E 65 78 74 5D	
64	       20 5B 64 3A 5D 5B	
65	       74 61 72 67 65 74	
66	       5F 70 61 74 68 5D	
67	       24	 	 	
68	 028D  46 69 6C 65 20 6E	 	file_not_found	db	'File n
	 	 	 	ot Found$'
69	       6F 74 20 46 6F 75	
70	       6E 64 24	 	 	
71	 029C  54 61 72 67 65 74	 	path_not_found	db	'Target
	 	 	 	 Path not Found$'
72	       20 50 61 74 68 20	
73	       6E 6F 74 20 46 6F	
74	       75 6E 64 24	 	
75	 02B2  0D 0A 6F 72 20 24	 	pc_dos_2_patch	db	13,10,'
	 	 	 	or $'
76	 02B8  53 6F 75 72 63 65	 	drives_conflict	db	'Source
	 	 	 	 and Target Disk Drives Conflict$'
77	       20 61 6E 64 20 54	
78	       61 72 67 65 74 20	
79	       44 69 73 6B 20 44	
80	       72 69 76 65 73 20	
81	       43 6F 6E 66 6C 69	
82	       63 74 24	 	 	
83	 02DF  55 6E 64 65 66 69	 	undefined_err	db	'Undefi
	 	 	 	ned Error: PC-DOS Function 56H$'
84	       6E 65 64 20 45 72	
85	       72 6F 72 3A 20 50	
 The IBM Personal Computer MACRO Assembler 01-20-85    	PAGE	1-3



86	       43 2D 44 4F 53 20	
87	       46 75 6E 63 74 69	
88	       6F 6E 20 35 36 48	
89	       24	 	 	
90	 0304  0A 0A 0D 20 2E 20	 	err_tail	db	10,10,1
	 	 	 	3,' . . . Aborting',10,13,13,'$'
91	       2E 20 2E 20 41 62	
92	       6F 72 74 69 6E 67	
93	       0A 0D 0D 24	 	
94	 031A  20 2E 20 2E 20 52	 	good_msg	db	' . . R
	 	 	 	EDirected to . . $'
95	       45 44 69 72 65 63	
96	       74 65 64 20 74 6F	
97	       20 2E 20 2E 20 24	
98	 0332  20 2E 20 2E 20 4E	 	bad_msg1	db	' . . N
	 	 	 	ot REDirected . . $'
99	       6F 74 20 52 45 44	
100	       69 72 65 63 74 65	
101	       64 20 2E 20 2E 20	
102	       24	 	 	
103	 034B  20 2E 20 2E 20 61	 	bad_msg2	db	' . . a
	 	 	 	lready exists$'
104	       6C 72 65 61 64 79	
105	       20 65 78 69 73 74	
106	       73 24	 	 	
107	 035F  0A 0D 24	 	 	 	end_line	db	10,13,'
	 	 	 	$'
108	 	 	 	 	;
109	 0362	 	 	 	code_start:	;parse command line int
	 	 	 	o source and target parameters
110	 0362  BA 0103 R	 	 	mov	dx,offset copyright
	 	 	 	 	;display copyright notice
111	 0365  B4 09	 	 	 	mov	ah,9h
112	 0367  CD 21	 	 	 	int	21h
113	 0369  B4 30	 	 	 	mov	ah,30h	 	
 	 	 	 	 	; get pc-dos version
114	 036B  CD 21	 	 	 	int	21h
115	 036D  A2 01D0 R	 	 	mov	pc_dos_ver,al
116	 0370  BE 0080	 	 	 	mov	si,80h	 	
 	 	 	 	 	;psp parameter byte count pointer
117	 0373  8A 0C	 	 	 	mov	cl,[si]	 	
 	 	 	 	 	;move byte count to cl
118	 0375  32 ED	 	 	 	xor	ch,ch	 	
 	 	 	 	 	;zero ch
119	 0377  E3 5F	 	 	 	jcxz	no_parms_passed	
 	 	 	 	 	;if cx is zero, there are no parameters
120	 0379  8B D1	 	 	 	mov	dx,cx	 	
 	 	 	 	 	;save byte count in dx
121	 037B  46	 	 	 	inc	si	 	
 	 	 	 	 	;point to parameter area
122	 037C  8B FE	 	 	 	mov	di,si	 	
 	 	 	 	 	;copy si to di for cleanup routine
123	 037E  FC	 	 	 	cld	 	 	
 The IBM Personal Computer MACRO Assembler 01-20-85    	PAGE	1-4



	 	 	 	 	;set direction flag to forward
124	 037F	 	 	 	clean_parms:	;change valid delimiter
	 	 	 	s to blanks, lower to upper case
125	 037F  AC	 	 	 	lodsb	 	 	
 	 	 	 	 	;load each character to al
126	 0380  57	 	 	 	push	di	 	
 	 	 	 	 	;save di on stack
127	 0381  BF 01D1 R	 	 	mov	di,offset valid_in
	 	 	 	 	;point to table of valid inputs
128	 0384  51	 	 	 	push	cx	 	
 	 	 	 	 	;save cx on stack
129	 0385  B9 001F	 	 	 	mov	cx,valid_num	
 	 	 	 	 	;set CX TO NUMBER OF INPUTS TO LOOK FOR
130	 0388  F2/ AE	 	 	repne	scasb	 	 	
 	 	 	 	 	;see if any are in al
131	 038A  E3 09	 	 	 	jcxz	clean_end	
 	 	 	 	 	;if not, change nothing
132	 038C  BB 001F	 	 	 	mov	bx,valid_num	
 	 	 	 	 	;set up bx to point to valid output
133	 038F  2B D9	 	 	 	sub	bx,cx	 	
 	 	 	 	 	;this will leave bx one off
134	 0391  8A 87 01EE R	 	 	mov	al,valid_out [bx-1]
	 	 	 	 	;load the valid output to al
135	 0395	 	 	 	clean_end:
136	 0395  59	 	 	 	pop	cx	 	
 	 	 	 	 	;restore cx
137	 0396  5F	 	 	 	pop	di	 	
 	 	 	 	 	;restore di
138	 0397  AA	 	 	 	stosb	 	 	
 	 	 	 	 	;store modified al back to psp
139	 0398  E2 E5	 	 	loop	clean_parms	 	
 	 	 	 	 	;loop until cx is zero
140	 	 	 	 	;
141	 039A  8B CA	 	 	 	mov	cx,dx	 	
 	 	 	 	 	;restore number of bytes in psp to cx
142	 039C  BA 0002	 	 	 	mov	dx,2	 	
 	 	 	 	 	;set dx to look for up to 2 parameters
143	 039F  BB 0132 R	 	 	mov	bx,offset source_file
	 	 	 	 	;set bx to address of 1st parameter
144	 03A2  B0 20	 	 	 	mov	al,' '	 	
 	 	 	 	 	;set up to scan for first non-blank
145	 03A4  BF 0081	 	 	 	mov	di,81h	 	
 	 	 	 	 	;set di to pc-dos parameter pointer
146	 03A7	 	 	 	find_parms:	;start looking for para
	 	 	 	meters, load to program storage
147	 03A7  F3/ AE	 	 	repe	scasb	 	 	
 	 	 	 	 	;scan while blanks
148	 03A9  8B F7	 	 	 	mov	si,di	 	
 	 	 	 	 	;set si to second non-blank byte
149	 03AB  4E	 	 	 	dec	si	 	
 	 	 	 	 	;adjust it to first non-blank byte
150	 03AC  41	 	 	 	inc	cx	 	
 	 	 	 	 	;adjust cx to compensate
 The IBM Personal Computer MACRO Assembler 01-20-85    	PAGE	1-5



151	 03AD  E3 22	 	 	 	jcxz	parms_loaded	
 	 	 	 	 	;if cx is zero, no parameters left
152	 03AF  8B FB	 	 	 	mov	di,bx	 	
 	 	 	 	 	;set di to parameter hold area
153	 03B1  8B C1	 	 	 	mov	ax,cx	 	
 	 	 	 	 	;store cx to first byte of hold area
154	 03B3  AA	 	 	 	stosb	 	 	
 	 	 	 	 	;di is adjusted to second byte here
155	 03B4  AC	 	 	store:	lodsb	 	 	
 	 	 	 	 	;load each byte to al
156	 03B5  3C 20	 	 	 	cmp	al,' '	 	
 	 	 	 	 	;is it a blank?
157	 03B7  74 01	 	 	 	jz	end_store	
 	 	 	 	 	;yes, end of this parameter
158	 03B9  AA	 	 	 	stosb	 	 	
 	 	 	 	 	;no, store the byte to hold area
159	 03BA	 	 	 	end_store:	
160	 03BA  E0 F8	 	 	 	loopnz	store	 	
 	 	 	 	 	;keep looking
161	 03BC  29 0F	 	 	 	sub	[bx],cx	 	
 	 	 	 	 	;store number of bytes in each
162	 03BE  E3 11	 	 	 	jcxz	parms_loaded	
 	 	 	 	 	;if cx is zero, no more parameters
163	 03C0  FE 0F	 	 	 	dec	byte ptr	[bx]
	 	 	 	 	;parameter to first byte of hold area
164	 03C2  8B FE	 	 	 	mov	di,si	 	
 	 	 	 	 	;set up to scan for next non-blank
165	 03C4  4F	 	 	 	dec	di	 	
 	 	 	 	 	;adjust di to point to the blank
166	 03C5  41	 	 	 	inc	cx	 	
 	 	 	 	 	;adjust cx to compensate
167	 03C6  4A	 	 	 	dec	dx	 	
 	 	 	 	 	;decrement dx counter
168	 03C7  83 FA 00	 	 	 	cmp	dx,0	 	
 	 	 	 	 	;is dx zero?
169	 03CA  74 05	 	 	 	jz	parms_loaded	
 	 	 	 	 	;yes all expected parameters loaded
170	 03CC  83 C3 4D	 	 	 	add	bx,path_file_len
	 	 	 	 	;no, point to next part of hold area
171	 03CF  EB D6	 	 	 	jmp	find_parms	
 	 	 	 	 	;go back and look for more
172	 03D1	 	 	 	parms_loaded:	 	 	
 	 	 	 	 	;all parameters are loaded
173	 03D1  80 3E 0132 R 00	 	 	cmp	source_file[0],0
	 	 	 	 	 	;if there are no bytes in the
174	 03D6  77 06	 	 	 	ja	fix_up	 	
 	 	 	 	 	;source_file, no paramters present
175	 03D8	 	 	 	no_parms_passed:	 	
 	 	 	 	 	;exit with an error if there are
176	 03D8  BA 023B R	 	 	mov	dx,offset no_parms
	 	 	 	 	;no parameters passed
177	 03DB  E9 04B6 R	 	 	jmp	error_exit
178	 03DE	 	 	 	fix_up:	 	 	 	
 The IBM Personal Computer MACRO Assembler 01-20-85    	PAGE	1-6



	 	 	 	 	;fix source_file and target_path
179	 	 	 	 	
180	 03DE  BE 0132 R	 	 	mov	si,offset source_file
	 	 	 	 	;for search and rename calls
181	 03E1  AC	 	 	 	lodsb	 	 	
 	 	 	 	 	;get number of bytes
182	 03E2  32 E4	 	 	 	xor	ah,ah	 	
 	 	 	 	 	;zero	ah
183	 03E4  8B FE	 	 	 	mov	di,si	 	
 	 	 	 	 	;mov si to di for scan
184	 03E6  03 F8	 	 	 	add	di,ax	 	
 	 	 	 	 	;start scan at end of parameter
185	 03E8  4F	 	 	 	dec	di	 	
 	 	 	 	 	;
186	 03E9  8B C8	 	 	 	mov	cx,ax	 	
 	 	 	 	 	;set cx to number of bytes
187	 03EB  B0 5C	 	 	 	mov	al,'\'	 	
 	 	 	 	 	;scan for the last '\'
188	 03ED  FD	 	 	 	std	 	 	
 	 	 	 	 	;set direction flag to reverse
189	 03EE  F2/ AE	 	 	repnz	scasb	 	 	
 	 	 	 	 	;scan while not '\'
190	 03F0  75 06	 	 	 	jnz	no_source_dir	
 	 	 	 	 	;if zero flag not set, '\' not found
191	 03F2  83 C7 02	 	 	 	add	di,2	 	
 	 	 	 	 	;add 2 to di to point to file name
192	 03F5  EB 0E 90	 	 	 	jmp	source_fixed	
 	 	 	 	 	;position
193	 03F8	 	 	 	no_source_dir:	 	 	
 	 	 	 	 	;no source directory was specified
194	 03F8  83 C7 01	 	 	 	add	di,1	 	
 	 	 	 	 	;adjust di
195	 03FB  80 3E 0134 R 3A	 	 	cmp	source_file[2],':'
	 	 	 	 	;check for specified disk drive
196	 0400  75 03	 	 	 	jne	source_fixed	
 	 	 	 	 	;none present, we're done
197	 0402  BF 0135 R	 	 	mov	di,offset source_file[3
	 	 	 	];yes, set di to point of first byte
198	 0405	 	 	 	source_fixed:	 	 	
 	 	 	 	 	;after ':'
199	 0405  89 3E 01CC R	 	 	mov	source_end,di	
 	 	 	 	 	;move di to source_end pointer
200	 	 	 	 	;
201	 0409  FC	 	 	 	cld	 	 	
 	 	 	 	 	;set direction flag to forward
202	 040A  BE 017F R	 	 	mov	si,offset target_path
	 	 	 	 	;set up to look for '\' present
203	 040D  AC	 	 	 	lodsb	 	 	
 	 	 	 	 	;get number of bytes
204	 040E  3C 00	 	 	 	cmp	al,0	 	
 	 	 	 	 	;if it's zero, no target specified
205	 0410  74 24	 	 	 	je	no_target
206	 0412  32 E4	 	 	 	xor	ah,ah	 	
 The IBM Personal Computer MACRO Assembler 01-20-85    	PAGE	1-7



	 	 	 	 	;zero ah
207	 0414  03 F0	 	 	 	add	si,ax	 	
 	 	 	 	 	;add it to si to point to end
208	 0416  4E	 	 	 	dec	si	 	
 	 	 	 	 	;decrement si to adjust
209	 0417  AC	 	 	 	lodsb	 	 	
 	 	 	 	 	;look at last byte
210	 0418  8B FE	 	 	 	mov	di,si	 	
 	 	 	 	 	;copy si to di
211	 041A  3C 5C	 	 	 	cmp	al,'\'	 	
 	 	 	 	 	;is last byte a '\'?
212	 041C  74 11	 	 	 	je	target_fixed	
 	 	 	 	 	;yes, everything's fine
213	 041E  80 3E 017F R 02	 	 	cmp	target_path[0],2
	 	 	 	 	;if target_path is 2 bytes long and
214	 0423  75 07	 	 	 	jne	store_slash	
 	 	 	 	 	;is a drive specification,
215	 0425  80 3E 0181 R 3A	 	 	cmp	target_path[2],':'
	 	 	 	 	;let it default to the current
216	 042A  74 03	 	 	 	je	target_fixed	
 	 	 	 	 	;directory
217	 042C	 	 	 	store_slash:	 	 	
 	 	 	 	 	;place a '\' at the end of
218	 042C  B0 5C	 	 	 	mov	al,'\'	 	
 	 	 	 	 	;target_path if user did not
219	 042E  AA	 	 	 	stosb
220	 042F	 	 	 	target_fixed:
221	 042F  89 3E 01CE R	 	 	mov	target_end,di	
 	 	 	 	 	;move di to target_end pointer
222	 0433  EB 07 90	 	 	 	jmp	find_file
223	 0436	 	 	 	no_target:	 	 	
 	 	 	 	 	;set up to allow target path default
224	 0436  C7 06 01CE R 0180 R	 	mov	target_end,offset targe
	 	 	 	t_path + 1	;to current path
225	 043C	 	 	 	find_file:
226	 043C  BA 0133 R	 	 	mov	dx,offset source_file +
	 	 	 	 1	;dx points to source file
227	 043F  B4 4E	 	 	 	mov	ah,4Eh	 	
 	 	 	 	 	;request function 4Eh (find first file)
228	 0441  B9 0000	 	 	 	mov	cx,0	 	
 	 	 	 	 	;set cx to zero for normal files only
229	 0444  CD 21	 	 	 	int	21h	 	
 	 	 	 	 	;call pc-dos
230	 0446  73 06	 	 	 	jnc	found_file	
 	 	 	 	 	;if no error, first file found
231	 0448  BA 028D R	 	 	mov	dx,offset file_not_foun
	 	 	 	d	;if no files found, exit
232	 044B  EB 69 90	 	 	 	jmp	error_exit	
 	 	 	 	 	 	;program with error message
233	 044E	 	 	 	found_file:
234	 	 	 	 	
235	 	 	 	 	
236	 044E  8B 3E 01CC R	 	 	mov	di,source_end	
 The IBM Personal Computer MACRO Assembler 01-20-85    	PAGE	1-8



	 	 	 	 	;di points to end of source path
237	 0452  BE 009E	 	 	 	mov	si,9Eh	 	
 	 	 	 	 	;si points to default DTA in psp
238	 0455  B9 000D	 	 	 	mov	cx,13	 	
 	 	 	 	 	;dta will have 13 bytes
239	 0458  F3/ A4	 	 	rep	movsb	 	 	
 	 	 	 	 	;move bytes to source_file
240	 045A  8B 3E 01CE R	 	 	mov	di,target_end	
 	 	 	 	 	;di points to end of target path
241	 045E  BE 009E	 	 	 	mov	si,9Eh	 	
 	 	 	 	 	;si points to default DTA in psp
242	 0461  B9 000D	 	 	 	mov	cx,13	 	
 	 	 	 	 	;DTA will have 13 bytes
243	 0464  F3/ A4	 	 	rep	movsb	 	 	
 	 	 	 	 	;move bytes to target_path
244	 	 	 	 	;
245	 0466  BA 0133 R	 	 	mov	dx,offset source_file +
	 	 	 	 1	;dx points to old file name
246	 0469  BF 0180 R	 	 	mov	di,offset target_path +
	 	 	 	 1	;di points to new file name
247	 046C  B4 56	 	 	 	mov	ah,56h	 	
 	 	 	 	 	;request function 56h (rename file)
248	 046E  CD 21	 	 	 	int	21h	 	
 	 	 	 	 	;call pc-dos
249	 0470  73 2C	 	 	 	jnc	good_red	
 	 	 	 	 	;if no error, call was successful
250	 0472  3D 0003	 	 	 	cmp	ax,3	 	
 	 	 	 	 	;check for error 3 (path not found)
251	 0475  75 06	 	 	 	jne	err_5
252	 0477  BA 029C R	 	 	mov	dx,offset path_not_foun
	 	 	 	d
253	 047A  EB 3A 90	 	 	 	jmp	error_exit	
 	 	 	 	 	;exit program with error message
254	 047D  3D 0005	 	 	err_5:	cmp	ax,5	 	
 	 	 	 	 	;check	for error 5 (file inaccessible)
255	 0480  75 0B	 	 	 	jne	err_17
256	 0482  C6 06 020D R 01	 	 	mov	err_flag,1	
 	 	 	 	 	;soft error -
257	 0487  E8 04CC R	 	 	call	red_msg	 	
 	 	 	 	 	;issue message with subroutine
258	 048A  EB 1A 90	 	 	 	jmp	next_file	
 	 	 	 	 	;and keep going
259	 048D  3D 0011	 	 	err_17:	cmp	ax,17	 	
 	 	 	 	 	;check for error 17 (drive conflict)
260	 0490  75 06	 	 	 	jne	undef
261	 0492  BA 02B8 R	 	 	mov	dx,offset drives_confli
	 	 	 	ct
262	 0495  EB 1F 90	 	 	 	jmp	error_exit	
 	 	 	 	 	;exit program with error message
263	 0498  BA 02DF R	 	undef:	mov	dx,offset undefined_err
	 	 	 	 	;undefined error from function 56h
264	 049B  EB 19 90	 	 	 	jmp	error_exit	
 	 	 	 	 	;exit program with error message
 The IBM Personal Computer MACRO Assembler 01-20-85    	PAGE	1-9



265	 049E	 	 	 	good_red:	 	 	
 	 	 	 	 	
266	 049E  C6 06 020D R 00	 	 	mov	err_flag,0	
 	 	 	 	 	;set error flag off and
267	 04A3  E8 04CC R	 	 	call	red_msg	 	
 	 	 	 	 	;issure message with subroutine
268	 04A6	 	 	 	next_file:	 	 	
 	 	 	 	 	;look for next file
269	 04A6  B4 4F	 	 	 	mov	ah,4Fh	 	
 	 	 	 	 	;request function 4fh (find next file)
270	 04A8  B9 0000	 	 	 	mov	cx,0
271	 04AB  CD 21	 	 	 	int	21h
272	 04AD  73 03	 	 	 	jnc	found_another	
 	 	 	 	 	;no error, another file was found
273	 04AF  EB 03 90	 	 	 	jmp	end_ok	 	
 	 	 	 	 	;error, we're done finding files
274	 04B2	 	 	 	found_another:
275	 04B2  EB 9A	 	 	 	jmp	found_file	
 	 	 	 	 	;go process next file
276	 04B4  CD 20	 	 	end_ok:	int	20h	 	
 	 	 	 	 	;exit to pc-dos
277	 	 	 	 	
278	 04B6	 	 	 	error_exit:	 	 	
 	 	 	 	 	;print error message and exit
279	 04B6  52	 	 	 	push	dx	 	
 	 	 	 	 	;save error message pointer on stack
280	 04B7  B4 09	 	 	 	mov	ah,9
281	 04B9  BA 020E R	 	 	mov	dx,offset err_head
282	 04BC  CD 21	 	 	 	int	21h
283	 04BE  B4 09	 	 	 	mov	ah,9
284	 04C0  5A	 	 	 	pop	dx
285	 04C1  CD 21	 	 	 	int	21h
286	 04C3  B4 09	 	 	 	mov	ah,9
287	 04C5  BA 0304 R	 	 	mov	dx,offset err_tail
288	 04C8  CD 21	 	 	 	int	21h
289	 04CA  CD 20	 	 	 	int	20h	 	
 	 	 	 	 	;exit to pc-dos
290	 04CC	 	 	 	red_msg	proc	near	;display messag
	 	 	 	e for each file
291	 04CC  B9 0002	 	 	 	mov	cx,2	 	
 	 	 	 	 	;2 fields - source & target file
292	 04CF  BB 0133 R	 	 	mov	bx,offset source_file +
	 	 	 	 1	;point to source file
293	 04D2  8B F3	 	 	start1:	mov	si,bx	 	
 	 	 	 	 	;copy bx to si
294	 04D4  AC	 	 	start2:	lodsb	 	 	
 	 	 	 	 	;load each byte to al
295	 04D5  3C 00	 	 	 	cmp	al,0	 	
 	 	 	 	 	;if ascii 0 end of field
296	 04D7  74 08	 	 	 	je	between
297	 04D9  8A D0	 	 	 	mov	dl,al	 	
 	 	 	 	 	;copy byte to dl for funtion 2h
298	 04DB  B4 02	 	 	 	mov	ah,2h	 	
 The IBM Personal Computer MACRO Assembler 01-20-85    	PAGE	1-10



	 	 	 	 	;request function 2h
299	 04DD  CD 21	 	 	 	int	21h	 	
 	 	 	 	 	;call pc-dos
300	 04DF  EB F3	 	 	 	jmp	start2	 	
 	 	 	 	 	;get next character
301	 04E1  83 F9 02	 	 	between:cmp	cx,2	 	
 	 	 	 	 	;is it first or second field
302	 04E4  75 1B	 	 	 	jne	cr_lf	 	
 	 	 	 	 	;if second, display end of message
303	 04E6  80 3E 020D R 00	 	 	cmp	err_flag,0	
 	 	 	 	 	;is this a success message?
304	 04EB  74 0A	 	 	 	jz	ok1	 	
 	 	 	 	 	;yes, go to good_msg
305	 04ED  BA 0332 R	 	 	mov	dx, offset bad_msg1
	 	 	 	 	;no, display first part of bad_msg
306	 04F0  B4 09	 	 	 	mov	ah,9h	 	
 	 	 	 	 	;request function 9h
307	 04F2  CD 21	 	 	 	int	21h	 	
 	 	 	 	 	;call pc-dos
308	 04F4  EB 33 90	 	 	 	jmp	next	 	
 	 	 	 	 	;go process next field
309	 04F7  BA 031A R	 	ok1:	mov	dx, offset good_msg
	 	 	 	 	;display good_msg
310	 04FA  B4 09	 	 	 	mov	ah,9h	 	
 	 	 	 	 	;request function 9h
311	 04FC  CD 21	 	 	 	int	21h	 	
 	 	 	 	 	;call pc-dos
312	 04FE  EB 29 90	 	 	 	jmp	next	 	
 	 	 	 	 	;go process next field
313	 0501  80 3E 020D R 00	 	cr_lf:	cmp	err_flag,0	
 	 	 	 	 	;is this a success message?
314	 0506  74 1A	 	 	 	jz	ok2	 	
 	 	 	 	 	;yes, go to terminate message
315	 0508  BA 034B R	 	 	mov	dx,offset bad_msg2
	 	 	 	 	;no, display second part of bad_msg
316	 050B  B4 09	 	 	 	mov	ah,9h	 	
 	 	 	 	 	;request function 9h
317	 050D  CD 21	 	 	 	int	21h	 	
 	 	 	 	 	;call pc-dos
318	 050F	 	 	 	pc_dos_2:	 	 	
 	 	 	 	 	;patch for incorrect error
319	 050F  80 3E 01D0 R 03	 	 	cmp	pc_dos_ver,3	
 	 	 	 	 	;return in pc_dos 2.0 and 2.1
320	 0514  73 0C	 	 	 	jae	ok2
321	 0516  BA 02B2 R	 	 	mov	dx,offset pc_dos_2_patc
	 	 	 	h
322	 0519  B4 09	 	 	 	mov	ah,9h
323	 051B  CD 21	 	 	 	int	21h
324	 051D  BA 029C R	 	 	mov	dx,offset path_not_foun
	 	 	 	d
325	 0520  CD 21	 	 	 	int	21h
326	 0522  BA 035F R	 	ok2:	mov	dx,offset end_line
	 	 	 	 	;terminate display line
 The IBM Personal Computer MACRO Assembler 01-20-85    	PAGE	1-11



327	 0525  B4 09	 	 	 	mov	ah,9h	 	
 	 	 	 	 	;request function 9h
328	 0527  CD 21	 	 	 	int	21h
329	 0529  83 C3 4D	 	 	next:	add	bx,path_file_len
	 	 	 	 	 	;move bx to point to next field
330	 052C  E2 A4	 	 	 	loop	start1	 	
 	 	 	 	 	;loop for second field
331	 052E  C3	 	 	 	ret	 	 	
 	 	 	 	 	;or end and return to calling point
332	 052F	 	 	 	red_msg	 	endp
333	 052F	 	 	 	red	ends
334	 	 	 	 	 	end	begin

 The IBM Personal Computer MACRO Assembler 01-20-85    	PAGE	Symbols
	 	 	 	-1



Segments and groups:

	 	N a m e	 	 	Size	align	combine	class

RED. . . . . . . . . . . . . . .	052F	PARA  	PUBLIC	'CODE'

Symbols:            

	 	N a m e	 	 	Type	Value	Attr         

BAD_MSG1 . . . . . . . . . . . .	L BYTE 	0332	RED
BAD_MSG2 . . . . . . . . . . . .	L BYTE 	034B	RED
BAD_VERSION. . . . . . . . . . .	L BYTE 	0222	RED
BEGIN. . . . . . . . . . . . . .	L NEAR 	0100	RED
BETWEEN. . . . . . . . . . . . .	L NEAR 	04E1	RED
CLEAN_END. . . . . . . . . . . .	L NEAR 	0395	RED
CLEAN_PARMS. . . . . . . . . . .	L NEAR 	037F	RED
CODE_START . . . . . . . . . . .	L NEAR 	0362	RED
COPYRIGHT. . . . . . . . . . . .	L BYTE 	0103	RED
CR_LF. . . . . . . . . . . . . .	L NEAR 	0501	RED
DECLARE. . . . . . . . . . . . .	L NEAR 	0103	RED
DRIVES_CONFLICT. . . . . . . . .	L BYTE 	02B8	RED
END_LINE . . . . . . . . . . . .	L BYTE 	035F	RED
END_OK . . . . . . . . . . . . .	L NEAR 	04B4	RED
END_STORE. . . . . . . . . . . .	L NEAR 	03BA	RED
ERROR_EXIT . . . . . . . . . . .	L NEAR 	04B6	RED
ERR_17 . . . . . . . . . . . . .	L NEAR 	048D	RED
ERR_5. . . . . . . . . . . . . .	L NEAR 	047D	RED
ERR_FLAG . . . . . . . . . . . .	L BYTE 	020D	RED
ERR_HEAD . . . . . . . . . . . .	L BYTE 	020E	RED
ERR_TAIL . . . . . . . . . . . .	L BYTE 	0304	RED
FILE_NOT_FOUND . . . . . . . . .	L BYTE 	028D	RED
FIND_FILE. . . . . . . . . . . .	L NEAR 	043C	RED
FIND_PARMS . . . . . . . . . . .	L NEAR 	03A7	RED
FIX_UP . . . . . . . . . . . . .	L NEAR 	03DE	RED
FOUND_ANOTHER. . . . . . . . . .	L NEAR 	04B2	RED
FOUND_FILE . . . . . . . . . . .	L NEAR 	044E	RED
GOOD_MSG . . . . . . . . . . . .	L BYTE 	031A	RED
GOOD_RED . . . . . . . . . . . .	L NEAR 	049E	RED
NEXT . . . . . . . . . . . . . .	L NEAR 	0529	RED
NEXT_FILE. . . . . . . . . . . .	L NEAR 	04A6	RED
NO_PARMS . . . . . . . . . . . .	L BYTE 	023B	RED
NO_PARMS_PASSED. . . . . . . . .	L NEAR 	03D8	RED
NO_SOURCE_DIR. . . . . . . . . .	L NEAR 	03F8	RED
NO_TARGET. . . . . . . . . . . .	L NEAR 	0436	RED
OK1. . . . . . . . . . . . . . .	L NEAR 	04F7	RED
OK2. . . . . . . . . . . . . . .	L NEAR 	0522	RED
PARMS_LOADED . . . . . . . . . .	L NEAR 	03D1	RED
PATH_FILE_LEN. . . . . . . . . .	Number	004D	
PATH_NOT_FOUND . . . . . . . . .	L BYTE 	029C	RED
PC_DOS_2 . . . . . . . . . . . .	L NEAR 	050F	RED
PC_DOS_2_PATCH . . . . . . . . .	L BYTE 	02B2	RED
 The IBM Personal Computer MACRO Assembler 01-20-85    	PAGE	Symbols
	 	 	 	-2



PC_DOS_VER . . . . . . . . . . .	L BYTE 	01D0	RED
RED_MSG. . . . . . . . . . . . .	N PROC	04CC	RED	Length =0063
SOURCE_END . . . . . . . . . . .	L WORD 	01CC	RED
SOURCE_FILE. . . . . . . . . . .	L BYTE 	0132	RED	Length =004D
SOURCE_FIXED . . . . . . . . . .	L NEAR 	0405	RED
START1 . . . . . . . . . . . . .	L NEAR 	04D2	RED
START2 . . . . . . . . . . . . .	L NEAR 	04D4	RED
STORE. . . . . . . . . . . . . .	L NEAR 	03B4	RED
STORE_SLASH. . . . . . . . . . .	L NEAR 	042C	RED
TARGET_END . . . . . . . . . . .	L WORD 	01CE	RED
TARGET_FIXED . . . . . . . . . .	L NEAR 	042F	RED
TARGET_PATH. . . . . . . . . . .	L BYTE 	017F	RED	Length =004D
UNDEF. . . . . . . . . . . . . .	L NEAR 	0498	RED
UNDEFINED_ERR. . . . . . . . . .	L BYTE 	02DF	RED
VALID_IN . . . . . . . . . . . .	L BYTE 	01D1	RED
VALID_NUM. . . . . . . . . . . .	Number	001F	
VALID_OUT. . . . . . . . . . . .	L BYTE 	01EF	RED

Warning Severe
Errors	Errors 
0	0
