COSC 243. Assembly Language Techniques. Lecture 9. COSC 243 (Computer Architecture)
|
|
- Christina Higgins
- 6 years ago
- Views:
Transcription
1 COSC 243 Assembly Language Techniques 1
2 Overview This Lecture Source Handouts Next Lectures Memory and Storage Systems 2
3 Parameter Passing In a high level language we don t worry about the number of parameters passed to a routine: add4(a, b, c, d); But in assembly how do we pass more parameters than there are registers? On the 6502 there are 3 registers we might use: A, X, Y How do we pass 4 parameters? 3
4 Parameter Passing This can be solved no-matter how many parameters The solution is called the calling-convention. It differs from high-level language to language. In C: 1. Push the parameters onto the stack (typically in reverse order) 2. Call the subroutine 3. The subroutine does the processing and returns 4. The stack is returned to its previous state To do this we need indexed addressing 4
5 Revision: Indexed Addressing The value to use is stored at the memory location that is the sum of the operands Useful for accessing stack-based parameters to a routine Examples include: LDY $311E,X ; Use memory location ($311E+X) X $10 LDY $311E,X Value Indexed F 312E 312D 312C 5
6 Example: Double a number In C: unsigned char double(unsigned char value); int main(void) { return double (0x10); } unsigned char double(unsigned char value) { return value + value; } 6
7 Example Registers Memory * = $ START: 0010 LDA #$ PHA 0013 JSR DOUBLE 0016 PLA 0017 END: 0017 JMP END 001A DOUBLE: 001A TSX A 00 X 00 Y 00 S PC D 6F F3 BC FF 01FE 01 01FC 01FB 01FA 01F9 01F8 01F7 001B LDA $0103,X CD 01F6 001E ADC $0103,X B5 01F STA $0103,X 89 01F RTS 23 01F F2 7
8 Example Registers Memory * = $ START: 0010 LDA #$ PHA 0013 JSR DOUBLE 0016 PLA 0017 OVER: 0017 JMP OVER 001A DOUBLE: 001A TSX A 10 X 00 Y 00 S PC D 6F F3 BC FF 01FE 01 01FC 01FB 01FA 01F9 01F8 01F7 001B LDA $0103,X CD 01F6 001E ADC $0103,X B5 01F STA $0103,X 89 01F RTS 23 01F F2 8
9 Example Registers Memory * = $ START: 0010 LDA #$ PHA 0013 JSR DOUBLE 0016 PLA 0017 OVER: 0017 JMP OVER 001A DOUBLE: 001A TSX A 10 X 00 Y 00 S FC PC F F3 BC FF 01FE 01 01FC 01FB 01FA 01F9 01F8 01F7 001B LDA $0103,X CD 01F6 001E ADC $0103,X B5 01F STA $0103,X 89 01F RTS 23 01F F2 9
10 Example Registers Memory * = $ START: 0010 LDA #$ PHA 0013 JSR DOUBLE 0016 PLA 0017 OVER: 0017 JMP OVER 001A DOUBLE: 001A TSX A 10 X 00 Y 00 S PC FA 001A BC FF 01FE 01 01FC 01FB 01FA 01F9 01F8 01F7 001B LDA $0103,X CD 01F6 001E ADC $0103,X B5 01F STA $0103,X 89 01F RTS 23 01F F2 10
11 Example Registers Memory * = $ START: 0010 LDA #$ PHA 0013 JSR DOUBLE 0016 PLA 0017 OVER: 0017 JMP OVER 001A DOUBLE: 001A TSX A 10 X FA Y 00 S PC FA 001B BC FF 01FE 01 01FC 01FB 01FA 01F9 01F8 01F7 001B LDA $0103,X CD 01F6 001E ADC $0103,X B5 01F STA $0103,X 89 01F RTS 23 01F F2 11
12 Example Registers Memory * = $ START: 0010 LDA #$ PHA 0013 JSR DOUBLE 0016 PLA 0017 OVER: 0017 JMP OVER 001A DOUBLE: 001A TSX 001B LDA $0103,X 001E ADC $0103,X X FA A 10 X FA Y 00 S FA PC 001E $ X BC CD B5 01FF 01FE 01 01FC 01FB 01FA 01F9 01F8 01F7 01F6 01F STA $0103,X 89 01F RTS 23 01F F2 12
13 Example Registers Memory * = $ START: 0010 LDA #$ PHA 0013 JSR DOUBLE 0016 PLA 0017 OVER: 0017 JMP OVER 001A DOUBLE: 001A TSX 001B LDA $0103,X 001E ADC $0103,X X FA A 20 X FA Y 00 S FA PC 0021 $ X BC CD B5 01FF 01FE 01 01FC 01FB 01FA 01F9 01F8 01F7 01F6 01F STA $0103,X 89 01F RTS 23 01F F2 13
14 Example Registers Memory * = $ START: 0010 LDA #$ PHA 0013 JSR DOUBLE 0016 PLA 0017 OVER: 0017 JMP OVER 001A DOUBLE: 001A TSX 001B LDA $0103,X 001E ADC $0103,X X FA A 20 X FA Y 00 S FA PC 0024 $ X BC CD B5 01FF 01FE 01 01FC 01FB 01FA 01F9 01F8 01F7 01F6 01F STA $0103,X 89 01F RTS 23 01F F2 14
15 Example Registers Memory * = $ START: 0010 LDA #$ PHA 0013 JSR DOUBLE 0016 PLA 0017 OVER: 0017 JMP OVER 001A DOUBLE: 001A TSX A 20 X FA Y 00 S FC PC BC FF 01FE 01 01FC 01FB 01FA 01F9 01F8 01F7 001B LDA $0103,X CD 01F6 001E ADC $0103,X B5 01F STA $0103,X 89 01F RTS 23 01F F2 15
16 Example Registers Memory * = $ START: 0010 LDA #$ PHA 0013 JSR DOUBLE 0016 PLA 0017 OVER: 0017 JMP OVER 001A DOUBLE: 001A TSX A 20 X FA Y 00 S PC BC FF 01FE 01 01FC 01FB 01FA 01F9 01F8 01F7 001B LDA $0103,X CD 01F6 001E ADC $0103,X B5 01F STA $0103,X 89 01F RTS 23 01F F2 16
17 Example Registers Memory * = $ START: 0010 LDA #$ PHA 0013 JSR DOUBLE 0016 PLA 0017 OVER: 0017 JMP OVER 001A DOUBLE: 001A TSX A 20 X FA Y 00 S PC BC FF 01FE 01 01FC 01FB 01FA 01F9 01F8 01F7 001B LDA $0103,X CD 01F6 001E ADC $0103,X B5 01F STA $0103,X 89 01F RTS 23 01F F2 17
18 Return Values In high level languages functions also return values Options: Store in a global variable Store on the stack Store in a register In C: 5. Return value in accumulator A Piecing it all together A subroutine that returns the sum of 4 unsigned chars 18
19 Example (Add 4 Numbers) START: END: LDA #$40 PHA LDA #$30 PHA LDA #$20 PHA LDA #$10 PHA JSR ADD4 TAX PLA PLA PLA PLA TXA JMP END ADD4: TSX LDA #$00 CLC ADC $103,X ADC $104,X ADC $105,X ADC $106,X RTS 19
20 Recursion (Fibonacci) #include <stdio.h> int main(void) { unsigned char result; result = fibonacci(7); printf("%d\n", result); return 0; } unsigned char fibonacci(unsigned char iteration) { unsigned left, right; if (iteration < 2) return 1; else { left = fibonacci(iteration - 1); right = fibonacci(iteration - 2); return left + right; } } COSC
21 Recursion (Fibonacci) START: LDA #$07 PHA JSR FIBONACCI PLA END: JMP END TMP: DCB $00 FIBONACCI: TXA ; save X PHA TYA ; save Y PHA TSX ; get stack LARGE: DEC $105,X LDA $105,X PHA JSR FIBONACCI TAY PLA DEC $105,X SMALL: LDA #$01 DONE: STA TMP PLA TAY ; restore Y PLA TAX ; restore X LDA TMP RTS LDA $105,X CMP #$02 BMI SMALL LDA $105,X PHA JSR FIBONACCI STA TMP PLA TYA CLC ADC TMP JMP DONE 21
22 Preamble and Postamble In the example, on entry to the routine we see the preamble: TXA ; save X PHA TYA ; save Y PHA TSX ; get stack This saves the registers we are going to use and loads the top of stack into X for indirect addressing At the end of routine postamble the registers are restored: PLA TAY PLA TAX ; restore Y ; restore X 22
23 Local Variables For recursion with local variables, the parameters and the local variables must both be stored on the stack This is one of the tasks of the compiler Exercise (in your own time) Rewrite the assembly in the recursion example to put TMP on the stack This gives us the traditional high level language procedural programming paradigm 23
24 Self-Modifying Code Recall Von Neumann Code and data are the same thing This can be exploited in assembly If we have 2 (or more) routines that do nearly the same thing then we can code it once and then write a program that changes the program. We call this selfmodifying code Example, a program that either ADDs or SUBTRACTs the members of an array 24
25 Self-Modifying Code START: LDX #ARRAY JSR MINUS END: ARRAY: JMP END DCB 1,2,3,4,5,6,7,8,9,0 PLUS: LDA #$7D ; ADC CLC JMP OPERATE MINUS: LDA #$ ; SBC SEC JMP OPERATE ; clear carry ; clear borrow OPERATE: LOOP: STA PL_MI LDA #$00 LDY $00,X CPY #$00 BEQ DONE PL_MI: ADC $00,X INX JMP LOOP DONE: RTS 25
26 Manipulate PC at Runtime The value of PC can be manipulated at run time. Recall that on a RTS PC is loaded with the value at the top of the stack (then 1 is added), so these are equivalent: *=$0010 START: LDA #$00 PHA *=$0010 START: JMP START LDA #$0F PHA RTS 26
27 Manipulate PC at Runtime This technique can also be used to change the return address inside subroutine call. This is useful if you want to return to a different address to the call address. This technique can be used to pass parameters inline 27
28 *=$0000 JMP START LO HI START END Manipulate PC at Runtime.BYTE $00.BYTE 00 JSR PLUS.BYTE $03.BYTE $06 JMP END PLUS TSX LDA $101,X STA LO LDA $102,X STA HI INC $101,X INC $101,X LDY #$01 LDA (LO),Y LDY #$02 CLC ADC (LO),Y RTS ; get return adress Lo ; save it ; get return addres Hi ; save it ; add 2 to return address ; so that RTS will skip data ; load first parameter ; recall, off buy 1 on RTSs ; store in A ; load seccond parameter ; clear the carry ; add to A NOTE: This program does not work with the assembler used in Lab 3. Remove the comments then try it here: 28
29 What Else? JMP START On an 8-bit 16-bit arithmetic? 32-bit arithmetic? 64-bit arithmetic? In this example we store the integers low-byte first then high byte. FIRST: DCB $CD DCB $F2 SECOND: DCB $10 DCB $20 RESULT: DCB $00, $00 START: LDX #$00 ; byte 0 CLC ; clear carry LDA FIRST,X ; $CD ADC SECOND,X ; $10 STA RESULT,X ; save ; don t clear carry INX ; byte 1 LDA FIRST,X ; $F2 ADC SECOND,X ; $20 STA RESULT,X ; save END: JMP END 29
COSC 243. Instruction Sets And Addressing Modes. Lecture 7&8 Instruction Sets and Addressing Modes. COSC 243 (Computer Architecture)
COSC 243 Instruction Sets And Addressing Modes 1 Overview This Lecture Source Chapters 12 & 13 (10 th editition) Textbook uses x86 and ARM (we use 6502) Next 2 Lectures Assembly language programming 2
More informationThe 6502 Instruction Set
The 6502 Instruction Set Load and Store Group LDA Load Accumulator N,Z LDX Load X Register N,Z LDY Load Y Register N,Z STA Store Accumulator STX Store X Register STY Store Y Register Arithmetic Group ADC
More information; Once Initialized, monitor character in calls to CN05 ; set carry for input, to be tested CN35 C SEC
// // Serialcode.s // 256 Byte Prom P8 and 512 Byte PROM P9A (second version) for Apple II Serial Card // P9A differs from P9 by adding RTS/ACK software flow control to output and // by removing batch
More informationA. CPU INSTRUCTION SET SUMMARY
A. CPU INSTRUCTION SET SUMMARY This appendix summarizes the CPU instruction set. Table A-1 is a matrix of CPU instructions and addressing modes arranged by operation code. Table A-2 lists the CPU instruction
More informationRegarding the change of names mentioned in the document, such as Mitsubishi Electric and Mitsubishi XX, to Renesas Technology Corp.
To all our customers Regarding the change of names mentioned in the document, such as Mitsubishi Electric and Mitsubishi XX, to Renesas Technology Corp. The semiconductor operations of Hitachi and Mitsubishi
More informationCode Secrets of Wolfenstein 3D IIGS. Eric Shepherd
Code Secrets of Wolfenstein 3D IIGS Eric Shepherd Fast Screen Refresh with PEI Slamming Or, Dirty Tricks with the Direct Page IIGS Features We Can Abuse Super high-resolution graphics shadowing Bank $01
More informationEECE.3170: Microprocessor Systems Design I Summer 2017 Homework 4 Solution
1. (40 points) Write the following subroutine in x86 assembly: Recall that: int f(int v1, int v2, int v3) { int x = v1 + v2; urn (x + v3) * (x v3); Subroutine arguments are passed on the stack, and can
More information:31 1/9 RLE Toolkit for CC65 v 1.0
2017-09-21 17:31 1/9 RLE Toolkit for CC65 v 1.0 RLE Toolkit for CC65 v 1.0 By MagerValp. The homepage and sources to this Toolkit is available here. Check that page for potential updates to this code.
More informationinstruction 1 Fri Oct 13 13:05:
instruction Fri Oct :0:0. Introduction SECTION INSTRUCTION SET This section describes the aressing modes and instruction types.. Aressing Modes The CPU uses eight aressing modes for flexibility in accessing
More informationApple /// Business BASIC Peek/Poke Invokable Module Information
APPLE /// COMPUTER INFORMATION Apple /// Business BASIC Peek/Poke Invokable Module Information Source Dr. John Jeppson SOFTALK magazine -- August 1982 -- pages 38-48 Compiled By David T Craig -- December
More informationQuicksort (for 16-bit Elements)
2017-09-21 17:30 1/9 Quicksort (for 16-bit Elements) Quicksort (for 16-bit Elements) by Vladimir Lidovski aka litwr, 13 Aug 2016 (with help of BigEd) It is well known that the best, the fastest sort routine
More informationDAN64: an AVR based 8-bit Microcomputer
DAN64: an AVR based 8-bit Microcomputer Juan J. Martínez jjm@usebox.net Manual for V.R - May 0, 06 Features Composite video black and white output, 56 x 9 resolution, x 4 characters (8 x 8 pixels font,
More informationBINARY LOAD AND PUNCH
BINARY LOAD AND PUNCH To easily decrease the amount of time it takes to load a long tape (Cassette or paper) a BINARY formatting technique can be used instead of the conventional ASCII format used by the
More informationCOSC345 Software Engineering. Basic Computer Architecture and The Stack
COSC345 Software Engineering Basic Computer Architecture and The Stack Outline Architectural models A little about the 68HC11 Memory map Registers A little bit of assembly (never did us any harm) The program
More informationLecture 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 informationLecture 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 informationECE 331: PC Lab 3 Stack and Subroutines
ECE 331: PC Lab 3 Stack and Subroutines Professor Andrew Mason Michigan State University Rev: S11 p.1 Announcements Objectives Topics Outline Review starting and using ASM development environment Pushing
More informationECE331 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 informationJBit E1 (1) Subroutines. Preface. Usage. Tables. Program Layout
JBit E1 (1) Preface, Usage, Program Layout, Subroutines, Tables Preface JBit E1 (1) The E1 series will show you how to write a complete application with JBit. While the application is trivial by today
More informationIII. Flags of the Processor Staus Register
III. Flags of the Processor Staus Register INHALT 1. Meaning 2. Application 2.1 Shifts 2.2 Branches 2.3 Addition and Subtraction 2.4 Comparisons in magnitude 1. Meaning processor status register Overflow
More informationContent. 1. General informations 2. direct addressing 3. indirect addressing 4. Examples including informations
IV. Addressing Modi Content 1. General informations 2. direct addressing 3. indirect addressing 4. Examples including informations 1. General Informations Address range for data and program : the 65xx
More informationProgramming 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 informationOutline. 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 informationProgramming 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 informationExample Programs for 6502 Microprocessor Kit
Example Programs for 6502 Microprocessor Kit 0001 0000 0002 0000 GPIO1.EQU $8000 0003 0000 0004 0000 0005 0200.ORG $200 0006 0200 0007 0200 A5 00 LDA $0 0008 0202 8D 00 80 STA $GPIO1 0009 0205 00 BRK 0010
More informationBRANCH 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 informationUser Manual for KRUSADER. Ken s Rather Useless Symbolic Assembly Development Environment for the Replica 1 or is that Reasonably Useful? You decide!
User Manual for KRUSADER Ken s Rather Useless Symbolic Assembly Development Environment for the Replica 1 or is that Reasonably Useful? You decide! Ken Wessen ken.wessen@gmail.com Version 1.3 December
More informationComputer Systems Lecture 9
Computer Systems Lecture 9 CPU Registers in x86 CPU status flags EFLAG: The Flag register holds the CPU status flags The status flags are separate bits in EFLAG where information on important conditions
More information2. Arithmetic Instructions addition, subtraction, multiplication, divison (HCS12 Core Users Guide, Sections 4.3.4, and ).
AS12 Assembler Directives A Summary of 9S12 instructions Disassembly of 9S12 op codes Huang Section 1.8, Chapter 2 MC9S12 V1.5 Core User Guide Version 1.2, Section 12 o A labels is a name assigned the
More informationCDA 3103 Computer Organization Homework #7 Solution Set
CDA 3103 Computer Organization Homework #7 Solution Set 1 Problems 1. Write a MARIE assembly program for the following algorithm where the subroutine takes two numbers and returns their product. Your assembly
More information538 Lecture Notes Week 2
538 Lecture Notes Week 2 (Sept. 13, 2017) 1/15 Announcements 538 Lecture Notes Week 2 Labs begin this week. Lab 1 is a one-week lab. Lab 2 (starting next week) is a two-week lab. 1 Answers to last week's
More informationTable 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 informationOSIAC 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 informationEE 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 informationUser s Guide. pico Viewer v.1.01
User s Guide pico Viewer 6502 v.1.01 ii User s Guide Copyright Notice This documentation and the software described herein are copyrighted with all rights reserved. Under the copyright laws, neither this
More informationA Technical Overview of Commodore Copy Protection. Glenn Holmer ( ShadowM ) World of Commodore Expo, 12/01/2007
A Technical Overview of Commodore Copy Protection Glenn Holmer ( ShadowM ) www.lyonlabs.org/commodore/c64.html World of Commodore Expo, 12/01/2007 Why Talk About This? These skills were a black art to
More informationAccumulator and memory instructions 1. Loads, stores, and transfers 2. Arithmetic operations 3. Multiply and divide 4. Logical operations 5. Data test
HC11 Instruction Set Instruction classes 1. 2. 3. 4. Accumulator and Memory Stack and Index Register Condition Code Register Program control instructions 2 1 Accumulator and memory instructions 1. Loads,
More informationAssembly Language Programming of 8085
Assembly Language Programming of 8085 1. Introduction A microprocessor executes instructions given by the user Instructions should be in a language known to the microprocessor Microprocessor understands
More informationCode Generation. Lecture 12
Code Generation Lecture 12 1 Lecture Outline Topic 1: Basic Code Generation The MIPS assembly language A simple source language Stack-machine implementation of the simple language Topic 2: Code Generation
More informationSample 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 informationSOEN228, Winter Revision 1.2 Date: October 25,
SOEN228, Winter 2003 Revision 1.2 Date: October 25, 2003 1 Contents Flags Mnemonics Basic I/O Exercises Overview of sample programs 2 Flag Register The flag register stores the condition flags that retain
More informationDecoding bitstreams for fun and profit
2018-12-01 11:25 1/13 Decoding bitstreams for fun and profit Decoding bitstreams for fun and profit by lft This article describes a technique for extracting bitfields from a long sequence of bytes stored
More informationMC9S12 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 informationDisassembly of MC9S12 op codes Decimal, Hexadecimal and Binary Numbers
Disassembly of MC9S12 op codes Decimal, Hexadecimal and Binary Numbers o How to disassemble an MC9S12 instruction sequence o Binary numbers are a code and represent what the programmer intends for the
More informationDisassembly of MC9S12 op codes Decimal, Hexadecimal and Binary Numbers
Disassembly of MC9S12 op codes Decimal, Hexadecimal and Binary Numbers o How to disassemble an MC9S12 instruction sequence o Binary numbers are a code and represent what the programmer intends for the
More informationMicrocontroller Intel [Instruction Set]
Microcontroller Intel 8051 [Instruction Set] Structure of Assembly Language [ label: ] mnemonic [operands] [ ;comment ] Example: MOV R1, #25H ; load data 25H into R1 2 8051 Assembly Language Registers
More informationCOMPUTE! ISSUE 36 / MAY 1983 / PAGE 244
Versatile Data Acquisition with VIC Doug Homer and Stan Klein COMPUTE! ISSUE 36 / MAY 1983 / PAGE 244 This simple method of adjusting the VIC's internal jiffy dock can slow it down to match your timing
More informationExam I Review February 2017
Exam I Review February 2017 Binary Number Representations Conversion of binary to hexadecimal and decimal. Convert binary number 1000 1101 to hexadecimal: Make groups of 4 bits to convert to hexadecimal,
More information컴퓨터개념및실습. 기말고사 review
컴퓨터개념및실습 기말고사 review Sorting results Sort Size Compare count Insert O(n 2 ) Select O(n 2 ) Bubble O(n 2 ) Merge O(n log n) Quick O(n log n) 5 4 (lucky data set) 9 24 5 10 9 36 5 15 9 40 14 39 15 45 (unlucky
More information1 Introduction Forth, the Language Why Forth? Comparing to other Forths Stack Checking... 5
1 Contents 1 Introduction 4 1.1 Forth, the Language......................... 4 1.1.1 Why Forth?.......................... 4 1.1.2 Comparing to other Forths................. 4 1.1.3 Stack Checking........................
More informationCall A.P.P.L.E. TOME OF COPY PROTECTION
Call A.P.P.L.E. World s Largest Apple User Group Since 1978 www.callapple.org TOME OF COPY PROTECTION Technical Errata for First Printing Compiled August 2018 Changes are Bold Page 20 Half Tracks * BE5A:
More informationCode Generation. The Main Idea of Today s Lecture. We can emit stack-machine-style code for expressions via recursion. Lecture Outline.
The Main Idea of Today s Lecture Code Generation We can emit stack-machine-style code for expressions via recursion (We will use MIPS assembly as our target language) 2 Lecture Outline What are stack machines?
More informationWe can emit stack-machine-style code for expressions via recursion
Code Generation The Main Idea of Today s Lecture We can emit stack-machine-style code for expressions via recursion (We will use MIPS assembly as our target language) 2 Lecture Outline What are stack machines?
More information1. Memory Mapped Systems 2. Adding Unsigned Numbers
1 Memory Mapped Systems 2 Adding Unsigned Numbers 1 1 Memory Mapped Systems Our system uses a memory space Address bus is 16-bit locations Data bus is 8-bit 2 Adding Unsigned Numbers 2 Our system uses
More informationLecture 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 information0b) [2] Can you name 2 people form technical support services (stockroom)?
ECE 372 1 st Midterm ECE 372 Midterm Exam Fall 2004 In this exam only pencil/pen are allowed. Please write your name on the front page. If you unstaple the papers write your name on the loose papers also.
More informationThe Motorola 68HC11 Instruc5on Set
The Motorola 68HC11 Instruc5on Set Some Defini5ons A, B * accumulators A and B D * double accumulator (A + B) IX, IY * index registers X and Y SP * stack pointer M * some memory loca5on opr * an operand
More informationARM Assembly Language. Programming
Outline: ARM Assembly Language the ARM instruction set writing simple programs examples Programming hands-on: writing simple ARM assembly programs 2005 PEVE IT Unit ARM System Design ARM assembly language
More information68HC11 PROGRAMMER'S MODEL
8H11 PROGRMMER'S MODEL s (,, and D) s and are general-purpose 8-bit accumulators used to hold operands and results of arithmetic calculations or data manipulations. Some instructions treat the combination
More informationMAHALAKSHMI ENGINEERING COLLEGE TIRUCHIRAPALLI
MAHALAKSHMI ENGINEERING COLLEGE TIRUCHIRAPALLI-621213. QUESTION BANK DEPARTMENT: EEE SUB CODE: EE2324 YR/ SEM:III/ VI SUB NAME: MICROPROCESSORS & MICROCONTROLLERS UNIT 2- PROGRAMMING OF 8085 MICROPROCESSORS
More informationLecture #3 Microcontroller Instruction Set Embedded System Engineering Philip Koopman Wednesday, 20-Jan-2015
Lecture #3 Microcontroller Instruction Set 18-348 Embedded System Engineering Philip Koopman Wednesday, 20-Jan-2015 Electrical& Computer ENGINEERING Copyright 2006-2015, Philip Koopman, All Rights Reserved
More informationCOE538 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 informationCSC 2400: Computer Systems. Using the Stack for Function Calls
CSC 24: Computer Systems Using the Stack for Function Calls Lecture Goals Challenges of supporting functions! Providing information for the called function Function arguments and local variables! Allowing
More informationAssembly Language Programming of 8085
Assembly Language Programming of 8085 Topics 1. Introduction 2. Programming model of 8085 3. Instruction set of 8085 4. Example Programs 5. Addressing modes of 8085 6. Instruction & Data Formats of 8085
More information17.1. Unit 17. Instruction Sets Picoblaze Processor
17.1 Unit 17 Instruction Sets Picoblaze Processor INSTRUCTION SET OVERVIEW 17.2 17.3 Instruction Set Review Defines the software interface of the processor and memory system Instruction set is the vocabulary
More informationIntroduction to C. Why C? Difference between Python and C C compiler stages Basic syntax in C
Final Review CS304 Introduction to C Why C? Difference between Python and C C compiler stages Basic syntax in C Pointers What is a pointer? declaration, &, dereference... Pointer & dynamic memory allocation
More informationUsing 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 informationINSTRUCTION SET AND EXECUTION
SECTION 6 INSTRUCTION SET AND EXECUTION Fetch F1 F2 F3 F3e F4 F5 F6 Decode D1 D2 D3 D3e D4 D5 Execute E1 E2 E3 E3e E4 Instruction Cycle: 1 2 3 4 5 6 7 MOTOROLA INSTRUCTION SET AND EXECUTION 6-1 SECTION
More informationAN2093. Motorola Semiconductor Application Note. Creating Efficient C Code for the MC68HC08. Freescale Semiconductor, I.
nc. Motorola Semiconductor Application Note Order this document by /D Creating Efficient C Code for the MC68HC08 by Stuart Robb East Kilbride, Scotland 1 Introduction The C programming language is a powerful,
More informationSubprograms: Arguments
Subprograms: Arguments ICS312 Machine-Level and Systems Programming Henri Casanova (henric@hawaii.edu) Activation Records The stack is useful to store and rieve urn addresses, transparently managed via
More informationCSC 8400: Computer Systems. Using the Stack for Function Calls
CSC 84: Computer Systems Using the Stack for Function Calls Lecture Goals Challenges of supporting functions! Providing information for the called function Function arguments and local variables! Allowing
More informationLecture 20: AVR Programming, Continued. AVR Program Visible State (ones we care about for now)
18 100 Lecture 20: AVR Programming, Continued S 15 L20 1 James C. Hoe Dept of ECE, CMU April 2, 2015 Today s Goal: You will all be ace AVR hackers! Announcements: Midterm 2 can be picked up in lab and
More information10-1 C D Pearson Education, Inc. M. Morris Mano & Charles R. Kime LOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e
10-1 C D E A B 10-2 A B A B C (A B) C D A A B (A B) C E D (A B) C D E (A B) C + D E (A B) C 10-3 Opcode Mode Address or operand 10-4 Memory 250 Opcode Mode PC = 250 251 ADRS 252 Next instruction ACC Opcode:
More informationCourse Administration
Fall 2018 EE 3613: Computer Organization Chapter 2: Instruction Set Architecture Introduction 4/4 Avinash Karanth Department of Electrical Engineering & Computer Science Ohio University, Athens, Ohio 45701
More informationUnit 17. Instruction Set Review INSTRUCTION SET OVERVIEW. Historical Instruction Format Options. Instruction Sets Picoblaze Processor
17.1 17.2 Unit 17 Instruction Sets Picoblaze Processor INSTRUCTION SET OVERVIEW 17.3 17.4 Instruction Set Review Defines the software interface of the processor and memory system Instruction set is the
More informationLecture Outline. Topic 1: Basic Code Generation. Code Generation. Lecture 12. Topic 2: Code Generation for Objects. Simulating a Stack Machine
Lecture Outline Code Generation Lecture 12 Topic 1: Basic Code Generation The MIPS assembly language A simple source language Stack-machine implementation of the simple language Topic 2: Code Generation
More informationProgramming the ARM. Computer Design 2002, Lecture 4. Robert Mullins
Programming the ARM Computer Design 2002, Lecture 4 Robert Mullins 2 Quick Recap The Control Flow Model Ordered list of instructions, fetch/execute, PC Instruction Set Architectures Types of internal storage
More informationCSCE 5610: Computer Architecture
HW #1 1.3, 1.5, 1.9, 1.12 Due: Sept 12, 2018 Review: Execution time of a program Arithmetic Average, Weighted Arithmetic Average Geometric Mean Benchmarks, kernels and synthetic benchmarks Computing CPI
More informationProgramming of 8085 microprocessor and 8051 micro controller Study material
8085 Demo Programs Now, let us take a look at some program demonstrations using the above instructions Adding Two 8-bit Numbers Write a program to add data at 3005H & 3006H memory location and store the
More informationIntroduction to Assembly Language Programming (Instruction Set) 1/18/2011 1
Introduction to Assembly Language Programming (Instruction Set) 1/18/2011 1 High Level Language Compiler Assembly Language Assembler Machine Code Microprocessor Hardware 1/18/2011 2 8085A Instruction Set
More informationMIPS 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 informationEE 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 informationECE 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 informationME 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 informationProgramming. 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 informationCS61 Section Solutions 3
CS61 Section Solutions 3 (Week of 10/1-10/5) 1. Assembly Operand Specifiers 2. Condition Codes 3. Jumps 4. Control Flow Loops 5. Procedure Calls 1. Assembly Operand Specifiers Q1 Operand Value %eax 0x104
More informationCSE351 Autumn 2012 Midterm Exam (5 Nov 2012)
CSE351 Autumn 2012 Midterm Exam (5 Nov 2012) Please read through the entire examination first! We designed this exam so that it can be completed in 50 minutes and, hopefully, this estimate will prove to
More informationInstruction Set Architecture
C Fortran Ada etc. Basic Java Instruction Set Architecture Compiler Assembly Language Compiler Byte Code Nizamettin AYDIN naydin@yildiz.edu.tr http://www.yildiz.edu.tr/~naydin http://akademik.bahcesehir.edu.tr/~naydin
More informationObjectives. ICT106 Fundamentals of Computer Systems Topic 8. Procedures, Calling and Exit conventions, Run-time Stack Ref: Irvine, Ch 5 & 8
Objectives ICT106 Fundamentals of Computer Systems Topic 8 Procedures, Calling and Exit conventions, Run-time Stack Ref: Irvine, Ch 5 & 8 To understand how HLL procedures/functions are actually implemented
More informationChapter 2A Instructions: Language of the Computer
Chapter 2A Instructions: Language of the Computer Copyright 2009 Elsevier, Inc. All rights reserved. Instruction Set The repertoire of instructions of a computer Different computers have different instruction
More informationCPE/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 informationC 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 informationTABLE 9-1. Symbolic Convention for Addressing Modes. Register indirect LDA (R1) ACC M[ R1] Refers to Figure 9-4. Addressing mode. Symbolic convention
T-236 Symbolic Convention for Addressing Modes TABLE 9-1 Symbolic Convention for Addressing Modes Refers to Figure 9-4 Addressing mode Symbolic convention Register transfer Effective address Contents of
More informationComputer Organization MIPS ISA
CPE 335 Computer Organization MIPS ISA Dr. Iyad Jafar Adapted from Dr. Gheith Abandah Slides http://www.abandah.com/gheith/courses/cpe335_s08/index.html CPE 232 MIPS ISA 1 (vonneumann) Processor Organization
More informationME4447/6405. Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics. Instructor: Professor Charles Ume LECTURE 7
ME4447/6405 Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics Instructor: Professor Charles Ume LECTURE 7 Reading Assignments Reading assignments for this week and next
More informationPractical Malware Analysis
Practical Malware Analysis Ch 4: A Crash Course in x86 Disassembly Revised 1-16-7 Basic Techniques Basic static analysis Looks at malware from the outside Basic dynamic analysis Only shows you how the
More informationCSE P 501 Exam 8/5/04
Name There are 7 questions worth a total of 65 points. Please budget your time so you get to all of the questions. Keep your answers brief and to the point. You may refer to the following references: Course
More informationMIGRATING TO THE 68HC12 IN C
MIGRATING TO THE 68HC12 IN C by Jean-Pierre Lavandier (Cosmic Software) and Greg Viot (Motorola) INTRODUCTION An important design goal of the 68HC12 was to maintain software compatibility with the 68HC11
More informationC Programming Language. Microcomputer Architecture and Interfacing Colorado School of Mines Professor William Hoff
C Programming Language 1 C C is better to use than assembly for embedded systems programming. You can program at a higher level of logic than in assembly, so programs are shorter and easier to understand.
More informationAn ability to program a microcontroller to perform various tasks
Learning Outcome #1 An ability to program a microcontroller to perform various tasks How? A. Architecture and Programming Model B. Instruction Set Overview C. Assembly Control Structures D. Control Structure
More information