Solution for HW#3: Instruction Set Summary (80 points) ECE473/ECE573, Microprocessor System Design

Similar documents
Flash Microcontroller. Architectural Overview. Features. Block Diagram. Figure 1. Block Diagram of the AT89C core

Atmel 8051 Microcontrollers Hardware Manual

8085 MICROPROCESSOR PROGRAMS

Instruction Set. Microcontroller Instruction Set. Instructions that Affect Flag Settings (1) The Instruction Set and Addressing Modes

8051 Serial Port. Crystal TXD. I/O Device RXD. Embedded Systems Peripherals

8051 hardware summary

ELEG3924 Microprocessor Ch.7 Programming In C

Embedded. Engineer s. Development. Tool (EEDT 5.0)

Flash Microcontroller. Memory Organization. Memory Organization

AT89C Bit Microcontroller with 1 Kbyte Flash. Features. Description. Pin Configuration

Section Microcontroller Instruction Set

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Question Bank Subject Name: EC Microprocessor & Microcontroller Year/Sem : II/IV

T.C. Yeditepe University. Department of Electrical-Electronics Engineering

Technical Note. SFDP for MT25Q Family. Introduction. TN-25-06: Serial Flash Discovery Parameters for MT25Q Family. Introduction

Complete 8086 instruction set

ASCII and BCD Arithmetic. Chapter 11 S. Dandamudi

SensyCal FCU200, FCU400 Universal measuring computer M-Bus protocol

Faculty of Engineering Student Number:

SHENZHEN JINGHUA DISPLAYS CO.,LTD.

8051 Integrated Development Environment

AN108 IMPLEMENTING A REALTIME CLOCK. Relevant Devices. Introduction. Key Points. Overview

MACHINE ARCHITECTURE & LANGUAGE

8-Bit Flash Microcontroller for Smart Cards. AT89SCXXXXA Summary. Features. Description. Complete datasheet available under NDA

PART B QUESTIONS AND ANSWERS UNIT I

8085 INSTRUCTION SET

4 Character 5x7 LED Matrix Display

Microcontroller Basics A microcontroller is a small, low-cost computer-on-a-chip which usually includes:

PACKAGE OUTLINE DALLAS DS2434 DS2434 GND. PR 35 PACKAGE See Mech. Drawings Section

Projector Control Command Reference Manual

BCD (ASCII) Arithmetic. Where and Why is BCD used? Packed BCD, ASCII, Unpacked BCD. BCD Adjustment Instructions AAA. Example

Using the Intel MCS -51 Boolean Processing Capabilities

CoE3DJ4 Digital Systems Design. Chapter 4: Timer operation

The WIMP51: A Simple Processor and Visualization Tool to Introduce Undergraduates to Computer Organization

Z80 Instruction Set. Z80 Assembly Language

MICROPROCESSOR AND MICROCOMPUTER BASICS

Sécurité des cartes à puce

2. Terminal arrangement. Default (PV display) (SV display) Communication protocol selection Selects the Communication protocol. Modbus ASCII mode:

8-bit Microcontroller with 2/4-Kbyte Flash AT89LP2052 AT89LP4052

8051 MICROCONTROLLER COURSE

M6800. Assembly Language Programming

COMPUTERS ORGANIZATION 2ND YEAR COMPUTE SCIENCE MANAGEMENT ENGINEERING JOSÉ GARCÍA RODRÍGUEZ JOSÉ ANTONIO SERRA PÉREZ

Site Master S251B Antenna and Cable Analyzer

Appendix B RCS11 Remote Communications

Versa Ware JTAG Software User Guide Rev 2.0

Master-Touch and ValuMass. Modbus Communications. INSTRUCTION MANUAL (Rev. 2.1)

8-bit Microcontroller with 8K Bytes In-System Programmable Flash. AT89LP52 - Preliminary

Hardware and Software Requirements

8. MACROS, Modules, and Mouse

TWO WAY WIRELESS DATA MESSAGING SYSTEM IN RURAL AREAS USING ZIGBEE

