Skip to content

About

8086 assembly language programs for emu8086: I/O, arithmetic, bit operations, loops, arrays, stack, procedures and string handling.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

8086 Assembly Language Programs

A collection of 8086 assembly programs written while learning assembly language, from a first "print a character" program up to string processing, sorting, stack usage and procedures. Every program is heavily practiced, runs in emu8086, and uses standard DOS interrupts (INT 21h).

Programs are written for the small memory model (.MODEL SMALL) with a 256-byte stack (.STACK 100H).


Table of Contents


Requirements

Item Details
Emulator emu8086 (Microsoft Windows)
OS Windows (emu8086 is a Windows application)
Language 8086 Assembly (MASM/TASM-style syntax)

Download emu8086 from its official publisher (search for "emu8086 microprocessor emulator"). The free/trial version is enough to run most of these programs; a registered licence removes the trial limitations.


How to Run a Program

  1. Clone or download this repository
    git clone https://github.com/mihrub/8086-Assembly-Language.git
    cd 8086-Assembly-Language
  2. Install and open emu8086.
  3. Click File → Open (or press Ctrl + O) and choose any .asm file from this repository.
  4. Click Compile to assemble the program. If it compiles with no errors, an emulator window opens automatically.
  5. In the emulator window, either:
    • click Run to execute the entire program, or
    • click Single Step to execute one instruction at a time and watch the registers, flags and memory change (great for understanding and dry-running code).
  6. The console window shows the program's output. Programs that take input (INT 21h, AH = 1) wait for you to type in that console window.
  7. Click Reload in the emulator to start the program again from the beginning.

Tips

  • Use Single Step together with the registers and flags panels to dry-run a program and verify your own hand-trace.
  • Open View → Memory or click aux → memory to inspect the data segment.
  • If a program seems to hang, it is usually waiting for keyboard input in the console window.
  • Input programs that read numbers expect digits only, finished with Enter.

Program Index

1. Basics and Program Structure

File Description
intro_to_assembly.asm Program skeleton with every directive explained in comments
first_program.asm Print ?, read a character, print it on a new line
test.asm Minimal read-one-character, print-one-character test
variables.asm Declaring and using variables in the data segment
constant.asm Defining and using constants
label_jump.asm Labels and unconditional jump

2. Input and Output

File Description
input_output.asm Basic character input and output
std_in_std_out.asm Reading characters and echoing them using DOS functions 01h and 02h
two_digit.asm Two-digit number input/output
print_two_digit_number.asm Printing a two-digit number
print_star.asm Printing * characters
print_upper_case_characters.asm Printing the uppercase alphabet
new_line_and_beep_sound.asm Carriage return, line feed and the beep character
display_entire_ibm_character_set.asm Displaying the IBM extended ASCII set
display_greater_ascii_character.asm Displaying the greater of two ASCII characters
print_in_the middle_of_a_grid.asm Printing in the middle of the screen grid
ascii_code_in_binary.asm Showing a character's ASCII code in binary
binary_input_output.asm Reading and printing numbers in binary
hexadecimal_input_ouput.asm Reading and printing numbers in hexadecimal
hexadecimal_to_decimal.asm Hexadecimal to decimal conversion
hexadecimal_to_decimal_loop.asm Hexadecimal to decimal using a loop
decimal_input_output_factorial.asm Decimal input and output, with factorial

3. Arithmetic

File Description
add_two_digits.asm Add two single-digit numbers
add_three_digits.asm Add three single-digit numbers
subtract_two_digit.asm Subtract two numbers
single_digit_multiply.asm Multiply single-digit numbers
multiplication_by_add_and_shift.asm Multiplication using repeated addition and shifts
expression.asm Evaluate an algebraic expression with IMUL
factorial.asm Factorial using MUL and LOOP
class_average.asm Averages from a 2D table of scores

4. Logic, Shift and Rotate Operations

File Description
and_operation.asm Bitwise AND
or_operation.asm Bitwise OR
odd_even_using_and_operation.asm Odd/even check with AND
odd_even_using_test.asm Odd/even check with TEST
shift_rotate.asm SHL, SHR, ROL, ROR
rotate_left_right.asm Rotating bits left and right
reverse_a_bit_pattern.asm Reversing the bits of a value
count_one_using_rol.asm Counting set bits using ROL

5. Conditions and Loops

File Description
compare_two_numbers.asm Compare two numbers
compare_three_numbers.asm Find the largest of three numbers
condition_check.asm Conditional jumps
positive_negative_zero.asm Classify a number as positive, negative or zero
grade_checker.asm Convert a score to a letter grade
loop.asm LOOP instruction basics
loop_reserved_keyword.asm Printing 80 stars with LOOP
nested_loop.asm Nested loops
dry_run.asm Loop with an even/odd check, used for dry-running

6. Arrays

File Description
sum_of_an_array.asm Sum the elements of an array
array_reverse_sum_print.asm Reverse an array, sum it and print it
reverse_array_element.asm Reverse an array in place
sort.asm Selection sort
sort_an_array.asm Sorting an array

7. Stack and Procedures

File Description
reverse_using_stack.asm Reverse a string using PUSH and POP
reverse_using_stack_and_vowel_count.asm Reverse a string with the stack and count vowels
read_string_procedure.asm A reusable procedure that reads a string
string_input_output_using_function.asm String input and output through procedures

8. Strings

File Description
string_copy.asm Copy one string to another
string_concat.asm Concatenate two strings
movsb_operation.asm REP MOVSB string move
count_number_of_characters.asm Count characters in a string
vowel_consonant_count.asm Count vowels and consonants
case_convertion.asm Case conversion
upper_case_to_lower_case.asm Uppercase to lowercase
lower_case_to_upper_case.asm Lowercase to uppercase
find_first_and_last_capital_letter.asm Find the first and last capital letters
reverse_word_by_word.asm Reverse a sentence word by word
palindrome.asm Palindrome check

Concepts Covered

  • Program structure: .MODEL, .STACK, .DATA, .CODE, PROC / ENDP
  • Registers, flags and addressing modes (LEA, [SI], [BX+SI])
  • DOS services via INT 21h: 01h (read char), 02h (print char), 09h (print string), 0Ah (read string), 4Ch (exit)
  • Number system conversion: binary, decimal, hexadecimal
  • Arithmetic: ADD, SUB, MUL, IMUL, DIV
  • Bit manipulation: AND, OR, TEST, SHL, SHR, ROL, ROR
  • Control flow: conditional/unconditional jumps, LOOP, nested loops
  • Arrays and two-dimensional data
  • The stack, PUSH / POP, CALL / RET
  • String instructions: MOVSB, STOSB, LODSB, SCASB, CLD, REP, REPNE

Repository Structure

.
├── README.md
├── intro_to_assembly.asm
├── first_program.asm
├── ...
└── palindrome.asm

Author

Mihrub Aziz Bhuiyan, CSE student at RUET.
GitHub: @mihrub

If this repository helped you learn assembly, a star is appreciated.

About

8086 assembly language programs for emu8086: I/O, arithmetic, bit operations, loops, arrays, stack, procedures and string handling.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages