Questions tagged [x86-16]

For programming and/or microarchitecture questions about the 16-bit x86 Intel CPUs, including the 8088, 8086, and later chips running in 16-bit mode.

x86-16 refers to the 16-bit family of instruction set architectures (ISAs) based on the Intel 8086 CPU. This processor was designed by Intel in the mid-1970s, and gave rise to the x86 architecture.

See the tag wiki for links to x86 ISA and assembly-language programming resources (mostly aimed at modern 32-bit and 64-bit implementations).

The 8086 uses the same instruction set as later processors, but it is limited to 16-bit mode and lacks support for instructions added with 186, 286, 386 (or later). This means that extremely useful instructions like movzx are unavailable, so many operations require moving data into ax for use with instructions that have it as an implicit operand. The 16-bit implementation of x86 is also limited with respect to which registers can be used in addressing modes. This addressing limitation persists in modern CPUs running in 16-bit mode, because the machine-code format is the same.

The 8088 is a derivative of the 8086. The 8088 is identical in functionality to the 8086 and is fully 16-bit internally, but it has an 8-bit external data bus (instead of the 8086's 16-bit external data bus). In terms of programming, there are no salient differences between the 8088 and 8086, so these are combined under a single tag. Feel free to mention which specific chip you're targeting in the body and/or title of the question, though.

This tag is also appropriate for questions about non-Intel CPUs that use the same instruction set as the 8086, including the NEC v20 and v30, AMD 8086 clones, etc. There are also some modern microcontrollers that use simple 8086 cores.

Note that, while it will run on modern x86 CPUs, code that uses only the 16-bit instructions (as would be supported on an 8086) is not usually considered good or efficient code.

However, there remains much interest in writing 16-bit code for emulators (such as DOSBox and ) and real vintage hardware, both from beginners and enthusiasts. retrocomputing.SE has an 8086 tag, but unless you're asking about actual ancient hardware, Stack Overflow is the right place for questions about 16-bit bootloaders, kernels, and DOS executables. Retrocomputing is mostly about even older systems, like 8-bit micros.



Debuggers

Single-stepping in a debugger and looking at registers is essential. Trying to write a program without one is like trying to build a robot blindfolded. It's very much worth the time to learn to use one. For 32/64-bit mode under a modern OS, see the debugging section at the bottom of the x86 tag wiki.

Under DOS:

  • @ecm's lDebug, based on debug.com from FreeDOS.
  • Turbo Debugger is widely recommended, and maybe can be found for free
  • debug.exe/debug.com in MS-DOS or FreeDOS is an option, although classic MS-DOS DEBUG is pretty terrible to actually program in, not having labels, only numeric addresses for jump targets and so on!

Full system (for bootloaders, or maybe DOS programs)

  • Bochs is usually the gold standard, with a built-in debugger that's aware of segmentation. Manual. Note that it's an optional config feature; some builds might not come with it enabled. It's great for debugging the switch to 32-bit protected mode, and 64-bit mode. It can parse and dump your GDT and page tables, to help you spot mistakes in what you put there, and it knows what mode the CPU is in so it will disassemble in the right mode to match execution, helping you catch mistakes where code was assembled for the wrong bitness.
  • QEMU: can act as a remote for GDB. GDB doesn't know about segmentation so this isn't ideal for real mode or during the switch to protected mode.
  • DOSBox: There's a DOSBox-X fork with a built-in debugger, and the mainline DOSBox apparently also has a debugger built-in. (Curses-based text UI)

Related Tags:

  • (for the x86 in general, including 32-bit and 64-bit. Lots of good stuff in the tag wiki, including some 16-bit links)
  • (for stuff specifically about the 64-bit extensions to the x86 ISA)
  • (for the legacy numeric coprocessor—aka floating point unit, as opposed to the SSE/SSE2 FPU)
  • (for programs written in assembly language of any kind, including x86, MIPS, ARM, and toy architectures like LC-3)
  • (for programs targeting DOS and/or questions about DOS APIs)
  • (for questions specifically about the EMU8086 emulator package, often used by students)
2894 questions
1
vote
1 answer

How to mask keyboard interrupt using IMR in 8086?

I would like to disable keyboard interrupts, by masking it in the IMR. I'm not really sure how to access it, and change it? As I realize, it's on the IRQ1 line, so the bit 1 should be 0.
Petros17
  • 40
  • 7
1
vote
1 answer

malloc in assembly 8086

I need to receive input from user and I am required to use malloc to init the buffer first. I can't find any example online. This is the buffer: section .bss buffer: resb 80 ;store my input How is it…
lolu
  • 370
  • 4
  • 20
1
vote
3 answers

Read from the middle of file ASM 8086

I am trying to read data from the middle of a file. I used int 21h, ah = 3fh, but it's read the file from his beginning. Is there a way to read data not from the beginning of the file? (ASM 8086, i am using TASM if it relevance)
Amir Zak
  • 37
  • 1
  • 5
1
vote
1 answer

Modifying Memory In An Assembly Application

I'm studying assembly language from the book "art of x86 assembly" and I have a question I couldn't figure the answer. the program goes like this: "in this exercise you will start a program running that examines and operates on values found in…
John Terry
1
vote
2 answers

can you help me with 8086 project for Delphi .net please

To find an Assembly programmer is very hard to help me I'm a established Delphi programmer that has an old copy of Delphi that is not .net And I have a *.dll that I'm converting into Delphi code for .net I'm on a big learning curve hear as i know…
lexdean
  • 151
  • 1
  • 2
  • 13
1
vote
1 answer

bug writing colored text in assembly (8086) int 10h\ah =9

I face a strange bug in assembly (8086) while using dosbox. I am trying to print text, colored green. this is my main, when i called the function: mov bl,2h ; set the color (green) mov dx,OFFSET str_msg ; set the…
bn12
  • 75
  • 1
  • 5
1
vote
1 answer

Can someone help me with segmentation and 8086 intel's microprocessor?

I am reading about the architecture of intel's 8086 and can't figure out the following things about segmentation: I know that segment registers point to segments respectively and contain the base address of a 64kb long segment. But who calculates…
LearningMath
  • 851
  • 4
  • 15
  • 38
1
vote
2 answers

how to store random generated numbers in arrays. Assembly 8086

mov bx,0 mov cx,0 copy: ;copy col arrays. mov dl,[col_star+bx] mov [go_right+bx],dl mov [go_left+bx],dl inc [go_right+bx] dec [go_left+bx] ;copy row arrays mov dl,[row_star+bx] mov [go_up+bx],dl mov [go_down+bx],dl dec [go_up+bx] inc…
Reub
  • 665
  • 2
  • 18
  • 35
1
vote
1 answer

printing coordinates assembly 8086

say i have to generate 20 random coordinates, 20 row and 20 column numbers. .model small .data ;///////////////////// VARIABLES ;array of colors color db 01h,02h,03h,04h,05h,06h,0Ah, 0Bh, 0Ch,0Dh,0Eh, 0Fh ;12 colors. star_char db '*',…
Reub
  • 665
  • 2
  • 18
  • 35
1
vote
1 answer

How to play chords in ASM 8086?

I want to know what is the best way to play more then 1 note at the time in assembly. If you can, please add a procedure that explain your answer. Thanks!
Orange
  • 79
  • 3
  • 9
1
vote
2 answers

8086 Assembler compare two operands without CMP

question: In data segment i have two arrays A,B (DW) with size 1
Mark Sabakov
  • 527
  • 1
  • 5
  • 9
1
vote
1 answer

how to use an interrupt to print strings in color in assembly 8086

I'm writing a NIM game in assembly 8086. It's almost finished, but there's a problem I'm facing. I have a procedure which prints piles (each pile contains some stick(s)). It runs perfectly, except for one thing. I want to color sticks for better…
Pooya
  • 89
  • 3
  • 13
1
vote
2 answers

printing piles in NIM game with assembly 8086

I'm writing a NIM game in assembly 8086 (with arbitrary number of piles and sticks, limited to maximum 45), but I'm new to assembly language. it's not complete yet, and for now I want to print the piles with some ASCII character. So I have written a…
Pooya
  • 89
  • 3
  • 13
1
vote
1 answer

Assembly 8088: 32-bit signed Multiplication with addition and bit manipulation using 16-bit registers

I am trying to write assembly program to multiply two 32-bit signed numbers and store the answer in 64-bit number but my code only gives me the correct answer up to 32-bits. I have goggled it and searched many sites but can't satisfy myself. I can't…
1
vote
2 answers

Assembly 8086 homework - fill in the blank, misunderstanding

Firstly I'd like to apologize, english is not my native tongue and I couldn't come up with a title that better fits my situation. I was given this incomplete assembly code: .code mov [mybyte],______ mov SP,0574h xor ax,ax here: add…
Oria Gruber
  • 1,513
  • 2
  • 22
  • 44
1 2 3
99
100