Chapter # 6 PROGRAMING THE BASIC COMPUTER.

Slides:



Advertisements
Similar presentations
PROGRAMMING THE BASIC COMPUTER
Advertisements

Chapter 7 Introduction to LC-3 Assembly Language Assembly Language Assembly Process Using the Editor & Simulator for Assembly Language Programming.
Cpe 252: Computer Organization1 Lo’ai Tawalbeh Programming The Basic Computer Chapter 6:
Basic Computer Organization and Design
Dale & Lewis Chapter 5 Computing components. Let’s design a computer Generic CPU with registers −Program counter (PC) – 5 bits (size of addresses) −Instruction.
1 CS Programming Languages Random Access Machines Jeremy R. Johnson.
Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2009
Computer System Architecture Dept. of Info. Of Computer Chap. 6 Programming the Basic Computer 6-1 Chap. 6 Programming the Basic Computer n 6-1 Introduction.
Computer Architecture I: Digital Design Dr. Robert D. Kent Computer Architecture Machine & Assembly Language Programming.
April 14, 2007CCSC-Central Plains Region1 Use of a Simulator and an Assembler in Teaching Input-Output Processing and Interrupt Handling Soe Than Department.
Chapter 6: Programming The Basic Computer CPIT 210
Computer System Architecture ESGD2204
Chapter No 5 Basic Computer Organization And Design.
1 Basic Computer Organization & Design Computer Organization Computer Architectures Lab BASIC COMPUTER ORGANIZATION AND DESIGN Instruction Codes Computer.
Eng. Mohammed Timraz Electronics & Communication Engineer University of Palestine Faculty of Engineering and Urban planning Software Engineering Department.
Bus Architecture Memory unit AR PC DR E ALU AC INPR 16-bit Bus IR TR
Lecture 15 Today’s lecture MARIE programming Assembler
Exam2 Review Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2009.
PROGRAMMING THE BASIC COMPUTER
1 Purpose of This Chapter In this chapter we introduce a basic computer and show how its operation can be specified with register transfer statements.
Lec 5 Basic Computer Organization
Dale & Lewis Chapter 5 Computing components
1 Basic Computer Organization & Design Computer Organization Prof. H. Yoon BASIC COMPUTER ORGANIZATION AND DESIGN Instruction Codes Computer Registers.
Instruction.
Ch5. 기본 컴퓨터의 구조와 설계.
Basic architecture.
Assembly Language Programming of 8085 BY Prof. U. V. THETE Dept. of Computer Science YMA.
Dr.Chao Tan, Carnegie Mellon University.
Introduction A computer system includes both hardware and software. The designer should be familiar with both of them. This chapter introduces some basic.
1 M. Morris Mano Computer System Architecture Chapter 6: Programming the Basic Computer 박 찬식 교육관 325 호,
Basic Computer Organization - Part 2 Designing your first computer
1 BASIC COMPUTER ORGANIZATION AND DESIGN Instruction Codes Computer Registers Computer Instructions Timing and Control Instruction Cycle Memory Reference.
PROGRAMMING THE BASIC COMPUTER
Unit 1 Instruction set M.Brindha AP/EIE
UNIT 2 REGISTER TRANSFER AND MICROOPERATIONS
PROGRAMMING THE BASIC COMPUTER
Assembly Language Programming of 8085
Microprocessor T. Y. B. Sc..
COMPUTER ARCHITECTURE
Symbol Hex Code Description I=0 I=1
PROGRAMMING THE BASIC COMPUTER
3.Instruction Set of 8085 Consists of 74 operation codes, e.g. MOV
Computer Organization and Design
BASIC COMPUTER ORGANIZATION AND DESIGN
Overview Instruction Codes Computer Registers Computer Instructions
BASIC COMPUTER ORGANIZATION AND DESIGN
BASIC COMPUTER ORGANIZATION AND DESIGN
Chapter 7 LC-2 Assembly Language.
By: A. H. Abdul Hafez CAO, by Dr. A.H. Abdul Hafez, CE Dept. HKU
سازمان و طراحي کامپيوتر پايه.
Assembler CASE Tool.
PROGRAMMING THE BASIC COMPUTER
Programming The Basic Computer
Chap. 6 Programming the Basic Computer
Instruction and Control II
Programming The Basic Computer
Computer Architecture and Organization: L11: Design Control Lines
Chapter 7 LC-2 Assembly Language.
ECEG-3202 Computer Architecture and Organization
By: A. H. Abdul Hafez Computer Architecture and Organization: L06: Stored program and Instruction code.
Computer Architecture and Organization: L07: Control Sequence
PROGRAMMING THE BASIC COMPUTER
ECEG-3202 Computer Architecture and Organization
Chapter 6 Programming the basic computer
Chapter 10 Instruction Sets: Characteristics and Functions
Location Counter (LC) = 0 while line of code <> END if ORG
Presentation transcript:

