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

SPCC Cheat

The document discusses various topics related to assembly language programming: 1. The two passes of an assembler - Pass 1 deals with syntax errors, undefined symbols, duplicate labels, etc. Pass 2 generates machine code and resolves symbolic addresses, catching errors like forward referencing. 2. Common types of assembler statements - Instruction statements contain mnemonic instructions. Directive statements provide assembler instructions. Label statements mark locations. Macro statements define reusable code snippets. 3. Features of macros - Code reusability, compile-time evaluation, conditional compilation, arbitrary code expansion, and stringification capabilities.

Uploaded by

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

SPCC Cheat

The document discusses various topics related to assembly language programming: 1. The two passes of an assembler - Pass 1 deals with syntax errors, undefined symbols, duplicate labels, etc. Pass 2 generates machine code and resolves symbolic addresses, catching errors like forward referencing. 2. Common types of assembler statements - Instruction statements contain mnemonic instructions. Directive statements provide assembler instructions. Label statements mark locations. Macro statements define reusable code snippets. 3. Features of macros - Code reusability, compile-time evaluation, conditional compilation, arbitrary code expansion, and stringification capabilities.

Uploaded by

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

Enlist the differnt types of errors that are handle by pass 1 and pass2 of assembler.

Write short note on **Assembler**: - An assembler is a program that translates assembly language code into Explain two - pass macro processor
In assembly language programming, the assembler typically consists of two passes: pass 1 and pass 2. Each pass machine code. - It converts mnemonic instructions and symbolic labels into binary instructions and memory with a flowchart.
serves different purposes and handles different types of errors: Pass 1 primarily deals with generating a symbol addresses. - The output of an assembler is typically an object file or executable directly executable by the Two pass translation
table and detecting errors related to the assembly process itself, such as: 1. **Syntax Errors**: Incorrect syntax computer's processor. 2. **Macro Processor**: - A macro processor is a program used in assembly language • Two pass translations consist of pass
in the source code, such as missing or misplaced punctuation, incorrect operand formats, etc. 2. **Undefined programming to generate repetitive code sequences. - It allows programmers to define macros, which are I and pass II. • Generally, LC
Symbols**: Symbols used in the code that are not defined anywhere in the source or library files. 3. **Duplicate shorthand notations for commonly used code patterns. - Macros are expanded by the macro processor into their processing performed in the first pass
Labels**: Multiple definitions of the same label within the same scope. 4. **Illegal Instructions**: Instructions respective code sequences before being processed by the assembler. 3. **Loader**: - A loader is a program and symbols defined in the program
that are not recognized by the assembler or are not allowed in the given assembly language. 5. **Illegal that loads executable programs into memory for execution. - It takes the object code generated by the assembler entered into the symbol table, hence
Operands**: Incorrect usage or type of operands for instructions. 6. **Expression Evaluation Errors**: Errors in or compiler and loads it into memory, resolving any external references. - The loader prepares the program for first pass performs analysis of the
evaluating expressions, such as arithmetic errors or invalid expressions. 7. **Overflow or Underflow**: execution by setting up memory addresses and initializing program variables. 4. **Linker**: - A linker is a source program. • So, two pass
Calculations that result in values outside the acceptable range, typically related to memory addresses or constant program that combines multiple object files and libraries into a single executable program. - It resolves translation of assembly lang. the
values.Pass 2 involves generating the machine code and resolving symbolic addresses. Errors detected in this references between different object files, ensuring that all symbols used in the program are defined and linked program can handle forward reference
phase include: 1. **Forward Referencing Errors**: When a label is referenced before its definition. 2. correctly. - The linker generates the final executable by merging the object files and libraries and assigning easily. • The second pass synthesizes
**Addressing Errors**: Incorrect calculation of addresses, resulting in incorrect memory access. 3. **Operand memory addresses to their constituent parts. 5. **Compiler**: - A compiler is a program that translates source the target form using the address
Mismatch**: Mismatch between the declared and actual number or types of operands. 4. **Memory Access code written in a high-level programming language into machine code or intermediate code. - It performs lexical information found in the symbol table.
Violations**: Attempts to access memory locations that are not allowed or do not exist. 5. **Linking Errors**: analysis, syntax analysis, semantic analysis, optimization, and code generation. - The output of a compiler is • Moreover, The first pass constructs
Errors in linking object modules or libraries, such as unresolved external references. These errors are typically an object file or executable that can be executed directly by the computer. 6. **Interpreter**: - An an intermediate representation of the
crucial to detect and handle during the assembly process to ensure the correctness and reliability of the resulting interpreter is a program that reads and executes source code line by line without translating it into machine code source program and that will be used
machine code. Proper error handling and reporting mechanisms are essential for debugging and troubleshooting beforehand. - It interprets each instruction or statement and executes it directly, typically without producing an by the second pass. • IR consists of two
assembly programs. intermediate executable. - Interpreters are often used in scripting languages and for rapid prototyping, offering main components: data structure + IC
ease of use and flexibility at the cost of execution speed. (intermediate code)
Explain macro and macro expansion, Different features of macros with examples. Single-pass translation • Similarly, A
Macro: A macro is a rule or pattern that specifies how a certain input sequence (the macro call) should be Explain different type of statements used in assemblers with respect to system programming one-pass assembler requires 1 scan of
transformed into an output sequence (the macro expansion). Macros are typically defined using a special syntax Instruction Statements: Instruction statements are the core of assembly language programming. They represent the source program to generate
provided by the programming language. In C and C++, macros are defined using the #define preprocessor the actual machine instructions to be executed by the processor. These statements include mnemonic instructions machine code. • Moreover, The
directive Macro Expansion: Macro expansion refers to the process of replacing macro calls in the code with like MOV, ADD, SUB, JMP, etc., which correspond to specific machine instructions. Instruction statements may process of forwarding references
their corresponding definitions. This process is typically performed by the preprocessor before the actual also include operands, such as registers, memory addresses, constants, or labels. Directive Statements: Directive talked using a process called back
compilation of the code. During expansion, the macro arguments are substituted into the macro body according statements provide instructions to the assembler rather than the CPU. They are used to define data, reserve patching. The operand field of an
to the rules defined in the macro definition. Features of Macros:Code Reusability: Macros allow developers to memory, set assembly options, or control the flow of assembly process. Examples of directive statements include instruction containing forward
define reusable code snippets, reducing redundancy and improving code maintainability.Compile-time DATA, ORG (origin), DB (define byte), DW (define word), DS (reserve storage), EQU (equivalent), etc. Label references left blank initially.
Evaluation: Macros are evaluated at compile time, which can lead to performance improvements compared to Statements: Labels are symbolic names given to memory locations or code segments within the program. They
runtime function calls. Conditional Compilation: Macros can be used for conditional compilation, allowing are typically used to mark the beginning of code sections, data sections, or specific memory addresses. Labels are
developers to include or exclude certain sections of code based on compile-time conditions. Arbitrary Code referenced by instruction statements to provide branching, looping, or data manipulation capabilities. Macro Explain direct linking loader in detaIL
Expansion: Macros are not limited to simple substitutions; they can contain arbitrarily complex code, including Statements: Macros are reusable code snippets defined by the programmer to simplify repetitive tasks. They are 1. **Linking Process**: During the compilation and linking process of a program, the direct linking loader
control flow statements and multiple expressions. Stringification: Macros can convert identifiers into strings expanded by the assembler whenever they are called in the code. Macros can include sequences of instructions, resolves external references to functions or resources from libraries by incorporating the necessary object code
using the # operator, allowing developers to generate string literals from macro arguments. labels, and directives. Comment Statements: Comments are non-executable statements used for documentation directly into the executable file. The linker collects object files generated from source code and resolves
Compiler Interpreter purposes. They provide human-readable explanations or annotations within the code. Comments are ignored by references to symbols defined in external libraries. 2. **Library Inclusion**: In direct linking, the object code
The compiler saves the Machine Language in form of The Interpreter does not save the Machine Language. the assembler during the translation process. from external libraries is physically copied into the executable file. This means that the resulting executable
Machine Code on disks. contains all the code necessary for the program to run, including the code from the external libraries. As a result,
Compiled codes run faster than Interpreter. Interpreted codes run slower than Compiler. Define loader and function the executable file becomes self-contained and does not rely on external libraries during runtime. 3. **Symbol
Linking-Loading Model is the basic working model of The Interpretation Model is the basic working model of 1. Loader: In computer science, a loader is a program or utility that loads other programs (typically executable Resolution**: The direct linking loader resolves external symbols by incorporating the addresses of these
the Compiler. the Interpreter. files) into memory for execution. Loaders are an essential part of the process of running software on a computer symbols directly into the executable file. This process involves updating the symbol tables and relocation
The compiler generates an output in the form of (.exe). The interpreter does not generate any output. system. They are responsible for tasks such as resolving references to external libraries, allocating memory for information within the executable file to reflect the memory addresses of the resolved symbols. 4. **No Dynamic
Errors are displayed in Compiler after Compiling Errors are displayed in every single line. the program, and initializing its execution environment. Loaders are commonly used in operating systems to Linking Overhead**: Since all required libraries are included in the executable file, there is no need for dynamic
together at the current time. launch applications and manage their execution. linking at runtime. This eliminates the overhead associated with dynamic linking, such as searching for libraries,
It does not require source code for later execution. It requires source code for later execution. 2. Function: In computer science and programming, a function is a self-contained block of code that performs a resolving symbols, and loading libraries into memory. 5. **Faster Startup Time**: Directly linked executables
Compilers more often take a large amount of time for In comparison, Interpreters take less time for analyzing specific task or computation. Functions are used to organize code into manageable and reusable units, promoting typically have faster startup times compared to dynamically linked executables because there is no need to load
analyzing the source code. the source code. modularity and code reusability. They typically accept inputs (parameters or arguments), perform operations on external libraries at runtime. The entire program, including all its dependencies, is loaded into memory in a single
CPU utilization is more in the case of a Compiler. CPU utilization is less in the case of a Interpreter. these inputs, and optionally return a result. Functions can be invoked or called from other parts of a program operation, resulting in quicker program initialization. 6. **Reduced Dependency Management**: Direct
The use of Compilers mostly happens in Production The use of Interpreters is mostly in Programming and whenever their functionality is needed. In many programming languages, functions are fundamental constructs linking simplifies dependency management because the executable file contains all the necessary code and
Environment. Development Environments. for structuring and implementing algorithms and applications. They provide a way to break down complex resources. There is no need to ensure that the required libraries are present on the target system or worry about
Object code is permanently saved for future use. No object code is saved for future use. problems into smaller, more manageable tasks, making code more readable, maintainable, and efficient. version compatibility issues. 7. **Code Duplication**: One drawback of direct linking is code duplication. If
C, C++, C#, etc are programming languages that are Python, Ruby, Perl, SNOBOL, MATLAB, etc are multiple executables include the same library, each executable will contain its own copy of the library code. This
compiler-based. programming languages that are interpreter-based. can lead to increased disk space usage and memory consumption. 8. **Static Libraries vs. Dynamic
Libraries**: Direct linking is commonly associated with static libraries

