Lab 2 Use Traps. Lab 2 Input and Output 2 nd Semester. Lab 2 English. Lab 2 Pseudocode

Size: px
Start display at page:

Download "Lab 2 Use Traps. Lab 2 Input and Output 2 nd Semester. Lab 2 English. Lab 2 Pseudocode"

Transcription

1 Lab 2 Input and Output Lab 2 Use Traps Write (i.e. design and implement) an assembly language program that will accept user input from the keyboard and echo this to the terminal screen. Input should terminate when the user presses the '.' key. The code should also convert all lower case letters to upper case. : User types: Code displays: abcde1234uiop. ABCDE1234UIOP. Trap #1 (ed Read) Waits for a character to be sent down the serial line. (Typically a keypress from the console window). The ascii value of the character read is returned in d0 Trap #2 (ed Write) Waits for free space in the internal transmit buffer and then sends the character held in d0 30 th Lecture, Dr. Michael Manzke, Page: 1 30 th Lecture, Dr. Michael Manzke, Page: 2 Lab 2 English Lab 2 Pseudocode Until the user inputs the '.' key read a character from the terminal using trap #1. Check to see if this is a lower case letter (i.e. in the range 'a' - 'z'). If it is then subtract 'a'-'a' from the ascii value to convert it to upper case. Write the ascii value back to the terminal using trap #2. Note that we must read at least 1 character from the user before processing. Therefore it is more appropriate to use a do-while loop rather than a while-do loop. 30 th Lecture, Dr. Michael Manzke, Page: 3 do { ascii = Read(); if(ascii >= 'a' AND ascii <= 'z') { ascii=ascii-'a'+'a'; } Write(ascii) } while(ascii!= '.') 30 th Lecture, Dr. Michael Manzke, Page: 4 1

2 Lab 2 Assembly Language s Echo user input to the terminal converting all chars to uppercase and terminating on '.' org $1000 DO trap #1 ascii=read() cmp.b #$60,d0 if lowercase bls ENDIF cmp.b #'z',d0 bhi ENDIF sub.b #'a',d0 convert to add.b #'A',d0 UPPER case ENDIF trap #2 cmp.b #'.',d0 while ascii!='.' bne DO trap #0 30 th Lecture, Dr. Michael Manzke, Page: 5 If a lot of data is being transferred from the calling program to the subroutine. Entire blocks of memory are set aside and designated as parameter blocks. May be located anywhere in memory. Only the address of the start of the block is passed to the subroutine Individual parameter in the block may be accessed using d(an) addressing mode: 30 th Lecture, Dr. Michael Manzke, Page: 6 s PB-Pointer Memory Calculate the 2s Complement of a 64-bit No. TC64(Num) Num (a0) Variable MASK equ $ffffffff TC64 eori.l #MASK,4(a0) Invert Low Long eori.l #MASK,(a0) Invert High Long addi.l #1,4(a0) Add 1 to Low IF bcc ENDIF IF(Carry) THEN addi.l #1,(a0) Add 1 to High ENDIF rts ENDIF In the above example a parameter block was used to represent the 64-bit number number (i.e.: 2long words). The a0 register is assumed to contain the address of the start of the parameter block. 30 th Lecture, Dr. Michael Manzke, Page: 7 30 th Lecture, Dr. Michael Manzke, Page: 8 2

3 On the Use a technique similar to parameter blocks In this case the block is located on the stack This technique is used widely by compilers to implement parameter passing required by high level languages. Difficulties: The return address and other values pushed onto the stack have to be taken into Remember: The PC has also been pushed onto the stack when the jsr/bsr has been executed. To facilitate this method the instructions link/unlk Re-write the FILL subroutine so that the parameters are passed via a stack parameter block (without using link/unlink). 30 th Lecture, Dr. Michael Manzke, Page: 9 30 th Lecture, Dr. Michael Manzke, Page: 10 Fill Memory Subroutine (start) Fill Memory Subroutine (end) The Fill Memory subroutine FILL(Prt,,) 10(a7) value 6(a7) value 4(a7) value FILL move.l a6,-(a7) Save(a6) movea.l a7,a6 =+4; adda.l #4,a6 movem.l a0/d0-d1/d7,-(a7) Save(Regs) Copy the parameters off the stack into regs. move.w 4(a6),d1 Get move.l 6(a6),d0 Get move.l 10(a6),a0 Get Fill the memory clr.l d7 Count=0; WHILE cmp.l d7,d0 WHILE Count<= beq.s ENDWHILE DO move.b d1,(a0)+ ()+=; addi.l #1,d7 ++; bra WHILE ENDWHILE Restore all the registers ENDWHILE movem.l (a7)+,a0/d0-d1/d7 movea.l (a7)+,a6 rts 30 th Lecture, Dr. Michael Manzke, Page: th Lecture, Dr. Michael Manzke, Page: 12 3

