Assembly Language in Computer Architecture YASH PAL, February 27, 2026February 28, 2026 Assembly Language in Computer Architecture – Assembly language is a low-level programming language, and a programming language is defined by a set of rules. The programs written in assembly language are compiled by an assembler. Every assembler has its own assembly language, which is designed for one specific computer architecture. The basic unit of an assembly language program is a line of code. Assembly Language mainly consists of mnemonic processor instructions or data, and other statements or instructions. It is produced with the help of compiling the high-level language source code like C, C++. Assembly Language, which helps in fine-tuning the program. An assembly program can be divided into three sections – The data section The bss section The text section The data Section: The data section is used for declaring initialized data or constants. This data does not change at runtime. You can declare various constant values, file names, or buffer sizes, etc., in this section. The syntax for declaring a data section is – section.data The bss Section: The bss section is used for declaring variables. The syntax for declaring bss section is – section.bss The text section: The text section is used for keeping the actual code. This section must begin with the declaration global_start, which tells the kernel where the program execution bagine The syntax for declaring a text section is – section.text global_start _start: Comments Assembly language comment begins with a semicolon (;). It may contain any printable character, including blank. It can appear on a line by itself, like – This program displays a message on screen or, on the same line along with an instruction, like – add eax, ebx ; adds ebx to eax Rules of the Assembly Language: Each line of an assembly language program is arranged in three columns called fields. The fields specify the following information. The label field may be empty, or it may specify a symbolic address. A symbolic address consists of one, two, or three, but not more than three alphanumeric characters. The first character must be a letter, the next two may be letters or numerals. The symbol can be chosen arbitrarily by the programmer. A symbolic address in the label field is terminated by a comma so that it will be recognized as a label by the assembler. The instruction field specifies a machine instruction or a pseudo-instruction. The instruction field in an assembly language program may specify one of the following instructions: A memory-reference instruction (MRI) A register-reference or input-output instruction (non-MRI) A pseudo instruction with or without an operand The comment field may be empty, or it may include a comment. A line of code may or may not have a comment, but if it has, it must be preceded by a slash for the assembler to recognize the beginning of a comment field. Comments are useful for explaining the program and are helpful in understanding the step-by-step procedure taken by the program. Comments are inserted for explanatory purposes only and are neglected during the binary translation process. Advantages of Assembly Language: It allows complex jobs to run in a simpler way. It is memory-efficient, as it requires less memory. It is faster in speed, as its execution time is shorter. It is mainly hardware-oriented. It requires less instruction to get the result. It is used for critical jobs. It is not required to keep track of memory locations. It is a low-level embedded system. It is most suitable for writing interrupt service routines and other memory-resident programs. Disadvantage of Assembly Language It takes a lot of time and effort to write the code for the same. It is very complex and difficult to understand. The syntax is difficult to remember. It has a lack of portability of the program between different computer architectures. It needs more size or memory of the computer to run the long programs written in Assembly Language. Let’s take an example to Write a assambly language program to subtract two numbers. ORG 100/Origin of the program is location 100LDA SUB/Load subtrahend to ACCMA/Complement ACINC/Increment ACADD MIN/Add minued to ACSTA DIF/Store differenceHLT/Halt computerMIN,DEC 83/MinuendSUB,DEC-23/SubtrahendDIF,HEX0/Difference stored hereEND/End of symbolic programAssembly Language Program to Subtract Two Numbers Let’s take another example to write the assembly programs to print “Hello world” in Windows. Open the notepad. Write below code global _main extern _printf section .text _main: push message call _printf add esp, 4 ret message: db 'Hello, World!', 10, 0 Save the file with any name, for example, XYZ.asm; the extension should be “.asm”. The above file needs to be compiled with the help of an assembler, which is NASM (Netwide Assembler). Run the command nasm -f win32 XYZ.asm After this, Nasm creates one object file that contains machine code, but not the executable code that is XYZ.obj To create the executable file for windows Minimal GNU is used, which provides the GCC compiler. Run the command gcc -o XYZ.exe XYZ.obj Execute the executable file now, “XYZ” It will show the output as “Hello, world”. Assembler An Assembler is used to translate the program written in Assembly Language into machine code. The source program is an input to an assembler that contains assembly language instructions or a symbolic language program. The output generated by the assembler is the object code or machine code understandable by the computer. Assembler An assembler primarily serves as the bridge between symbolically coded instructions written in assembly language and the computer processor, memory, and other computational components. An assembler works by assembling and converting the source code of assembly language into object code or an object file that constitutes a stream of zeroes and ones of machine code, which are directly executable by the processor. Assemblers are classified based on the number of times it takes them to read the source code before translating it; there are both single-pass and multi-pass assemblers. Moreover, some high-end assemblers provide enhanced functionality by enabling the use of control statements, data abstraction services and providing support for object-oriented programming structures. There are two types of assembler are: Single-pass assembler Second pass assembler Single Pass Assembler A single assembler pass is referred to as the complete scan of the source program input to the assembler or equivalent representation and translation by the statement, on the basis of the statement, called a single pass assembler or one pass translation. Flowchart For First Pass of Assembler It isolates the label, mnemonics, and operand field of the system. It validates the code instructions by looking them up in the mnemonic code table. It enters the symbol found in the label field and the address of the text available machine word into the symbol table. This pass is fast and effective, and no need to construct the intermediate code. Second Pass Assembler A table-lookup procedure is a search of table entries to determine whether a specific item matches one of the items stored in the table. The assembler uses four tables. We assign the following names to the four tables: Pseudo instruction table: Four symbols (END, OGR, DEC, & HEX) MRI table: Seven symbols of memory reference instructions Non-MRI table: 18 registers reference and I/O instruction Address symbol table: Generate during the single pass Any symbol that is encountered in the program must be available as an entry in one of these tables; the symbol cannot be interpreted. Computer System Architecture engineering subjects Computer System Architecture