Explain dynamic linking loader in detail Explain the working of single pass macro with neat flowchat ? Explain Different Features of Macros With Suitable examples
Dynamic linking loader, also known as dynamic linker or dynamic loader, is a component of an operating system Read a line from the source code: Macros are a powerful feature available in many programming languages, allowing developers to define reusable
responsible for loading shared libraries into a running process at runtime. Dynamic linking allows multiple The processor starts by reading a code snippets or macros. They offer several features that enhance code readability, maintainability, and
programs to share common code and resources, reducing memory usage and facilitating code maintenance and line of code from the source file or efficiency. Here are some key features of macros with suitable examples:
updates. Here's a detailed explanation of dynamic linking loader: 1. **Loading Shared Libraries**: When a input stream.Check if the line 1. Code Replacement:
program is compiled, it may reference functions or resources from external libraries. In dynamic linking, these contains a macro invocation: It Macros can replace code fragments with other code, thereby reducing redundancy and improving code
libraries are not directly incorporated into the executable file. Instead, the linker inserts references to these readability. This feature is particularly useful for defining constants or shortening repetitive code patterns.
checks if the current line contains a
external functions or resources into the executable, along with information about which libraries are needed. 2. Example (C/C++):
macro invocation.Extract the
**Symbol Resolution**: When a program is executed, the dynamic linker is responsible for resolving references #define PI 3.14159
to external symbols (functions, variables, etc.) in the shared libraries. It searches for these symbols in the available macro name and arguments: If a
float circle_area(float radius) {
shared libraries and resolves them to the actual memory addresses of the corresponding functions or variables. 3. macro invocation is found, the
return PI * radius * radius;
**Dynamic Library Search Path**: The dynamic linker maintains a list of directories known as the library processor extracts the macro name }
search path. This path includes standard system directories as well as any additional directories specified by and its arguments.Look up the 2. Parameterized Macros:
environment variables like `LD_LIBRARY_PATH` in Unix-like systems. When loading a shared library, the macro definition table: The Macros can take parameters, making them flexible and versatile. Parameterized macros enable developers to
dynamic linker searches these directories to locate the required library files. 4. **Lazy Binding**: To improve processor looks up the macro name create generic code snippets that can be reused with different inputs.
loading time and memory usage, modern dynamic linkers often use lazy binding. Instead of resolving all external in the macro definition table to find #define SQUARE(x) ((x) * (x))
symbols at once when the program starts, lazy binding defers symbol resolution until the first time a function its corresponding int main() {
from the library is called. This reduces startup time by loading only the necessary libraries and resolving symbols definition.Expand the macro: It int result = SQUARE(5);
as needed 5. **Symbol Table and Relocation**: Shared libraries typically contain a symbol table that maps expands the macro by replacing the return 0; }
symbol names to memory addresses. When a shared library is loaded, the dynamic linker performs relocation, macro invocation with its 3. Conditional Compilation:
adjusting memory addresses within the library code to reflect the actual memory layout of the process. This Macros can control the compilation process based on conditions. This feature is often used for platform-specific
definition, substituting the
ensures that references to external symbols are resolved correctly. 6. **Versioning and Compatibility**: code or debug configurations.
arguments as necessary.Continue
Dynamic linking loaders often support versioning mechanisms to manage compatibility between different #define DEBUG_MODE
versions of shared libraries. They can handle situations where multiple versions of the same library are installed to the next line: After processing
#ifdef DEBUG_MODE
on the system, ensuring that each program uses the appropriate version of the library. 7. **Runtime Linker the current line, the
#define DEBUG_PRINT(x) printf("Debug: %s\n", x)
Errors**: If a required shared library cannot be found or if there are unresolved symbols, the dynamic linker processor moves on #else
generates runtime linker errors. These errors indicate that the program cannot be executed due to missing to the next line of #define DEBUG_PRINT(x)
dependencies or other issues with the shared libraries. code.Output the line #endif
unchanged: If no int main() {
Application of two pass assember macro invocation is DEBUG_PRINT("This is a debug message");
1. **Symbol Resolution**: The first pass of a two-pass assembler is dedicated to resolving symbolic addresses found on the line, the return 0;
and constructing a symbol table. This allows the assembler to handle forward references, where symbols are used processor outputs the }
before they are defined. Symbol resolution is essential for generating correct machine code because it ensures line 4. Stringification: 5. Token Concatenation:
that all memory addresses are properly resolved. 2. **Error Detection and Reporting**: During the first pass, unchanged.Continue System Software Application Software
the assembler can perform preliminary error checks on the assembly source code. It can detect syntax errors, System Software maintains the system resources and Application software is built for specific tasks.
to the next line:
undefined symbols, and other potential issues. By identifying errors early in the assembly process, the assembler gives the path for application software to run.
After processing the
provides informative error messages to the programmer, helping them debug their code more efficiently. 3. Low-level languages are used to write the system While high-level languages are used to write the
**Optimization**: A two-pass assembler can perform simple optimizations during the second pass. For current line, the
processor moves on software. application software.
example, it can optimize instruction encoding, rearrange code for better memory access patterns, or eliminate It is general-purpose software. While it’s a specific purpose software.
redundant instructions. These optimizations improve the efficiency and performance of the generated machine to the next line of
Without system software, the system stops and can’t While Without application software system always
code. 4. **Macro Expansion**: Many assembly languages support macros, which are sequences of instructions code.Check if there
run. runs.
defined by the programmer. In the first pass, the assembler can expand macros into their corresponding assembly are more lines in the System software runs when the system is turned on While application software runs as per the user’s
code, making the code more readable and easier to understand. Macro expansion simplifies the assembly process source code: The and stops when the system is turned off. request.
and reduces the complexity of the generated machine code. 5. **Cross-Referencing**: The symbol table processor checks if Example: System software is an operating system, etc. Example: Application software is Photoshop, VLC
generated during the first pass can be used to create cross-reference information, which maps symbols to their there are more lines player, etc.
corresponding memory addresses or locations in the source code. This cross-referencing information is useful for in the source code to System Software programming is more complex than Application software programming is simpler in
documentation purposes and helps programmers understand the relationships between different parts of their code be processed.Go to application software. comparison to system software.
6. **Relocation**: In the second pass, the assembler generates machine code or object code based on the step 1: If there are A system software operates the system in the Application software runs in the front end according to
resolved symbols and addresses. It performs relocation, adjusting memory addresses and references as necessary
more lines, the processor repeats the process starting from step 1 for the next line.End: Once all lines background until the shutdown of the computer. the user’s request.
to ensure that the generated code can be loaded into memory and executed correctly. Relocation is crucial for
have been processed, the processing ends. The system software has no interaction with users. It Application software connects an intermediary
producing relocatable object files that can be linked together to form executable programs.
serves as an interface between hardware and the end between the user and the computer.
user.
System software runs independently. Application software is dependent on system software
because they need a set platform for its functioning.

You might also like