LectureXIII-Introduction to Assembly-ii(2).pptx

LectureXIII-Introduction to Assembly-ii(2).pptx -...

Info icon This preview shows pages 1–10. Sign up to view the full content.

Part-II COMP 2130 Intro Computer Systems Computing Science Thompson Rivers University Introduction to Assembly Language
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

A source program’s format Source-file: a pure ASCII-character textfile Is created using a text-editor (such as ‘vi’) You cannot use a ‘word processor’ (why?) Program consists of series of ‘statements’ Each program-statement fits on one line Program-statements all have same layout Design in 1950s was for IBM punch-cards
Image of page 2
Statement Layout (1950s) Each ‘statement’ was comprised of four ‘fields’ Fields appear in a prescribed left-to-right order These four fields were named (in order): -- the ‘label’ field -- the ‘opcode’ field -- the ‘operand’ field -- the ‘comment’ field In many cases some fields could be left blank Extreme case (very useful): whole line is blank!
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

The ‘as’ program The ‘assembler’ is a computer program It accepts a specified text-file as its input It must be able to ‘parse’ each statement It can produce onscreen ‘error messages’ It can generate an ELF-format output file (That file is known as an ‘object module’) It can also generate a ‘listing file’ (optional)
Image of page 4
The ‘label’ field A label is a ‘symbol’ followed by a colon (‘:’) The programmer invents his own ‘symbols’ Symbols can use letters and digits, plus a very small number of ‘special’ characters ( ‘.’, ‘_’, ‘$’ ) A ‘symbol’ is allowed to be of arbitrarily length The Linux assembler (‘as’) was designed for translating source-text produced by a high- level language compiler (such as ‘cc’) But humans can also write such files directly 1: movb $10, %eax
Image of page 5

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

The ‘opcode’ field Opcodes are predefined symbols that are recognized by the GNU assembler There are two categories of ‘opcodes’ (called ‘instructions’ and ‘directives’) ‘Instructions’ represent operations that the CPU is able to perform (e.g., ‘add’, ‘inc’) ‘Directives’ are commands that guide the work of the assembler (e.g., ‘.globl’, ‘.int’)
Image of page 6
Instructions vs Directives Each ‘instruction’ gets translated by ‘as’ into a machine-language statement that will be fetched and executed by the CPU when the program runs (i.e., at ‘runtime’) Each ‘directive’ modifies the behavior of the assembler (i.e., at ‘assembly time’) With GNU assembly language, they are easy to distinguish: directives begin with ‘.’
Image of page 7

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

A list of the Pentium opcodes An ‘official’ list of the instruction codes can be found in Intel’s programmer manuals: But it’s three volumes, nearly 1000 pages (it describes ‘everything’ about Pentiums) An ‘unofficial’ list of (most) Intel instruction codes can fit on one sheet, front and back:
Image of page 8
The AT&T syntax The GNU assembler uses AT&T syntax (instead of official Intel/Microsoft syntax) so the opcode names differ slightly from
Image of page 9

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern