University of Toronto at Scarborough CSC CSSF - Microprocessor Systems

Similar documents
Q. Classify the instruction set of 8051 and list out the instructions in each type.

Microcontroller Intel [Instruction Set]

Microprocessors 1. The 8051 Instruction Set. Microprocessors 1 1. Msc. Ivan A. Escobar Broitman

Instruction Set Of 8051

INSTRUCCIONES ARITMETICAS ERROR! MARCADOR NO DEFINIDO.

MASSEY UNIVERSITY PALMERSTON NORTH CAMPUS

Digital Blocks Semiconductor IP

Digital Blocks Semiconductor IP

DR bit RISC Microcontroller. Instructions set details ver 3.10

Dodatak. Skup instrukcija

Digital Blocks Semiconductor IP

Dragonchip. Instruction Set Manual

Embedded Controller Programming

Microcontroller. Instruction set of 8051

Programming of 8085 microprocessor and 8051 micro controller Study material


SN8F5000 Family Instruction Set

Application Brief D-005

8051 Overview and Instruction Set

80C51 family programmer s guide and instruction set. 80C51 Family. PROGRAMMER S GUIDE AND INSTRUCTION SET Memory Organization. Philips Semiconductors

UNIT 2 THE 8051 INSTRUCTION SET AND PROGRAMMING

Memory organization Programming model - Program status word - register banks - Addressing modes - instruction set Programming examples.

Module Contents of the Module Hours COs

Architecture & Instruction set of 8085 Microprocessor and 8051 Micro Controller

UNIT THE 8051 INSTRUCTION SET AND PROGRAMMING

AL8051S 8-BIT MICROCONTROLLER Application Notes

8051 Microcontroller

C51 Family. Architectural Overview of the C51 Family. Summary

ET355 Microprocessors Thursday 6:00 pm 10:20 pm

Introduction to uc & Embedded Systems

Programming Book Microcontroller Kit. Rev 3.0 January, Wichit Sirichote

Principle and Interface Techniques of Microcontroller

Legacy documentation refer to the Altium Wiki for current information. TSK51x MCU

MCS -51 Programmer s Guide and Instruction Set

TUTORIAL Assembly Language programming (2)

Application Brief D-002

8051 Core Specification

MASSEY UNIVERSITY PALMERSTON NORTH CAMPUS

8051 Microcontrollers

Highlights. FP51 (FPGA based 1T 8051 core)

8051 Programming: Arithmetic and Logic

CHAPTER 6 ARITHMETIC, LOGIC INSTRUCTIONS, AND PROGRAMS

NAME as31 - An Intel 8031/8051 assembler. SYNOPSIS as31 [-h] [-l] [-s] [-v] [-Aarg] [-Ffmt] [-Ofile] infile.asm

TUTORIAL. Donal Heffernan University of Limerick May Tutorial D.Heffernan 2000,

What Registers are available? Programming in Assembler. Assembler Programming - like early Basic. Assembler Data Movement Instructions

Y51 Microcontroller. Technical Manual

Assembly Language programming (2)

C51 Family. C51 Family Programmer s Guide and Instruction Set. Summary

Lecture Instruction Set

Chapter Family Microcontrollers Instruction Set

Arithmetic and Logic

8051 Instruction Set

Legacy documentation refer to the Altium Wiki for current information. TSK52x MCU

ELEG3923 Microprocessor Ch.6 Arithmetic and Logics

Core8051. Advanced v0.1

ENE 334 Microprocessors

8051 Programming using Assembly

UNIT MICROCONTROLLER AND ITS PROGRAMMING

EEE3410 Microcontroller Applications Department of Electrical Engineering Lecture 4 The 8051 Architecture

VRS540-4kB Flash, 128B RAM, 25~40MHz, 8-Bit MCU

IA8044/IA8344 Variants IA8044 4kB internal ROM with R0117 version 2.3 firmware, 192 byte internal RAM, 64kB external program and data space.

VRS550-8kB Flash, 256B RAM, 25~40MHz, 8-Bit MCU VRS560-16kB Flash, 256B RAM, 40MHz, 8-Bit MCU

8051 Single Board Monitor Programming. Minmon - Yeralan & Ahluwalia. PaulMon1 & PaulMon2 - Paul Stoffregen

8051 Microcontroller Assembly Programming

MICROPROCESSOR LABORATORY MANUAL

Section Microcontroller Instruction Set

Microcontroller and Applications

Control Transfer Instructions Jump, Loop, and Call. ECE473/573 Microprocessor System Design, Dr. Shiue

~: Simple Programs in 8051 assembly language :~

8051 Microcontroller Logical Operations. Prepared by : A. B. Modi Target Audience : 5 th Semester Students

VRS570 32K Flash, 1kB RAM, 25~40MHz, 8-Bit MCU VRS580 64K Flash, 1kB RAM, 25~40MHz, 8-Bit MCU

Principle and Interface Techniques of Microcontroller

