Upload
tremain-punch
View
49
Download
0
Embed Size (px)
DESCRIPTION
EE314 Microprocessor Systems. Chapter 3. Objectives: The style of source files written in 80x86 assembly language The different addressing modes of the 80x86 The operation and use of the processor flags Data transfer and string instructions. - PowerPoint PPT Presentation
Citation preview
Chapter 380x86 Instruction, Part 1: Addressing Modes, Flags, Data Transfer, and String Instructions
Objectives:
The style of source files written in 80x86 assembly language
The different addressing modes of the 80x86
The operation and use of the processor flags
Data transfer and string instructions
EE314Microprocessor Systems
Based on "An Introduction to the Intel Family of Microprocessors" by James L. Antonakos
3.2 Assembly language programming
Assembler
...
Linker Library
Object files
Final object file or executable file
Source file(TOTAL.ASM)
List file(TOTAL.LST)
Object file(TOTAL.OBJ)
3.2 Assembly language programmingA Sample Source File
ORG 8000HTOTAL: MOV AX,7000H ;load address of data area;
MOV DS,AX ;init data segment registerMOV AL,0 ;clear resultMOV BL,16 ;init loop counterMOV SI,0 ;init data pointer
ADDUP: ADD AL,[SI] ;add data value to resultINC SI ;increment data pointerDEC BL ;decrement loop counterJNZ ADDUP ;jump if counter not zeroMOV [SI],AL ;save sumRET ;returnEND
1 8000 2 8000 B8 7000 3 8003 8E D8 4 8005 B0 00 5 8007 B3 10 6 8009 BE 0000 7 800C 02 04 8 800E 46 9 800F FE CB10 8011 75 F911 8013 88 0412 8015 CB13
DATA SEGMENT PARA ‘DATA’ORG 7000H
POINTS DB 16 DUP (?)SUM DB (?)DATA ENDS
CODE SEGMENT PARA ‘CODE’ASSUME CS:CODE, DS:DATA
CODE ENDSEND TOTAL
8000 B8 8001 008002 70
LabelEnd Segment
Begin of Data segment
Data name
Begin of Code segment
End Source file Start execution address
3.2 Assembly language programmingA Sample Source File
ORG 8000HTOTAL: MOV AX,7000H ;load address of data area;
MOV DS,AX ;init data segment registerMOV AL,0 ;clear resultMOV BL,16 ;init loop counterMOV SI,0 ;init data pointer
ADDUP: ADD AL,[SI] ;add data value to resultINC SI ;increment data pointerDEC BL ;decrement loop counterJNZ ADDUP ;jump if counter not zeroMOV [SI],AL ;save sumRET ;returnEND TOTAL
1 8000 2 8000 B8 7000 3 8003 8E D8 4 8005 B0 00 5 8007 B3 10 6 8009 BE 0000 7 800C 02 04 8 800E 46 9 800F FE CB10 8011 75 F911 8013 88 0412 8015 CB13
.MODEL SMALL
.DATAORG 7000H
POINTS DB 16 DUP (?)SUM DB (?)
.CODE
3.2 Assembly language programmingPredefined .MODEL types
Memory Model
Data Segments
Copde Segments Special Features
TINY one one .COM files. CS and DS combinedSMALL one one smallest .EXE modelMEDIUM one multipleCOMPACT multiple oneLARGE multiple multipleHUGE multiple multiple Uses normalized addressFLAT one one 32 bit addressing
3.3 Instruction TypesInstruction Types Scope Data size
Data transfer reg<->reg; reg<->mem 8, 16, 32 bitStrings move, scan, compare strings in memory 64KBArithmetic add, sub (signed or no), mul, div, BCD, ASCII 8, 16, 32 bitBit manipulation AND, OR, XOR, NOT, shift, rotate 8, 16, 32 bitLoops and jumps Conditional and unconditional program jumpsSubrutine and interrupt Subrutine (far, near) and interrupt, stack controlProcessor control control flags, enable/disable interrupts,