Presentation is loading. Please wait.

Presentation is loading. Please wait.

Assembly Language Advantages 1. It reveals the secret of your computer’s hardware and software. 2. Speed. 3. Some special applications and occasions. Disadvantages.

Similar presentations


Presentation on theme: "Assembly Language Advantages 1. It reveals the secret of your computer’s hardware and software. 2. Speed. 3. Some special applications and occasions. Disadvantages."— Presentation transcript:

1 Assembly Language Advantages 1. It reveals the secret of your computer’s hardware and software. 2. Speed. 3. Some special applications and occasions. Disadvantages 1. Not as easy to do the programming. 2. Debug is not as easy compared with high- level language. 3. Not transferable between different CPUs.

2 Registers Intel 16-bits registers AH AL BH BL CH CL DH DL AX BX CX DX Flag IP BP SP SI DI CS SS DS ES Status and Control RegistersSegment Registers Date Registers Index Registers

3 Registers Intel 32-bits registers AX BX CX DX FLAGS IP EAX EBX ECX EDX EFLAGS EIP EBP ESP ESI EDI CS SS DS ES Status and Control RegistersSegment Registers Date Registers Index Registers FS GS

4 Flag Register 16-bits Flag Register The most common used flag bits x x x x O D I T S Z x A x P x C O D I S Z A P C O—Overflow D--- Direction I-----Interrupt S----Sign Z---Zero A---Auxiliary Carry P----Parity C----Carry

5 General Rules about Flags “1”---Set the flag. “0”---Clear the flag. “?”---May change the flag to an undetermined value (Blank)---The flag is not changed * ----Change the flag to specific rules associated with the flag

6 Examples * * * ADD --- Instruction O D I S Z A P C HLT---Stop the CPU until a hardware interrupt occurs. O D I S Z A P C IDIV---Signed Integer Division ? ? ?

7 The Hello World Program title Hello World Program (hello.asm) ; This program displays "Hello, world!".model small.stack 100h.data message db "Hello, world!",0dh,0ah,'$'.code main proc mov ax,@data mov ds,ax mov ah,9 mov dx,offset message int 21h mov ax,4C00h int 21h main endp end main

8 Arithmetic Instructions ADD and SUB instructions ADD reg, reg ADD mem, reg ADD reg, mem ADD reg, immed ADD mem, immed ADD accum, immed Flag O D I S Z A P C SUB has the similar instruction format * * *

9 Debug -F -D -E -T----Make sure you check the IP to see if its counts is pointing the right location. -R IP to change it -A 100 Mov dl, [0200] Mov [0201], dl Mov ax, 4c00(h) Int 21

10 Debug Mov si, 0200 Mov ax, [si] Mov [0270], ax Mov ax, 4c00 Int 21 -T

11 Assembling, linking, And Debugging Debug and Assembler Source File Listing File Object File Link Library Map File Executable Program Output Assembler Linker Loader

12 Start Stop Length Name Class 00000H 004D0H 004D1H _TEXT CODE 004D2H 00665H 00194H _DATA DATA 00670H 0076FH 00100H STACK STACK Origin Group 004D:0 DGROUP Program entry point at 0000:0000 A typical Map File (From Hello.asm) The main feature for the map file is that it list all the information about each program segments.

13 Object File (From Hello.asm) € C:\IRVINE\CH01\HELLO.asm! ˆ ¡CV7–K STACK_DATADGROUP _TEXT$$TYPES $$SYMBOLSDEBTYP DEBSYMSTACKDATACODEø˜H ö˜ H ú˜ t ß™ !† ¦™! š ÿÿY Hello, world!$† ¸ ŽØ´º Í!¸ LÍ!Õœ ÈUÄX” ¨ òñ, Š HELLO.obj6 /Microsoft (R) Macro Assembler Version 6.13.7299 message main œ ÌRÌvTŽŠ ÁP ^

14 Target Processor Directives.8086----8086, 8088.186---.286---.386.486.586.287.387 When using.386, the program can only run on 386 and above processors.

15 Floating-Point Unit 80-bit Registers ST(0) ST(1) ST(7) FPU Instruction Pointer FPU Data Pointer Tag Register Control Register Status Register 48-bit Pointer Register 16-bit Control Register Opcode Register

16 Debug and Debugger MASM supplies a good 16-bit debugger named Code View. TASM supplies one named Turbo Debugger. For 32-bit Windows Console programs, the preferred debugger is Microsoft Visual Studio (msdev.exe), part of Microsoft Visual C++.


Download ppt "Assembly Language Advantages 1. It reveals the secret of your computer’s hardware and software. 2. Speed. 3. Some special applications and occasions. Disadvantages."

Similar presentations


Ads by Google