1589, 3/80 ȸ  α  
   asdzxc301
   2

http://www.hackerschool.org/HS_Boards/zboard.php?id=Free_Lectures&no=1135 []


2
--------------------------------------------------------------------------------
MOV ɰ
° ۸ɿ ؼ ؼ մϴ.
*.Ϳ ġ Ѵ.
*.Ϳ ̿ ͸ Ѵ.
*.Ϳ ޸ ̿ ͸ Ѵ.

ȭ鿡 " AB " ǥ ϴ α׷
MAIN    SEGMENT             ; ׸Ʈ ˸ ǻ
        ASSUME  CS:MAIN     ;
;
        MOV     DL,41H      ; ƽŰڵ 41H ' A  ' ̴.
        MOV     AH,2
        INT     21H
        MOV     DL,'B'
        MOV     BL,2
        MOV     AH,BL
        INT     21H
;                            ; ܼ Ե
        MOV     AH,4CH       ; α׷
        INT     21H
;
MAIN    ENDS
        END

ڱⰡ ۼ ҽα׷ ״ Ʈ ȭ .LST
.ǻ , ۾ 帧
Ҷ ߿ ݴϴ.
⼭ MAIN  ̸̵ .
ASSUME  CS:MAIN
̶ ǻ Ҷ ڵ弼׸Ʈ(CS:) ϶
MAIN ̶ ̸ ׸Ʈ ϶ ϴ Դϴ.
ASSUME 4 ׸Ʈ(CS,DS,SS,ES) ׸Ʈ ̸ Ű  
ϴ.
ݵ CS:(ڵ弼׸Ʈ )
END . END ۹ Ҽִ.


α׷ ⺻
AMIN    SEGMENT
        ASSUME  CS:MAIN
       ..........
        
       ..........
MAIN    ENDS
        END


(comment,  ּ) ¹
;
Դϴ. ; ڴ Դϴ.


8086 (register)
--------------------------------------------------------------------------------
AX,BX,CX,DX   8 Ʈ Ҽ ִ.
SI,DI,BP,SP   16 Ʈμ ۿ Ҽ .

Ư ǥ ʴ ġ 10μ ޵˴ϴ.
16 Ҷ ڿ H(Hexa decimal) ٿ ǥմϴ.
ġ ĺ Ҷ " 0 " ٿ ̸ ȥ Ѵ.

MOV     DL,  41H                ; DL  <----- 41H      41H DL ϶.
   +--- |    | ----------+
   |    +----+           |
༱(DESTINATION), (SOURCE)

ý ȣ    INT  21H <---- ͷƮ (interrupt-)
CPU ϴ Ű

MOV     DL,'1'      ; ڸ οȣ ʿ 쿡
                      ׹ڿ ϴ ƽŰڵ尡 ֵ˴ϴ.
                      1 ƽŰڵ尪 31H ġ˴ϴ.

α׷ ġ
MOV     AH,4CH     ; MS-DOS SYSTEM CALL 4CH ° ƾ
INT     21H        ; α׷ ġ OS ư.


͸ δ (1)
--------------------------------------------------------------------------------
α׷߿ ͸ ΰ , ͸ Ϳ ϴ
̸ :
XXX     DB      'X'       ; DB define byte
YYY     DW      3456H     ; DW define word
|        |        ---------> ʱġ
|        +---------------->
+-----------------------≯
DB ..... Ʈ
DW ..... (2Ʈ)
DD ..... (4Ʈ)
DQ ..... Ʈ (8Ʈ)
DT ..... 10 Ʈ
*.  +----------+--------+-----------+
          | ̸ |   DB   |         |
          +----------+--------+-----------+

׸Ʈ ϴ ASSUME ǻ
MAIN    SEGMENT
        ASSUME  CS:MAIN, DS:MAIN
MAIN :     ׸Ʈ ø
CS:MAIN    ڵ弼׸Ʈ MAIN ̶ ̸ ׸Ʈ Ǿִٴ°
DS:MAIN    Ÿ׸Ʈ MAIN ̶ ̸ ׸Ʈ Ǿ ִٴ°

8086 Ÿ Ÿ׸Ʈ ִ μ ؼǹǷ ,ͼ׸Ʈ
ִ° ؾѴ.

ɵ Ÿ Ѵ MAIN ̶ ̸ ׸Ʈ Ƿ
ASSUME  CS:MAIN, DS:MAIN

׷ ̰ ̴
Ÿ óϴ δ ʴ´
׸Ʈ ʱ⼳(initialize) ϱؼ
MOV     AX,CS
MOV     DS,AX
̿ͰϿ ,AX ͸ Ͽ DS   CS ǰ Ͽ
2 ׸Ʈ ġŰ ȵ˴ϴ.
̰ Դϴ.