Chapter # 6 PROGRAMING THE BASIC COMPUTER

Contents Machine language Assembly language The Assembler Program Loops Programming Arithmetic and Logic Operations Subroutines Input-Output Programming

Table 6-1 Computer Instruction Sym I=0 I=1 Description AND 0xxx 8xxx And Memory to AC ADD 1xxx 9xxx Add Memory to AC LDA 2xxx Axxx Load To AC STA 3xxx Bxxx Store Of AC BUN 4xxx Cxxx Branch Uncondionary BSA 5xxx Dxxx Return Address ISZ 6xxx Exxx Skip If Zero

CLA 7800 Clear AC Clear E Comp. AC Comp. E Cir. Right AC and E Table 6-1 Instruction CLA 7800 Clear AC Clear E Comp. AC Comp. E Cir. Right AC and E Cir. Left AC and E Increment AC Skip If AC is Positive Skip If AC is Negative Skip If AC is Zero Skip If E is 0 Halt Computer CLE 7400 CMA 7200 CME 7100 CIR 7080 CIL 7040 INC 7020 SPA 7010 SNA 7008 SZA 7004 SZE 7002 HLT 7001

Instruction For Computer INP F800 Input to AC OUT F400 Output From Ac SKI F200 Skip on Input Flag SKO F100 Skip On Output Flag ION F080 Interrupt On IOF F040 Interrupt Off

Table 6-4 Symbolic Operation Code Location Instruction Comments 000 LDA 004 Load First operand In AC 001 ADD 005 Add second operand to Ac 002 STA 006 Store in location 006 003 HLT Halt Computer 004 0053 First Operand 005 FFE9 Second Operand is Negative 006 0000 Store Sum Here

Table 6-3 Hexadecimal Add two Number Location Instruction 000 2004 001 1005 002 3006 003 7001 004 0053 005 FFE9 006 0000

Table 6-2 Binary to Add Two Numbers Location Instruction Code 0 0010 0000 0000 0100 1 0001 0000 0000 0101 10 0011 0000 0000 0110 11 0111 0000 0000 0001 100 0000 0000 0101 0011 101 1111 1111 1110 1001 110 0000 0000 0000 0000

Table 6-5 Assembly Language Program ORG 0 Origin is 0 LDA A Load operation A ADD B Add operation B STA C Store Location C HLT Halt Computer A, DEC 83 Decimal Operand B, DEC –23 Decimal Operand C, DEC 0 Store in Location C END End Of Program

Table 6-6 Fortran Program to ADD Two Number Integer A, B, C Data A, 83 B, -23 C = A+B End

Table 6-7 Definition Of Pseudoinstructions Symbol Information For Assembler ORG N N operation for hexadecimal operand listed line. END End of Program DEC N N converted to Binary HEX N Hexadecimal Converted to Binary

Instruction Field of Program CLA NON-MRI ADD OPR DIRECT ADDRESS MRI ADD PTR I INDIRECT ADDRESS MRI

