0% found this document useful (0 votes)
43 views

CAM4 System Software

The document discusses system software, specifically assemblers and compilers. It defines an assembler as a software that converts assembly language code to machine code by taking basic computer commands and converting them to binary code. A compiler takes source code as a whole and translates it directly into object code in one pass through multiple steps, including preprocessing, compiling, assembling, and linking to produce an executable file. Assembly language is closer to machine language but more readable by humans, using mnemonics to represent instructions.

Uploaded by

namitha r
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views

CAM4 System Software

The document discusses system software, specifically assemblers and compilers. It defines an assembler as a software that converts assembly language code to machine code by taking basic computer commands and converting them to binary code. A compiler takes source code as a whole and translates it directly into object code in one pass through multiple steps, including preprocessing, compiling, assembling, and linking to produce an executable file. Assembly language is closer to machine language but more readable by humans, using mnemonics to represent instructions.

Uploaded by

namitha r
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 54

SYSTEM SOFTWARE

ASSEMBLER
Assembler

• Assembler is a Software that converts an assembly


language code to machine code

• It takes basic computer commands and converts


them into binary bode that computer’s processor
can use to perform its basic operations

• These instructions are written in assembly


language.
Assembly language
•  assembly language is a low-level language.

• It gives instructions to the processors for different tasks.

• The machine language only consists of 0s and 1s


therefore, it is difficult to write a program in it.

• On the other hand, the assembly language is close to a


machine language but has a simpler language and code.
• It is specific for any processor.

• there is a one-to-one correspondence between


many simple assembly statements and machine
language instructions.

• Each computer architecture has its own machine
language. Computers differ in the number and type
of operations they support, in the different sizes
and numbers of registers, and in the
representations of data in storage.

• While most general-purpose computers are able to


carry out essentially the same functionality, the
ways they do so differ; the corresponding assembly
languages reflect these differences.
•  assembly language is uses opcode for the instructions.

• An opcode basically gives information about the particular


instruction.

• The symbolic representation of the opcode (machine level


instruction) is called mnemonics.

• Programmers use them to remember the operations in


assembly language.

For example ADD A,B


• Here, ADD is the mnemonic that tells the processor that it has
to perform addition function. Moreover, A and B are the
operands. Also, SUBB, MUL, DIV, etc. are other mnemonics
used in 8051 microcontroller.
Types of Assembler
• two types of assemblers- based on how many passes through
the source are needed (how many times the assembler reads
the source) to produce the object file.

• One-pass assemblers process the source code once. For


symbols used before they are defined, the assembler will emit 
"errata" after the eventual definition, telling the linker or the
loader to patch the locations where the as yet undefined
symbols had been used.

• Multi-pass assemblers create a table with all symbols and


their values in the first passes, then use the table in later
passes to generate code.
• In both cases, the assembler must be able to
determine the size of each instruction on the
initial passes in order to calculate the
addresses of subsequent symbols.

• The original reason for the use of one-pass


assemblers was memory size and speed of
assembly – often a second pass would require
storing the symbol table in memory (to
handle forward references), rewinding and
rereading the program source.
• Later computers with much larger memories
(especially disc storage), had the space to
perform all necessary processing without such
re-reading.

• The advantage of the multi-pass assembler is


that the absence of errata makes the linking
process (or the program load if the assembler
directly produces executable code) faster.
S1 B FWD
.
.
FWD EQU *
.
.
BKWD EQU * .
.
.
S2 B BKWD
• Here, a one-pass assembler would be able to
determine the address of the backward
reference BKWD when assembling
statement S2, but would not be able to
determine the address of the forward
reference FWD when assembling the branch
statement S1;

• FWD may be undefined.

• A two-pass assembler would determine both


addresses in pass 1, so they would be known
when generating code in pass 2.
•  Assembly language instructions usually consist of
an opcode mnemonic followed by an operand, which
might be a list of data, arguments or parameters.  

• Some instructions may be "implied," which means


the data upon which the instruction operates is
implicitly defined by the instruction itself—such an
instruction does not take an operand.

• The resulting statement is translated by


