Assemble Language - PowerPoint PPT Presentation

1 / 79
About This Presentation
Title:

Assemble Language

Description:

Title: Author: zfp Last modified by: kj Created Date: 10/13/2002 8:32:02 AM Document presentation format: – PowerPoint PPT presentation

Number of Views:96
Avg rating:3.0/5.0
Slides: 80
Provided by: zfp7
Category:

less

Transcript and Presenter's Notes

Title: Assemble Language


1
?7? ?????????
2
Assemble Language
  • ?????????????,?????????????????(??????????),??????
    ???????????????

3
Assemble Language
  • ???????????????????,??????????????????????????????
    ??????????????????
  • ??????

4
  • ???????????????
  • ?????????????????,?????????,???????????????
  • ??????????????????,????????????????

5
  • ??
  • 1. ?????(???????????????)
  • 2. ????????????????
  • ????????????????????????????????

6
????
DATA SEGMENT ???
NUM DW 0011101000000111B NOTES
DB The result is , DATA ENDS CODE
SEGMENT ???
ASSUME CSCODE,DSDATA BEGIN
MOV AX, DATA MOV DS,AX
MOV DX,OFFSET NOTES ??????
MOV AH,9H INT 21H
MOV BX,NUM ????BX
MOV CH,4
CH??????
7
????(?)
ROTATE
DISPLAY MOV CL, 4
CL?????? MOV DL, AL ??16???
ROL BX,CL
MOV AH,2 MOV AL,BL
INT 21H
AND AL,0FH AL????16??? DEC CH
ADD AL,30H ???ASCII?? JNZ
ROTATE CMP AL,9 ?09????
MOV AX,4C00H??DOS JLE DISPLAY
INT 21H
ADD AL,07H ?AF?? CODE
ENDS ?????
END
BEGIN ????
8
???????
STACK SEGMENT STACK STA DB 50 DUP (?)
TOP EQU LENGTH STA STACK ENDS CODE SEGMENT
ASSUME CSCODE,DSDATA,SSSTACK STARTMOV
AX,DATA MOV DS,AX MOV
AX,STACK MOV SS, AX
MOV SP,TOP CODE
ENDS END START
9
7.1.2 ??????????
  • 1. ??????????
  • ??????????????????,???????????????????????????
    ?????,??????
  • ?????5.0?(MASM V5.0)??,?????????????????
    ?????????????????128??????????????????
    ?????????????????????

10
  • ???????????,????
  • ?????????????1,?????2, ??
  • ??,??????(????)??????????????,????(???????)??????
  • ??????????????????(????)?????????????
  • ?
  • A DB 20H,30H ??

11
  • ??????????,????
  • ???????????????1,??????2??
  • ??,???????(???)?????????????,????(???????)??????
  • ????????
  • ???????,????????????????
  • ?
  • L ADD AX,BX ??

12
  • ???????????????????,???????????????,??????????
  • ??????????????????,????????????????
  • ????????,???????????CPU??,??CPU????????????????

13
7.1.4 ????????
  • 1. ????????
  • 2. ?????????( ????)
  • (1) ?????
  • ?????????,??????????????????????
  • 8086/8088CPU??????????? ?????????BCD?????(???),
    ??????????????BCD??,??????(???)?

14
  • ?????????????
  • (???????????????????????, ???????????????)
  • ??????????EQU????
  • ??,A EQU 7? A 7?????A???????7?
  • ????????EQU?????????????,??????????????
  • ?,A EQU 7 ??A7
  • A EQU 8 (???) A8

15
  • (2) ??
  • ???????????,????????????????????????????????,?????
    ??(DS? ES? SS? CS),??????????(DS)????(ES)?
  • ?????????DB?DW?DD?????????????????,????????????,??
    ?????????

16
  • ??, ?????????,
  • A DB 50,60,70,80
  • DW 50,60,70,80
  • DD 50,60,70,80
  • ?DB?DW?DD???????4???,?????????????

17
  • ?DB??????????????,?DW?????????????????,?DD????????
    ?????????,??????????????????,???DB?????????????A?
  • A???DB???????(?DB?????50???)????
  • ????????
  • ?????? ??????????
  • ??????? ?????????????????
  • ????? ??????????????

18
  • (3) ??
  • ???????????,???????????
  • ??????????(?????),???????????????????(CS)?,???????
    ????????????????,???????????????????, ????????,
  • MOV CX, 2
  • LDEC CX
  • JZ L
  • L????,??JZ????????(????).

19
  • ????????
  • ?????? ????????????????????
  • ??????? ????????????????????
  • ????? ??????,????????????????????????

20
  • (4) ??
  • ????????SEGMENT?ENDS?????????,SEGMENT?ENDS???????,
    ????SEGMENT?ENDS??????
  • ??????,ENDS????????SEGMENT????????

21
  • (5) ???
  • ????????,??????,??????????????????????,?????????
  • ????????PROC?ENDP??????????,PROC?ENDP???????,?????
    PROC?ENDP??????
  • ???????,ENDP????????PROC????????
  • ????????,??????????

22
??(???)?????
  • Proc-A PROC NEAR(?FAR)
  • ____________
  • ??? ____________
  • .
  • .
  • .
  • ____________
  • RET
  • Proc-A ENDP

23
  • (6) ???????
  • ?????????????????,???????????????????????????????
    ?????????
  • ????????????????
  • ?????????,????( ???)????0,??,????????????,??????
    ,?????????????????
  • ??,??????????????????

24
  • ?????,??????????????,??A??????0074H,???
  • A DW 1, 2, 4, 3, 4, 4 ?????4??????A4,???4
    ??????A10?
  • ???
  • ???44(A4)4(0074H4)4007CH
  • ???44(A10)4(0074H0AH)40082H

25
  • ????,????????????,????????????????????,JZ
    6???????????????6,6????????????????,????????,
  • DEC CX
  • JZ 5
  • MOV AX, 2
  • LAB ...
  • ????JZ???????,?JZ???2???,???MOV
    ???3???,??,??????,JZ????????LAB??????, ???LAB ???

26
3. ????????(??)?
  • ????????????,?????????????????????????(??)???????(
    ??)????????(??)??????????????????????????
  • ??????????????,???????????,?????????CPU????
  • ?????????????,???????????

27
(1) ?????
  • ?????-?MOD?SHL?SHR??/?7???,??????????(???)??????
    ?????????????????????????,?-?????????????????????
    ??
  • ??????????,????????????
  • ??,??????,
  • 124 MOD 3????1
  • 10110101B SHL 2????11010100B

28
  • ???,??????,
  • W1 DW 1, 2, 3, 4, 5, 6, 7
  • B1 DB 10, 20, 30, 40, 50
  • N1 EQU B1-W1
  • N2 EQU -W1
  • B2 DB 0
  • ?N114,???W1???B1????????????
  • N219,???W1???B2(?????)?????????????

29
(2) ?????
  • ??????????????,?EQ?NE?LT?GT?LE?GE?6???,???????????
    ?????????????????,??????????
  • ?????,?????,??????,????????-1(n??1)??,??0(
    n??0)???
  • ??,?????
  • (60H LE 70H) GE (60H LT 30H) FFFFH GE 0000H
    FFFFH?

30
(3) ?????
  • ?NOT?AND?OR?XOR?4???,????????????,??????(???)?????
    ??
  • ??,?????,1234H OR 2AFEH 3AFEH,
  • NOT 0F0H
    FF0FH
  • ??????,NOT 0F0H 0FH?

31
(4) ????(??)???
  • ??DUP????,?????(??)?????????(??),?????
  • ????DUP (??1, ??2, )
  • ??,??????????(165535),??1???2 ??????????,

32
  • ??????????
  • W DW 25,8,2,3,2,3,6,8,2,3,2,3,6
  • W DW 25,2 DUP(8,2,3,2,3,6)
  • W DW 1 DUP(25),2 DUP(8,2 DUP(2,3),6)
  • W DW 1 DUP(25),2 DUP(1 DUP(8),2 DUP(2,3),1
    DUP(6))
  • ???????13?????13?,????1?????????13???????,????25?
    ???,????(8,2,3,2,3,6)?????

