Académique Documents
Professionnel Documents
Culture Documents
Because the example loader does not need to perform such functions
as liking and program relocation, its operation is very simple. All
functions are accomplished in a single pass. The Header record is
checked to verify that the correct program has been presented for
loading. As each Text record is read, the object code it contains moved
to the indicated address in memory. When the End record is
encountered, the loader jumps to the specified address to begin
execution of the loaded program.
Each pair of bytes from the object program record must be packed
together into one byte during loading. Each printed character represents
one byte of the object program record. On the other hand, each printed
character represents one hexadecimal digit in memory (i.e., a halfbyte).
Most machine store object programs in a binary form, with each byte of
object code stored as a single byte in the object program.
Begin
read Header record
begin
{if object code is in character form, convert into
internal representation}
move object code to specified location in memory
end
jump to address specified in End record
end
Early computers (such as the PDP-1 through PDP-8 and early models of
the PDP-11) had a row of toggle switches on the front panel to allow the
operator to manually enter the binary boot instructions into memory
before transferring control to the CPU. The boot loader would then read
in either the second-stage boot loader (called Binary Loader of paper
tape with checksum), or the operating system from an outside storage
medium such as paper tape, punched card, or a disk drive.
· an alphabet (Σ)
· a start state (s S)
· an alphabet (Σ)
· a start state (s S)
Where P(S) is the power set of S and ε is the empty string. The
machine starts in the start state and reads in a string of symbols from its
alphabet. It uses the transition relation T to determine the next state(s)
using the current state and the symbol just read or the empty string. If,
when it has finished reading, it is in an accepting state, it is said to
accept the string, otherwise it is said to reject the string. The set of
strings it accepts form a language, which is the language the NFA
recognizes.
A DFA or NFA can easily be converted into a GNFA and then the
GNFA can be easily converted into a regular expression by reducing the
number of states until S = {s, a}.
M = (S, Σ, T, s, A)
· Σ = {0, 1}
· S = {S1, S2}
· s = S1
· A = {S1}
o T(S1, 0) = S2
o T(S1, 1) = S1
o T(S2, 0) = S1
o T(S2, 1) = S2
Simply put, the state S1 represents that there has been an even
number of 0s in the input so far, while S2 signifies an odd number. A 1 in
the input does not change the state of the automaton. When the input
ends, the state will show whether the input contained an even number of
0s or not.
There are two main methods for handling where to generate the
outputs for a finite state machine. They are called a Moore Machine and
a Mearly Machine, named after their respective authors.
· Hierarchical Task Analysis (HTA): though it does not look at states, HTA
is a task decomposition technique that looks at the way a task can be
split into subtasks, and the order in which they are performed [4]
Lexical Analysis
Syntax Analysis
The parser has two functions. It checks that the tokens appearing
in its input, which is the output of the lexical analyzer, occur in patterns
that are permitted by the specification for the source language. It also
imposes on the tokens a tree-like structure that is used by the
subsequent phases of the compiler.
Three-Address Code
A: = B op C
Code Optimization
· Local Optimization
· Loop Optimization
Code Generation
LOAD B
ADD C
STORE A
As all static memory allocations have sizes and address offsets that
are known at compile-time and are explicitly initialised, there is very
little that can go wrong with them. Data can be read or written past the
end of such variables, but that is a common problem with all memory
allocations and is generally easy to locate in that case. On systems that
separate read-only data from normal data, writing to a read-only variable
can be quickly diagnosed at run-time.
Compiler
Compiler Backend
1. Scanning – breaking the source code text into small pieces, tokens –
sometimes called ‘terminals’ – each representing a single piece of the
language, for instance a keyword, identifier or symbol names. The token
language is typically a regular language, so a finite state automaton
constructed from a regular expression can be used to recognize it.
B) Editors
· HTML editor
· text editor
· graphics editor
C) Debuggers
When the program crashes, the debugger shows the position in the
original code if it is a source-level debugger or symbolic debugger,
commonly seen in integrated development environments. If it is a low-
level debugger or a machine-language debugger it shows the line in
the disassembly. (A "crash" happens when the program cannot continue
because of a programming bug. For example, perhaps the program tried
to use an instruction not available on the current version of the CPU or
attempted access to unavailable or protected memory.)
List of Debuggers
· CodeView
· DAEDALUS
· dbx
· DDD, Data Display Debugger
· Eclipse
D) Interpreter