Unpacked BCD Arithmetic. BCD (ASCII) Arithmetic. Where and Why is BCD used? From the SQL Server Manual. Packed BCD, ASCII, Unpacked BCD

ASSEMBLY LANGUAGE PROGRAMMING (6800) (R. Horvath, Introduction to Microprocessors, Chapter 6)

AN1304. NFC Type MIFARE Classic Tag Operation. Application note PUBLIC. Rev October Document information

CHD603BM-U USB Mifare Card Reader User Manual

The Hexadecimal Number System and Memory Addressing

How To Use A Computer With A Screen On It (For A Powerbook)

ND48-RS ASCII A2.04 Communication Protocol

MS-DOS, PC-BIOS, and File I/O Chapter 13

ASSEMBLY PROGRAMMING ON A VIRTUAL COMPUTER

Number Systems. Introduction / Number Systems

2011, The McGraw-Hill Companies, Inc. Chapter 3

LABORATORY MANUAL EE0310 MICROPROCESSOR & MICROCONTROLLER LAB

DS87C530/DS83C530. EPROM/ROM Micro with Real Time Clock PRELIMINARY FEATURES PACKAGE OUTLINE DALLAS DS87C530 DS83C530 DALLAS DS87C530 DS83C530

MTS Master Custom Communications Protocol APPLICATION NOTES

LSN 2 Number Systems. ECT 224 Digital Computer Fundamentals. Department of Engineering Technology

1 Classical Universal Computer 3

Modbus RTU Communications RX/WX and MRX/MWX

Binary Representation. Number Systems. Base 10, Base 2, Base 16. Positional Notation. Conversion of Any Base to Decimal.

DS18B20 Programmable Resolution 1-Wire Digital Thermometer

CAM-VGA100 User Manual

Modbus Tutorial 7/30/01. Tutorial on TTDM-PLUS and TTSIM System Integration using Modbus

Electronic Multi-Measuring Instrument

HOST Embedded System. SLAVE EasyMDB interface. Reference Manual EasyMDB RS232-TTL. 1 Introduction

Chapter 4: Computer Codes

Revision Summary: This is the Initial release of this Application Note.

8-bit Microcontroller with 2K Bytes Flash AT89C2051

A Structured Approach to Assembly Language Programming. I, = 0.45 e-15b. I = 0.9 el /88/ $01.OO IEEE

Type 2 Tag Operation Specification. Technical Specification T2TOP 1.1 NFC Forum TM NFCForum-TS-Type-2-Tag_

UMBC. ISA is the oldest of all these and today s computers still have a ISA bus interface. in form of an ISA slot (connection) on the main board.

DS1821 Programmable Digital Thermostat and Thermometer

TOSHIBA CMOS DIGITAL INTEGRATED CIRCUIT SILICON MONOLITHIC T6963C

MEMOBUS/Modbus Communications

Site Master S331D MS2712

AN880. Converting from 8051 to Microchip Assembler: A Quick Reference INTRODUCTION

Computer Organization and Architecture

DS2786 Stand-Alone OCV-Based Fuel Gauge

NTAG213/215/216. The mechanical and electrical specifications of NTAG21x are tailored to meet the requirements of inlay and tag manufacturers.

Binary Numbers. Binary Octal Hexadecimal

1. Convert the following base 10 numbers into 8-bit 2 s complement notation 0, -1, -12

Call Subroutine (PC<15:0>) TOS, (W15)+2 W15 (PC<23:16>) TOS, Process data. Write to PC NOP NOP NOP NOP

Lecture 3 Addressing Modes, Instruction Samples, Machine Code, Instruction Execution Cycle

Keil C51 Cross Compiler

Softstarters. Type PSTX Fieldbus communication, Built-in Modbus RTU. 1SFC132089M0201 April SFC132089M0201 1

Digital codes. Resources and methods for learning about these subjects (list a few here, in preparation for your research):

Microcontroller Based Infrared Tracking Device In 2D Motion

Counting in base 10, 2 and 16

Notes on Assembly Language

Interfacing Analog to Digital Data Converters

DS1921G Thermochron ibutton