4 Call Fill Subroutine What happens on the stack? To call the new FILL subroutine, the parameter must be loaded into the parameter block on the stack: Program to demonstrate passing parameters on the stack. Pushes parms to FILL and then calls it. Pops parms on return. org $4000 move.l #$4600,-(a7) Push(.l) move.l #30,-(a7) Push(.l) move.w #'A',-(a7) Push(.w) jsr FILL FILL($4600,30,'A') adda.l #10,a7 POP the parms trap #0 This seemingly overly complicated procedure is to allow us to use the stack as normal (ie: for saving values of registers in the subroutine) and yet still accessing the stack as a parameter block. 30 th Lecture, Dr. Michael Manzke, Page: 13 The following series shows what happens on the stack during a call to the FILL subroutine: Before FILL is called Bottom Top of of After FILL is called Bottom Top of of 30 th Lecture, Dr. Michael Manzke, Page: 14 What happens on the stack? During the execution of the FILL subroutine, the a6 register is used as a temporary pointer to the parameter block on the stack, so that the may be used as normal to save register on the stack etc.: FILL: Use a6 as param. block pointer Bottom Top of Saved old a6 a6 FILL: Save registers as normal Bottom Top of of Saved old a6 Saved Registers a6 After execution of the while loop The FILL subroutine Restores the register Restores a6 And returns as normal Which removes the return address from the stack The calling program must remove the parameter block from the stack By adding 10 to the The parameter block is 10 bytes long 30 th Lecture, Dr. Michael Manzke, Page: th Lecture, Dr. Michael Manzke, Page: 16 4

5 Frames The link and unlk are used to manage the stack in this way. They are used to create stack frames. Reserved space for parameter on the stack frames are usually used to contain local variable in subroutines. move.l d0,-(a7) move.w d1,-(a7) bsr Routine adda.l #6,a7 Pop params Before Routine is called After bsr Bottom Top of of Bottom Top of of 30 th Lecture, Dr. Michael Manzke, Page: th Lecture, Dr. Michael Manzke, Page: 18 link & unlk Frame Pointer Routine link a0,#-8 2 local longs move.l d0,-4(a0) 1 st local move.l d7,-8(a0) 2 nd local COMP... unlk a0 remove frame rts a0 After link Bottom Top of of Old a0 a0 Executing main Bottom Top of Old a0 saved d0 saved d7 Frame 30 th Lecture, Dr. Michael Manzke, Page: 19 A0 is known as the frame pointer. All local variables and parameter are accessed via it. Local variable -> Negative offset -> Positive offset 30 th Lecture, Dr. Michael Manzke, Page: 20 5

Stack Frames. Compilers use the stack: to store the to to a subroutine for storage of declared in the subroutine and a place to

Stack Frames. Compilers use the stack: to store the to to a subroutine for storage of declared in the subroutine and a place to Stack Frames EE 357 Unit 8 Stack Frames Compilers use the stack: to store the to to a subroutine for storage of declared in the subroutine and a place to Every call to a subroutine will create a data structure

More information

Subroutine. Chapter 8

Subroutine. Chapter 8 Chapter 8 Subroutine Expected Outcomes Describe and apply the stack for data storage Describe the process of subroutine in any programs Develop a subroutine and code Interpret subroutine process in the

More information

C Calling Conventions

C Calling Conventions C Calling Conventions 1. parameters are passed on the run-time or system stack, SP (or A7) 2. parameters pushed on stack in right to left order of call A6 used as the stack frame pointer local variables

More information

Recursive Subroutine Calls Example

Recursive Subroutine Calls Example The purpose of this example is to examine how all parameters, local variables, return addresses, and frame pointers are stored on the stack when a main program calls a procedure "Process" as well as when

More information

Alex Milenkovich 1. CPE/EE 421 Microcomputers: Motorola 68000: Assembly Language and C. Outline

Alex Milenkovich 1. CPE/EE 421 Microcomputers: Motorola 68000: Assembly Language and C. Outline Outline CPE/EE 421 Microcomputers: Motorola 68: Assembly Language and C Instructor: Dr Aleksandar Milenkovic Lecture Notes ACIA Example: Pseudo-code + Assembly Passing parameters In registers Passing by

More information

PART II: Cap. 6 - Linguaggio macchina M68000

PART II: Cap. 6 - Linguaggio macchina M68000 192 CHAPTER 3 ARM, MOTOROLA, AND INTEL INSTRUCTION SETS 3.20 Rewrite the byte-sorting program in Figure 3.15b as a subroutine that sorts a list of 32-bit positive integers. The calling program should pass

More information

Physics 116B Winter 2006: Problem Assignment 8

Physics 116B Winter 2006: Problem Assignment 8 Physics 116B Winter 2006: Problem Assignment 8 Due Wednesday, March 15 1. You may use a calculator for the following: (a) Convert to decimal: $9F03. (b) Express in binary: $3CFA. (c) Convert to hexadecimal:

More information

stack frame where register An is used as the argument pointer.

stack frame where register An is used as the argument pointer. STACK FRAMES The MC68000 provides two special instructions to allocate and deallocate a data structure called a frame in the stack to make subroutines easier to code. general structure of a frame: SP local

More information

Subroutines. passing data

Subroutines. passing data Subroutines passing data Mechanisms: pass by value pass by result pass by value result/ value return/ copy restore pass by reference pass by name pass by lazy evaluation Techniques: 1. in registers 2.

More information

Module 7: Address Registers & Array Processing

Module 7: Address Registers & Array Processing Module 7: Address Registers & Array Processing Special instructions for address registers CMPA, MOVEA, SUBA, ADDA LEA Understanding arrays Array applications 2006 munim@utm.my,athif@fke.utm.my,kamal@bip.utm.my

More information

Student # (In case pages get detached) The Edward S. Rogers Sr. Department of Electrical and Computer Engineering

Student # (In case pages get detached) The Edward S. Rogers Sr. Department of Electrical and Computer Engineering ECE 243S - Computer Organization The Edward S. Rogers Sr. Department of Electrical and Computer Engineering Mid-term Examination, March 2005 Name Student # Please circle your lecture section for exam return

