Intel 210200-002 Baby Furniture User Manual


 
ARCHITECTURE AND INSTRUCTIONS
The
ASSUME
statement on line 2 complies
with the following rule:
at the very beginning
of
any segment contain-
ing code,
we
must
tell the assembler what to
assume
is
in the CS register when that code is
executed. This will always be the starting
address, without the last four
"0" bits of the
segment, so
we
must include the statement:
ASSUME CS: Name_oLsegment
ASM-86 Program Structure
Now consider a more detailed ASM-86 pro-
gram (shown below)
to
understand the
structure of such programs in general. This
program will be referred
to
as the "sample
program"
throughout this chapter.
Line 1 introduces a segment somewhere in
the
8088
memory
(we
don't care where) and
gives it the name
MY-DATA.
Line 3 ends the segment. The only thing in
1.
MY
_DATA
SEGMENT
2.
SUM DB
?
3.
MY_DATA
ENDS
4.
MY_CODE
SEGMENT
the segment
is
SUM, defined
to
be a byte
(DB)
of
data.
The question mark
on
line 2 indicates that
the generated object code needs to reserve a
place in memory for SUM,
but
it need
not
specify any particular initial contents for
that
location. MY_DATA
is
apparently going
to
be
used as a data segment.
Lines 4-18 define another segment with the
name MY_CODE. An examination
of
lines 7
to
17
reveals that the segment contains
instructions for use as a code segment.
Line
19
flags the end of the source program
and indicates that when the program
is
exe-
cuted, execution should start with the instruc-
tion labeled GO (line
7).
Assumption
About
OS
The
ASSUME
statement on line 5 tells the
assembler what it should assume will be in
the CS
and
DS
register when the segment of
code
is
executed.
;data segment
;reserve a byte for SUM
;code segment
5.
ASSUME
CS:MY
_CODE,
DS:MY_
DATA
6.
PORT_VAL
EQU
7.
GO: MOV
8.
MOV
9.
MOV
10.
CYCLE:
CMP
11.
JNA
12.
MOV
13.
OUT
14.
HLT
15.
NOT_DONE:
IN
16.
ADD
17. JMP
18.
MY_CODE
ENDS
19.
END
3
AX,MY_DATA
DS,AX
SUM,O
SUM,100
NOT_DONE
AL,SUM
PORT _ VAL,AL
AL,PORT
_VAL
SUM,AL
CYCLE
GO
2-21
;contents
of
CS and DS
;symbolic name
for
port number
;initialize
DS
to
MY_DATA
;clear sum
;if SUM exceeds
100
;
...
then output SUM to
port
3
;
...
and stop execution
;otherwise add next
input
;and repeat the test
;this is the end of the
assembly