MOV     DS,CS
Ҽ ϴ.׸Ʈ (CS,DS,SS,ES) ͵ ۿ
͸ ϴ Ǿ ʱ Դϴ.
׸Ʈ Ϳ ڳ Ҽ ϴ.
Ʈ
8A 16 0020 R
R  .... ̶ (relative address) Ÿ ϴ.


͸ δ (2)
--------------------------------------------------------------------------------
׸Ʈ δ
MAIN    SEGMENT  ---+
        ......      |
MAIN    ENDS     ---+
DATA    SEGMENT  ---+
        .....       |
DATA    ENDS     ---+ ̿ ΰ ׸Ʈ ϰ Ѵ.

ASSUME  CS:MAIN,DS:DATA
͸ ϴ ִ 쿡 ʹ DATA ̸ ׸Ʈ ִ
ϰ ۼ϶ Դϴ.

MOV     AX,DATA
MOV     DS,AX
׸Ʈ ʱ ϴ κԴϴ.

α׷ Ҷ ׸Ʈ θ ߿
׸Ʈ ִ°  Ű澲 ʰ ,α׷ ۼҼϴ.


(1)
--------------------------------------------------------------------------------
Ʈ ʹ Ͽ Ҽִ.
DB Ͽ ͸ ϴ 쿡 ' ABC ' Ͽ ڶ
͸ Ҽ ϴ.
XXX     DB      'ABC'      ------+ ΰ.
XXX     DB      'A','B','C'      |
XXX     DB      41H,42H,43H   ---+
        |
        +---->DW,DD,DQ,DT ٸ ͵ Ҽ ֽϴ.
׷ ġν ڿν ־ ѹ 2
ڿۿ ټ .
AAA     DD      'AB','CD','EF'
AAA     DD      'ABCD', 'EFGH' ȵȴ.

DB 쿡 Ưϰ 3 ̻ ڿ
'A','B','C'     ϴ ſ     'ABC' Ҽִ.

,׷  XXX ̸ ҿ Ǿִ ͸
ִ°
MOV     AL,XXX
ϸ XXX ҿ ڿ ó   'A'=41H AL
Ϳ ۵˴ϴ.(XXX ϴ ̸ ҿ ִ ͸ ALͿ ϶)

ڸ ִ (OFFSET ):
MOV     BX,offset XXX
                  |      ̸ ٿ ü BX Ϳ
                  +-----> Դϴ.
OFFSET :  ̸ ٿ Ͱ ִ .
¹ : ׸Ʈ

MOV     BL,XXX ; BL   XXX 8 Ʈ ̹Ƿ
MOV     BX,XXX ; BX 16Ʈ , XXX 8Ʈ ̹Ƿ

[  ] :
 [ ] [  ] δ.
MOV     DL,[1FH] ; 1FH ִ ͸ DL ͷ ϶

BX ͳ XXX ó Ͱ DL ͷ ۵˴ϴ.
̰ ǥ մϴ.
2 ° ʹ +1 Ǿ Ƿ, ⼭ BX + 1
Ǵ Դϴ. BX+2,BX+3 .......
MOV     DL,[BX+1]
[  ] Ÿ
Ǿ ִ ϰ ϴ.
̿ (indirect addressing )̶ θϴ.
MOV     AX,[1234H]
μ
(direct addressing mode) ̶ θϴ
MAIN    SEGMAIN                ;  *.͸ ׸Ʈ δ
        ASSUME  CS:CODE,DS:DATA

        MOV     AX,DATA
        MOV     DS,AX
        +-----------+
        |       |
        +-----------+
MAIN    ENDS

DATA    SEGMENT
XXX     DB      'ABC'
DATA    ENDS
        END

(2)
--------------------------------------------------------------------------------
Ҽ ִ ʹ 4̴
BX,BP,SI,DI
ֱ׷ ϴ 8086 ڰ س ̴.

[BX+DI]
[BX+SI+1]
̵鳢 մϴ
) [BX+SI+4]
BX=1000H
SI=1234H  
1000H + 1234H + 4H = 2238H ȴ.

չ Ģ:
+----+       +-------+       +--------------+
| BX |       |  SI   |       |  16Ʈ |
| BP |   +   |  DI   |    +  |  8Ʈ   |
||       |   |       |          |
+----+       +-------+       +--------------+
  [BP] ܵ Ҽ ϴ.
ܼ ࿡ Դϴ ϰ ʹٸ   [BP+0] մϴ.
MOV     DL,[BX+SI]
; BX ۹ , SI 3 ,
DL η 4 ° Ʈ Ͱ DL Ϳ  
.   *.SI= 0 θ Ų.

) MOV5.ASM
޸𸮿 ڿ" ABCDEFG" ׹°, ټ° DE
MAIN    SEGMENT
        ASSDUME CS:MAIN,DS:DATA
