Computer Science 210 Computer Organization Overview of Assembly Language.

Slides:



Advertisements
Similar presentations
Chapter 7 Introduction to LC-3 Assembly Language Assembly Language Assembly Process Using the Editor & Simulator for Assembly Language Programming.
Advertisements

Introduction to Computing Systems from bits & gates to C & beyond Chapter 7 LC-2 Assembly Language.
Chapter 7 Assembly Language. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 7-2 Human-Readable Machine Language.
Introduction to Computing Systems from bits & gates to C & beyond Chapter 7 LC-2 Assembly Language.
Introduction to Computer Engineering ECE/CS 252, Fall 2010 Prof. Mikko Lipasti Department of Electrical and Computer Engineering University of Wisconsin.
Chapter 7 Assembly Language. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 7-2 Human-Readable Machine Language.
Fall EE 333 Lillevik 333f06-l4 University of Portland School of Engineering Computer Organization Lecture 4 Assembly language programming ALU and.
IT253: Computer Organization Lecture 6: Assembly Language and MIPS: Programming Tonga Institute of Higher Education.
1 COMS 361 Computer Organization Title: Instructions Date: 9/28/2004 Lecture Number: 10.
The assembler is the system program that translate source code written in assembly language to object code( Machine Language) and other information for.
Introduction to C Programming
Chapter 3 Assembly Language: Part 1. Machine language program (in hex notation) from Chapter 2.
Introduction to LC-3 Assembly Language. LC-3 Assembly Language Syntax Each line of a program is one of the following: –an instruction –an assember directive.
Choice for the rest of the semester New Plan –assembler and machine language –Operating systems Process scheduling Memory management File system Optimization.
Overview Intro to Project 2 - Serial I/O – RS232, USB Assembly Language Programming Using the LC-3 Simulator.
Introduction to LC-3 Assembly Language
Overview Projects The Assembly Process Programmed I/O Interrupt Driven I/O.
Introduction to C Programming
Computer Science 210 s1c Computer Systems Semester 1 Lecture Notes James Goodman (revised by Robert Sheehan) Credits: “McGraw-Hill” slides prepared.
Introduction to Computer Engineering CS/ECE 252, Spring 2007 Prof. Mark D. Hill Computer Sciences Department University of Wisconsin – Madison.
Assembly & Machine Languages
Computer Science 210 Computer Organization The Instruction Execution Cycle.
Assembly Language part 1.
Chapter 7 LC-3 Assembly Language. 2 College of Charleston, School of Science and Mathematics Dr. Anderson, Computer Science CS 250 Comp. Org. & Assembly.
Fortran 1- Basics Chapters 1-2 in your Fortran book.
Assembly Language.
Assemblers.
Introduction to Computing Systems and Programming Assembly Language.
The LC-3 – Chapter 7 COMP 2620 Dr. James Money COMP
Chapter 7 Assembly Language. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Our Bag of Tricks so far Control.
Programming With C.
TCSS 490A Topics in Computing & Software Systems “Introduction to Computer Systems”
Introduction to Computer Engineering CS/ECE 252, Fall 2007 Prof. Mark D. Hill Computer Sciences Department University of Wisconsin – Madison.
Computer Science 210 Computer Organization More on Assembler.
Chapter 7 Assembly Language. 7-2 Human-Readable Machine Language Computers like ones and zeros… Humans like symbols… Assembler is a program that turns.
1 Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
Computer Science 210 s1c Computer Systems Semester 1 Lecture Notes James Goodman (revised by Robert Sheehan) Credits: “McGraw-Hill” slides prepared.
Computer Science 210 Computer Organization
Introduction to Computer Engineering
Computer Science 210 Computer Organization
Chapter 7 Assembly Language
Chapter 7 & 9.2 Assembly Language
Assembly Language Ms. V.Anitha AP/CSE SCT
Computer Science 210 Computer Organization
Chapter 7 Assembly Language
Chapter 3 Machine Language and Assembly Language.
Chapter 3 Machine Language and Assembly Language.
Computer Science 210 Computer Organization
Computer Science 210 Computer Organization
Chapter 7 LC-2 Assembly Language.
Computer Science 210 Computer Organization
Computer Science 210 Computer Organization
Introduction to Computer Engineering
Introduction to Computer Engineering
Computer Science 210 Computer Organization
Chapter 7 Assembly Language
Chapter 7 LC-2 Assembly Language.
COSC121: Computer Systems
Introduction to Computer Engineering
Chapter 7 Assembly Language
Chapter 7 Assembly Language
MARIE: An Introduction to a Simple Computer
Introduction to Computer Engineering
Chapter 7 Assembly Language An Hong 2016 Fall
Chapter 6 Programming the basic computer
Introduction to Computer Engineering
Introduction to Computer Engineering
Introduction to Computer Engineering
Introduction to Computer Engineering
Chapter 7 Assembly Language
Presentation transcript:

