-
Notifications
You must be signed in to change notification settings - Fork 0
/
n_myexec.asm
228 lines (226 loc) · 5.49 KB
/
n_myexec.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
; .286
; .Model Tiny
; .Code
; Org 100h
;m5_Entry:
; Jmp m5_Start
; FileToExec Db 'commandr.com', 0
m5_P500 Proc Near
Push Ax
Mov Ah, 9
Int 21h
Pop Ax
Ret
m5_P500 Endp
m5_Baddos Db 'DOS 2.00 or later required', 07, '$'
m5_Nocomm Db 'No file entered', 07, '$'
m5_Badmem Db 'Unable to release memory. Error: '
m5_Memerr Dw 0
Db 7, '$'
m5_Badcal1 Db 'Unable to execute program $'
m5_Badcal2 Db ' Error: '
m5_Callerr Dw 0
Db 7, '$'
m5_Prog Db 80 Dup(0)
m5_Comm1 Db 80 Dup(0)
m5_Fcb1 Db 40 Dup(0)
m5_Fcb2 Db 40 Dup(0)
m5_Stak Dw 0
Dw 0
m5_Signature Dw 01237h
m5_Another Dw 0
m5_Prog1 Db 80 Dup(0)
m5_Prog2 Db 80 Dup(0)
m5_Prog3 Db 80 Dup(0)
m5_Prog4 Db 80 Dup(0)
m5_Parm1 Dw 0
m5_Parm2 Dd 0
m5_Parm3 Dd 0
m5_Parm4 Dd 0
m5_Endprog Db 0
m5_Start:
pusha
push es
push ds
m5_P000:
Mov Ah, 30h
Int 21h
Cmp Al, 0
Jnz m5_P005
Mov Dx, Offset m5_Baddos
Call m5_P500
Jmp m5_P099
m5_P005:
Push Ds
Xor Ax, Ax
Mov Ds, Ax
Mov Si, 4F0h
Mov Ax, Offset m5_Another
Mov [Si], Ax
Add Si, 2
Mov Ax, Es
Mov [Si], Ax
Pop Ds
m5_P010:
Mov Si, 80h
m5_P015:
Mov Al, [Si]
Cmp Al, 0
Jmp m5_Main
Mov Dx, Offset m5_Nocomm
Call m5_P500
Jmp m5_P099
m5_P020:
Mov Ch, 0
Mov Cl, Al
Inc Si
Mov Al, [Si]
Cmp Al, ' '
Jnz m5_P021
Inc Si
Dec Cl
m5_P021:
Push Cx
Mov Al, 0
Mov Cx, Offset m5_Stak
Mov Di, Offset m5_Prog
Sub Cx, Di
Repnz Stosb
Pop Cx
Mov Di, Offset m5_Prog
m5_P022:
Mov Al, [Si]
Cmp Al, ' '
Jz m5_P025
Cmp Al, '/'
Jz m5_P025
Mov [Di], Al
Inc Si
Inc Di
Loop m5_P022
m5_Main:
Push Si
Push Di
Push Ax
Mov Si, Offset FileToExec
Mov Di, Offset m5_Prog
m5_@D:
Mov Ah, [Si]
Cmp Ah, 0
Je m5_@Ms
Mov [Di], Ah
Inc Si
Inc Di
Jmp m5_@D
m5_@Ms:
Mov Byte Ptr [Di], 0
Pop Ax
Pop Di
Pop Si
m5_P025:
Push Si
Mov Di, Offset m5_Comm1
Mov [Di], Cl
Inc Di
Repnz Movsb
Mov Al, 0Dh
Mov [Di], Al
Pop Si
Mov Di, Offset m5_Fcb1
Mov Ah, 29h
Mov Al, 1
Int 21h
Mov Di, Offset m5_Fcb2
Mov Ah, 29h
Mov Al, 1
Int 21h
m5_P040:
Mov Bx, 4096
Mov Ah, 4Ah
Int 21h
Jnc m5_P050
Aam
Add Ax, 3030h
Xchg Ah, Al
Mov Si, Offset m5_Memerr
Mov [Si], Ax
Mov Dx, Offset m5_Badmem
Call m5_P500
Jmp m5_P099
m5_P050:
Mov Si, Offset m5_Parm2
Mov Dx, Offset m5_Comm1
Mov [Si], Dx
Mov Ax, Ds
Mov [Si+2], Ax
m5_P060:
Mov Si, Offset m5_Parm3
Mov Dx, Offset m5_Fcb1
Mov [Si], Dx
Mov Ax, Ds
Mov [Si+2], Ax
Mov Si, Offset m5_Parm4
Mov Dx, Offset m5_Fcb2
Mov [Si], Dx
Mov Ax, Ds
Mov [Si+2], Ax
m5_P070:
Mov Si, Offset m5_Stak
Mov [Si], Sp
Mov [Si+2], Ss
Mov Ah, 4Bh
Mov Al, 0
Mov Dx, Offset m5_Prog
Mov Bx, Offset m5_Parm1
Int 21h
Mov Bx, Cs
Mov Ds, Bx
Mov Es, Bx
Mov Si, Offset m5_Stak
Cli
Mov Sp, [Si]
Mov Ss, [Si+2]
Sti
Jnc m5_P080
Aam
Add Ax, 3030h
Xchg Ah, Al
Mov Si, Offset m5_Callerr
Mov [Si], Ax
Mov Dx, Offset m5_Badcal1
Call m5_P500
Mov Si, Offset m5_Comm1
Mov Al, '$'
Mov [Si], Al
Mov Dx, Offset m5_Prog
Call m5_P500
Mov Dx, Offset m5_Badcal2
Call m5_P500
Jmp m5_P099
m5_P080:
Mov Si, Offset m5_Another
Mov Cx, [Si]
Jcxz m5_P099
Dec Cx
Mov [Si], Cx
Mov Si, Offset m5_Prog1
Mov Ax, 80
Mul Cx
Add Si, Ax
Jmp m5_P015
m5_P099:
Push Ds
Xor Ax, Ax
Mov Ds, Ax
Mov Si, 4F0h
Mov [Si], Ax
Add Si, 2
Mov [Si], Ax
Pop Ds
pop ds
pop es
popa
ret
; Int 20h
;End m5_Entry
;End.