Assembly Language Concepts: A Comprehensive Guide

System SoftwareApplication Software
Manages and controls computer hardware and resources

Performs specific tasks for end users

Interfaces between hardware and application software

Interfaces between system software and end users

Operating systems, device drivers, utility programs

Web browsers, word processors, spreadsheet software

General-purpose softwareSpecific-purpose software
Typically written in low-level languagesUsually written in high-level languages
LiteralImmediate Operand
A constant value specified in the assembly language program that is not part of the machine instructionA constant value that is encoded directly into the machine instruction

The assembler generates the literal value as a constant at a separate memory location. The address of this constant is used as the operand in the machine instruction

The immediate value is assembled as part of the machine instruction itself

The literal is specified using special syntax like ‘=value

The immediate value is encoded directly in the instruction operand field

Used when the constant does not fit in the immediate field of the instruction or when the constant needs to be stored in memory

Used when the constant fits in the immediate field and doesn’t need to be stored in memory

ADD AREG,='5' (adds the value 5 stored at a separate memory location to register AREG)

ADD AREG, #5 (adds the immediate value 5 to register AREG)


MacroFunction
Macro is preprocessed.Function is compiled.
Macro does not support type checking.Function supports type checking.
Program length increases.Program length remains the same.
There is a side effect when using a macro.No side effect when using a function.
Execution is faster.Execution is slower.

Useful where small source code appears many times.

Useful where large source code appears many times.

Macro does not check compile errors.Function checks compile errors.

Before compilation, the macro name is replaced by the macro value.

During the function call, the transfer of control takes place.

MacroProcedure
The corresponding machine code is written every time a macro is called in a program.The corresponding machine code is written only once in memory.
Requires more memory space for the program.Requires less memory space for the program.
No transfer of program counter.Transferring of the program counter is required.
Faster execution.Slower execution.
Assembly time is more.Assembly time is less.

No overhead of using the stack for transferring control.

Overhead of using the stack for transferring control.


InterpreterCompiler

The source program is interpreted every time it is to be executed, and every time the source program is analyzed. Hence, interpretation is less efficient than compilation.

In the process of compilation, the program is analyzed only once, and then the code is generated. Hence, the compiler is more efficient than the interpreter.

Interpreters do not produce object code.Compilers produce object code.
Interpreters can be made portable because they do not produce object code.The compiler has to be present on the host machine when a particular program needs to be compiled.
Interpreters are simpler and give us an improved debugging environment.The compiler is a complex program and requires a large amount of memory.
One PassTwo Pass
It performs translation in one pass.It performs translation in two passes.
It scans the entire file only once.It requires two passes to scan the source file.
It generates intermediate code.It does not generate intermediate code.

Data structure: Symbol table, literal table, pool table, and table of incomplete instructions.

Data structure: Symbol table, literal table, and pool table.

Perform some processing of assembler directives.Perform processing of assembler directives not done in Pass – 1.
It is faster than a two-pass assembler.It is slower than a one-pass assembler.
No object program is written; hence, no loader is required.The loader is required as the object code is generated.


Macro Call

  • This is the point in the source code where the macro name is used. It’s like invoking a function.
  • The compiler encounters the macro name and recognizes it as a macro.
  • The compiler then replaces the macro call with the corresponding macro body.

Macro Expansion

  • This is the process of replacing the macro call with its macro body.
  • The compiler substitutes the actual arguments provided in the macro call for the formal parameters defined in the macro.
  • The resulting expanded code is then inserted into the source code where the macro call was originally located.

html>