Table 6-8 Assembly language program subtract Two number ORG 100 ORIGIN LOCATION IS 100 LDA SUB LOAD TO AC CMA COMPLEMENT AC INC INCREMENT AC ADD MIN ADD TO AC STA DIF STORE DIFFERENCE HLT HALT COMPUTER MIN, DEC 83 MINUEND SUB, DEC –23 SUMTRAHEND DIF, HEX 0 DIFFERENCE STORE HERE END END PROGRAM

Table 6-9 translated program of table 6-8 HEXADECIMAL LOCATION CINTENT SYMBOLIC PROGRAM ORG 100 100 2107 LDA SUB 101 7200 CMA 102 7020 INC 103 1106 ADD MIN 104 3108 STA DIF 105 7100 HLT 106 0053 MIN, DEC 83 107 FFE9 SUB, DEC -23 108 0000 DIF, HEX0 END

ADDRESS SYMBOL HEXADECIMAL MIN 106 SUB 107 DIF 108 Address symbol Table ADDRESS SYMBOL HEXADECIMAL MIN 106 SUB 107 DIF 108

Table 6-11 line of code: pl3, ld,sub1 Memory word symbol hex-code binary represent 1 PL 50 AC 0101 0000 0100 1100 2 3, 33 2C 0011 0011 0010 1100 3 L D 4C 44 0100 1100 0100 0100 4 A 41 20 0100 0001 0010 0000 5 SU 53 55 0101 0011 0101 0101 6 B 42 20 0100 0010 0010 0000 7 I CR 49 OD 0100 1001 0000 1100

Figure 6-1 First pass of assembler LC 0 Scan line code Set LC Yes Label ORG No No Yes End Yes Store symbol in Address symbol With Ac Go to second pass No Increment LC

MEMORY SYMBOL HEX-CODE Binary rep.. WORD ( LC ) Table 6-12 Address symbol MEMORY SYMBOL HEX-CODE Binary rep.. WORD ( LC ) 1 M I 4D 49 0100 1101 0100 1001 2 N , 4E 2C 0100 1110 0010 1100 3 (LC) 01 06 0000 0001 0000 0110 4 S U 53 55 0101 0011 0101 0101 5 B , 42 2C 0100 0010 0010 1100 6 (LC) 01 07 0001 0001 0000 0111 7 DI 44 49 0100 0100 0100 1001 8 F 46 2C 0100 0110 0010 1100 9 (LC) 01 08 0000 0001 0000 1000

Figure 6-2 Flowchart for second pass of assembler LC 0 DONE Scan next line of code Set LC yes yes Pseudo instruction ORG no END yes no DEC or HEX no yes MRI no Convert operand To binary and store In location Given by LC Get operation code and set bits 2-4 Valid Non-MRI instruction no Search address symbol Table for binary equivalent Of symbolic address And set bits 5-16 yes Store binary Equivalent of Instruction In loaction given By LC Error in line Of code yes no I Set first bit to 1 Set first Bit to 0 Assemble all parts and store In location give by LC Increment LC

Table 6-13 Program to Add 100 Number Line 1 2 3 4 5 6 7 Lop, 8 9 10 13 ADS, 14 PTR, 15 NBR, 16 CTR, 17 SUM, 118 119 Org 100 LDA ADS STA PTR LDA NBR STA CTR CLA ADD PTR1 ISZ PTR ISZ CTR BUN LOP HEX 150 HEX 0 DEC –100 DEC 23 END / Origin is HEX 100 / Load First Address Of Operand / Store in Pointer / Load Minus 100 / Store in Counter / Clear Ac / Add To Ac / Inc Pointer / Inc Counter / Loop Again / First Address Of Operand / Reserved for Pointer / Initialized Counter / Reserved For Counter / Sum is Stored Here / Last Operand / End Program

Figure 6-3 Flowchart For Multiplication Program X=0000 1111 Y=0000 1011 0000 1111 0001 1110 0000 0000 0111 1000 1010 0101 CTR - 8 P 0 P 0000 0000 0000 1111 0010 1101 1010 0101 E 0 AC Y cir EAC Y AC Cil EAC =0 =1 E X AC P P+X E 0 CTR CTR+1 AC X CTR #0 =0 Stop