More information

CPE/EE 421 Microcomputers

CPE/EE 421 Microcomputers CPE/EE 421 Microcomputers Instructor: Dr Aleksandar Milenkovic Lecture Note S06 *Material used is in part developed by Dr. D. Raskovic and Dr. E. Jovanov CPE/EE 421/521 Microcomputers 1 Course Administration

More information

EECE416 :Microcomputer Fundamentals and Design Instruction Sets and Groups

EECE416 :Microcomputer Fundamentals and Design Instruction Sets and Groups EECE416 :Microcomputer Fundamentals and Design 68000 Instruction Sets and Groups 1 Instruction Groups Data Transfer Groups Arithmetic Group Logical Group Shift and Rotate Group Bit Manipulation Group Binary

More information

Today s objective: introduction to really simple subroutines to simplify program structure for I/O

Today s objective: introduction to really simple subroutines to simplify program structure for I/O a 1 st look procedures and functions in high level languages are modeled on subroutines typically, assembly code is very modular with the main routine less than 100 lines long Today s objective: introduction

More information

CPE/EE 421 Microcomputers

CPE/EE 421 Microcomputers CPE/EE 421 Microcomputers Instructor: Dr Aleksandar Milenkovic Lecture Note S07 Outline Stack and Local Variables C Programs 68K Examples Performance *Material used is in part developed by Dr. D. Raskovic

More information

68000 Architecture, Data Types and Addressing Modes. 9/20/6 Lecture 2 - Prog Model 1

68000 Architecture, Data Types and Addressing Modes. 9/20/6 Lecture 2 - Prog Model 1 68000 Architecture, Data Types and Addressing Modes 9/20/6 Lecture 2 - Prog Model 1 Lecture Overview Assembler Language Programmers Model Registers Addressing Modes 9/20/6 Lecture 2 - Prog Model 2 Assembler

More information

Tutorial 1 Microcomputer Fundamentals

Tutorial 1 Microcomputer Fundamentals Tutorial 1 Microcomputer Fundamentals Question 1 What do these acronyms mean? (a) CPU? (b) ROM? (c) EPROM? (d) RWM? (e) RAM? (f) I/O? What role does the CPU play in a computer system? Why is ROM an essential

More information

Programming the Motorola MC68HC11 Microcontroller

Programming the Motorola MC68HC11 Microcontroller Programming the Motorola MC68HC11 Microcontroller COMMON PROGRAM INSTRUCTIONS WITH EXAMPLES aba Add register B to register A Similar commands are abx aby aba add the value in register B to the value in

More information

Lecture 9 Subroutines

Lecture 9 Subroutines CPE 390: Microprocessor Systems Spring 2018 Lecture 9 Subroutines Bryan Ackland Department of Electrical and Computer Engineering Stevens Institute of Technology Hoboken, NJ 07030 Adapted from HCS12/9S12

More information

Programming. A. Assembly Language Programming. A.1 Machine Code. Machine Code Example: Motorola ADD

Programming. A. Assembly Language Programming. A.1 Machine Code. Machine Code Example: Motorola ADD A. Assembly Language Programming Programming of a computer system: Machine code direct execution Assembly language tool: assembler High level programming language tool: interpreter tool: compiler Programming

More information

INTRODUCTION TO BRANCHING. There are two forms of unconditional branching in the MC68000.

INTRODUCTION TO BRANCHING. There are two forms of unconditional branching in the MC68000. INTRODUCTION TO BRANCHING UNCONDITIONAL BRANCHING There are two forms of unconditional branching in the MC68000. BRA instruction BRA Program control passes directly to the instruction located at

More information

Subroutines. we jump to a new location in the code

Subroutines. we jump to a new location in the code Subroutines EE 57 Unit 7 Subroutines Stacks Subroutines (or functions) are portions of code that we can call from anywhere in our code, execute that t subroutine, and then A subroutine to calculate the

More information