DS1302 Trickle-Charge Timekeeping Chip

NORITAKE ITRON VFD MODULES GU126x64D-K610A4

Transcription:

Solution for HW#3: Instruction Set Summary (80 points) ECE473/ECE573, Microprocessor System Design 1. Determine the Opcode for each of the following instructions (10 points) (1) ADD A, R3 (see page p249: MOV A, Rn) Opcode = 00101rrr = 00101011B=2BH (1-byte instruction) (2) MOV P2, A (see page 270: MOV direct, A) Opcode=11110101 aaaaaaaa = F5H, A0H (2-byte instruction) (3) MOV PSW, #0F3H (see page 271: MOV direct, #data) Opcode = 01110101 aaaaaaaa dddddddd = 75H, D0H, F3H (3-byte instruction) (4) ANL A, 56H (see page 252: ANL A, direct) Opcode = 01010101 aaaaaaaa = 55H, 56H (2-byte instruction) (5) MOV A, @R0 (see page 269: MOV A, @Ri) Note that only R0 and R1 are used!!! Opcode = 1110011i = 11100110=E6H (1-byte instruction) (6) MOV DPTR, #8040H (see page 272: MOV DPTR, #data16) Opcode = 10010000 dddddddd dddddddd = 90H, 80H, 40H (3-byte instruction) (7) SJMP A032H (in memory locations of A005 and A006) (see page 283: SJMP rel) Opcode = 10000000 eeeeeeee = 80H, 2BH (here A032-A007=2BH) (2-byte instruction) (8) AJMP 1F35H (in memory locations of 1F21 and 1F22) (see page 250: AJMP addr11) Since 1F35H = 0001 1(111: moved to front) 0011 0101B Opcode = aaa0001aaaaaaaa =(111)00001 0011 0101 = E1H, 35H (2-byte instruction) (9) LJMP 7FE3H (see page 268: JMP addr16) Opcode = 00000010 aaaaaaaa aaaaaaaa = 02H, 7FH, E3H (3-byte instruction) (10) MOVC A, @A+DPTR (see page 273: MOVC A, @A+DPTR) Opcode = 10010011 = 93H (1-byte instruction)

2. Write a program to copy the value 68H to RAM memory locations 40H to 89H using indirect addressing mode with a loop. (5 points) MOV A, #68H MOV R0, #40H MOV R2, #73 Again: MOV @R0, A INC R0 DJNZ R2, Again ; A=68H ; R0 is a pointer starting from 40H ; 89H-40H=49H = 73 decimal (loop iterations) ; loop 3. Write a program to clear 20 RAM locations starting at RAM address 80H. (5 points) CLR A MOV R1, #80H MOV R7, #20 Again: MOV @R1, A INC R1 DJNZ R7, Again ; the content in ACC is used to clear RAM locations ; R1 is a pointer starting from 80H ; 20 iterations ; loop 4. Write a program to copy a block of 10 bytes of data from RAM locations starting at 35H to RAM locations starting at 60H. (5 points) MOV R0, #35H MOV R1, #60H MOV R3, #10 Back: MOV A, @R0 MOV @R1, A INC R0 INC R1 DJNZ R3, Back ; R0 is a pointer starting from 35H ; R1 is the other pointer starting from 60H ; 10 iterations ; loop 5. Assuming that ROM space starting at 248H contains Shiue, write a program to transfer the bytes into RAM locations starting at 37H using indexed address mode (6 points) ORG 0 MOV DPTR, #MYDATA MOV R0, #37H MOV R2, #5 Back: CLR A MOVC A, @A+DPTR MOV @R0, A INC DPTR INC R0 ; ROM location starts from 0000H ; Copy the content in ROM to RAM ; R0 is a pointer starting from 37H ; Shiue has 5 characters ; A is reused, so it needs to be cleared ; DPTR is a pointer