an assembler into machine language instructions
that can be loaded into memory and executed.
• In some assembly languages (eg:8051) the same mnemonic,
such as MOV, may be used for a family of related instructions
for loading, copying and moving data, whether these are
immediate values, values in registers, or memory locations
pointed to by values in registers or by immediate (a.k.a. direct)
addresses.

• Other assemblers may use separate opcode mnemonics such


as L for "move memory to register", ST for "move register to
memory", LR for "move register to register", MVI for "move
immediate operand to memory", etc.

• If the same mnemonic is used for different instructions, that


means that the mnemonic corresponds to several different
binary instruction codes, excluding data depending on the
operands that follow the mnemonic.
• In a case like this where the same mnemonic can
represent more than one binary instruction, the
assembler determines which instruction to generate
by examining the operands.

• Assembly languages are always designed so that


this sort of unambiguousness is universally enforced
by their syntax.

• Eg: In 8051, immediate data begins with #


COMPILER
Compilers

• A compiler takes the source code as a whole


and translates it into object code all in one go.
Once converted, the object code can be run at
any time. This process is called compilation.

• All of the object files used in a program must


be combined before the program can be run.
This is done using a linker tool, which takes
one or more objects and groups them into a
single executable or a library.
Compilers have several advantages:

• Compiled programs run quickly since they have


already been translated.

• A compiled program can be supplied as an


executable file. An executable file is a file that is
ready to run. Since an executable file cannot be
easily modified, programmers prefer to supply
executables rather than source code.
Compilers have several disadvantages:

• Because the source code is translated as a whole, there must


be enough memory space to hold the source code, the
compiler and the generated object code.

• There also needs to be temporary working space for the


compiler to perform the translation. Modern systems either
have enough memory or use virtual memory to hold all the
data.

• Compilers do not usually spot errors - the program has to be


compiled and run before errors are encountered. This makes it
harder to see where the errors lie.
• The source code must be recompiled every
time the programmer changes the program.

• Source code compiled on one platform will not


run on another - the object code is specific to
the processor's architecture.
• The compilation process transforms a human-
readable code into a machine-readable format.

• Eg: For C programming language, it happens


before a program starts executing to check the
syntax and semantics of the code.

• The compilation process in C involves four


steps: pre-processing, compiling,
assembling, and linking then, we run the
obtained executable file to get an output on
the screen.
• Pre-processing is the first step in the compilation
process in C performed using the pre-processor
tool (A pre-written program invoked by the
system during the compilation).

• All the statements starting with the # symbol in


a C program are processed by the pre-processor,
and it converts our program file into an
intermediate file with no # statements.
following pre-processing tasks are performed

Comments Removal
• Comments in a C Program are used to give a
general idea about a particular statement or part
of code

• comments are the part of code that is removed


during the compilation process by the pre-
processor as they are not of particular use for
the machine.
Macros Expansion
• Macros are some constant values or expressions defined
using the #define directives in C Language.

• A macro call leads to the macro expansion. The pre-


processor creates an intermediate file where some pre-
written assembly level instructions replace the defined
expressions or constants (basically matching tokens).

• To differentiate between the original instructions and


the assembly instructions resulting from the macros
expansion, a '+' sign is added to every macros expanded
statement.
File inclusion
• File inclusion in C language is the addition of
another file containing some pre-written code into C
Program being compiled during the pre-processing.

• It is done using the #include directive. File inclusion during


pre-processing causes the entire content of filename to be
added to the source code, replacing
the #include<filename> directive, creating a new
intermediate file.

• Example: If we have to use basic input/output functions


like printf() and scanf() in C program, we have to include a
pre-defined standard input output header file i.e. stdio.h.
•  compiler software to convert the intermediate
(.i) file into an Assembly file (.s) having assembly
level instructions (low-level code).

•  The whole program code is parsed (syntax


analysis) by the compiler software in one go,
and it tells us about any syntax
errors or warnings present in the source code
through the terminal window.
• Assembly level code (.s file) is converted into a
machine-understandable code (in
binary/hexadecimal form) using an assembler.

• Assembler is a pre-written program that translates


