AssemblyLanguageforIntelBasedComputers5editionchapt12HighLevelLanguageInterface

上传人:E**** 文档编号:90582570 上传时间:2019-06-13 格式:PPT 页数:42 大小:236KB
返回 下载 相关 举报
AssemblyLanguageforIntelBasedComputers5editionchapt12HighLevelLanguageInterface_第1页
第1页 / 共42页
AssemblyLanguageforIntelBasedComputers5editionchapt12HighLevelLanguageInterface_第2页
第2页 / 共42页
AssemblyLanguageforIntelBasedComputers5editionchapt12HighLevelLanguageInterface_第3页
第3页 / 共42页
AssemblyLanguageforIntelBasedComputers5editionchapt12HighLevelLanguageInterface_第4页
第4页 / 共42页
AssemblyLanguageforIntelBasedComputers5editionchapt12HighLevelLanguageInterface_第5页
第5页 / 共42页
点击查看更多>>
资源描述

《AssemblyLanguageforIntelBasedComputers5editionchapt12HighLevelLanguageInterface》由会员分享,可在线阅读,更多相关《AssemblyLanguageforIntelBasedComputers5editionchapt12HighLevelLanguageInterface(42页珍藏版)》请在金锄头文库上搜索。

1、Assembly Language for Intel-Based Computers, 5th Edition,Chapter 12: High-Level Language Interface,(c) Pearson Education, 2006-2007. All rights reserved. You may modify and copy this slide show for your personal use, or for use in the classroom, as long as this copyright statement, the authors name,

2、 and the title are not changed.,Slide show prepared by the author Revision date: June 4, 2006,Kip R. Irvine,Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007.,2,Chapter Overview,Introduction Inline Assembly Code Linking to C/C+ in Protected Mode Linking to C/C+ in Real-Address Mod

3、e,Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007.,3,Why Link ASM and HLL Programs?,Use high-level language for overall project development Relieves programmer from low-level details Use assembly language code Speed up critical sections of code Access nonstandard hardware device

4、s Write platform-specific code Extend the HLLs capabilities,Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007.,4,General Conventions,Considerations when calling assembly language procedures from high-level languages: Both must use the same naming convention (rules regarding the na

5、ming of variables and procedures) Both must use the same memory model, with compatible segment names Both must use the same calling convention,Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007.,5,Calling Convention,Identifies specific registers that must be preserved by procedures

6、 Determines how arguments are passed to procedures: in registers, on the stack, in shared memory, etc. Determines the order in which arguments are passed by calling programs to procedures Determines whether arguments are passed by value or by reference Determines how the stack pointer is restored af

7、ter a procedure call Determines how functions return values,Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007.,6,External Identifiers,An external identifier is a name that has been placed in a modules object file in such a way that the linker can make the name available to other p

8、rogram modules. The linker resolves references to external identifiers, but can only do so if the same naming convention is used in all program modules.,Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007.,7,Whats Next,Introduction Inline Assembly Code Linking to C/C+ in Protected M

9、ode Linking to C/C+ in Real-Address Mode,Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007.,8,Inline Assembly Code,Assembly language source code that is inserted directly into a HLL program. Compilers such as Microsoft Visual C+ and Borland C+ have compiler-specific directives tha

10、t identify inline ASM code. Efficient inline code executes quickly because CALL and RET instructions are not required. Simple to code because there are no external names, memory models, or naming conventions involved. Decidedly not portable because it is written for a single platform.,Irvine, Kip R.

11、 Assembly Language for Intel-Based Computers 5/e, 2007.,9,_asm Directive in Microsoft Visual C+,Can be placed at the beginning of a single statement Or, It can mark the beginning of a block of assembly language statements Syntax:,_asm statement _asm statement-1 statement-2 . statement-n ,Irvine, Kip

12、 R. Assembly Language for Intel-Based Computers 5/e, 2007.,10,Commenting Styles,mov esi,buf ; initialize index register mov esi,buf / initialize index register mov esi,buf /* initialize index register */,All of the following comment styles are acceptable, but the latter two are preferred:,Irvine, Ki

13、p R. Assembly Language for Intel-Based Computers 5/e, 2007.,11,You Can Do the Following . . .,Use any instruction from the Intel instruction set Use register names as operands Reference function parameters by name Reference code labels and variables that were declared outside the asm block Use numer

14、ic literals that incorporate either assembler-style or C-style radix notation Use the PTR operator in statements such as inc BYTE PTR esi Use the EVEN and ALIGN directives Use LENGTH, TYPE, and SIZE directives,Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007.,12,You Cannot Do the

15、 Following . . .,Use data definition directives such as DB, DW, or BYTE Use assembler operators other than PTR Use STRUCT, RECORD, WIDTH, and MASK Use the OFFSET operator (but LEA is ok) Use macro directives such as MACRO, REPT, IRC, IRP Reference segments by name. (You can, however, use segment reg

16、ister names as operands.),Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007.,13,Register Usage,In general, you can modify EAX, EBX, ECX, and EDX in your inline code because the compiler does not expect these values to be preserved between statements Conversely, always save and restore ESI, EDI, and EBP.,See the Inline Test demonstration program.,Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007.,14,File Encryption Example,Reads a file,

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 高等教育 > 大学课件

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号