Skip to content

Latest commit

 

History

History
43 lines (27 loc) · 1.27 KB

File metadata and controls

43 lines (27 loc) · 1.27 KB

Selection Sort in x86 Assembly (TASM)

A minimal implementation of the Selection Sort algorithm written in x86 assembly for Turbo Assembler (TASM), targeting DOS real mode.

Overview

The program sorts a byte array of signed integers in ascending order using selection sort. It demonstrates low-level array manipulation, procedure calls with stack-based parameter passing, and a helper FindMin routine.

How It Works

  1. SelectionSort receives the array offset and length via the stack. On each iteration it calls FindMin for the unsorted portion, then swaps the found minimum with the current element.
  2. FindMin scans a sub-array and returns the minimum value (in AL) and its relative index (in BX), using signed comparison (JL).

Building & Running

# Assemble
tasm SelectionSort.asm

# Link
tlink SelectionSort.obj

# Run (in DOSBox or a real DOS environment)
SelectionSort.exe

Note: There is no console output by default — the sorted array lives in memory. Use a debugger (e.g. Turbo Debugger td) to inspect the result.

Example

Input:  12, -5, 0, 34, -10, 7
Output: -10, -5, 0, 7, 12, 34

Requirements

  • Turbo Assembler (TASM) / compatible assembler
  • DOS environment or DOSBox

License

MIT