New version page

MSU ECE 3724 - Preparing/Executing a Program

Documents in this Course
Timers

Timers

38 pages

TEST 4

TEST 4

9 pages

Flags

Flags

6 pages

Timers

Timers

6 pages

Timers

Timers

54 pages

TEST2

TEST2

8 pages

Load more
Upgrade to remove ads

This preview shows page 1-2-3 out of 8 pages.

Save
View Full Document
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience

Upgrade to remove ads
Unformatted text preview:

1Preparing/Executing a ProgramTextEditorSourceCodeFileCompilerAssembler(object)FileListingFileAssembler LinkingLibraryexecutableFilemapFileAssemblerFileListingFileexecutableFileLoaderPhysicalMemoryMASM 8086 Instruction - Basic StructureLabel Operator Operand[s] ;CommentLabel - optional alphanumeric string1st character must be a-z,A-Z,?,@,_,$Last character must be :Operator - assembler language instructionmnemonic an instruction format for humansassembler translates mnemonic into hexadecimal opcodeexample mov is f8hOperand[s] - 0 to 3 pieces of data required by instructioncan be several different formsdelineated by commasimmediate, register name, memory data, memory addressComment - Extremely useful in assembler languagegeneral rule is 1 comment per instructionThese fields are separated by White Space (tab, blank, \n, etc.)8086 Instruction - ExampleLabel Operator Operand[s] ;CommentINIT: mov ax, bx ; Copy contents of bx into axLabel - INIT:Operator - movOperands - ax and bxComment - alphanumeric string between ; and \n• Not case sensitive• Unlike other assemblers, destination operand is first• mov is the mnemonic that the – assembler translates into an opcode• unassemble translates opcode into mnemonic2Anatomy of MASM Source File• Assembler Program Divided Into Segments– Not Exactly the same as Memory Segments– Program can have Several Segments; Only 1 Active• Segments Defined in 1 or More Modules– contain instructions, data, directives• Each Module is a Separate File– Assembler Translates Modules to Object Files• Linker Does Several Things– Combines Multiple Object Files– Resolves Relative Addresses– Inserts Loader Code– Creates ExecutableAssembler Language Segment Types• Stack– For Dynamic Data Storage– Source File Defines Size– Must Have Exactly 1 - Context Switching• Data– For Static Data Storage– Source File Defines Size– Source File Defines Content (Optional)– Can Have 0 or More• Code– For Machine Instructions– Must Have 1 or MoreUsing MASM Assembler• to get help:C:\> masm /h• Can just invoke MASM with no arguments:C:\> masmSource Filename [.ASM]: helloObject Filename [HELLO.OBJ]:Source Listing [NUL.LST]:Cross Reference [NUL.CRF]:• .ASM - Assembler Source File Prepared by Programmer• .OBJ - Translated Source File by Assembler• .LST - Documents “Translation” Process– Errors, Addresses, etc.• .CRF - Symbol Table3Using MASM Assembler/Linker (Cont.)• Another way to invoke assembler:C:\> masm hello,,hello,hello• This Causes MASM to Create:HELLO.OBJ HELLO.LST HELLO.CRF• Yet Another Way:C:\> masm hello• This Causes MASM to Create:HELLO.OBJ• Next Step is to Create Executable File using the Linker:C:\> link hello• This Causes Linker to Create:HELLO.EXEMASM Assembler Language• Each Module Contains 4 Types of Statements:1. Executable Instructions2. MASM Assembler Directives3. MASM Macroinstruction Definitions4. MASM Macroinstruction CallsExecutable Instr. Instructions that the x86 can fetch from memory and executeMASM Dir. Programmer supplied directives that guide the “translation” processMASM Macro Defs. and Calls Similar to “Functions” explored in a laboratory assignmentx86 Instruction Type Classifications• DATA TRANSFER– General mov ax, DAT1 ;ax gets contents of mem– Strings cmpsb ;if DS:SI=ES:DI then ZF=1– Special Purpose xchg ax, bx ;ax gets bx and bx gets ax• ARITHMETIC/LOGIC– Integer add ax, bx ;ax gets ax+bx– ASCII, BCD aaa ;changes ASCII # to int.– Floating Point fadd DAT ;ST get ST+DAT– Logical and ax, bx ;ax gets ax AND bx– Shifting ror ax, 2 ;ax contents shifted-2 right• CONTROL TRANSFER– Branching jnz LABEL1 ;if ZF=1 then IP=LABEL1– Interrupt int 21h ;invoke INT handler 21h– Subroutine call SUB1 ;invoke subroutine, SUB1– Modify Flag cli ;IF gets zero– Halt Processor hlt ;need RESET to run again– No Operation nop ;takes up space/time4x86 Instruction Set Summary(Not Included in Following Slides)• Floating Point - 8087• Special Protected Mode 80386• MMX (DSP) Pentium MMX• SSE - Special SIMD Pentium III• Others (few specialized added with each gen.)x86 Instruction Set Summary(Data Transfer)CBW ;Convert Byte to Word in AXCWD ;Convert Word to Double in AX,DXIN ;InputLAHF ;Load AH with 8080 Flags LDS ;Load pointer to DS LEA ;Load EA to register LES ;Load pointer to ES LODS ;Load memory at SI into AX MOV ;Move MOVS ;Move memory at SI to DI OUT ;Output POP ;Pop POPF ;Pop Flags PUSH ;Push PUSHF ;Push Flags SAHF ;Store AH into 8080 Flags SCAS ;Scan memory at DI compared to AXSEG ;Segment register STOS ;Store AX into memory at DI XCHG ;Exchange XLAT ;Translate byte to ALx86 Instruction Set Summary(Arithmetic/Logical)AAA ;ASCII Adjust for Add in AXAAD ;ASCII Adjust for Divide in AX AAM ;ASCII Adjust for Multiply in AXAAS ;ASCII Adjust for Subtract in AXADC ;Add with Carry ADD ;Add AND ;Logical AND CMC ;Complement CarryCMP ;CompareCMPS ;Compare memory at SI and DICWD ;Convert Word to Double in AX,DXDAA ;Decimal Adjust for Add in AXDAS ;Decimal Adjust for Subtract in AXDEC ;DecrementDIV ;Divide (unsigned) in AX(,DX)IDIV ;Divide (signed) in AX(,DX)IMUL ;Multiply (signed) in AX(,DX)INC ;Increment5x86 Instruction Set Summary (Arithmetic/Logical Cont.)MUL ;Multiply (unsigned) in AX(,DX) NEG ;Negate NOT ;Logical NOT OR ;Logical inclusive OR RCL ;Rotate through Carry Left RCR ;Rotate through Carry Right ROL ;Rotate Left ROR ;Rotate Right SAR ;Shift Arithmetic Right SBB ;Subtract with Borrow SCAS ;Scan memory at DI compared to AXSHL/SAL ;Shift logical/Arithmetic Left SHR ;Shift logical Right SUB ;Subtract TEST ;AND function to flags XLAT ;Translate byte to AL XOR ;Logical Exclusive ORx86 Instruction Set


View Full Document
Download Preparing/Executing a Program
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Preparing/Executing a Program and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Preparing/Executing a Program 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?