Skip to content

Explore fundamental assembly practice codes here, ideal for mastering the basics of low-level programming in assembly language

Notifications You must be signed in to change notification settings

IFTE-13/Assembly_Language

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Assembly Language

Welcome to my Assembly Language repository. This repository contains various assembly language codes, demonstrating fundamental concepts and operations. Assembly language provides a close interaction with hardware, making it powerful for low-level programming. Below is an overview of some key assembly concepts:

Table of Contents


Introduction to Assembly Language

Assembly language is a low-level programming language that allows you to write instructions that are directly translated to machine code. Each instruction corresponds to a specific operation performed by the CPU. It is architecture-dependent, meaning that code written for one processor architecture might not work on another.


Hex to Binary Conversion

In assembly language, hexadecimal numbers are often used as they are more human-readable than binary. However, converting from hex to binary is essential as computers operate in binary:

  • Hexadecimal: Base 16 (digits 0-9 and A-F).
  • Binary: Base 2 (digits 0 and 1).

Example:
Hex 0xA = Binary 1010

Assembly instructions often work directly with hex or binary values depending on the context.


Jumps

Jump instructions allow you to change the flow of execution within your program. Common jump instructions include:

  • JMP – Unconditional jump to a specified memory address.
  • JE (Jump if Equal) – Jump if two values are equal.
  • JNE (Jump if Not Equal) – Jump if two values are not equal.
  • JG (Jump if Greater) – Jump if one value is greater than the other.

Jumps are critical for implementing loops and conditional logic.


Loops

Loops in assembly are implemented using jump instructions. A common pattern is to decrement a counter and use a conditional jump to repeat a block of code until a condition is met.

Example:

MOV CX, 10  ; Set counter to 10
LOOP_LABEL:
  ; Your loop code here
  DEC CX    ; Decrease the counter
  JNZ LOOP_LABEL ; Jump to the start of the loop if CX != 0

Arithmetic Operations

Addition

ADD AX, BX  ; AX = AX + BX

Subtraction

SUB AX, BX  ; AX = AX - BX

Multiplication

MUL BX  ; AX = AX * BX

Divition

DIV BX  ; AX = AX / BX

Conditional Statements (IF-ELSE)

Conditional statements can be implemented using comparison instructions (CMP) followed by a jump based on the result.

Example:

CMP AX, BX  ; Compare AX with BX
JE EQUAL_LABEL  ; Jump if AX == BX
; ELSE block
JMP END_IF
EQUAL_LABEL:
; IF block
END_IF:

Counting

Counting loops involve initializing a counter and decreasing or increasing its value until a condition is met. This is particularly useful in array processing or iterating over a range of values.

Example:

MOV CX, 5  ; Initialize counter
START_COUNT:
  DEC CX    ; Decrease counter
  JNZ START_COUNT  ; Repeat until CX = 0

Contributing

Tip

Contributions are welcome! If you'd like to improve this repository, feel free to fork the repository and submit a pull request with your changes. Ensure that your code follows the project's coding standards and practices.

About

Explore fundamental assembly practice codes here, ideal for mastering the basics of low-level programming in assembly language

Topics

Resources

Stars

Watchers

Forks