33
  • ??????,????????????????W???,?W????W???????W??????,
    W????1,???2,???2????????????????
  • ?????A DB 1, 2, 5 DUP(0,1,2 DUP(3)),??A?????6????
    ????? .

34
(5) ???(????)???
  • ????????????????????????SEG?OFFSET?TYPE?LENGTH?SIZ
    E?5???,??????????????????????????,????????????
  • ??? SEG ??????
  • ?????????????????,?A???????,?SEG
    A??A????????
  • ??? OFFSET ??????
  • ?????????????????,?A????????OFFSET
    A??A????????

35
  • ??? TYPE ??????
  • ??????????????
  • ??? LENGTH ???
  • ???????,??DUP???????????? ???????
  • ? ?? SIZE ???
  • ???????,?TYPELENGTH???????,SIZETYPELENGTH?

36
??TYPE?LENGTH?SIZE?????
  • ??W1 DW 20 DUP(3, 10 DUP(7)),?TYPE W12,LENGTH
    W120,SIZE W140
  • ??W2 DW 8, 20 DUP(3, 10 DUP(7)),?TYPE
    W22,LENGTH W21, SIZE W22
  • ??B1 DB 20 DUP(3, 10 DUP(7)),?TYPE B11,LENGTH
    B1 ,SIZE B1
  • ??B2 DB 8, 20 DUP(3, 10 DUP(7)),?TYPE B2
    ,LENGTH B2 , SIZE B2 ?

37
(6) ????(????)???
  • ????????????????????????,????PTR??THIS?3???,?????
    ? ??????????????????????????????????????????
  • ? ?? ??? PTR ?????????
  • ??,??MOVBX, 5???????5??????BX?
    ????????????BX??,??????DS????????????5??????,?????
    ????BX?????????,???????

38
  • ??? ????? ??????
  • ?????????????????,MOV AX,
    ESBX?????????????ES,??????DS?
  • ??? THIS ???
  • ????????????????????,THIS BYTE???????????????,THIS
    FAR???????????????
  • THIS??????????????????????????,????????THIS??????
    ???

39
  • THIS ???PTR??????????(BYTE,WORD?DWORD)?????(NEAR?F
    AR)???????????????????????????????
  • THIS ?????????EQU ??,?????????????????????,???????
    ????????????????????
  • A EQU THIS BYTE
  • B DD 12345678H
  • ???????????B???????????,??A ?????????????

40
  • ?
  • .
  • A EQU THIS BYTE
  • B DD 12345678H
  • ...
  • CLD
  • MOV SI, OFFSET A
  • LODSB AL (DSSI),
    SI SI1

41
  • DATA SEGMENT
  • A EQU THIS BYTE
  • B DD 12345678H
  • DATA ENDS
  • CODE SEGMENT
  • ASSUME CSCODE, DSDATA
  • START
  • MOV AX,DATA
  • MOV DS,AX
  • CLD
  • MOV SI, OFFSET A
  • LODSB AL
    (DSSI), SI SI1
  • MOV AX,4C00H
  • INT 21H
  • CODE ENDS
  • END START

42
  • ??
  • START EQU THIS FAR
  • MOV CX ,100
  • ??,MOV ?? ???FAR ?????START,????????JMP
    ??????START??

43
(7) ?????
  • ?SHORT?HIGH?LOW??,???????????(?????????????)??????
    ?????????
  • ? ?? SHORT ??
  • ??????IP??(??-IP)????,??????(??)???
  • ? ?? HIGH ????
  • ???????????????,HIGH 1234H??????12H?
  • ? ?? LOW ????
  • ???????????????,LOW 1234H??????34H?

44
4. ????????
  • (1) ??????
  • ????????????????????,?????????????????????????????
    ????????????????????????????
  • ? ?????
  • ? ?????
  • ? ?????
  • ? ?????

