Title: ????? ?? ??(Fig.4-1 ??)
1????? (1)- 8086 ??? ?????
2??????? ??
- ????? ??
- ??? ??? ???? ?? ??? ?? ??
- ??? ???? ??
- ????? ?? ??(Fig.4-1 ??)
- ?? ??(High-level Language)
- ??? ???? ???? ??? ????? ??
- BASIC, ADA, FORTRAN, PASCAL, C, JAVA ?
- ?? ??(Middle-level Language)
- ?? ??? ?? ?? ??? ????? ??
- C, FORTH ?
- ?? ??(Low-level Language)
- ??? ??? ??
- ???, ????? ?
3???? ???? (1)
- ????? ??? ????? ??? ??? ???? ????
4???? ???? (2)
- ???? ????? ??
- ????(Compiler)
- ?? ??? ???? ???? ?? ??? ???? ??
- ??? ??? ?? ??
- ??? ??? ??? ?? ????? ???? ??? ??
- ? ?? ?? ?? ?? ??? ??
- ?????(Interpreter)
- ?? ??? ??? ????? ??
- ??? ??? ??? ??
- ?? ??? ??
- ?? ?? ?? ?? ???? ???? ?? ?? ??? ????
5????
- ?????(Assembly Language)
- 2?? ??? ???? ????? ???? ??? ??
- Machine Code ? Mnemonic Code
- e.g) in 8086 Processor
- 100010 ? MOV
- 000000 ? ADD
- 001010 ? SUB
- ??? ??? ????? ?? ???? 11 ?? ??
- ????(Assembler)
- ????? ????? ??? ???? ??
- ??????? ??
6????? ??????? ??
???? ??
???? ??
(?????)
???
(?????)
?? ??
?? ??
?? ??
1
1
?? ??
????
????
?? ??
?? ??
n
1
???
7????? ??? ??
- ?????? ?? ?? ??
- ????? ??? ??? ???? ???? ??
- ?? ??
- ??? ?? ? ???? ???
- ??? ???
- ???? ?? ??? ?? ? ?? ??? ???
- ??? ???? ??? ??
- ?? ??
- ????? ???
- ??? ?? ??? ??
- ???? ??? ??? ??? ??? ? ?? ??? ???
88086 ????? ??(1)
- 8086 ???? ??? ??
- ???(Instructions)
- ??? ??(Mnemonic Code) ??? ??? ???? CPU?? ????
??? - ???? ????? ??? ??
- ???(Directives)
- ?? ??(Pseudo Code) ?????? ????? ??? ??? ?????
?? ??? ???? ???? ?? - ???? ????? ?? ??
98086 ????? ??(2)
108086 ????? ??(3)
118086 ????? ??(4)
- ???(instruction)? ??
- ???? ??? 3??? ??
- 0 ?? ???
- e.g) CLC
- 1?? ???
- e.g) DEC CX
- 2?? ???
- e.g) MOV AX, BX
122-?? ??? ?
MOV AL,BL
MOV AX,BX
16 8 7 0
16 8 7 0
1 2 3 4
1 2 3 4
???
? ? ?
BX
BX
BH BL
BH BL
0 0 0 0
0 0 0 0
???
AX
AX
AH AL
AH AL
1 2 3 4
1 2 3 4
BX
? ? ?
BX
???
BH BL
BH BL
1 2 3 4
0 0 3 4
AX
???
AX
AH AL
AH AL
138086 ????? ??(5)
- 8086 ??? ??
- ??? ?? ?? MOV
- ???? ?? ADD, ADC, SUB, SBB, MUL, DIV, INC, DEC
- ???? ?? AND, OR, XOR, NOT, NEG
- ????(???) ?? SHL, SHR, SAR, ROL, ROR, RCL, RCR
- ?? ?? ?? CMP, TEST, JMP, JE, JNE, JAE, LOOP,
LOOPE, LOOPNE, CALL, RET - ??? ?? LODSB, STOSB, MOVSB, MOVSW
- I/O ?? IN, OUT
- ???? ?? INT, IRET
- CPU ?? ?? WAIT, ESC, LOCK, HLT, NOP
- ?? ?? PUSH, POP, XCHG, XLAT
148086 ????? ??(6)
- ?? ?? ??(Addressing Mode)
- ???? ???? ??? ??? ??? ???? ????? ???? ??? ??? ??
- ???? ???? ?? ??
- ??? ??(Immedimate data addressing mode)
- ?? ?? ??(Direct addressing mode)
- ?? ?? ??(Indirect addressing mode)
- ???? ???? ??
- ??? ?? ??
- ??? ?? ??
- ??? ??? ?? ??
15???? ????? ????
- MAIN SEGMENT
- ASSUME CSMAIN
- ???? ??
- MAIN ENDS
- END
16?? A? ???? ????
- 1 MAIN SEGMENT
- 2 ASSUME CS MAIN
- 3 MOV DL, A
- 4 MOV AH, 2
- 5 INT 21H
- 6 MOV AH, 4CH
- 7 INT 21H
- 8 MAIN ENDS
- 9 END
17??? (directives) (1)
- ?? ?? ??? listing control directives
- PAGE length , width
- ??? 50, 80
- PAGE ? ?? ?? ???? ???
- TITLE text (60???), SUBTTL text (60???)
- ?) PAGE 60, 130
- TITLE HEX TO BINARY CONVERSION
- ???? ??? PROC directive
- proc-name PROC type
- ?? ???? ??? ???? ??
- ?? CALL? ?? ??. RET? ?? ???
- type NEAR(???) FAR
- ??? ENDP? ??
18??? (directives) (2)
- ???? ??? segment directive
- seg-name SEGMENT align combine 'class'
- ????? ?? ??
- ?? ??(align type) ?? ??
- PARA ????? ??(???)
- BYTE WORD DWORD PARA PAGE(100H)
- ?? ??(combine type) ???? ? ??? ?? ?????? ?? ??
- NONE(???) PUBLIC STACK COMMON AT
- ??? ??(class type) ??? ? ?? ???? ?????? ??
- code stack data
- ??? ENDS? ??
19??? (directives) (3)
- ?) ????? ????
- Codename SEGMENT PARA 'code'
- subroutinename PROC FAR
-
- subroutinename ENDP
- Codename ENDS
20??? (directives) (4)
- ?? ???
- ASSUME seg-regseg-name , ...
- ???? ??? ???? ????? ?????? ???
- seg-reg CS DS ES SS FS GS
- seg-name segment names NOTHING GROUPS
- ?) ASSUME CSCODESG, DSDATASG, SSSTACK
- END proc name
- ?? ????? ??? ? ??
- name GROUP seg-name , segname
- ?? ??? ?? ????? ??? ???? ? ????? ???? ? (?? ???)
21??? (directives) (5)
- ???? ???? ???
- .CODE name - ?? ???? ?? (?? ?? ??)
- .DATA - ??? ???? ?? (near data ?)
- .STACK size - ??? ?? / ??? ?? 1KB
- .MODEL memory-model
- ??? ????, ASSUME ? GROUP ??? ??
- memory models (?? ?)
- TINY SMALL MEDIUM COMPACT LARGE HUGE
22??? (directives) (6)
Model of code segments of data segments
TINY - -
SMALL 1 1
MEDIUM gt1 1
COMPACT 1 gt1
LARGE gt1 gt1 (array size lt 64K)
HUGE gt1 gt1 (array size gt 64K)
23??? (directives) (7)
- ???? ???? ???(??)
- .STARTUP ???? ????? ????? ?? ??
- .EXIT ????? ?? ?
- INT 21H function 4CH ?? ??
- ?)
- .MODEL SMALL
- .STACK 100
- .DATA
- ??? ??
- .CODE
- ??
- END
24??? (directives) (8)
- ??? ?? ??? data allocation directives
- ???? ??
- ??? ?? ???(' '), ???(" ") ?? character strings
- ?) 'This converts ... ' "in 1950's ..."
- 10?? ?? ??? ?? D? ?? (MASM 6.0??? T? ??)
- ?) 578 ?? 578D
- 16?? ?? ??? AF? ?? 0? ??. ?? H? ??
- ?) 3AH, 0C38DH
- 2?? ?? B? ?? (MASM 6.0??? Y? ??)
- ?) 00110010B
- ?? ?? R? ??
- DUP ??? ??? ??? ??
- ?) 10 DUP('K'), 2 DUP(?)
25??? (directives) (9)
- ??? ?? ??? data allocation directives
- ORG expression
- ?? ???? ???? ???. ?) ORG 0
- ????? ?? ??? ??
- name EQU expression, name EQU ltstringgt
- ??? ??, ?? ?? ?? ???? ??? ????
- ?? ??(constant)? ??
- ?)
- FIVE EQU 5
- SUM EQU TOTAL
- SUBJ EQU lt'System Prog'gt
26??? (directives) (10)
- ??? ?? ??? data allocation directives
- ???? ??
- ???? ????? ??? ??? ?? ??? ??? ?? ??
- DB(Define Byte), BYTE
- DW, WORD 2 ???
- DD, DWORD 4 ???(doubleword)
- DF, FWORD 6 ???(farword)
- DQ, QWORD 8 ???(quadword)
- DT, TWORD 10 ???(tenbytes)
- ??? ?? ??
- name directive (Dn) expression
- name directive (Dn) repeat-count DUP(exp)
27??? (directives) (11)
- ??? ?? ??? data allocation directives
- ?)
- UNK DB ? ????? ?? ??
- VALU BYTE 40 ???? ??
- SEQ DW 1000, 2000, 3000, ...
- A WORD 100 DUP(?) ????? ?? ?? 100?
- B BYTE 2 DUP(3 DUP(4)) 4? 6 ?
- C DB 'Data definition' ???
28??? (directives) (12)
- ?? ???
- OFFSET operator
- ?? ??????? ????? ??? ??? ??
- ?)
- move bx,offset data_x bx points to data_x
- SEG operator
- ????? ??? ?? ????(? ??)? ??
- ?)
- push ds save DS, currently
used segment - mov ax,seg list set DS to segment of
list - mov ds,ax
- mov bx,offset list get the lists offset
- perform list
processing - pop ds restore DS
29??? (directives) (13)
- ?? ???(??)
- PTR operator
- ????? ??? ??
- BYTE PTR, WORD PTR, DWORD PTR,
- ?)
- dec bx ? ?? bx? ???? ?? ????? ???? ? ? ?? ? ??
- dec word ptr bx ?? ?? ?? ??? ????? ??
30??? (directives) (14)
- ?? ???(??)
- LABEL directive
- ??? ??? ??? ????(override) ? ??
- var_name label byte/word/dword/qword/tbyte
- ?)
byte0 label byte word0 dw 4567h word1 label
word byte1 db 41h byte2 db 20h
mov al,byte0 al ? 67h mov
bx,word1 bx ? 2041h
31??? ?? (system call)
- ??? ??
- ????? ???? ???(?? ??? ??)? ???? ?? ??
- e.g) ???? ?? ??? ??
- MS-DOS??? ????? ????? ???? ??? ??? ??
- ???? ?? 21H
- ?) ??? ?? A? ??
- MOV DL, A ??? ???? DL ????? ??
- MOV AH, 02H ?????(subcommand)? AH ???? ??
- INT 21H ???? ??
- subcommand(or function number)
- 01H ??? ?? ??, 02H ????? ?? ??
- 06H ????? ?? ??, 09H ????? ??? ??
- 0AH ????? ??? ??
32???? ????? ??(1)
- ???? ????? ??
- ???
- ???? ??, ?? ?? ??
- ?) PAGE 50, 120
header
stack segment
data segment
code segment
ending
33???? ????? ??(2)
- ???? ??? ??? ?? ??
- INT 21H
- DOS ???? ??. AH ????? ?? function code? ??? ???
?? - function code 4CH
- ???? ??? ?? ??. AL ????? ?? ?? ??. "00"?? ???? ??
- ?????
- MOV AH, 4CH request end
- MOV AL, retcode return code(optional)
- INT 21H exit to DOS
- ???? ??
- MOV AX, 4C00H
34???? ????? ??(3)
- protected mode? ?? ???
- 80386 ?? ? ??? ????? ??
- ????? ????(DWORD)? ??(align)
- 32 ??? ??? ??? ????? ???? ???? ????
- USE32 use type
- 32-bit protected mode? ??? ?? ??
- .386
- segname SEGMENT DWORD USE32
- ??? ???? ????? ???
- MOV EAX,DATASG get address of data
segment - MOV DS,AX load 16-bit portion
35???? ????? ??(4)
- ? 1) skeleton of an .exe program
- ??? ??? ????. ??? ???? ??
- 1 PAGE 60,132
- 2 TITLE P04ASM1 Skeleton of an .EXE
Program - 3 ------------------------------------
- 4 STACKSG SEGMENT PARA STACK 'Stack'
- 5 ...
- 6 STACKSG ENDS
- 7 ------------------------------------
- 8 DATASG SEGMENT PARA 'Data'
- 9 ...
- 10 DATASG ENDS
-
(??)
36???? ????? ??(5)
- 11 ------------------------------------------
- 12 CODESG SEGMENT PARA 'Code'
- 13 BEGIN PROC FAR
- 14 ASSUME SSSTACKSG,DSDATASG,CSCODESG
- 15 MOV AX,DATASG Get address of data
segment - 16 MOV DS,AX Store address in DS
- 17 ...
- 18 MOV AX,4C00H Request
- 19 INT 21H exit to DOS
- 20 BEGIN ENDP
- 21 CODESG ENDS
- 22 END BEGIN
37???? ????? ??(6)
- ? 2)
- TITLE P04ASM1 (EXE) Move and add operations
- .exe source program with conventional segments
- -------------------------------------
- STACKSG SEGMENT PARA STACK 'Stack'
- DW 32 DUP(0)
- STACKSG ENDS
- DATASG SEGMENT PARA 'Data'
- FLDA DW 250
- FLDB DW 125
- FLDC DW ?
- DATASG ENDS
- -----------------------------------
- (??)
38???? ????? ??(7)
- CODESG SEGMENT PARA 'Code'
- BEGIN PROC FAR
- ASSUME SSSTACKSG,DSDATASG,CSCODESG
- MOV AX,DATASG Set address of DATASG
- MOV DS,AX in DS register
- MOV AX,FLDA Move 0250 to AX
- ADD AX,FLDB Add 0125 to AX
- MOV FLDC,AX Store sum in FLDC
- MOV AX,4C00H Exit to DOS
- INT 21H
- BEGIN ENDP End of procedure
- CODESG ENDS End of segment
- END BEGIN End of program
39???? ????? ??(8)
- ? 3)
- PAGE 60,132
- TITLE P04ASM2 (EXE) Move and add operations
- .exe source program with simplified segment
directives - -----------------------------------
- .MODEL SMALL
- .STACK 64 Define stack
- .DATA Define data
- FLDA DW 250
- FLDB DW 125
- FLDC DW ?
- -----------------------------------
- (??)
40???? ????? ??(9)
- .CODE Define code segment
- BEGIN PROC FAR
- MOV AX,_at_data Set address of DATASG
- MOV DS,AX in DS register
- MOV AX,FLDA Move 0250 to AX
- ADD AX,FLDB Add 0125 to AX
- MOV FLDC,AX Store sum in FLDC
- MOV AX,4C00H Exit to DOS
- INT 21H
- BEGIN ENDP End of procedure
- END BEGIN End of program
41??? ?? ?? MOV (1)
- MOV ??
- ???? ?? ?? ????? ????? ???? ??? ?? ???? ???
- ?)
- MOV AH, 01H ????? ???? ??
- MOV AX, BX ?????? ??? ??
- MOV AX, WORD PTR BX ??? ???? ????? ??
- MOV BX, AL ???? ???? ???? ??
42??? ?? ?? MOV (2)
- MOV ?? ?? 1
- MAIN SEGMENT
- ASSUME CSMAIN
-
- MOV DL, 41H
- MOV AH, 02H
- INT 21H
- MOV DL, B
- MOV AH, 02H
- INT 21H
-
- MOV AH, 4CH
- INT 21H
- MAIN ENDS
- END
43??? ?? ?? MOV (3)
- MOV ?? ?? 2
- MAIN SEGMENT
- ASSUME CSMAIN, DSMAIN
-
- MOV AX, CS
- MOV DS, AX
- MOV DL, XXX
- MOV AH, 02H
- INT 21H
- MOV CX, YYY
- MOV DL, CH
- MOV AH, 02H
- INT 21H
- MOV DL, CL
- MOV AH, 02H
- INT 21H
-
MOV AH, 4CH INT 21H XXX DB
X YYY DB 3456H MAIN ENDS END
44??? ?? ?? MOV (4)
- MOV ?? ?? 3
- MAIN SEGMENT
- ASSUME CSMAIN, DSDATA
-
- MOV AX, DATA
- MOV DS, AX
-
- MOV BX, XXX
- MOV DL, BH
- MOV AH, 02H
- INT 21H
- MOV DL, BL
- MOV AH, 02H
- INT 21H
-
MOV AH, 4CH INT 21H MAIN
ENDS DATA SEGMENT XXX DB AB MAIN
ENDS END
45??? ?? ?? MOV (5)
- MOV ?? ?? 4
- MAIN SEGMENT
- ASSUME CSMAIN, DSDATA
-
- MOV AX, DATA
- MOV DS, AX
-
- MOV BX, OFFSET XXX
- MOV DL, BX
- MOV AH, 02H
- INT 21H
- MOV DL, BX1
- MOV AH, 02H
- INT 21H
- MOV DL, BX2
- MOV AH, 02H
- INT 21H
-
MOV AH, 4CH INT 21H MAIN
ENDS DATA SEGMENT XXX DB ABC MAIN
ENDS END
46??? ?? ?? MOV (6)
- MOV ?? ?? 5
- MAIN SEGMENT
- ASSUME CSMAIN, DSDATA
-
- MOV AX, DATA
- MOV DS, AX
-
- MOV BX, OFFSET XXX
- MOV AX, AB
- MOV BX, AX
- MOV CX, XXX
- MOV DL, CH
- MOV AH, 02H
- INT 21H
- MOV DL, CL
- MOV AH, 02H
- INT 21H
-
MOV AH, 4CH INT 21H MAIN
ENDS DATA SEGMENT XXX DW ? MAIN
ENDS END
47MOV?? ???? ??? ??
MOV ltoperand1gt, ltoperand2gt
operand2
? ?
??
?
operand1
?? r.
???? r.
?? r. ???? r. (CS? ??) ???????
? ?
? ? ?
? ?
? ?
4880x86 ???? ?? -??? ?? simple addressing modes
- ?? ?? immediate addressing mode
- ???? register, constant
- ?? ????? ?? ?? ?? ??? ??
- MOV AL, Q
- MOV EAX, 29AB3H
- ?? ?? direct mode
- ???? offset address, register
- MOV ???? ???? ????(AL, AX, EAX) ??? ??? ??? ??
- MOV AX, DATA5
- MOV HERE, AL
4980x86 ???? ?? ???? ?? ?? register-based modes
- ???? ?? register mode
- ???? register, register
- MOV AX, BX
- ?? ?? displacement mode
- ???? ??? ??, ????
- ?? ??? ??? ?? ?? ??? ??
- MOV ES, OFFDAT
- MOV NUM, BP
5080x86 ???? ?? ???? ?? ?? register-based modes
- ???? ?? ?? register indirect mode
- ???? register, register
- BX, DI, SI (or EBX, EDI, ESI) ???? ?? ??? ?????
?? ??? - BP (or EBP) ???? ?? ?? ????? ?? ???
- MOV DI, BX (??? ??? ??? ??)
- MOV CX, BX
- MOV BP, DL
5180x86 ???? ?? ???? ?? ?? register-based modes
- ???? ?? ?? register relative mode
- ???? registeroffset or offsetregister,
register - ESP, SP? ?? ??
- MOV AX, DI100H
- MOV LISTBP2, CL
5280x86 ???? ?? ??? ?? ?? indexed addressing
modes
- ?????? ?? base-plus-index mode
- ???? registerregister, register
- registerregister base register(BP, BX, or
other 32-bit registers) index register(DI, SI,
or other 32-bit registers) - SP, ESP ? ?? ??
- ?? ???? ??
- MOV CX, BXDI
- MOV BPDI, CX
- MOV EAXEBX, ECX
5380x86 ???? ?? ??? ?? ?? indexed addressing
modes
- ??? ????? ?? base-relative-plus-index mode
- ???? registerregisteroffset or
offsetregisterregisteroffset, register - MOV DH, BXDI30H
- MOV LISTBPSI10, AX
- MOV AH, FILEEBXECX2
5480x86 ???? ?? ??? ?? ?? indexed addressing
modes
- ?
- .MODEL SMALL
- .DATA
- FILE EQU THIS BYTE
- RECA DB 10 DUP (?)
- RECB DB 10 DUP (?)
- RECC DB 10 DUP (?)
- RECD DB 10 DUP (?)
- .CODE
- .STARTUP
- MOV BX, OFFSET RECA
- MOV DI, 0
- MOV AL, FILEBXDI
- MOV BX, OFFSET RECC
- MOV DI, 2
- MOV FILEBXDI, AL
- .EXIT
- END
5580x86 ???? ?? ??? ?? ?? indexed addressing
modes
- ???-??? ?? scaled-index mode
- ???? 32-bit register, sfregisteroffset or
offsetsfregister - sf scaling factor
- MOV EAX, EBX4ECX
- MOV LISTEAX2EBX10, DX
5680x86 ???? ?? PC ?? ?? PC-related addressing
modes
- ?? ??
- ??? ??? ???? ?? ? ? ?? (?? ???? ??)
- JMP 10000H ? CS 1000H, IP 0000H
- ?? ??
- ?? ?????? ?? ??
- short jump(1-byte displacement), near jump(2-byte
displacement) - JMP 2 ? ???? ???
- ?? ??
- JMP AX
- JMP NEAR PTRBX
- JMP TABLEBX
5780x86 ???? ?? - ??
- ??
- near, far ??
- near address ??? ?????? ??
- far address ????? ????? ??. segmentoffset
- segment override prefix
- ?? ???? ????(ES, FS, GS)? ???? ???? ??? ?
- ?)
- MOV CX, ESBX move to CX from ESBX
- MOV ESDI12, AH move to ESDI12 from AH
5880x86 ???? ?? - ??
- ?
- .MODEL SMALL select SMALL
model - .DATA
indicate start of DATA segment - ARRAY1 DB 10 DUP (?) reserve 10 bytes
for ARRAY1 - ARRAY2 DB 10 DUP (?) reserve 10 bytes
for ARRAY2 - .CODE
indicate start of CODE segment - .STARTUP
indicate start of program - MOV AX,0
address segment 0000 with ES - MOV ES,AX
- MOV DI,0
address element 0 - MOV CX,10 count
of 10 - LAB1
- MOV AL,ESDI copy
00000000 through 00000009 - MOV ARRAY1DI,AL into ARRAY1
- INC DI
- LOOP LAB1
5980x86 ???? ?? - ??
- MOV DI,0
address element 0 - MOV CX,10 count
of 10 - MOV AL,0
initial value - LAB2
- MOV ARRAY2DI,AL fill ARRAY2
- INC AL
- INC DI
- LOOP LAB2
- MOV DI,3
exchange array data - MOV AL,ARRAY1DI
- MOV AH,ARRAY2DI2
- MOV ARRAY1DI,AH
- MOV ARRAY2DI2,AL
- .EXIT
exit to DOS - END
end of file
6080x86 ???? ?? ?? ?? ?? ?? ??
- ?? ?? ?? ??
- ????? ???? ???? ?? ??? ??
- ?? ??? ??
- ?? ?? ??? ???? ????
- 4?? ????? ?? ?? - BX, BP, SI, DI
- ?? ?? ?? ??
- ???? ?? ??
- 3? ?? ??? ??, 8-bit offset? ???? ??, BP ? ??
6180x86 ???? ?? ?? ?? ?? ?? ??
- ?? ?? ?? ??(??)
- ???? ?? ??
- ????? ???? ??? ????? ??? ????
- ???? ??? ??? ???? ??? ??
- BP? ???? ?? ????? ???? ?? ????? ??? ??
- ?? ?? ?? ?? ?? ??? ??
- ?? ?? D, pp.338 ??