;
        MOV     AX,DATA
        MOV     DS,AX
        MOV     BX,OFFSET AAA
        MOV     SI,3
        MOV     DL,[BX+SI]
        MOV     AH,2
        INT     21H
        MOV     DL,[BX+SI+1]
        MOV     AH,2
        INT     21H
;
MAIN    ENDS
;
DATA    SEGMENT
AAA     DB      'ABCDEFG'
;
DATA    ENDS
        END
*. ϴ Ϳ    BP  Ͱ ԵǴ 쿡 ,
   ؼ׸Ʈ(SS:) Ͱ ִ μ ؼȴ.
(   BP ͸ ϴ° Դϴ. )



--------------------------------------------------------------------------------
CODE    SEGMENT
        ASSUME  CS:CODE,DS:DATA
;
        MOV     AX,DATA          ; DS
        MOV     DS,AX
;
        MOV     BX,OFFSET AAA    ; AAA BX
        MOV     AX,'AB'          ; ϳ 8Ʈ
        MOV     [BX],AX          ; BX Ű AAA 'AB' ִ´
        MOV     CX,AAA
        MOV     DL,CH            ; DL A ִ´
        MOV     AH,2       ----+
        INT     21H        ----+ A δ.
        MOV     DL,CL            ; DL B ִ´.
        MOV     AH,2       ----+ B δ.
        INT     21H        ----+
        MOV     AH,4CH
        INT     21H              ; ϰ OS εư.
;
CODE    ENDS
;
DATA    SEGMENT
AAA     DW                     ; AAA ؼ Ȯ϶
DATA    ENDS
        END

AAA     DW      ?     '? ' ڴ ƹ̶ ٶ ǹԴϴ.

̹ δ
MOV     [BX+SI+5],1234H
MOV     AAA,'AB'
մϴ.

MOV     [BX],[SI+3]
׷  ̿ ,۷ Ҽ ϴ.

MOV     BX,[0008] -----> 8 ´
͸ ʰ ġ ϴ ̷
(direct addressing)̶ մϴ.
, MASM ̿ ӿ ϴ.
װ ޸ Ŀ   (dynamic) ȰDZ⶧ ,  
Ҽٰ DZ ̶ ˴ϴ.

EQU ǻ
--------------------------------------------------------------------------------
ϴ EQU ǻ
MAIN    SEGMENT
        ASSUME  CS:MAIN
CHAR1   EQU     'A'    ;'A' = 41H ˴ϴ --+
CHAR2   =       42H    ;  = ǰ        |
DISP    EQU     2      ;  EQU ǰ Ұ, --+ Ҷ ġȯ
;
        MOV     DL,CHAR1
        MOV     AH,DISP
        INT     21H
        MOV     DL,CHAR2
        MOV     AH,DISP
        INT     21H
        MOV     AH,4CH
        INT     21H
;
MAIN    ENDS
        END


EQU ǻɿ ǿ DB  ǿ ̴ :
EQU ؼ - Ҷ ڷ ġȯ
DB  ؼ - Ͱ Ǿ ִ μ ġȯ
)
MOV CHAR1,DL  ----->  Ұ
'=' ؼ ǵ ڸ ٽ Ҷ ,ٽ '=' ؼ Ѵ.
ۼ س鼭 ֱ ǵ ڸ
ڷν մϴ.
˴ϴ.
CHAR1   =       41H
        MOV     DL,CHAR1
CHAR1   =       56H
        MOV     DL,CHAR1
:
=       0041
0000    B2      41
=       0056
0002    B2      56


PTR
--------------------------------------------------------------------------------
(type):
Ʈ,(2Ʈ),(4Ʈ)
ũ ٰ ֵȴ.

)
۷忡 ͸ ũ ʿ
) , Դϴ.

MOV     [BX],12H
⿡ BX 10H սô.׷ ⼭
1) 10H Ʈ 12H Ұ,
2) 10H 11 0012H   ϴ ˼ ϴ.

*.Ʈ                        *.嵥
  |        |        |         |           |         |         |       |
      +--------+        +---------+               +---------+         +-------+
10H  | 55     |  12H   |  12     |           10H |   55    | 0012H   |  12   |
      +--------+------> +---------+               +---------+-------> +-------+
11H  | 66     |        |  66     |           11H |   66    |         |  00   |
      +--------+        +---------|               +---------+         +-------+
      |        |        |         |               |         |         |       |
12H Ʈ ͷν 쿡 11H ʰ
12H    ͷν 쿡  11H ϴ.



PTR
--------------------------------------------------------------------------------
Ȯϰ ϱϿ
MOV     BYTE PTR [BX],12H  ; PTR POINTER
MOV     WORD PTR [BX],12H
̿ ۵Ǵ BYTE Ǵ WORD մϴ.
̶ PTR ̶ Ʈ (overwrite) ڿ Բ ϵ Ǿ ϴ.
Ǿ ִ DB ̵ DW ̵  BYTE , WORD ʴ Ҽ
ϴ.