MODEL ANSWER WINTER 17 EXAMINATION Subject Title: Microcontroller and applications

CPEG300 Embedded System Design. Lecture 6 Interrupt System

INTEGRATED CIRCUITS P89C669 USER MANUAL. Preliminary Supersedes data of 2003 Jul Sep 16

MICROPROCESSOR & MICROCONTROLLER

Assembly Language programming (3)

1. Write A Program to move a block of data within the internal RAM

UNIT MICROCONTROLLER

Introduction To MCS-51

International Journal of Digital Application & Contemporary research Website: (Volume 1, Issue 2, September 2012)

Lab-Report Microprocessors

Q.1. A) Attempt any THREE of the following:

CS 320. Computer Architecture Core Architecture

Chapter 09. Programming in Assembly

WINTER 14 EXAMINATION

3.4 Tập lệnh

Lecture 5. EEE3410 Microcontroller Applications Department of Electrical Engineering Assembly Language Programming (1)

MODEL ANSWER SUBJECT- MICROCONTROLLER(12187) CLASS-EJ5E CLASS TEST-02 Q1.)Attempt any THREE of the following.

MODULE-1. Short Answer Questions

SUMMER 13 EXAMINATION

8051 microcontrollers

Contents. Join the Technical Community Today!

MICROPROCESSORS AND MICROCONTROLLERS MATERIAL. Features of 8051:

EE6502- MICROPROCESSOR AND MICROCONTROLLER

Question Bank Microprocessor and Microcontroller

CoE3DJ4 Digital Systems Design. Chapter 6: Interrupts

S.J.P.N Trust's. Hirasugar Institute of Technology, Nidasoshi.

PART-A INTRODUCTION TO 8051 MICROCONTROLLER. 8-bit data bus - It can access 8 bits of data in one operation

MODEL ANSWER SUMMER 17 EXAMINATION Subject Title: Microcontroller and Applications Subject Code:

Transcription:

Final Exam - December l&l997 University of Toronto at Scarborough CSC CSSF - Microprocessor Systems 3 hours - No notes or similar aids allowed. Marks Examiner: Gyula Lorincz P3 oc-3-20 1. Explain in detail what the following C program does. Bits Pi.0 to P1.3 are connected to four switches while bits P1.4 t0 P1.7 are connected to LEDs. For full credit you must comment each line of the program, and explain the overall operation of the program. #pragma nointvector #pragma code symbols #include <reg83c51.h> #include <stdio.h> unsigned char varl=o; -,,J&, L.&y t&&< unsigned char var2=100; $J,&i 5 " V' unsigned char var3=250; s&a /. sbit Pl-0 = 0x90; sbit Pl-1 = 0x91; sbit Pl-2 = 0x92; sbit Pl-3 = 0x93; sbit Pl-4 = 0x94; sbit Pl-5 = 0x95; sbit Pl-6 = 0x96; 0, sbit Pl-7 = 0x97; -,Jj,/&A, / i 2 void int-handler (void) interrupt 1 us&g l{,; -. _..A TRO = 0; THO = -20000/256; TLO = -200008256; TRO = 1; ++varl; if (varl==var2) Pl=OxOF;.,,,~,~p else if (varl==var3){ varl=o; Pl-4=Pl-3; --, Pl 7=Pl-0; ) - 1 t void main (void){ TMOD=OxOl; Pl=OxOF; c - 3,,ywfi TFO=l; E=Ox82; while (l)( 1

20 3. A photogate is used to count boxes movin,u along a conveyor belt. The output of the photogate, which is connected to the Tl input of an,8052, is logic 0 when a box blocks the beam and logic 1 otherwise. Write a program in 8052 assembly language that uses an interrupt service routine to trigger an alarm connected to output P1.7 after five hundred boxes pass the photogate. Assume that the alarm is on if P1.7 equals 1. You must include the code needed in the main routine to set up the interrupts. Comments are required. 20 3. The diagram below shows an external (serial in/parallel out) shift register connected to a the TXD and RXD lines of the serial port of a 8051. This allows an extra 8 bits to be output from the 8051. Write a program that initializes the 8051 serial port for shift register mode (mode 0) and then uses a timer interrupt to output the contents of a 10 element array in external data memory to the extra 8 outputs, with a delay between values of 1 second. You must include the code needed in the main routine to set up the interrupt. Comments are required. 8 Exm outpurs FGURE 54 Serial port shift register mode TxD(F3.1) RXD (P3.0) ) CLOCK * Daa Shifi register 15 4. (a) nterrupt service routine NTl makes use of the 8051 registers RO to R7 for local variables. Assume that the main routine also uses the same registers in bank 0. Explain using an example, how this can cause the main program to malfunction. Modify NTl to use register bank 3 instead. NTl:......... 1 (b) Suppose NT performs some CJNE instructions. Expain how this can also cause the main program to malfunction. Modify NTl to prevent these problems.

