<s>
An	O
instruction	B-Application
set	I-Application
simulator	I-Application
(	O
ISS	O
)	O
is	O
a	O
simulation	O
model	O
,	O
usually	O
coded	O
in	O
a	O
high-level	B-Language
programming	I-Language
language	I-Language
,	O
which	O
mimics	O
the	O
behavior	O
of	O
a	O
mainframe	O
or	O
microprocessor	B-Architecture
by	O
"	O
reading	O
"	O
instructions	O
and	O
maintaining	O
internal	O
variables	O
which	O
represent	O
the	O
processor	O
's	O
registers	B-General_Concept
.	O
</s>
<s>
To	O
simulate	O
the	O
machine	B-Language
code	I-Language
of	O
another	O
hardware	O
device	O
or	O
entire	O
computer	O
for	O
upward	O
compatibility	B-Application
—	O
a	O
full	B-Application
system	I-Application
simulator	I-Application
typically	O
includes	O
an	O
instruction	B-Application
set	I-Application
simulator	I-Application
.	O
</s>
<s>
For	O
example	O
,	O
the	O
IBM	B-Device
1401	I-Device
was	O
simulated	O
on	O
the	O
later	O
IBM/360	B-Application
through	O
use	O
of	O
microcode	B-Device
emulation	B-Application
.	O
</s>
<s>
To	O
monitor	O
and	O
execute	O
the	O
machine	B-Language
code	I-Language
instructions	O
(	O
but	O
treated	O
as	O
an	O
input	O
stream	O
)	O
on	O
the	O
same	O
hardware	O
for	O
test	O
and	O
debugging	O
purposes	O
,	O
e.g.	O
</s>
<s>
with	O
memory	B-General_Concept
protection	I-General_Concept
(	O
which	O
protects	O
against	O
accidental	O
or	O
deliberate	O
buffer	B-General_Concept
overflow	I-General_Concept
)	O
.	O
</s>
<s>
To	O
improve	O
the	O
speed	O
performance	O
—	O
compared	O
to	O
a	O
slower	O
cycle-accurate	B-Application
simulator	I-Application
—	O
of	O
simulations	O
involving	O
a	O
processor	O
core	O
where	O
the	O
processor	O
itself	O
is	O
not	O
one	O
of	O
the	O
elements	O
being	O
verified	O
;	O
in	O
hardware	O
description	O
language	O
design	O
using	O
Verilog	B-Language
where	O
simulation	O
with	O
tools	O
like	O
ISS	O
can	O
be	O
run	O
faster	O
by	O
means	O
of	O
"	O
PLI	O
"	O
(	O
not	O
to	O
be	O
confused	O
with	O
PL/1	B-Language
,	O
which	O
is	O
a	O
programming	O
language	O
)	O
.	O
</s>
<s>
An	O
ISS	O
is	O
often	O
provided	O
with	O
(	O
or	O
is	O
itself	O
)	O
a	O
debugger	B-Application
in	O
order	O
for	O
a	O
software	O
engineer/programmer	O
to	O
debug	O
the	O
program	O
prior	O
to	O
obtaining	O
target	O
hardware	O
.	O
</s>
<s>
GDB	B-Language
is	O
one	O
debugger	B-Application
which	O
has	O
a	O
compiled-in	O
ISS	O
.	O
</s>
<s>
It	O
is	O
sometimes	O
integrated	O
with	O
simulated	O
peripheral	O
circuits	O
such	O
as	O
timers	O
,	O
interrupts	B-Application
,	O
serial	B-Protocol
ports	I-Protocol
,	O
general	O
I/O	B-Architecture
ports	I-Architecture
,	O
etc	O
.	O
</s>
<s>
to	O
mimic	O
the	O
behavior	O
of	O
a	O
microcontroller	B-Architecture
.	O
</s>
<s>
Instead	O
,	O
the	O
entry	B-Language
point	I-Language
within	O
the	O
loaded	O
program	O
is	O
calculated	O
,	O
and	O
a	O
pseudo	O
program	B-Device
status	I-Device
word	I-Device
(	O
PSW	O
)	O
is	O
set	O
to	O
this	O
location	O
.	O
</s>
<s>
A	O
set	O
of	O
pseudo	O
registers	B-General_Concept
are	O
set	O
to	O
what	O
they	O
would	O
have	O
contained	O
if	O
the	O
program	O
had	O
been	O
given	O
control	O
directly	O
.	O
</s>
<s>
If	O
the	O
instruction	O
is	O
about	O
to	O
alter	O
memory	O
,	O
check	O
memory	O
destination	O
exists	O
(	O
for	O
this	O
thread	B-Operating_System
)	O
and	O
is	O
sufficiently	O
large	O
.	O
</s>
<s>
If	O
OK	O
,	O
load	O
appropriate	O
pseudo	O
registers	B-General_Concept
into	O
temporary	O
real	O
registers	B-General_Concept
,	O
perform	O
equivalent	O
move	O
with	O
the	O
real	O
registers	B-General_Concept
,	O
save	O
address	O
and	O
length	O
of	O
altered	O
storage	O
if	O
trace	O
is	O
"	O
on	O
"	O
and	O
go	O
to	O
4	O
.	O
</s>
<s>
If	O
the	O
instruction	O
is	O
a	O
"	O
register-to-register	O
"	O
operation	O
,	O
load	O
pseudo	O
registers	B-General_Concept
into	O
monitor	O
's	O
real	O
registers	B-General_Concept
,	O
perform	O
operation	O
,	O
store	O
back	O
to	O
respective	O
pseudo	O
registers	B-General_Concept
,	O
go	O
to	O
4	O
.	O
</s>
<s>
If	O
instruction	O
is	O
an	O
operating	O
system	O
call	O
,	O
do	O
real	O
call	O
from	O
monitoring	O
program	O
by	O
"	O
faking	O
"	O
addresses	O
to	O
return	O
control	O
to	O
monitor	O
program	O
and	O
then	O
reset	O
pseudo	O
registers	B-General_Concept
to	O
reflect	O
call	O
;	O
go	O
to	O
4	O
.	O
</s>
<s>
For	O
test	O
and	O
debugging	O
purposes	O
,	O
the	O
monitoring	O
program	O
can	O
provide	O
facilities	O
to	O
view	O
and	O
alter	O
registers	B-General_Concept
,	O
memory	O
,	O
and	O
restart	O
location	O
or	O
obtain	O
a	O
mini	O
core	B-Error_Name
dump	I-Error_Name
or	O
print	O
symbolic	O
program	O
names	O
with	O
current	O
data	O
values	O
.	O
</s>
<s>
A	O
very	O
good	O
example	O
from	O
the	O
IBM	B-Application
S/360	I-Application
world	O
is	O
the	O
following	O
instruction	O
sequence	O
that	O
can	O
cause	O
difficulties	O
debugging	O
without	O
an	O
instruction	O
simulation	O
monitor	O
.	O
</s>
<s>
*	O
all	O
registers	B-General_Concept
on	O
error	O
contain	O
nulls	O
.	O
</s>
<s>
For	O
testing	O
purposes	O
this	O
is	O
normally	O
quite	O
acceptable	O
as	O
powerful	O
debugging	O
capabilities	O
are	O
provided	O
including	O
instruction	B-General_Concept
step	I-General_Concept
,	O
trace	O
and	O
deliberate	O
jump	O
to	O
test	O
error	O
routine	O
(	O
when	O
no	O
actual	O
error	O
)	O
.	O
</s>
<s>
In	O
addition	O
,	O
a	O
full	O
instruction	O
trace	O
can	O
be	O
used	O
to	O
test	O
actual	O
(	O
executed	O
)	O
code	B-Application
coverage	I-Application
.	O
</s>
<s>
Re-entrancy	O
bugs	O
:	O
accidental	O
use	O
of	O
static	B-General_Concept
variables	I-General_Concept
instead	O
of	O
"	O
dynamic	O
"	O
thread	B-Operating_System
memory	O
can	O
cause	O
re-entrancy	O
problems	O
in	O
many	O
situations	O
.	O
</s>
<s>
Hot	O
spot	O
analysis	O
&	O
instruction	O
usage	O
by	O
counting	O
the	O
instructions	O
executed	O
during	O
simulation	O
(	O
which	O
will	O
match	O
the	O
number	O
executed	O
on	O
the	O
actual	O
processor	O
or	O
unmonitored	O
execution	O
)	O
,	O
the	O
simulator	O
can	O
provide	O
both	O
a	O
measure	O
of	O
relative	O
performance	O
between	O
different	O
versions	O
of	O
algorithm	O
and	O
also	O
be	O
used	O
to	O
detect	O
"	O
hot	O
spots	O
"	O
where	O
optimization	O
can	O
then	O
be	O
targeted	O
by	O
the	O
programmer	B-Application
.	O
</s>
<s>
In	O
this	O
role	O
it	O
can	O
be	O
considered	O
a	O
form	O
of	O
performance	O
analysis	O
as	O
it	O
is	O
not	O
easy	O
to	O
obtain	O
these	O
statistics	O
under	O
normal	O
execution	O
and	O
this	O
is	O
especially	O
true	O
for	O
high	B-Language
level	I-Language
language	I-Language
programs	O
which	O
effectively	O
'	O
disguise	O
 '	O
the	O
extent	O
of	O
machine	B-Language
code	I-Language
instructions	O
by	O
their	O
nature	O
.	O
</s>
<s>
In	O
the	O
first	O
volume	O
of	O
The	B-General_Concept
Art	I-General_Concept
of	I-General_Concept
Computer	I-General_Concept
Programming	I-General_Concept
,	O
Donald	O
Knuth	O
wrote	O
:	O
"	O
In	O
the	O
author	O
's	O
opinion	O
,	O
entirely	O
too	O
much	O
programmers	B-Application
 '	O
time	O
has	O
been	O
spent	O
in	O
writing	O
such	O
[	O
machine	O
language ]	O
simulators	O
and	O
entirely	O
too	O
much	O
computer	O
time	O
has	O
been	O
wasted	O
in	O
using	O
them.	O
"	O
</s>
