Category Archives: 8086 TASM

8086 Assembly Program to Print ‘hello’ using 09H

DOS interrupt 21h function 09h is the easiest way to print a string in 8086 assembly: point DX at your string, set AH to 09h, call INT 21h, and you’re done. No loop, no character counter, no BX pointer arithmetic. The tradeoff is a minor convention: the string must end with a $ character so DOS knows where to stop. Compare this with the function 02h character loop approach — 09h is cleaner for fixed strings; 02h gives you more control for dynamic output.

Continue reading 8086 Assembly Program to Print ‘hello’ using 09H

Interrupting BIOS with 8086 Assembly Program

INT 10h is the BIOS video interrupt — completely separate from the DOS INT 21h family. Where INT 21h talks to the operating system, INT 10h talks directly to the video BIOS to control the screen: cursor shape, cursor position, character output, screen modes. This short program demonstrates two of those functions: setting the cursor shape and moving it to a specific screen position.

Continue reading Interrupting BIOS with 8086 Assembly Program

Implementing JUMP, PUSH, POP, IN & OUT in Assembly Program on 8086

This program is a sandbox for five instructions you’ll encounter constantly in real 8086 code: unconditional jump (JMP), stack push and pop, and port I/O (IN/OUT). Rather than demonstrating each in isolation, the program weaves them together into a two-iteration loop that modifies variables, saves and restores registers through the stack, then reads from and writes to an I/O port at the end. It’s a useful reference for anyone trying to understand how these instructions interact.

Continue reading Implementing JUMP, PUSH, POP, IN & OUT in Assembly Program on 8086

8086 Assembly Program to Display String ‘hello’

There are two ways to print a string in 8086 DOS assembly. One is the clean, one-call approach using INT 21h function 09h. The other — shown here — is the character-by-character loop using function 02h. It’s more verbose, but it gives you a clear picture of how string output actually works at the hardware level: load a character into DL, call INT 21h, move to the next character, repeat. Once you understand this version, the shortcut function 09h makes a lot more sense.

Continue reading 8086 Assembly Program to Display String ‘hello’

8086 Assembly Program for Subtraction of Two 8-bit Numbers

8-bit subtraction on the 8086 follows the same register-first pattern as 16-bit subtraction — but with one extra gotcha to watch: because only AL is involved in the computation, AH retains whatever value it had from the segment setup code. When you later store the full AX into the result variable, that dirty AH comes along for the ride. The emu8086 and NASM versions below fix this with a single xor ah, ah. This post walks through a working implementation in three environments: MASM/TASM, emu8086, and NASM.

Continue reading 8086 Assembly Program for Subtraction of Two 8-bit Numbers

8086 Assembly Program for Multiplication of Two 8-bit Numbers

8-bit multiplication on the 8086 is simpler than its 16-bit counterpart in one important way: the result always fits in a single register pair. MUL with an 8-bit operand multiplies the implicit AL register by that operand and places the full 16-bit result in AX — no separate DX needed. This post walks through a working implementation in three environments: MASM/TASM, emu8086, and NASM.

Continue reading 8086 Assembly Program for Multiplication of Two 8-bit Numbers

8086 Assembly Program for Division of Two 8-bit Numbers

8-bit division in 8086 assembly has a subtle but important difference from 16-bit division: the dividend is always the full 16-bit AX register, not just AL. When you write DIV b with a byte operand, the CPU divides the 16-bit value in AX by that byte — quotient lands in AL, remainder in AH. Getting AH cleared to zero before the divide is therefore essential for a correct result. This post walks through a working implementation in three environments: MASM/TASM, emu8086, and NASM.

Continue reading 8086 Assembly Program for Division of Two 8-bit Numbers