Table 6-15 Add Two Double Precision LDA AL /Load a Low ADD BL /Add B low ,Carry In E STA CL /Store in C Low CLA /Clear Ac CIL /Carry into Ac ADD Ah /A high and carry ADD BH /Add B high STA CH /Store in C High HLT AL, ____ /Location Of Operand AH, _____ BL, _____ BH, ______ CL, _______ CH, _________

Table 6-16 Demonstrates the use of subroutines Location 100 101 102 103 104 105 107 X, 108 Y, 109 SH4 10A 10B 10C 10D 10E 10F 110 MSK, ORG 100 LDA X BSA SH4 STA X LDA Y BSA SH4 STA Y HLT HEX 1234 /Main Program /Load X /Branch to Subroutine /Store shifted Number /Load Y /Branch To Subroutine /Store Shifted Number /Shift Left 4 Times /Store return Address here /Cir Left Once /Cir Left Forth Times /Set Ac(13—16) To Zero Return To Main Program /Mask Operand HEX FFF0 CIL CIL CIL CIL AND MSK BUN SH4 HEX FFF0 END

Table 6-20 Input pack to characters IN2, ________ /Subroutine entry FST, SKI BUN FST INP /Input first character OUT BSA SH4 /Shift 4 times BSA SH4 /Sift 4 more times SCD, SKI BUN SCD INP /Input second Character BUN IN21 /Return

Table 6-21 Program Input Character in a Buffer LDA ADS /LOAD IN BUFFER STA PTR /INITIALIZE POINTER BSA IN2 /GO IN IN2 STA PTR 1 / STORE IN BUFFER ISZ PTR / INCREMENT POINTER BUN LOP /INPUT MORE CHRACTER HLT HEX 500 /FIRST ADRESS OF BUFFER HEX 0 /LOCATION FOR POINTER. LOP, ADS, PTR,

Table 6-22 Compare Two Words LDA WD1 /LOAD FIRST WORD CMA INC /FORM 2’S COMPLEMENT ADD WD2 /ADD SECOND WORD SZA /SKIP IF AC IS ZERO BUN UEQ /UNEQUAL ROUTINE BUN EQL /EQUAL ROUTINE _____ WD1, WD2,

Table 6-19 Input-Output One Character (a) Input a Character: CIF, SKI /CHECK INPUT FLAG BUN CIF /FLAG=0 INP /FLAG=1 OUT /PRINT CHARACTER STA CHR /STORE CHARACTER HLT CHR, ____ /STORE CHARACTER (b) Output one character: LDA CHR /LOAD INTO AC COF, SKO /CHECK OUTPUT FLAG BUN COF /FLAG=0 OUT /FLAG=1 CHR, HEX0057 /CHARACTER IS “W”

Table 6-23 program to service an Interrupt Location 0 ZERO, _______ /RETURN ADDRESS 1 BUN SRV /BRANCH ROUTINE 100 CLA /RUNING PROGRAM 101 ION /TURN ON FACILITY 102 LDA X 103 ADD Y /INTERRUPT HERE 104 STA Z /PROGRAM RETURN HERE . .. . .. /INTERRUPT ROUTINE S 200 SRV, STA SAC /STORE AC CIR /MOVE E INTO AC(1) STA SE /STORE OF E SKI /CHECK INPUT FLAG BUN NXT /FLAG IS OFF INP /FLAG IS ON OUT /PRINT FORM STA PT1 /STORE BUFFER ISZ PT1 /INC INPUT POINTER NXT, SKO /OUTPUT FLAG BUN EXT / FLAG IS OFF LDA PT2 1 /INC OUTPUT POINTER

Table 6-23 program to service an Interrupt ISZ PT1 /INC INPUT POINTER LDA SE /RESERVE VALUE CIL /SHIFT IT TO E LDA SAC /RESTORE AC ION ZR0 1 /RETURN TO PROGRAM _____ /AC IS STORE HERE ______ /E IS STORED HERE _______ / POINTER OF INPUT BUFFER _________ /OUTPUT BUFFER EXT, SAC, SE, PT1 PT2,