MIPS Programming. A basic rule is: try to be mechanical (that is, don't be "tricky") when you translate high-level code into assembler code.

MIPS Programming. A basic rule is: try to be mechanical (that is, don't be tricky) when you translate high-level code into assembler code. MIPS Programming This is your crash course in assembler programming; you will teach yourself how to program in assembler for the MIPS processor. You will learn how to use the instruction set summary to

More information

ECE232: Hardware Organization and Design

ECE232: Hardware Organization and Design ECE232: Hardware Organization and Design Lecture 4: Logic Operations and Introduction to Conditionals Adapted from Computer Organization and Design, Patterson & Hennessy, UCB Overview Previously examined

More information

Module 8: Atmega32 Stack & Subroutine. Stack Pointer Subroutine Call function

Module 8: Atmega32 Stack & Subroutine. Stack Pointer Subroutine Call function Module 8: Atmega32 Stack & Subroutine Stack Pointer Subroutine Call function Stack Stack o Stack is a section of RAM used by the CPU to store information temporarily (i.e. data or address). o The CPU needs

More information

OSIAC Read OSIAC 5362 posted on the course website

OSIAC Read OSIAC 5362 posted on the course website OSIAC 5362 Read OSIAC 5362 posted on the course website The Basic Structure of Control Unit m CLK Run/Inhibit Control Step Counter m Preset (to any new state) Reset IR Decoder/Encoder (combinational logic)

More information

EE 3170 Microcontroller Applications

EE 3170 Microcontroller Applications EE 3170 Microcontroller Applications Lecture 12: Advanced Assembly Language Programming Part II- Stacks Calling Conventions & Base Pointer Usage & Subroutine Examples - Miller 5.5-5.7 Based on slides for

More information

EE 361 University of Hawaii Fall

EE 361 University of Hawaii Fall C functions Road Map Computation flow Implementation using MIPS instructions Useful new instructions Addressing modes Stack data structure 1 EE 361 University of Hawaii Implementation of C functions and

More information

Computer Architecture 5.1. Computer Architecture. 5.2 Vector Address: Interrupt sources (IS) such as I/O, Timer 5.3. Computer Architecture

Computer Architecture 5.1. Computer Architecture. 5.2 Vector Address: Interrupt sources (IS) such as I/O, Timer 5.3. Computer Architecture License: http://creativecommons.org/licenses/by-nc-nd/3./ Hardware interrupt: 5. If in an eternal device (for eample I/O interface) a predefined event occurs this device issues an interrupt request to

More information

Addressing Modes. To review data transfer instructions and applying the more advanced addressing modes.

Addressing Modes. To review data transfer instructions and applying the more advanced addressing modes. Addressing Modes Aims To review 68000 data transfer instructions and applying the more advanced addressing modes. Intended Learning Outcomes At the end of this module, students t should be able to Review

More information

Assembly Language. Operand Size. The internal registers. Computers operate on chunks of data composed of a particular number of bits.

Assembly Language. Operand Size. The internal registers. Computers operate on chunks of data composed of a particular number of bits. 1 2 Chapter 6 Assembly Language Operand Size 8 bits 16 bits Computers operate on chunks of data composed of a particular number of bits. The 68K has a 32-bit architecture and a 16-bit organization. Internal

More information

Last Time. Compiler requirements C preprocessor Volatile

Last Time. Compiler requirements C preprocessor Volatile Last Time Compiler requirements C preprocessor Volatile Today Coding and translation of interrupt handlers Coding inline assembly Compiler intrinsics Interrupts 30-second interrupt review: Interrupts are

More information

EE 3170 Microcontroller Applications

EE 3170 Microcontroller Applications Lecture Overview EE 3170 Microcontroller Applications Lecture 7 : Instruction Subset & Machine Language: Conditions & Branches in Motorola 68HC11 - Miller 2.2 & 2.3 & 2.4 Based on slides for ECE3170 by

More information

Multiplies the word length <ea> times the least significant word in Dn. The result is a long word.

Multiplies the word length <ea> times the least significant word in Dn. The result is a long word. MATHEMATICAL INSTRUCTIONS Multiply unsigned MULU ,dn Action Notes: Example: Multiplies the word length times the least significant word in Dn. The result is a long word. 1. The lowest word of

More information

Using the stack and the stack pointer

Using the stack and the stack pointer Using the stack and the stack pointer o The Stack and Stack Pointer o The stack is a memory area for temporary storage o The stack pointer points to the last byte in the stack o Some instructions which

More information

reply db y prompt db Enter your favourite colour:, 0 colour db 80 dup(?) i db 20 k db? num dw 4000 large dd 50000

reply db y prompt db Enter your favourite colour:, 0 colour db 80 dup(?) i db 20 k db? num dw 4000 large dd 50000 Declaring Variables in Assembly Language As in Java, variables must be declared before they can be used Unlike Java, we do not specify a variable type in the declaration in assembly language Instead we

More information

ME 4447/6405. Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics. Instructor: Professor Charles Ume LECTURE 6

ME 4447/6405. Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics. Instructor: Professor Charles Ume LECTURE 6 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics Instructor: Professor Charles Ume LECTURE 6 MC9S12C Microcontroller Covered in Lecture 5: Quick Introduction

More information

COE538 Lecture Notes Week 3 (Week of Sept 17, 2012)

COE538 Lecture Notes Week 3 (Week of Sept 17, 2012) COE538 Lecture Notes: Week 3 1 of 11 COE538 Lecture Notes Week 3 (Week of Sept 17, 2012) Announcements My lecture sections should now be on Blackboard. I've also created a discussion forum (and anonymous

More information

Manual Instrumentation 2 Manual Instrumentation Process Throughout this document we will refer to the code in an unsupported language as the original

Manual Instrumentation 2 Manual Instrumentation Process Throughout this document we will refer to the code in an unsupported language as the original CodeTEST Tools Application Note Manual Instrumentation Manually insert test-point instructions, or tags, in source code to gather real time execution analysis using the Freescale CodeTEST Tools. Purpose

More information

Outline. 2.8 Stack. 2.9 Subroutines

Outline. 2.8 Stack. 2.9 Subroutines Outline 21 Assembly language program structure 22 Data transfer instructions 23 Arithmetic instructions 24 Branch and loop instructions 25 Shift and rotate instructions 26 Boolean logic instructions 27

More information

SEE 3223 Microprocessors. 4: Addressing Modes. Muhammad Mun im Ahmad Zabidi

SEE 3223 Microprocessors. 4: Addressing Modes. Muhammad Mun im Ahmad Zabidi SEE 3223 Microprocessors 4: Addressing Modes Muhammad Mun im Ahmad Zabidi (munim@utm.my) Addressing Modes Aims To review 68000 data transfer instruchons and applying the more advanced addressing modes.

More information

CPE/EE 421 Microcomputers

CPE/EE 421 Microcomputers CPE/EE 421 Microcomputers Instructor: Dr Aleksandar Milenkovic Lecture Note S04 *Material used is in part developed by Dr. D. Raskovic and Dr. E. Jovanov CPE/EE 421/521 Microcomputers 1 The 68000 Family

More information

Lecture 16: Passing Parameters on the Stack. Push Examples. Pop Examples. CALL and RET

Lecture 16: Passing Parameters on the Stack. Push Examples. Pop Examples. CALL and RET Lecture 1: Passing Parameters on the Stack Push Examples Quick Stack Review Passing Parameters on the Stack Binary/ASCII conversion ;assume SP = 0202 mov ax, 124h push ax push 0af8h push 0eeeh EE 0E F8

More information

ME 6405 Introduction to Mechatronics

ME 6405 Introduction to Mechatronics ME 6405 Introduction to Mechatronics Fall 2005 Instructor: Professor Charles Ume LECTURE 9 Homework 1 Solution 1. Write an assembly language program to clear the usable internal RAM in the M68HC11E9. Solution:

More information

Module 1-G. Marcos and Structured Programming

Module 1-G. Marcos and Structured Programming Module 1-G Marcos and Structured Programming 1 Learning Outcome #1 An ability to program a microcontroller to perform various tasks How? A. Architecture and Programming Model B. Instruction Set Overview

More information

Today s Menu. >Use the Internal Register(s) >Use the Program Memory Space >Use the Stack >Use global memory

Today s Menu. >Use the Internal Register(s) >Use the Program Memory Space >Use the Stack >Use global memory Today s Menu Methods >Use the Internal Register(s) >Use the Program Memory Space >Use the Stack >Use global memory Look into my See examples on web-site: ParamPassing*asm and see Methods in Software and

More information

Part 7. Stacks. Stack. Stack. Examples of Stacks. Stack Operation: Push. Piles of Data. The Stack

Part 7. Stacks. Stack. Stack. Examples of Stacks. Stack Operation: Push. Piles of Data. The Stack Part 7 Stacks The Stack Piles of Data Stack Stack A stack is an abstract data structure that stores objects Based on the concept of a stack of items like a stack of dishes Data can only be added to or

More information

Lab 7: Asynchronous Serial I/O

Lab 7: Asynchronous Serial I/O CpE 390 Microprocessor Systems Lab 7: Asynchronous Serial I/O 1. Introduction Serial communications is the transfer of data, one bit at a time, over a communications channel. Serial communications can

More information

Exceptions. user mode. software should run in supervisor mode Certain features/privileges il are only allowed to code running in supervisor mode

Exceptions. user mode. software should run in supervisor mode Certain features/privileges il are only allowed to code running in supervisor mode Status Register EE 357 Unit 9 Exceptions Used for debugging; when set, it can be used to pause the CPU after execution of each instruction Coldfirecan run programs in two modes: supervisor mode (for OS

More information

Interfacing Compiler and Hardware. Computer Systems Architecture. Processor Types And Instruction Sets. What Instructions Should A Processor Offer?

Interfacing Compiler and Hardware. Computer Systems Architecture. Processor Types And Instruction Sets. What Instructions Should A Processor Offer? Interfacing Compiler and Hardware Computer Systems Architecture FORTRAN 90 program C++ program Processor Types And Sets FORTRAN 90 Compiler C++ Compiler set level Hardware 1 2 What s Should A Processor

More information

Lecture 6 Assembly Programming: Branch & Iteration

Lecture 6 Assembly Programming: Branch & Iteration CPE 390: Microprocessor Systems Spring 2018 Lecture 6 Assembly Programming: Branch & Iteration Bryan Ackland Department of Electrical and Computer Engineering Stevens Institute of Technology Hoboken, NJ

More information

CprE 288 Introduction to Embedded Systems Course Review for Exam 3. Instructors: Dr. Phillip Jones

CprE 288 Introduction to Embedded Systems Course Review for Exam 3. Instructors: Dr. Phillip Jones CprE 288 Introduction to Embedded Systems Course Review for Exam 3 Instructors: Dr. Phillip Jones 1 Announcements Exam 3: See course website for day/time. Exam 3 location: Our regular classroom Allowed

More information

NAM M6800 DISK-BUG DS VER 3.5 OPT PAG

NAM M6800 DISK-BUG DS VER 3.5 OPT PAG NAM M6800 DISK-BUG DS VER 3.5 OPT PAG Floppy Disk Controller Debug Monitor Written 27 Aug 1980 Michael Holley Record of modifications 18 OCT 1981 Disk routines DC-1 23 JAN 1982 Command Table 8 MAY 1982

More information

ECE331 Handout 3- ASM Instructions, Address Modes and Directives

ECE331 Handout 3- ASM Instructions, Address Modes and Directives ECE331 Handout 3- ASM Instructions, Address Modes and Directives ASM Instructions Functional Instruction Groups Data Transfer/Manipulation Arithmetic Logic & Bit Operations Data Test Branch Function Call

More information

Exam 2 E2-1 Fall Name: Exam 2

Exam 2 E2-1 Fall Name: Exam 2 Exam 2 E2-1 Fall 2002 1. Short Answer [10 pts] Exam 2 a.[2 pts] Briefly describe what each of the following instructions do so that it is clear what the differences between them are: STAA -2,X STAA 2,-X

More information

ECE 471 Embedded Systems Lecture 8

ECE 471 Embedded Systems Lecture 8 ECE 471 Embedded Systems Lecture 8 Vince Weaver http://web.eece.maine.edu/~vweaver vincent.weaver@maine.edu 21 September 2018 Announcements HW#2 was due HW#3 will be posted today. Work in groups? Note

More information

RCX internals (Revised February 24)

RCX internals (Revised February 24) CMSC 23000 Winter 2006 Operating Systems Handout 3 January 27 RCX internals (Revised February 24) 1 Introduction This document collects together various pieces of information about the hardware in the

More information

Program Development. Chapter 5

Program Development. Chapter 5 Chapter 5 Program Development Expected Outcomes Distinguish between various codes in the programming language Explain the role of assembler and compiler Distinguish between different data types Use directive

More information

68000 Assembler by Paul McKee. User's Manual

68000 Assembler by Paul McKee. User's Manual Contents 68000 Assembler by Paul McKee User's Manual 1 Introduction 2 2 Source Code Format 2 2.1 Source Line Format............................... 2 2.1.1 Label Field............................... 2 2.1.2

More information

Assembly Assignment 6 - Lottery

Assembly Assignment 6 - Lottery Assembly Assignment 6 - Lottery Valdemar Örn Erlingsson Pseudo-Code Again, I write in a language I know very well, C++. Writing real code lets me test all functionality before I start. #include

More information

Computer Science 2500 Computer Organization Rensselaer Polytechnic Institute Spring Topic Notes: MIPS Programming

Computer Science 2500 Computer Organization Rensselaer Polytechnic Institute Spring Topic Notes: MIPS Programming Computer Science 2500 Computer Organization Rensselaer Polytechnic Institute Spring 2009 Topic Notes: MIPS Programming We spent some time looking at the MIPS Instruction Set Architecture. We will now consider

More information

AMIGA Programming in Machine Code A.Forness & A.Holten translation & minor corrections by Amix73 a.k.a. Herpes of Sign in 2009

AMIGA Programming in Machine Code A.Forness & A.Holten translation & minor corrections by Amix73 a.k.a. Herpes of Sign in 2009 Programming in machine code on the Amiga A. Forness & N. A. Holten Copyright 1989 Arcus Copyright 1989 DATA SCHOOL Issue 5 Content sprite "Follow Me" Machine Code IV DATA SCHOOL Postbox 62 Nordengen 18

More information

Programming Book for 6809 Microprocessor Kit

Programming Book for 6809 Microprocessor Kit Programming Book for 6809 Microprocessor Kit Wichit Sirichote, wichit.sirichote@gmail.com Image By Konstantin Lanzet - CPU collection Konstantin Lanzet, CC BY-SA 3.0, Rev1.2 March 2018 1 Contents Lab 1

More information

Midterm 2 Review Chapters 4-16 LC-3

Midterm 2 Review Chapters 4-16 LC-3 Midterm 2 Review Chapters 4-16 LC-3 ISA You will be allowed to use the one page summary. 8-2 LC-3 Overview: Instruction Set Opcodes 15 opcodes Operate instructions: ADD, AND, NOT Data movement instructions:

More information

Computer Organization and Structure. Bing-Yu Chen National Taiwan University

Computer Organization and Structure. Bing-Yu Chen National Taiwan University Computer Organization and Structure Bing-Yu Chen National Taiwan University Instructions: Language of the Computer Operations and Operands of the Computer Hardware Signed and Unsigned Numbers Representing

More information

ECE 372 Microcontroller Design Assembly Programming. ECE 372 Microcontroller Design Assembly Programming

ECE 372 Microcontroller Design Assembly Programming. ECE 372 Microcontroller Design Assembly Programming Assembly Programming HCS12 Assembly Programming Basic Assembly Programming Top Assembly Instructions (Instruction You Should Know!) Assembly Programming Concepts Assembly Programming HCS12 Assembly Instructions

More information

2B 52 AB CA 3E A1 +29 A B C. CS120 Fall 2018 Final Prep and super secret quiz 9

2B 52 AB CA 3E A1 +29 A B C. CS120 Fall 2018 Final Prep and super secret quiz 9 S2 Fall 28 Final Prep and super secret quiz 9 ) onvert 8-bit (2-digit) 2 s complement hex values: 4-29 inary: Hex: x29 2) onvert 8-bit 2 s complement hex to decimal: x3 inary: xe5 Decimal: 58 Note 3*6+

More information

H8/300L Series Programming Manual

H8/300L Series Programming Manual H8/300L Series Programming Manual Notice When using this document, keep the following in mind: 1. This document may, wholly or partially, be subject to change without notice. 2. All rights are reserved:

More information

68000 Instruction Set (2) 9/20/6 Lecture 3 - Instruction Set - Al 1

68000 Instruction Set (2) 9/20/6 Lecture 3 - Instruction Set - Al 1 68000 Instruction Set (2) 9/20/6 Lecture 3 - Instruction Set - Al 1 Lecture Overview The 68000 Instruction Set continued The understand and effectively use an architecture must understand the register

More information

Table 1: Mnemonics Operations Dictionary. Add Accumulators Add B to Y. Add with carry to B. Add Memory to B. Add 16-bit to D And B with Memory

Table 1: Mnemonics Operations Dictionary. Add Accumulators Add B to Y. Add with carry to B. Add Memory to B. Add 16-bit to D And B with Memory Table 1: Mnemonics s Dictionary ABA ABX ABY ADCA ADCB ADDA ADDB ADDD ANDA ANDB ASL ASLA ASLB ASLD ASR ASRA ASRB BCC BCLR BCS BEQ BGE BGT BHI BHS BITA BITB BLE BLO BLS BLT Add Accumulators Add B to X Add

More information

Module Title: Microprocessor Systems 2

Module Title: Microprocessor Systems 2 CORK INSTITUTE OF TECHNOLOGY INSTITIÚID TEICNEOLAÍOCHTA CHORCAÍ Autumn Examinations 2008/09 Module Title: Microprocessor Systems 2 Module Code: ELTR6017 School: Electrical and Electronic Engineering Programme

More information

MC9S12 Assembler Directives A Summary of MC9S12 Instructions Disassembly of MC9S12 op codes. Summary of HCS12 addressing modes ADDRESSING MODES

MC9S12 Assembler Directives A Summary of MC9S12 Instructions Disassembly of MC9S12 op codes. Summary of HCS12 addressing modes ADDRESSING MODES MC9S12 Assembler Directives A Summary of MC9S12 Instructions Disassembly of MC9S12 op codes o Review of Addressing Modes o Which branch instruction to use (signed vs unsigned) o Using X and Y registers

More information

Lecture XXIV: Review Xuan Guo CSC 3210 Computer Organization and Programming Georgia State University April 23, 2015 Xuan Guo Lecture XXIV: Review

Lecture XXIV: Review Xuan Guo CSC 3210 Computer Organization and Programming Georgia State University April 23, 2015 Xuan Guo Lecture XXIV: Review CSC 3210 Computer Organization and Programming Georgia State University April 23, 2015 This lecture Review: set instruction register saving subroutine linkage arguments passing printf function instruction

More information

538 Lecture Notes Week 5

538 Lecture Notes Week 5 538 Lecture Notes Week 5 (Sept. 30, 2013) 1/15 538 Lecture Notes Week 5 Answers to last week's questions 1. With the diagram shown for a port (single bit), what happens if the Direction Register is read?

More information

538 Lecture Notes Week 5

538 Lecture Notes Week 5 538 Lecture Notes Week 5 (October 4, 2017) 1/18 538 Lecture Notes Week 5 Announements Midterm: Tuesday, October 25 Answers to last week's questions 1. With the diagram shown for a port (single bit), what

More information

UNIMPLEMENTED INSTRUCTIONS

UNIMPLEMENTED INSTRUCTIONS UNIMPLEMENTED INSTRUCTIONS OVERVIEW: This Programming Assignment will take the sine computation program you wrote for Programming Assignment #4 and implement it as a 68000 assembly language instruction.

More information

EE 5340/7340 Motorola 68HC11 Microcontroler Lecture 1. Carlos E. Davila, Electrical Engineering Dept. Southern Methodist University

EE 5340/7340 Motorola 68HC11 Microcontroler Lecture 1. Carlos E. Davila, Electrical Engineering Dept. Southern Methodist University EE 5340/7340 Motorola 68HC11 Microcontroler Lecture 1 Carlos E. Davila, Electrical Engineering Dept. Southern Methodist University What is Assembly Language? Assembly language is a programming language

More information

Condition Code Register. Microcomputer Architecture and Interfacing Colorado School of Mines Professor William Hoff

Condition Code Register. Microcomputer Architecture and Interfacing Colorado School of Mines Professor William Hoff Condition Code Register 1 Topics Condition code register Addition and subtraction instructions Conditional branches 2 Condition Code Register Condition code bits are automatically set by some instructions

More information

Compiling Code, Procedures and Stacks

Compiling Code, Procedures and Stacks Compiling Code, Procedures and Stacks L03-1 RISC-V Recap Computational Instructions executed by ALU Register-Register: op dest, src1, src2 Register-Immediate: op dest, src1, const Control flow instructions

More information

Systems Architecture The Stack and Subroutines

Systems Architecture The Stack and Subroutines Systems Architecture The Stack and Subroutines The Stack p. 1/9 The Subroutine Allow re-use of code Write (and debug) code once, use it many times A subroutine is called Subroutine will return on completion

More information

NET3001. Advanced Assembly

NET3001. Advanced Assembly NET3001 Advanced Assembly Arrays and Indexing supposed we have an array of 16 bytes at 0x0800.0100 write a program that determines if the array contains the byte '0x12' set r0=1 if the byte is found plan:

More information

Run time environment of a MIPS program

Run time environment of a MIPS program Run time environment of a MIPS program Stack pointer Frame pointer Temporary local variables Return address Saved argument registers beyond a0-a3 Low address Growth of stack High address A translation

More information

Sample Problem Set #1

Sample Problem Set #1 Sample Problem Set #1 Notes: These problems are typical exam problems; most are drawn from previous homeworks and exams. This exam is open book, open notes. It may help to have a calculator. For partial

More information

CHAPTER 8. Solutions for Exercises

CHAPTER 8. Solutions for Exercises CHAPTER 8 Solutions for Exercises E8.1 The number of bits in the memory addresses is the same as the address bus width, which is 20. Thus the number of unique addresses is 2 20 = 1,048,576 = 1024 1024

More information

Something Cool. RFID is an exciting and growing. This reader from Parallax is $40 and has a serial interface

Something Cool. RFID is an exciting and growing. This reader from Parallax is $40 and has a serial interface Something Cool RFID is an exciting and growing technology This reader from Parallax is $40 and has a serial interface Lab Lab 1 due next Tues Seemed to go pretty well on Tues? Questions? Quiz Results Problem

More information

CprE 288 Introduction to Embedded Systems ARM Assembly Programming: Translating C Control Statements and Function Calls

CprE 288 Introduction to Embedded Systems ARM Assembly Programming: Translating C Control Statements and Function Calls CprE 288 Introduction to Embedded Systems ARM Assembly Programming: Translating C Control Statements and Function Calls Instructors: Dr. Phillip Jones 1 Announcements Final Projects Projects: Mandatory

More information

SINE AND COSINE SUBROUTINES

SINE AND COSINE SUBROUTINES SINE AND COSINE SUBROUTINES OVERVIEW: You developed a procedure for computing a fixed point sine function in Programming Assignment #4. In part 1 of this lab, you will convert that procedure into a subroutine

More information

BRANCH IF REGISTER IS HIGHER/GREATHER/ THAN OPERAND e.g. CMPA #$D0

BRANCH IF REGISTER IS HIGHER/GREATHER/ THAN OPERAND e.g. CMPA #$D0 Midterm Review 1. Branch instructions BHI (unsigned), BGT (signed) Take a look at the preceding comparison instruction. Then, you can use this instead of using complex formula in the instruction reference.

More information

CSE Lecture In Class Example Handout

CSE Lecture In Class Example Handout CSE 30321 Lecture 07-08 In Class Example Handout Part A: J-Type Example: If you look in your book at the syntax for j (an unconditional jump instruction), you see something like: e.g. j addr would seemingly

More information

538 Lecture Notes Week 3

538 Lecture Notes Week 3 538 Lecture Notes Week 3 (Sept. 16, 2013) 1/18 538 Lecture Notes Week 3 Answers to last week's questions 1 Write code so that the least significant bit of Accumulator A is cleared, the most significant

More information

MIPS Assembly Programming

MIPS Assembly Programming COMP 212 Computer Organization & Architecture COMP 212 Fall 2008 Lecture 8 Cache & Disk System Review MIPS Assembly Programming Comp 212 Computer Org & Arch 1 Z. Li, 2008 Comp 212 Computer Org & Arch 2

More information

Page 1. Lab. Something Cool. Quiz Results. Last Time. Embedded Compilers. Today: Intro to Embedded C

Page 1. Lab. Something Cool. Quiz Results. Last Time. Embedded Compilers. Today: Intro to Embedded C Something Cool Lab RFID is an exciting and growing technology This reader from Parallax is $40 and has a serial interface Lab 1 due next Tues Seemed to go pretty well on Tues? Questions? Quiz Results Last

More information

Chapter 2. Instructions:

Chapter 2. Instructions: Chapter 2 1 Instructions: Language of the Machine More primitive than higher level languages e.g., no sophisticated control flow Very restrictive e.g., MIPS Arithmetic Instructions We ll be working with

More information

Exam 2 E2-1 Fall Name: Exam 2

Exam 2 E2-1 Fall Name: Exam 2 Exam 2 E2-1 Fall 2004 1. Short Answer [20 pts] Exam 2 a. [4 points] Show the contents of registers A, B, SP, and X after the following code executes: lds #$a00 ldab #$23 A = ldaa #$87 ldx #$2543 B = pshd

More information

COMP 303 Computer Architecture Lecture 3. Comp 303 Computer Architecture

COMP 303 Computer Architecture Lecture 3. Comp 303 Computer Architecture COMP 303 Computer Architecture Lecture 3 Comp 303 Computer Architecture 1 Supporting procedures in computer hardware The execution of a procedure Place parameters in a place where the procedure can access

More information

ORG ; TWO. Assembly Language Programming

ORG ; TWO. Assembly Language Programming Dec 2 Hex 2 Bin 00000010 ORG ; TWO Assembly Language Programming OBJECTIVES this chapter enables the student to: Explain the difference between Assembly language instructions and pseudo-instructions. Identify

More information

1. bit manipulation instructions such as BTST, BCHG

1. bit manipulation instructions such as BTST, BCHG 1. bit manipulation instructions such as BTST, BCHG 9. (Exam #2, 1990) If ($53EFE)=$ 0A ($5FFFE)=$ 00 ($53EFF)=$ EE ($5FFFF)=$ 00 ($53F00)=$ FF ($60000)=$ 00 ($53F01)=$ 00 ($60001)=$ 00 ($53F02)=$ 12 ($60002)=$

More information

Alex Milenkovich 1. CPE/EE 421 Microcomputers: Motorola 68000: Architecture & Assembly Programming. Outline

Alex Milenkovich 1. CPE/EE 421 Microcomputers: Motorola 68000: Architecture & Assembly Programming. Outline Outline CPE/EE 421 Microcomputers: Motorola 68000: Architecture & Assembly Programming Instructor: Dr Aleksandar Milenkovic Lecture Notes Programmer s Model Assembly Language Directives Addressing Modes

More information

C SC 230 Computer Architecture and Assembly Language April 2000 Exam Sample Solutions

C SC 230 Computer Architecture and Assembly Language April 2000 Exam Sample Solutions C SC 230 Computer Architecture and Assembly Language April 2000 Exam Sample Solutions 1. (12 marks) Circle the correct answer for each of the following: The 8-bit two's complement representation of -15

More information

INTRODUCTION TO BRANCHING

INTRODUCTION TO BRANCHING INTRODUCTION TO BRANCHING UNCONDITIONAL BRANCHING There are two forms of unconditional branching in the MC68000. BRA instruction BRA Program control passes directly to the instruction located at

More information