lect12 - CMSC 216 Introduction to Computer Systems Lecture...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CMSC 216 Introduction to Computer Systems Lecture 12 Assembly Language Jan Plane & Pete Keleher {jplane, keleher}@cs.umd.edu Administrivia Start reading Bryant and OHallaron Chapter 3 (IA-32 instruction set architecture) and 4.1 (Y86 subset) CMSC 216 - Wood, Sussman, Herman, Plane 2 Last Time: Assembly language concepts Registers Fast-access locations that the CPU uses, rather than storing all variables in memory In the code we'll be examining, these are named by three-letter codes, and begin with % Y86 has 8 registers, listed on pg. 168 in Figure 3.2 Memory Program text is here, along with any data which cannot fit in the registers Since there are usually many different pieces of data involved in a program, and a limited number of registers, program variables are stored in memory when not in immediate use 3 Assembly language instructions These typically have an instruction name, a list of registers, and sometimes have a constant value too Examples: irmovl $1000,%edx subl %ecx,%edx jge Loop Specify which operation to perform, which registers to act upon, and any values that might be needed 4 Assembling assembly Machine code (pure numbers) is generated by translating each instruction into binary numbers that the CPU uses This process is called "assembling"; conversely, we can take assembled code and disassemble it into (mostly) human readable assembly language 5 Labels When the assembler encounters a label (e.g., Loop: ), the address of the labeled instruction is used by the assembler to replace all references to that label in the program Labels do not need to be declared before use In Y86, instructions have variable lengths, and are not aligned; most take 6 bytes, but some use fewer 6 Label translation irmovl $0,%eax irmovl $1,%ecx Loop: addl %ecx,%eax irmovl $1,%edx addl %edx,%ecx irmovl $1000,%edx subl %ecx,%edx jge Loop wrint %eax irmovl $10,%edx wrch %edx halt 0x00: irmovl $0,%eax 0x06: irmovl $1,%ecx 0x0c: addl %ecx,%eax 0x0e: irmovl $1,%edx 0x14: addl %edx,%ecx 0x16: irmovl $1000,%edx 0x1c: subl %ecx,%edx 0x1e: jge 0x0c 0x23: wrint %eax 0x25: irmovl $10,%edx 0x2b: wrch %edx 0x2d: halt 7 CMSC 216 Introduction to Computer Systems Lecture 11 Linked Lists (cont) & Assembly Language Programming Jan Plane & Pete Keleher {jplane, keleher}@cs.umd.edu Assembling assembly Machine code (pure numbers) is generated by translating each instruction into binary numbers that the CPU uses This process is called "assembling"; conversely, we can take assembled code and disassemble it into (mostly) human readable assembly language CMSC 216 - Wood, Sussman, Herman, Plane 9 Labels When the assembler encounters a label (e.g., Loop: ), the address of the labeled instruction is used by the assembler to replace all references to that label in the program Labels do not need to be declared before use In Y86, instructions have variable lengths, and are not aligned; most take 6 bytes, but some use fewer CMSC 216 - Wood, Sussman, Herman, Plane 10 Label translation...
View Full Document

This note was uploaded on 01/13/2012 for the course CMSC 216 taught by Professor Plane during the Spring '11 term at Maryland.

Page1 / 18

lect12 - CMSC 216 Introduction to Computer Systems Lecture...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online