Академический Документы
Профессиональный Документы
Культура Документы
Assembly Language
and
Computer Organization
EE2801-L07P01
Doing something useful with a computer involves reading data from one location, operating
on it, and storing it in another location. It really doesnt matter what the information is, or
what the desired action is, the process remains the same.
Text
Assembler
Editor
EDIT
ASCII
TASM
Source
Linker
(.asm)
Object
TLINK
Files
Executable
(.obj)
(.exe)
Debugger
TD
EE2801-L07P02
writing to an address.
reading
from an address.
Portability is achieved (in part) by having rules, or standards, for how addresses are
assigned and for the behavior that is supposed to occur when addresses are accessed.
F0000h
EFFFFh
E0000h
DFFFFh
C0000h
BFFFFh
128Kb Video
Memory
A0000h
9FFFFh
640Kb
Conventional
Memory
00000h
EE2801-L07P03
It is the job of a loader to assign the image to the proper memory space(s).
9FFFFh
Data
Loader
Stack
Executable
640Kb
Conventional
Memory
(.exe)
Code
not initialized!
00000h
EE2801-L07P04
CS = A000h
Shift CS Left
IP = 27A5h
CS:IP = A27A5h
All of the segment registers in the 80x86 work this way, however the offset does not usually
come from the IP register when the DS, SS, and ES registers are used.
EE2801-L07P05
FFFFFh
64K Code
Segment
64K Extra
CS
Segment
ES
64K Stack
Segment
SS
64K Data
Segment
DS
00000h
EE2801-L07P06
Although segments and offset might sound a little confusing, there some typical ways that
segments and offsets are associated with each other, and some typical applications of the
various segments.
CS - Code Segment Register
This register is used to find addresses for program instructions. The physical address of an
instruction is normally calculated using the IP register (CS:IP).
DS - Data Segment Register
This register is used to find addresses for data items in memory. There are a number of
ways that an offset may be obtained such as direct input of a number or using the BX, DI,
or SI registers (or a combination).
ES - Extra Segment Register
The extra segment is not used very often in simple programs. When it is, it is usually
associated with string operations and the offset usually comes from the DI register.
SS - Stack Segment Register
The SP register is the most common source of an offset into the stack segment. BP is also
commonly used.
EE2801-L07P07
A
B
C
.Data
;Create a symbolic name
db 7d ;Create a symbolic name
db 12d ;Create a symbolic name
db ?
;Create a symbolic name
start:
.Code
nop
mov ax,@data
mov ds,ax
stop:
for
for
for
for
mov
mov
add
mov
al,byte ptr[A]
bl,byte ptr[B]
al, bl
byte ptr[C],al
;Instruction
;Instruction
;Instruction
;Instruction
at
at
at
at
jmp
stop
;Instruction at CS:0012
Notice:
EE2801-L07P08