25 p3 3of YJ- 5. The following program is to be executed on the 8051 controlled train system used in the assignments. A single train starts off in sector 1. Explain in detail what the program does. For full credit you must comment each line of the program, and explain the overall operation of the program and each subroutine. $ XREF ERRORPRNT CONTROL EQU OFBOOH PORTA EQU OF800H PORTB EQU OF900H RESETH EQU OE200H RESETL EQU OEOOOH C EQU ODH CSEG AT 5000H USNG 0 START: SUB4 SETB P1.2 SETB C BT,C SUB2 SETB P1.0 L2: A,#00110000B RO,#16 DPTR,#PORTA L3: A,#11101111B C,Pl.O JC L4 NEWA,A NEWA,#OOOO1111B JMP L5 L4: NC A ORL A,#00110000B DJNZ RO,L3 A,#00110000B RO,#8 L7: DPTR,#PORTA A,#11011111B X @DPTR,A C,Pl.O JC L8 NEWA,A NEWA,#00001111B ORL NEwA.~oao1oooas

JMP L8: NC ORL DJNZ JMP L5: CPL DV ADD ADD JMP L5 A A,#0011000OB RO,L7 SUB3 L2 SUB3 BT C,BT SUB2 A,NEWA B,#lO AB A,#30H SUB1 A,B A,#30H SUB1 A,#C SUB1 L2 SUBl: JNB T,$ CLR T SBUF,A SUBZ: DPTR,#PORTB Pl.l,C R6,#8 A,#00111000B LOOPl: X @DPTR,A A,#11000111B ORL A,#00111000B NC A DJNZ R6,LOOPl SUB3: RO,#lOO L6: Rl,#lOO DJNZ Rl,$ DJNZ R0,L6

sl.24: X DJNZ X X DPTR,#RESETH @DPTR,A R6,#25 R6,$ DPTR,#RESETL @DPTR,A DPTR,#CONTROL A,#80H @DPTR,A BSEG AT 0 BT: DBT 1 DSEG AT 30H NEWA: DS 1 END

MNEMONC DESCRPTON MNEMONC DESCRPTON Arithmetic Operations ADD Asource ADD A,#data ADDC A.source ADDC A,#data SUBB A,source SUBB A,#data NC A NC source DEC A DEC source NC DPTR MUL A6 DV AB DA A Logical Operations ANL Asource ANL A.#data ANL dire&a ANL direct,#data ORL Asource ORL A,#data ORL direct,a ORL direct,#data XRL Asource add source to A add with carry subtract from A with borrow increment decrement increment DPTR multiply A & B divide A by B decimal adjust A logical AND logical OR logical XOR XRL A,#data XRL direct,a XRL direct,#data CLR A clear A CPL A complement A RL A rotate A left RLC A (through C) RR A rotate A right RRC A (through C) SWAP A swap nibbles LEGEND Rn direct @Ri source dest #data #data1 6 bit rel addrli addrl6 register addressing using RO-R7 8-bit internal address (OOH-FFH) indirect addressing using RO or Rl any of [Rn,direct.@ri] any of (Rn,direct,@ri] 8-bit constant included in instr. 16-bit constant 8-bit direct address of bit signed 8-bit offset 11 -bit address in current 2k page 16-bit address FlGURE A - Quick reference chart MNEMONC DESCRPTON MNEMONC DESCRlPTlON Data Transfer Operations Asource A,#data dest.a destsource dest,#data DPTR,#datalG C A,@A + DPTR C A,@A + PC X A,@Ri X A,@DPTR X @Ri,A X @DPTR,A PUSH direct POP direct, XCH Asource XCHD A,@Ri move source to destination move from code memory move from data mewry push onto stack pop from stack exchange bytes exchange low order digits Boolean Variable Manipulation CLR C clear bit CLR bit SETB C set bit SETB bit CPL c - complement bit CPL bit ANL C,bit AND bit with C ANL C./bit AND NOT bit with C ORL ORL JC JNC JB JNB JBC C.bit C./bit C,bit bit,c rel rel bit,rel bit.rel bit,rel Program Branching A addrl 1 L addr16 AJMP addrll LJMP addr16 SJMP rel JMP @A + DPTR JZ rel JNZ rel CJNE A,direct,rel CJNE A,#data.rel CJNE Rn,#data,rel CJNE @Ri.#data,rel DJNZ Rn,rel DJNZ NOP dire&ret OR bit with C OR NOT bit with C move bit to bit jump if C set if C not set jump if bit set if bit not set if set then clear call subroutine return from sub. from interrupt jump jumpifa=o ifanot = 0 compare and jump if not equal decrement and jump if not zero no operation

- -- PT2 TMOD n GATE C/ Ml MO - msb lsb ctfl TCON TR TFO TRO El n-1 EO T T0 T2CON 2 a-2 CP/R SCON c SMO PSW C AC FO RSl RSO OV - P EA -- ET?, Es ET1 Exl Fxo Exo P PS PT pm Pro PXO