80x86 assembly language program structure and simple I/O

11
80x86 assembly languag e program structure and simple I/O Assistant : 蘇蘇蘇 (Su Jain-Zh ong) LAB : ISMP LAB Tel : 62530-58 E-Mail : [email protected]. tw

description

80x86 assembly language program structure and simple I/O. Assistant : 蘇建仲 (Su Jain-Zhong) LAB : ISMP LAB Tel : 62530-58 E-Mail : [email protected]. INT 21H(DOS 插斷 ). 輸出字元 AH=02H ; DL= 要輸出的字元 - PowerPoint PPT Presentation

Transcript of 80x86 assembly language program structure and simple I/O

Page 1: 80x86 assembly language program structure and  simple I/O

80x86 assembly languageprogram structure and simple I/O

Assistant : 蘇建仲 (Su Jain-Zhong)LAB : ISMP LABTel : 62530-58E-Mail : [email protected]

Page 2: 80x86 assembly language program structure and  simple I/O

INT 21H(DOS 插斷 )

輸出字元 AH=02H ; DL= 要輸出的字元 PUTCHAR MACRO CHAR

MOV DL,CHAR MOV AH,02H INT 21H ENDM

Page 3: 80x86 assembly language program structure and  simple I/O

INT 21H(DOS 插斷 )(Cont.)

輸出字串 AH=09H ; DS:DX= 欲顯示字串起始位置 以“ $” 結束 PRINT MACRO BUFF

LEA DX,BUFF MOV AH,09H INT 21H ENDM

Page 4: 80x86 assembly language program structure and  simple I/O

INT 21H(DOS 插斷 )(Cont.)

輸入字元 AH=08H READCHAR MACRO

MOV AH,08H INT 21H ENDM

AL 輸入的字元

Page 5: 80x86 assembly language program structure and  simple I/O

INT 21H(DOS 插斷 )(Cont.)

輸入字串 AH=0AH ; DS:DX 緩衝區起始位置 INPUT MACRO BUFF

LEA DX,BUFF MOV AH,0AH INT 21H ENDM

最大輸入字元 實際輸入字元

輸入字串

DS:DX

Page 6: 80x86 assembly language program structure and  simple I/O

An Example

Reference progam2-1

Page 7: 80x86 assembly language program structure and  simple I/O

MACRO

Problem TEST ASC1,X ……………

TEST ASC2,Y L1: …………. LOOP L1 …………. L1: ………… LOOP L1 ………….

Solve

TEST MACRO STR,X ………. L1: ……….. LOOP L1 ………. ENDM

error

TEST MACRO STR,X LOCAL L1 ………. L1: ……….. LOOP L1 ………. ENDM

Page 8: 80x86 assembly language program structure and  simple I/O

MARCO Lib

Reference program2-2

Page 9: 80x86 assembly language program structure and  simple I/O

Subroutine

Parameter passing By register By data segment Reference example program2-3,4

Calling External Program Calling program: EXTRN var: type Called program: PUBLIC var

Type:BYTE,WORD,DWORD

Page 10: 80x86 assembly language program structure and  simple I/O

Subroutine link in diff. files

PUBLIC subroutine nameEXTRN subroutine name:FAR

Page 11: 80x86 assembly language program structure and  simple I/O

How to use assembler

Assembly Tool masm asm_file.asm link obj_file.obj [+ obj_file2.obj] ….. ml asm_file.asm + asm_file2.asm

Debug tool debug exe_file.exe codeview exe_file.exe