Computer Science 210 Computer Organization Overview of Assembly Language

Problems with Machine Language Opcodes are in binary, hard to remember Immediate operands, register # are in binary Destinations of branches must are in binary and must be calculated by hand Memory locations (variables) are in binary

Problems with Machine Language When an instruction is inserted or removed, many fields in other instructions must be updated Easy to get the format of an instruction wrong

Needed Improvements Mnemonic symbols (ADD, BRp) for opcodes Mnemonic symbols (count, endwhile) for data variables in memory and destinations of branches Automatic update of addresses after modifications to code

Needed Improvements Use of decimal or hex numeric literals for immediate operands Simple syntax checking (format of instructions, undeclared labels, etc.) Reserve memory and initialize it

Program Development Assembler Linker Loader Runtime System Editor Translate to machine code Add library code Place code in appropriate memory locations Execute code Create source code /opt/lc3tools/lc3as usage:./lc3as

An Assembly Language Program ; ; Program to multiply a number by the constant 6 ; Author: Ken Lambert ;.ORIGx3050 ; Beginning address of code LDR1, SIX LDR2, NUMBER ANDR3, R3, #0; Clear R3. It will ; contain the product. ; The loop ; AGAINADDR3, R3, R2 ADDR1, R1, #-1; R1 keeps track of BRpAGAIN; the iteration. ; HALT ; NUMBER.BLKW1 ; Data for the program SIX.FILLx0006 ;.END

LC-3 Assembly Language Syntax Each line of code is –An instruction –An assembler directive (or pseudo-op) –A comment Whitespace is ignored Instruction format: LABEL OPCODE OPERANDS ; COMMENTS optionalmandatory

Opcodes and Operands Opcodes are reserved symbols like AND, ADD, etc. Operands –Registers: specified by Ri –Numbers: indicated by # (decimal) or x (hex) –Label: symbolic name of memory location Separated by a comma

Labels and Comments Placed at the beginning of a line or included as an operand within an instruction LOOPADDR1,R1,#-1 BRpLOOP A comment begins with ; and extends to the end of that line

Assembler Directives OpcodeOperandMeaning.ORIG addressstarting address of program.END end of program.BLKW nallocate n words of storage.FILL nallocate one word, initialize with value n.STRINGZ n-character string allocate n+1 locations, initialize w/characters and null terminator Tell the assembler what to do at assembly time, start with a dot (.)

Trap Codes Pseudo-instructions for trap codes: CodeEquivalentDescription HALTTRAP x25 Halt execution and print message to console. INTRAP x23 Print prompt on console, read (and echo) one character from keybd. Character stored in R0[7:0]. OUTTRAP x21 Write one character (in R0[7:0]) to console. GETCTRAP x20 Read one character from keyboard. Character stored in R0[7:0]. PUTSTRAP x22 Write null-terminated string to console. Address of string is in R0.

Style Guidelines Use the following style guidelines to improve the readability and understandability of your programs: 1.Provide a program header, with author’s name, date, etc., and purpose of program. 2.Start labels, opcode, operands, and comments in same column for each line. (Unless entire line is a comment.) 3.Use comments to explain what each register does. 4.Give explanatory comment for most instructions. 5.Use meaningful symbolic names. Mixed upper and lower case for readability. ASCIItoBinary, InputRoutine, SaveR1 6.Provide comments between program sections. 7.Each line must fit on the page -- no wraparound or truncations. Long statements split in aesthetically pleasing manner.