MOV ɰ
---------------------------------
ADDRESING MODE:
*.ġ (immediate mode)
AAA     EQU     1234H
        MOV     AX,AAA  ;޸ Ʈ ͹Ʈ ̳ϰ
CS,DS,ES,SS IP,FL Ϳ ġ Ҽ ϴ.

*. ( )
ϴ
MOV     DS,AX
MOV     CL,BH   ; ũⰡ ġϴ 8Ʈ Ȥ 16Ʈ Ѵ.
׸Ʈ Ͱ Ҽ . IP ,FL ʹ Ҽ ,
CS ͷ Ҽ ϴ.

*. (޸ )
ϴ Ǿ ִ - 2
1) BX,BP,SI,DI 4 Ϳ ڸ  սŲ.
MOV     AX,[BX+DI+4]
2) ͸ μ ϰ ,׺̸ Ͽ ϴ
MOV     AX,AAA ; ڰ ִ ٿ ̸Ͽ ϴ°

Ŀ :
+-  BX  -+   +-  SI  -+   +-   8Ʈ   -+
|   BP   | + |   DI   | + |   16Ʈ    |
+- -+   +- -+   +-           -+

ʴ չ
1) 8Ʈ ڸ ϴ ( 16Ʈ ƴϸ Ҽ )
׷  MOV   AX,[1234H] Ҽ .
޸ Ͽ ϰ -
MOV     BX,1234H
MOV     AX,[BX]    ; ȵ˴ϴ.
2) [BP] Ҽ .
[BP] ϰ [BP + 0 ] ϸ ȴ

Ҷ :
1) ڵ ׸Ʈ ִٰ
2)ʹ ׸Ʈ ִٰ ȴ.
3)BP ϴ ʹ ׸Ʈ ִٰ ȴ.
4)α׷ ó ׸Ʈ ʱ⼳ ʿ
  MOV   AX,DATA
  MOV   DS,AX    ; DATA   Ÿ ׸Ʈ .

  MOV   AX,CS
  MOV   DS,AX    ; Ÿ ׸Ʈ ڵ弼׸Ʈ .

׷  ؼ ׸Ʈ ̿ ׸Ʈκ ͸
ʹٴ ׸Ʈ Ʈ Ƚ(segment overwrite prefix) ,
ɿ ؼ ׸Ʈ ͸ ų,
ϴ.
)
MOV     AX,ES:[BX]
MOV     CS:[DI+2],CX
׸Ʈ Ʈ Ƚ 4 Դϴ.
CS:,DS:,SS:,ES:




MOV ۰
--------------------------------------------------------------------------------
MOV     AX,CS
MOV     DS,AX
· DS   <---- CS ,׸Ʈ Ͱ
ʱ Դϴ.
,׸Ʈ Ϳ ڸ ϴ Ǿ ʽϴ.
IP,FL ʹ MOV ɿ Ҽ Ǿ ϴ.
CS Ϳ ʽϴ.
CS ʹ о⸸ մϴ.




  Hit : 9004     Date : 2008/12/13 11:06



    
1549   ¥.. ;;; Ф[3]     dkdkfjgh
12/03 7322
1548   vmware ϴ ֳ [3]     playground
03/06 8309
1547   ̾ ۿ ؼ.....[2]    
10/06 9046
1546   7 [2]     asdzxc301
12/13 11184
1545   6     asdzxc301
12/13 9111
1544   5     asdzxc301
12/13 21479
1543   4     asdzxc301
12/13 11674
1542   3     asdzxc301
12/13 10158
  2     asdzxc301
12/13 9003
1540   1[1]     asdzxc301
12/13 13950
1539        asdzxc301
12/13 20871
1538   [8]     gnsehfvlr
05/09 11185
1537   ~~~~~~~ 𸣽ôºе -_-;;[7]     hayanho
08/08 11495
1536    Ͻô αδ Դϴ[6]     lsykoh2
01/17 7161
1535   ȣ[1]     oldlove7
08/02 8632
1534   ȣȭ Ŷ ȣؼϴ ּ[5]     leewoongki
12/07 9029
1533   ȣȭ[3]     leewoongki
12/07 7181
1532   ˾` `2 PC׸ `[10]     koresong
11/01 7859
1531   ȵ̵SDKƮ ܱ[1]     pshshs
02/17 6783
1530   ȵ̵ ڵ ̵ Դϴ.     oldlove7
12/11 9264
[1][2] 3 [4][5][6][7][8][9][10]..[80]

Copyright 1999-2024 Zeroboard / skin by Hackerschool.org / Secure Patch by Hackerschool.org