45
(2) ????????
  • ??????????????????????
  • ? (i) ()? ?ltgt(ii) LENGTH?WIDTH?SIZE?MASK
  • (iii) (????????) (iv)
    (?????????)
  • (v) PTR?OFFSET?SEG?TYPE?THIS (vi)
    HIGH?LOW
  • ? (i) (??)?- (??) (ii) ?/
  • (iii) MOD?SHL?SHR (iv)
    ? -
  • ? EQ?NE?LT?LE?GT?GE
  • ? (i) NOT (ii) AND
    (iii) OR?XOR
  • ? SHORT
  • ??,??HIGH???????,??,
  • HIGH 1234H 2 12H 2 14H
  • HIGH (1234H 2) HIGH 1236H
    12H

46
7.1.5 ???????????
  • 1. ????(??????)
  • ?????????????,?????????????????????,?DB?DW?DD?DF?D
    Q?DT?6?????
  • ????????????????????????????????3?(??)?????4??????
    10??????

47
  • ??,??????,
  • A DB 12H, ?
  • B DW ?, 3456H
  • C DD 789ABCDEH
  • D DB 'A', 'B', 'C', 'D'
  • E DB 'ABCD'
  • F DW 'AB', 'CD'
  • ????????????7.4?????,DB'AB'?DW'AB'????????

48
A
12
?
B
DE
C
41
D
41
E
42
F
BC
42
42
41
?
?
9A
43
43
44
56
78
44
44
43
34
?7.4 ????????????
49
???
  • DATA SEGMENT
  • TAB DW 1,2,3,4,5,6
  • ENTRY EQU 3
  • DATA ENDS
  • CODE SEGMENT
  • ASSUME CSCODE, DSDATA
  • L MOV AX, DATA
  • MOV DS, AX
  • MOV BX,OFFSET TAB
  • ADD BX, ENTRY MOV AX,
    TAB3
  • MOV AX, BX
  • CODE ENDS
  • END L
  • ???????,AX

50
2. ????(?????)
  • ? ?EQU?PURGE?3????,???????????????(??)?
  • (1)?? ??? ???
  • ???????????,??????????????????
  • (2) ?? ??? EQU ??????????
  • ??????????????????,???????????????????????????
  • (3) ?? PURGE ???1,???2,
  • ??(??)?EQU??????,?????EQU??????????????

51
3. ???
  • ????????3?,?SEGMENT?ENDS?ASSUME,??????????????????
    ??
  • (1) ?? ?? SEGMENT????????'??'
  • ??????????????????????????????'??'??????,?????????
    ?????
  • ? ???? ???????????????????????????4???
  • BYTE ??????????XXXX XXXX XXXX XXXX XXXX(????)??
  • WORD ?????????XXXX XXXX XXXX XXXX XXX0(????)??
  • PARA(??) ?????????XXXX XXXX XXXX XXXX
    0000(16???)??
  • PAGE ?????????XXXX XXXX XXXX 0000
    0000(256???)???
  • ??,1?(paragraph) ?16??,1??16??256???

52
? ???? ?????????????????????????6???
  • PUBLIC
  • STACK
  • COMMON
  • MEMORY
  • AT???
  • NONE(??)
  • ???????????NONE??,?????????,?????????
  • ????,???STACK????,???? ?

53
  • ? '??' ??????????'??'????,???????????????'??'????
    ???????????????????40??????(???)?
  • (2)?? ?? ENDS
  • ??????????????????????SEGMENT????????
  • (3) ?? ASSUME ?????1??1,?????2??2,
  • ????????????????????,??????(?????)????????????????
    ?????

54
4. ?????????
  • ????ORG?EVEN?????,???????????????????
  • (1) ?? ORG ?????
  • ????????????????????????,?????????????
  • (2) ?? EVEN
  • ????????????????????????,????????????????????

55
  • ??,???????????,
  • ORG 1000H
  • A DB 47H, 12H, 45H
  • EVEN
  • B DB 47H
  • ORG 1000H ?A??????????1000H,?A????3?????,????100
    0H?1001H?1002H,B??????????1003H,?EVEN????B????????
    ??????1004H?

56
  • ?????,??????????,??????EVEN ??????????,??
  • DATA-SEG SEGMENT
  • EVEN
  • WORD-ARRAY DW 100 DUP(?)
  • DATA-SEG ENDS

57
5. ????
  • ?PROC?ENDP?????,??????????????,???????
  • (1)?? ??? PROC ?????
  • ?????????????????,???????????NEAR?FAR????,????????
    ???,????????????
  • ?????????????NEAR,???????
  • (2)?? ??? ENDP
  • ????????????????????????PROC?????????

58
??(???)?????
  • Proc-A PROC NEAR(?FAR)
  • ____________
  • ??? ____________
  • .
  • .
  • .
  • ____________
  • RET
  • Proc-A ENDP

59
6. ????
  • ???????????,?LABEL,????????????????????,??????????
    ?
  • ?? ?????? LABEL ?????
  • LABEL?EQU THIS?????

60
7.???????????
  • ?(MACRO)??????????????????????????????,???????????
    ?????
  • ?????????????????

Macro-name
??MACRO?ENDM?????????,????????????????????????
61
  • ?????????????????????,?????????????,???????
  • Macro-name actual parameter list(??????????)
  • ????????,????????????????
  • ?????????????????????,????????????????????

62
  • ?1. ????????
  • ???SAVEREG MACRO
  • PUSH AX
  • PUSH BX
  • PUSH CX
  • PUSH DX
  • PUSH SI
  • PUSH DI
  • ENDM
  • ??? SAVEREG
  • ??? ????????(??????????)?????

?????
???
????
?????
63
  • ?2 ????????
  • ??? FOO MACRO P1, P2, P3
  • MOV AX, P1
  • P2 P3
  • ENDM
  • ??? FOO WORD_VAR, INC, AX
  • ??? MOV AX, WORD_VAR
  • INC AX

64
????????????????
  • ?????????

???
???Q(x,y)
?????
X?A,y?B
Q . .
. RET
CALL Q
x?C,y?D
CALL Q
65
  • ???????

???
?????
Q(A,B)
Q A,B
Q C,D
Q(C,D)
Q MACRO x,y
ENDM
66
????????????????
1. ????????? 2. ????????????,??????,??????????,???
???????????????,???????????????,??????? 3.
??????????
67
7.1.3 ?????????
68
??????????????
69
?????
70
?????????
  • ???????
  • ???????(ASM.EXE)
  • ??????(MASM.EXE),?????????

71
  1. ?????
  2. ???????????,???????
  3. ??????(.OBJ),????????(???????????????????????,???.
    LST??)???????(??????????????????????,???.CRF??)?
  4. ??????

72
????
  • ???????OBJ??????????,???????.EXE???????
  • ?????????????(LINK.EXE),?OBJ?????????,????????EXE?
    ??????
  • ????,????MAP???LIB???

73
?????
74
????(DEBUG.COM)
  • gtDEBUG PROG.EXE
  • - U (???)
  • - g ???? ????
  • - T ?? ????

75
??????????????
Handwritten source program
EDIT Editor program
MASM assembler program
PROG1.CRF
PROG1.LST
PROG1.OBJ
Other .OBJ files
Libraries
LINK linker program
DEBUG debug program
Final debugged run module
76
BIOS?DOS??
  • ROM BIOS(Basic Input Output System)?????0FE00H??
    ?8k ROM?,?????????,????,??I/O??????????????????
  • ??BIOS????,??????????I/O???????,????????????,?????
    ???

77
????
  • ??????
  • ?????
  • INT XXH
  • ? MOV CX,0
  • MOV DX,0
  • MOV AH,1 ????1
  • INT 1AH

????
78
DOS ??(DOS ??????)
  • ????21H?????,??????????????????????????,??????????
    ???????/?????????????
  • ??????????
  • MOV DL, (24H) ??????
  • MOV AH, 6 ??????6
  • INT 21H DOS??????

79
?7? ??
  • ???
  • 1? 5? 9? (1)(2)10?11?
Write a Comment
User Comments (0)
About PowerShow.com