11 while(*ptr
== ' ') ptr
++;
12 if( (fname
=ptr
) == 0 ) return 0;
13 while(*ptr
& *ptr
!= ' ') ptr
++;
15 if( open_file(fname
) >= 0 ) for(len
=file_length(); len
>0; len
-=1024)
17 if( read_block(buffer
) < 0 ) break;
19 write(1, buffer
, 1024);
21 write(1, buffer
, len
);
24 printf("Cannot open file '%s'\n", fname
);
30 extern unsigned int current_address
;
31 extern int number_base
;
61 while(*ptr
== ' ') ptr
++;
62 if( (fname
=ptr
) == 0 ) return 0;
63 while(*ptr
& *ptr
!= ' ') ptr
++;
67 if( open_file(fname
) >= 0 ) for(len
=file_length(); len
>0; len
-=1024)
69 if( read_block(buffer
) < 0 ) break;
70 if( len
> 1024 ) cc
= 1024; else cc
= len
;
71 for(sptr
=buffer
; cc
>0 ; cc
--,sptr
++)
73 if( more_char(*sptr
& 0xFF) < 0 ) goto break_break
;
77 printf("Cannot open file '%s'\n", fname
);
86 static int line_number
= 0;
88 if( ch
== -1 ) { line_number
= 0; return 0; }
90 if( (ch
& 0xE0 ) || ch
== '\n' )
92 if( ch
== '\n' && ++line_number
== 24)
95 printf("More ?"); fflush(stdout
);
96 if( read(0, buf
, 1) <= 0 ) return -1;
97 if( buf
[0] == 3 || buf
[0] == '\033'
98 || buf
[0] == 'q' || buf
[0] == 'Q' ) return -1;
99 if( buf
[0] == '\r' ) line_number
--;
100 if( buf
[0] == ' ' ) line_number
=2;
110 for(; len
>0 && *str
; len
--,str
++)
111 if( more_char( *str
& 0xFF ) < 0 ) return -1;
116 /**************************************************************************/
121 static char * helps
[] = {
123 "zimage filename [args] Start Linux-386\n",
124 "bzimage filename [args] Start Linux-386\n",
125 "=filename [args] Start Linux-386\n",
127 "help Display help file\n",
128 "dir Display directory\n",
129 "type Display file to screen\n",
130 "more Display file to screen\n",
131 "m[em] [address] Hexdump memory\n",
132 "seg [val] Set/show default segment\n",
133 "rel [segment] Relocate this program\n",
134 "base [val] Set default number base (or 'n' cmd)\n",
135 "init Re-init program\n",
136 "r[egs] Display register values\n",
144 if( more_strn(*p
, strlen(*p
)) <0 )
154 #ifdef __STANDALONE__
155 printf(": AX=%04x BX=%04x CX=%04x DX=%04x SI=%04x DI=%04x",
156 __argr
.x
.ax
, __argr
.x
.bx
, __argr
.x
.cx
, __argr
.x
.dx
,
157 __argr
.x
.si
, __argr
.x
.di
);
158 printf(" CF=%x", __argr
.x
.cflag
);
159 printf(" CS=%04x DS=%04x ES=%04x\n", __get_cs(), __get_ds(), __get_es());
161 printf("Only in standalone\n");
172 #define rmem(x) __peek_es( (x)+current_address )
174 getnum(&ptr
, ¤t_address
);
175 getnum(&ptr
, &count
);
177 for(i
=0; i
<count
; i
+=16)
179 printf("%04x:%04x:", es
, current_address
);
181 printf(" %s%02x", (j
==8)?" ":"", rmem(j
));
184 if( rmem(j
) >= ' ' && rmem(j
) <= '~' )
189 current_address
+= 16;
190 current_address
&= 0xFFFF;
201 if( getnum(&ptr
, &es
) )
207 printf("Current segment 0x%04x\n", es
);
211 int cmd_set_base(ptr
)
213 int obase
= number_base
;
217 if( getnum(&ptr
, &nbase
) )
219 if( nbase
< 2 || nbase
> 36 )
220 printf("Can't use that base\n");
224 else printf("Current base is %d\n", obase
);
239 if( __get_cs() == cs
)
240 printf("Didn't relocate; CS=$%04x DS=$%04x\n", __get_cs(), __get_ds());
242 printf("Relocated to CS=$%04x DS=$%04x\n", __get_cs(), __get_ds());