1 / 35

UNIT

UNIT. The Program Development Process. Topics:. Assembler Language Syntax The Assembly Process. Unit: The Program Development Process. Unit Introduction. Assembler Language provides the tools to communicate instructions between a programmer and a computer.

heman
Download Presentation

UNIT

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. UNIT The Program Development Process Topics: • Assembler Language Syntax • The Assembly Process

  2. Unit: The Program Development Process Unit Introduction • Assembler Language provides the tools to communicate instructions between a programmer and a computer. • Learning the syntax or rules of structure, increases your ability to communicate instructions. Instructions are • then translated or converted to Machine Language, which can be executed by the computer. • This unit deals with: • Language syntax (language structure) • The process of translating it into Machine code that can be read by the central processing unit Introduction

  3. Unit: The Program Development Process Unit Objectives • At the end of this unit, you will be able to: • Describe the Assembler Language programming syntax • List the fields that makeup the Assembler Language statement • Identify the various types of Assembler Language statements • Understand the process used by the Assembler program to convert Assembler Language to Machine language • Read the Assembler output listing • Define both the External Symbol and the Relocation Dictionary • List some possible diagnostic messages produced by the Assembler Introduction

  4. UNIT The Program Development Process Topics: • Assembler Language Syntax • The Assembly Process

  5. Topic: Assembler Language Syntax Unit: The Program Development Process Topic Objectives • At the end of this topic, you will be able to: • Define Statements • Understand the constituents of Assembler Language Statements • Understand the use of Comments • Understand the formatting of Assembler Language Statements Introduction

  6. Topic: Assembler Language Syntax Unit: The Program Development Process Assembler Language Statements • What are Statements? • Assembler Language programs are made up of • statements. Statements are composed of • characters. Lower case alphabetic characters are • considered equivalent uppercase characters by • the Assembler, except when used in • quoted strings. Characters: Alphabetic characters a –z and A- Z National characters @, $, and # Underscore _ Digits 0 – 9 Special characters + - , = , * ( ) ‘ / & blank Continued… Concepts

  7. Topic: Assembler Language Syntax Unit: The Program Development Process Assembler Language Statements (cont’d) • What constitutes Assembler Language • Statements? • Assembler Language Statements are coded in 80 • character records or lines. By default, each 80 • character line consists of 3 fields; positions 1-71 • constitute the statement field, 72 is the • continuation indicator field, and 73-80 is the • identifier/sequence field. • Assembler Language statements and comments • must be written in the statement field. It consists • of: • Begin Column - The first position of the statement field • Continue Column - second and subsequent statements of a continued statement begin • Continuation Indicator Field - The position following the end column STATEMENT Identifier/ Sequence Field Statement Field 1 71 72 73 ……….80 Continuation Indicator Field Begin Column (Position 1) End Column (Position 71) Concepts

  8. Topic: Assembler Language Syntax Unit: The Program Development Process Are We on Track? • Match the following. • 1. Statement A. 1 - 71 • 2. Statement Field B. Positions • 3. Continuation Indicator C. 73 - 80 • 4. Identifier/Sequence D. 72 Review

  9. Topic: Assembler Language Syntax Unit: The Program Development Process Are We on Track? • Which of the following are valid characters in an Assembler program? • A. A • B. 4 • C. $ • D. [ Review

  10. Topic: Assembler Language Syntax Unit: The Program Development Process Assembler Language Instruction Statements • Assembler Language Instruction Statement • consists of up to 4 fields, specified in the • following order: • Name • Operation • Operand • Comments Begin Column (Position 1) BE EQUALRTN BRANCH ON EQUAL NOTEQ MVC THERE,HERE SET THERE FIELD CLI C’A’,TESTFLD COMPARE TO”A” STORERTN STM 2,12,SAVEAREA SAVE REGISTERS Comment Field Operand Field Name Field Operation Field Continued… Concepts

  11. Topic: Assembler Language Syntax Unit: The Program Development Process Assembler Language Instruction Statements (cont’d) • Assembler Language instructions are free format, • with one or more blanks delimiting fields. The • name field and operation field is separated by one • or more blanks, as are the operation and the • operand, and the operand and the comment. • Embedded blanks are not allowed in the operand • field, unless they are part of a quoted string. • Otherwise they would indicate the end of the • operand field. • The name field, if present, must begin in the begin • column. If the name field is omitted, the operation • field must start after the begin column. Begin Column (Position 1) BE EQUALRTN BRANCH ON EQUAL NOTEQ MVC THERE,HERE SET THERE FIELD One or more BLANKS denoting Change of Field Continued… Concepts

  12. Topic: Assembler Language Syntax Unit: The Program Development Process Assembler Language Instruction Statements (cont’d) • Although the Assembler allows free format • statements, most programmers align their fields • (operation, operand and comments) in specific • positions for readability. • If you wish to code a comment field on a • statement with no operand field, you must indicate • to the Assembler, that the operand field is • missing. You do this by coding a comma, • preceded and followed by a blank, between the • operation and the comment. An example of this is • shown on the right. Coding a Comment Field with no Operand Field: Comma Statement End , The end of the program BLANK Concepts

  13. Topic: Assembler Language Syntax Unit: The Program Development Process Are We on Track? • Fields in Assembler statements are separated by one or more _____________ • characters. Review

  14. Topic: Assembler Language Syntax Unit: The Program Development Process Are We on Track? • How many possible fields are there in one Assembler statement? • A. 2 • B. 3 • C. 4 • D. 5 Review

  15. Topic: Assembler Language Syntax Unit: The Program Development Process Use of Comments • How can you use comments effectively? • As noted previously comments can be included as • the fourth field on any Assembler Language • instruction statement. • It is also possible to have statements in your • program consisting entirely of comments. • An Assembler Language comment statement has • an asterisk in the statement in the begin column. • The rest of the statement, up to and including the • end column, is interpreted as a comment. * * * * THE FOLLOWING ROUTINE IS USED TO INITIALIZE THE OUTPUT AREA Begin Column (Position 1) End Column (Position 71) Concepts

  16. Topic: Assembler Language Syntax Unit: The Program Development Process Use of Comments (cont’d) • How can you use comments effectively? • It is good programming practice to include plenty • of comments. It is desirable to clearly document • what your code is doing when using a low level • language like Assembler Language. • A block of comment statements should describe • the purpose of each module and of each major • section of code. • Comments should be coded on instruction • statements to indicate the purpose of each • individual statement. NOTEQ MVC THERE,HERE SET THERE FIELD CLI C’A’,TESTFLD COMPARE TO”A” STORERTN STM 2,12,SAVEAREA SAVE REGISTERS Comment Field Typical Comments Concepts

  17. Topic: Assembler Language Syntax Unit: The Program Development Process Are We on Track? • A statement consisting of all comments has a(n) ____________ coded in the begin • column. Review

  18. Topic: Assembler Language Syntax Unit: The Program Development Process Are We on Track? • Which of the following statements pertain to the comment field? • A. Indicate the purpose in individual statements • B. Describe the purpose of a block of code • C. Describe ‘tricky’ coding techniques • D. Ensure that every statement has four fields Review

  19. Topic: Assembler Language Syntax Unit: The Program Development Process Formatting Assembler Language Statements Position 1 Position 16 Position 72 X INDCB DCB DDNAME=INFILE,DSORG=PS,MACRF=GM,RECFM=FB, LRECL=80,EODAD=ENDRTN Most Assembler Language statements will easily fit in one line. Sometimes, particularly with complex macro instructions, a statement will not fit on a single line, between the start and end columns. The example above shows a statement continued on the next line. Concepts

  20. Topic: Assembler Language Syntax Unit: The Program Development Process Breaking Statements Position 1 Position 16 Position 72 X BE EQUALRTN BRANCH ON EQUAL THE COMMENT FOR THIS STATEMENT CONTINUES ON LINE 2 X TO FIELD,’ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMN MVC OPQRSTUVWXYZ0123456789’ Following are the two ways of breaking a statement for continuation: 1. Code the statement up to the end column, put a non-blank character in the continuation indicator column and resume coding in the continuation column of the next line 2. Code the statement to the end of a complete operand and its following comma, put a non-blank character in the continuation indicator column and resume coding with the start of the next operand in the continuation column of the next line Concepts

  21. Topic: Assembler Language Syntax Unit: The Program Development Process Are We on Track? • Where does the Assembler statement continuation line begin? • A. Column 1 • B. Column 16 • C. Column 72 • D. Anywhere after column 15 Review

  22. Topic: Assembler Language Syntax Unit: The Program Development Process Are We on Track? • If an operand being continued does not extend to position 71, the last non blank character in the statement must be a(n) __________________. Review

  23. Topic: Assembler Language Syntax Unit: The Program Development Process Topic Summary • Now that you have completed this topic, you should be able to: • Define Statements • Understand the constituents of Assembler Language Statements • Understand the use of Comments • Understand the formatting of Assembler Language Statements Summary

  24. UNIT The Program Development Process Topics: • Assembler Language Syntax • The Assembly Process

  25. Topic: The Assembly Process Unit: The Program Development Process Topic Objectives • At the end of this topic, you will be able to: • Understand the functions of the Assembler • Convert addresses to base displacement format Introduction

  26. Topic: The Assembly Process Unit: The Program Development Process Assembler Functions • What are the functions of an Assembler? • The major purpose of the Assembler is to take a • source program, written in Assembler Language • and convert it to an object module in Machine • Language. This conversion includes: • Converting Assembler Language mnemonic opcodes into Machine Language numeric opcodes • Converting the Assembler Language instruction formats into Machine Language forms • Converting the numeric notation used in the source program (decimal by default) to hexadecimal form used in the Machine Language • Determining the address of all the instructions and data areas used in the program • Converting reference symbols into base displacement addresses ASSEMBLER (Converts Assembler Language to Machine Language) OBJECT MODULE Concepts

  27. BALR R12,0 Load the base register USING *,R12 Established address ability Topic: The Assembly Process Unit: The Program Development Process Converting Addresses to Base-Displacement Format • What is USING Instruction? • In order for the Assembler to convert addresses to • base-displacement format, you must tell the • Assembler what register to use as a base register, • and what value the register will contain at • execution time. This information is provided with • the USING instruction. • You must also include machine instructions in • your program, to load the proper value into the • base register at execution time. A standard way of • accomplishing these two actions is with the • following instructions, included as part of the • program initiation: • BALR R12,R0 and USING*, R12 Continued… Concepts

  28. BALR R12,0 Loads next Instruction intro R12 ABSOLUTE ADDRESS USING *,R12 Current Value Established R12 as the Base Register Topic: The Assembly Process Unit: The Program Development Process Converting Addresses to Base-Displacement Format (cont’d) • The first of these instructions, a Machine • instruction, places the absolute address of the • next instruction after BALR into register 12. The * • symbol is used to represent the current value of • the location counter in an Assembler program. • The USING instruction tells the Assembler that • R12 is to be used as the base register, and that • R12 will contain the address of the current • instruction. • Since BALR has in fact loaded R12 with the • address of the instruction following BALR (which • is now the current instruction) this correctly • establishes addressability in the program. To established Program Address ability: Concepts

  29. Topic: The Assembly Process Unit: The Program Development Process SS Instruction Example • As previously discussed, storage operands can • be represented as either symbols, or in base • displacement format. The Assembler allows • certain portions of the base displacement, base • index displacement, or base length displacement • forms to be omitted, and uses default values for • the omitted parts. • This process is indicated in the table on the right. • After the Assembler produces an object module it • can be linked and executed. Full Operand From Omission Assembler Default D B=0 D (B) D X=0 , B=0 D (X,B) D (X) B=0 D (,B) X=0 B=0 , 1=length Attribute of D D D (1,B) B=0 1=length attribute of D D (1) D (,B) Concepts

  30. Topic: The Assembly Process Unit: The Program Development Process Are We on Track? • In an Assembler Program addressability is established by the __________ instruction. Review

  31. Topic: The Assembly Process Unit: The Program Development Process Are We on Track? • The Base Register of Operand2 is __________ value, when the following instruction is translated: L R3, 0(R4). Review

  32. Topic: The Assembly Process Unit: The Program Development Process Glossary • Mnemonic Opcode – That portion of Assembly Language instruction that specifies the type of instruction and the structure of the data on which it operates. • Machine Language • Numeric Opcode – That portion of Machine Language instruction that specifies the type of instruction and the structure of the data on which it operates. • Base Register – A general register that is used to hold the base address. The base address remains constant and provides a reference point from which a location of a byte of data can be calculated. Glossary

  33. Topic: The Assembly Process Unit: The Program Development Process Topic Summary • Now that you have completed this topic, you should be able to: • Understand the functions of the Assembler • Convert addresses to base displacement format Summary

  34. Unit: The Program Development Process Unit Summary • Now that you have completed this unit, you should be able to: • Describe the Assembler Language programming syntax • List the fields that makeup the Assembler Language statement • Identify the various types of Assembler Language statements • Understand the process used by the Assembler program to convert Assembler Language to Machine Language • Read the Assembler output listing • Define both the External Symbol and the Relocation Dictionary • List some possible diagnostic messages produced by the Assembler Summary

More Related