DEV Community

Cover image for Mastering the basics: A dive into low-level programming essentials(Part 2)
BitCraft
BitCraft

Posted on

Mastering the basics: A dive into low-level programming essentials(Part 2)

Basic Features of PC Hardware: (A must know)

The main internal hardware of a PC consists of the processor, memory and the registers. The registers are processor components that hold data and address. To execute a program the system copies it from the external device into the internal memory. The processor executes the program instructions.

execution cycle

The fundamental unit of computer storage is a bit; it could be on (1) or off (0). A group of nine related bits makes a byte. Eight bits are used for data and the last one is used for parity. According to the rule of parity, number of bits that are on (1) in each byte should always be odd.

So, the parity bit is used to make the number of bits in a byte odd. If the parity is even, the system assumes that there had been a parity error (though rare) which might have caused due to hardware fault or electrical disturbance.

The processor supports the following data sizes:

  • Word: a 2-byte data item
  • Doubleword: a 4-byte (32 bit) data item
  • Quadword: an 8-byte (64 bit) data item
  • Paragraph: a 16-byte (128 bit) area
  • Kilobyte: 1024 bytes
  • Megabyte: 1,048,576 bytes

Each personal computer has a microprocessor that manages the computer's arithmetical, logical and control activities.

Each family of processors has its own set of instructions for handling various operations like getting input from keyboard, displaying information on screen and performing various other jobs. These set of instructions are called 'Machine language instruction'.

instruction fetch sequence in CPU operation
Processor understands only machine language instructions which are strings of 1s and 0s. However, machine language is too obscure and complex for using in software development. So, the low-level assembly language is designed for a specific family of processors that represents various instructions in symbolic code and a more understandable form.
Borrow the knowledge of the previous article if you missed it from Mastering the basics: Part 1 of this post


Commonly Used Assembly Languages

There are several assembly languages used in various computer architectures. Here are some of the most used ones:

x86 Assembly Languages

  • x86 Assembly: Used for Intel and AMD processors, x86 assembly is a widely used assembly language for personal computers.

  • MASM (Microsoft Macro Assembler): A popular assembly language for x86 processors, used for Windows and DOS applications.

  • NASM (Netwide Assembler): A free, open-source assembly language for x86 processors, widely used in Linux and other Unix-like operating systems.

ARM Assembly Languages

  • ARM Assembly: Used for ARM-based processors, commonly found in mobile devices, embedded systems, and some servers.

  • ADSP-BF533: A digital signal processing (DSP) assembly language for ARM-based processors.

RISC-V Assembly Language

RISC-V is an open-source instruction set architecture (ISA) that has gained popularity in recent years. The RISC-V assembly language is designed to be simple, extensible, and free from patents.


Other Assembly Languages

  • MIPS Assembly: Used for MIPS-based processors, commonly found in embedded systems and some servers.

  • PowerPC Assembly: Used for PowerPC-based processors, commonly found in Apple’s Power Macs and some servers.

  • SPARC Assembly: Used for SPARC-based processors, commonly found in Sun Microsystems’ servers.


General Assembly Languages Overview

Here’s a brief overview of three commonly used assembly languages:

x86 Assembly

  • Origin: Intel 8086 processor (1978)

  • Syntax: Uses a complex syntax with many instructions and addressing modes

  • Usage: Widely used for x86-based systems, including Windows, Linux, and macOS

  • Example: mov eax, 5 (move the value 5 into the EAX register)

ARM Assembly

  • Origin: Advanced RISC Machines (ARM) processor (1985)

  • Syntax: Uses a simpler syntax with a focus on reduced instruction set computing (RISC)

  • Usage: Used in mobile devices, embedded systems, and some servers

  • Example: mov r0, #5 (move the value 5 into the R0 register)

RISC-V Assembly

  • Origin: University of California, Berkeley (2010)

  • Syntax: Designed to be simple, extensible, and open source

  • Usage: Used in a variety of applications, including embedded systems, servers, and supercomputers

  • Example: li x0, 5 (load the value 5 into the X0 register)


Differences and Applications

Here’s a brief comparison of the three assembly languages:

x86:

  • Complex instruction set with many instructions

  • Used in personal computers, such as desktops and laptops

  • Supports a wide range of operating systems, including Windows and Linux

ARM:

  • Designed for low-power consumption and high performance

  • Used in mobile devices, such as smartphones and tablets

  • Also used in embedded systems, like routers and set-top boxes

RISC-V:

  • Reduced instruction set with a focus on simplicity and flexibility

  • Used in academia and research, as well as in some commercial applications

  • Open-source and royalty-free, making it a popular choice for custom hardware designs

Top comments (0)