Chapter 3 Elements of Assembly LanguageAssembly Language StatementsAssembly Language Statements ContinuedBasic Elements of Assembly LanguageBasic Elements of Assembly Language ContinuedSlide 6Slide 7Statements in Assembly LanguageStatements in Assembly Language ContinuedSlide 10Slide 11Statements in Assembly Language ContinuedSlide 13Statements in Assembly Language Continued (Memory Allocation)Statements in Assembly Language Continued DB (Memory Allocation) DirectiveStatements in Assembly Language Continued DB (Memory Allocation) DirectiveStatements in Assembly Language Continued DW (Memory Allocation) DirectiveStatements in Assembly Language Continued DD (Memory Allocation) DirectiveHow Data is StoredSample ProgramSlide 21Data Transfer InstructionsData Transfer Instructions ContinuedData Transfer Instructions Continued Operands with DisplacementsData Transfer Instructions Continued The Exchange (XCHG) InstructionsArithmetic InstructionsArithmetic Instructions ContinuedSlide 28Slide 29Slide 30Basic Operand TypesSlide 32Basic Operand Types ContinuedInput/Output Using IO.hSlide 35Review QuestionReview Questions ContinuedCSC 20601/14/19 1Chapter 3 Elements of Assembly Language Instructor: James HutchinsonCSC 20601/14/19 2Assembly Language StatementsThere are three types of functional assembly language statements.Instructions: statement translatable into one or more bytes of machine code.Add eax, ebxMov edi, 0 Directives: statement that instruct the assembler to take some action..Nolist.titleMacro: statements that represent a sequence of other statements.A macro can represent a sequence of instructions, orA sequence of directives, orOther macros A any combination of instruction, directives, or other macros.An assembly language statement can be up to 512 bytes long. Assembly language programs are not very self documenting, requiring the use of multiple comments.Comments are text included in a program to explain the programmers intent.A comment is created by including a semicolon (;) in a statement.An entire line is a comment if the semicolon appear in the first column.CSC 20601/14/19 3Assembly Language Statements ContinuedAssembly Language Instructions:Definition: An assembly language instruction is a symbolic representation of a single machine instruction.–General form of an assembly instruction:[Label:] mnemonic [Operands] ; [comments]Where: Labels are place markers used to identify the location of the instruction.–Mnemonics are shorthand designation of the operation specified in the instruction–Operands are data or storage location where the data can be found. Operands may be registers, memory locations, or immediate data.Example: add EAX, ebx ; instruction to add two registersmnemonicdestination operand source operandcommentCSC 20601/14/19 4Basic Elements of Assembly LanguageAssembly Languages statements are made up of constants, literals, names, mnemonics, operands, and comments.A constant is a value that is known or calculated at assembly time.A constant can be a number or a string of characters.A constant cannot be changed at runtime.The following are examples of constants:‘ABC’, 2134, 5*6, (1+2)/3string constantinteger constantconstant expressionCSC 20601/14/19 5Basic Elements of Assembly Language ContinuedIntegers.Definition: An integer is a numeric value that represents a whole number.An integer is made up of numeric digits followed by an optional radix character.Integer Radixd = decimal 200 decimalh = hexadecimal 0A1Ch hexadecimal (hex)b = binary 00110010b binaryo or q = octal 1234q octalCSC 20601/14/19 6Basic Elements of Assembly Language ContinuedReal Numbers Definition: A real number contains digits, a single decimal point, an optional exponent, and a optional leading sign. The syntax of a real number is as follows:General form [+ or -] digits.digits [E + or -] digits.Examples:2.3 +200.576E+05 0.22222E-5 -6.0e3String ConstantsA string constant is two or more ASCII characters enclosed in single or double quotation marks.A character constant is one ASCII character enclosed within single or double quotation marks.Examples:“a” ‘ a’ character constant‘ABC’ “ the car” string constantCSC 20601/14/19 7Basic Elements of Assembly Language ContinuedConstant Expressions.Definition: Constant Expression are arithmetic expression consisting of a combination of numeric literals, arithmetic operators, and defined symbolic constants.Symbolic constants are constants assigned to a name.Example: row = 10 columns = 30 pi = 3.14These are not variable declarations written in high level language. Examples of Constant Expressions.5 26.5 4*3 -3*4/2 -2.301E+04row + columns * (-3*4/2)pi * 16CSC 20601/14/19 8Statements in Assembly LanguageAssembly language statements consist of an optional name (lable), a mnemonic, operands, and optional comments. Formant: [label] mnemonic dest. operand, src. operand [comments]Statements fall into two classes, directives and instructions.Directives are statements that provide information to assist the assembler in producing executable code.Instructions are executable statements.Statements are free form, they may be written in any column with any number of spaces between operands. Blank lines are permitted anywhere in a program to aid readability.A statement must be written on a single line and must be less than a 128 characters in length.CSC 20601/14/19 9Statements in Assembly LanguageContinuedA directive, or pseudo-operation, is used to define variables and specify how executable code should be generated.Example count byte 50.TitleDOSSEGAn Instruction fall into five categories:program control call MySubdata transfer mov eax, 5arithmetic add 6ax, 15logical jz nextStatementinput output in al, 20CSC 20601/14/19 10Statements in Assembly LanguageContinuedNames or LabelsA name identifies a label, variable, symbol, or Keyword. It may contain any of the following characters.Character DescriptionA...Z, a...z Letters0…9 Digits? Question Mark_ Underscore@ At sign$ Dollar sign. PeriodCSC 20601/14/19 11Statements in Assembly LanguageContinuedAssembler Names have the following restrictions:Only the first 31 characters are recognized.There is no distinction between upper and lower case letters; that
View Full Document