DJNZ R2, Back Here: SJMP Here ; keep in the loop ORG 248H MYDATA: DB Shiue ; the data in the ROM starting 248H END 6. Write a program to get the x value from P1 and send x 2 to P2 continuously using indexed addressing mode. (6 points) ORG 0 ; ROM locations starts from 0000H MOV DPTR, #300H ; DPTR is a pointer starting from 300H MOV A, #0FFH ; Make P1 as an INPUT MOV P1, A ; Back: MOV A, P1 ; get x from P1 MOVC A, @A+DPTR ; get x 2 from table MOV P2, A SJMP Back ORG 300H Table: DB 0, 1, 4, 9, 16, 25, 36, 49, 64, 81 END 7. Illustrate how to add two 6-digit binary-coded decimal (BCD). The first is in internal memory locations 40H, 41H, and 42H, and the second is in locations 43H, 44H, and 45H. The most significant digits are in locations 40H and 43H. Place the BCD result in locations 70H, 71H and 72H. (4 points) MOV A, 42H ADD A, 45H ; Add 2 low-byte DA A ; Decimal adjust for BCD MOV 70H, A MOV A, 41H ADDC A, 44H ; using ADDC due to carry DA A MOV 71H, A MOV A, 40H ADDC A, 43H ; using ADDC due to carry DA A MOV 72H, A

8. Write a program to add two 16-bit numbers. The numbers are 3CE7H and 3B8DH. Place the sum in R7 (high byte) and R6 (low byte). (4 points) CLR C MOV A, #0E7H ADD A, #80H MOV R6, A MOV A, #3CH ADDC A, #3BH MOV R7, A ; low byte ; high byte 9. Assume that 5 BCD data item are stored in RAM starting at 40H. Write a program to sum all numbers. The result should be BCD. 40=(71H), 41=(11H), 42=(65H), 43=(59H), and 44=(37H) (6 points) MOV R0, #40H ; R0 is a pointer MOV R2, #5 ; 5 iterations CLR A MOV R7, A Again: ADD A, @R0 ; loop DA A ; adjust for BCD JNC Next ; Jump if C=0 INC R7 ; C=1 Next: INC R0 ; C=0 DJNZ R2, Again 10. Write a program to get hex data in the range of 00~FFH from P1 and convert it to decimal. Save the digits in R7 (LSB), R6, and R5. Analyze the program, assuming that P1 has a value of FDH for data. (hex converts to decimal using DIV AB) (6 points) MOV A, #0FFH MOV P1, A MOV A, P1 MOV B, #10 DIV AB MOV R7, B ; P1 as an INPUT ; Get data from P1 ; Hex Decimal MOV B, #10 DIV AB MOV R6, B MOV R5, A ; if A <10

11. Assume P1 is an input port connected to a temperature sensor. Write a program to read the temperature and test it for the value 75. (6 points) if T = 75 A=75 T < 75 R1=T T > 75 R2=T MOV P1, #0FFH ; P1 is an INPUT MOV A, P1 ; get data from P1 CJNE A, #75, Over SJMP Exit ; if A=75, exit Over: JNC Next MOV R1, A ; A<75 SJMP Exit Next: MOV R2, A ; A>75 Exit: : 12. Assume internal RAM memory locations 40H~44H contain the daily temperature for 5 days. Such as 40H=(76), 41H=(79), 42H=(69), 43H=(65), 44H=(62). Search to see if only if the value equals to 65. If value 65 does exist in the table, give its location to R4; otherwise, make R4=0. (6 points) MOV R4, #0 MOV R0, #40H MOV R2, #05 Back: MOV A, #65 CJNE A, @R0, Next MOV R4, R0 SJMP Exit Next: INC R0 DJNZ R2, Back Exit: : 13. Write a program that finds the number of 1 s in a given byte. (6 points) MOV R1, #0 MOV R7, #8 MOV A, #97H Again: RLC A JNC Next INC R1 Next: DJNZ R7, Again

14. Assume the register A has packed BCD (29H), write a program to convert packed BCD to two ASCII numbers and place them in R2 and R6. (5 points) MOV A, #29H MOV R2, A ANL A, #0FH ORL A, #30H MOV R6, A MOV A, R2 ANL A, #0F0H SWAP A ORL A, #30H MOV R2, A