assembly code into machine code. It takes basic
instructions from an assembly code file and converts
them into binary/hexadecimal code specific to the
machine type known as the object code.

• The file generated has the same name as the


assembly file and is known as an object file with an
extension of .obj in DOS and .o in UNIX OS.
INTERPRETER
interpreter
• An interpreter translates source code into object
code one instruction at a time.

• It is similar to a human translator translating what a


person says into another language, sentence by
sentence.

• The resulting object code is then executed


immediately.

• The process is called interpretation.


Interpreters have several advantages:

• Instructions are executed as soon as they are translated.

• Since instructions are executed once translated, they are


not stored for later use. As a result, interpreters require
less available memory.

• Errors can be spotted quickly. Once an error is found, the


program stops running and the user is notified at which
part of the program the interpretation has failed. This
makes interpreters extremely useful when developing
programs.
Interpreters also have several disadvantages:

• Interpreted programs run more slowly. The processor has to wait


for each instruction to be translated before it can be executed.

• Additionally, the program has to be translated every time it is run.

• Interpreters do not produce an executable file that can be


distributed. As a result, the source code program has to be
supplied and this could be modified without permission.

• Interpreters do not optimise code - the translated code is


executed as it is.
LINKER
• Linking is a process of including the library
files into program. 

• Library Files are some predefined files that


contain the definition of the functions in the
machine language and these files have an
extension of .lib.

• Some unknown statements are written in the


object (.o/.obj) file that operating system
can't understand.
• Similar to how you will use a dictionary to find the
meaning of those words You cannot understand
while reading a book

• Similarly, we use Library Files to give meaning to


some unknown statements from our object file. The
linking process generates an executable file with an
extension of .exe in DOS and .out in UNIX OS.
LOADER
• A loader is a piece of software that is
responsible for loading executable files into
memory to enable the central processing unit
(CPU) to run them.

• It calculates the size of a program and


dedicates enough memory space for it to run
efficiently.
• Loading a program involves either memory-
mapping or copying the contents of
the executable file containing the program
instructions into memory, and then carrying
out other required preparatory tasks to
prepare the executable for running.
• Once loading is complete, the operating
system starts the program by passing control
to the loaded program code.

• In many operating systems, the loader resides


permanently in memory, though some
operating systems that support virtual
memory may allow the loader to be located in
a region of memory that is pageable.
• In the case of operating systems that support
virtual memory, the loader may not actually
copy the contents of executable files into
memory

• It may simply declare to the virtual memory


subsystem that there is a mapping between a
region of memory allocated to contain the
running program's code and the contents of
the associated executable file.
• The virtual memory subsystem is then made
aware that pages with that region of memory
need to be filled on demand if and when
program execution actually hits those areas of
unfilled memory.

• This may mean parts of a program's code are


not actually copied into memory until they are
actually used, and unused code may never be
loaded into memory at all.
DEBUGGER
• A debugger or debugging tool  is a computer
program used by programmers to test and find
bugs (errors) in a target program and debug it.

• The main use of a debugger is to run the target


program under controlled conditions that permit
the programmer to track its execution and
monitor changes in computer resources that may
indicate malfunctioning code.
• Typical debugging facilities include the ability to
run or halt the target program at specific points,
display the contents of memory, CPU registers or
storage devices (such as disk drives), and modify
memory or register contents in order to enter
selected test data that might be a cause of faulty
program execution.
• The code to be examined might alternatively be
running on an instruction set simulator (ISS), a
technique that allows great power in its ability to
halt when specific conditions are encountered,
but which will typically be somewhat slower than
executing the code directly on the appropriate
(or the same) processor.

• Some debuggers offer two modes of operation,


full or partial simulation, to limit this impact.
• Debuggers offer more sophisticated functions such as
running a program step by step (single-
stepping or program animation), stopping (breaking)
(pausing the program to examine the current state)
at some event or specified instruction by means of
a breakpoint, and tracking the values of variables. 

• Some debuggers have the ability to modify program


state while it is running.

• It may also be possible to continue execution at a


different location in the program to bypass a crash or
logical error.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy