Category:8086 Assembly: Difference between revisions

m
mNo edit summary
Line 4:
===Segmented Memory===
The 8086 uses a segmented memory model, similar to the Super Nintendo Entertainment System. Unlike banked memory models used in the Commodore 64 and late NES games, segment addresses are held in <i>segment registers</i>. These segment registers are 16 bit and get left-shifted by 4 and added to the pointer register of interest to determine the memory address to look up. The 8086 has four in total, but only the Data Segment and Extra Segment can be used by the programmer. (The other two are reserved for the stack pointer and instruction pointer.) On the 8086, you can only load segment registers with the value in a data register, or with the <code>POP</code> command. So first you must load a segment into a data register, THEN into a segment register.
 
<lang asm>;This is NOT valid code!
mov ds, @data ;you're trying to move the data segment location directly into DS. You can't!
 
 
;This is the proper way:
mov ax, @data ;I chose AX but I could have used BX, CX, or DX.
mov ds, ax ;load DS with the data segment.</lang>
 
===Data Registers===
1,489

edits