Assembler Instruction Set for High-Level Language Expressions: Lecture 3, Slides of Microcomputers

Instruction set examples for various high-level language constructs such as if, for, and while using assembler. It covers topics like testing, recoverability, and pseudocode.

Typology: Slides

2012/2013

Uploaded on 05/08/2013

anandini
anandini 🇮🇳

4.7

(9)

119 documents

1 / 20

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Program Design Examples
9/20/6 Lecture 3 - Instruction Set - Al 1
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14

Partial preview of the text

Download Assembler Instruction Set for High-Level Language Expressions: Lecture 3 and more Slides Microcomputers in PDF only on Docsity!

Program Design Examples

9/20/6 Lecture 3 - Instruction Set - Al 1

Lecture Overview

  • Have seen the initial part of
    • Top down design
    • Modular design
    • Parameter Passing
    • Stack and Local Variables
  • Today
    • Structured Programming continued
  • Example 9/20/6 Lecture 3 - Instruction Set - Al 2

Assembler for HLL Expressions 2

  • HLL: IF (cond L) THEN S1 ELSE S
    • TST.B D
    • BEQ.S ELSE
    • S1_actions
    • BRA.S EXIT
    • ELSE S2_actions
    • EXIT 9/20/6 Lecture 3 - Instruction Set - Al 4

Assembler for HLL Expressions 3

  • HLL: FOR I = N1 TO N2 DO S
    • MOVE.B #N1,D1 d1 lp cntr
    • NEXT S_actions
    • ADDQ.B #1,D1 inc lp cntr
    • CMP.B #N2+1,D1 test
    • BNE NEXT
    • EXIT 9/20/6 Lecture 3 - Instruction Set - Al 5

Assembler for HLL Expressions 5

  • HLL: REPEAT S UNTIL L
    • NEXT S_actions
    • TST.B D
    • BEQ NEXT
    • EXIT 9/20/6 Lecture 3 - Instruction Set - Al 7

Assembler for HLL Expressions 6

  • HLL: FOR I=N DOWNTO -1 DO S
  • MOVE.W #n,D
  • NEXT S_actions
  • DBRA D1,NEXT
    • Decrement D1 and loop if not - 9/20/6 Lecture 3 - Instruction Set - Al 8

Recoverabiltiy

  • Also call exception handling
  • What does the system do with erroneous data
  • What does system do in response to certain

classes or errors.

  • Decision on what action to take when these

conditions occur

  • A poorly designed plan may be far worse than

no plan at all.

9/20/6 Lecture 3 - Instruction Set - Al 10

Pseudocode (PDL)

  • PDL is a way to write down an algorithm
    • A compromise between HLL and assembler
    • Facilitates the production of reliable code
    • Much like modern HLLs 9/20/6 Lecture 3 - Instruction Set - Al 11

Program Specs 2

  • Scratch storage may be placed after the end of

the buffer – up to 32 bytes

  • When buffer is full oldest data is overwritten –

bit 31 of D0 is set to indicate overflow

  • Underflow action – D0.B set to 0 – msb set
  • No other register modified 9/20/6 Lecture 3 - Instruction Set - Al 13

Circular Buffer concept

9/20/6 Lecture 3 - Instruction Set - Al 14

PDL

  • Level 2
    • Module: Circular_buffer
    • Save working registers
    • IF [D1]=0 THEN Initialize END IF
    • IF [D2]=1 THEN Input_char END IF
    • IF [D1]=2 THEN Output_char END IF
    • End Circular_buffer 9/20/6 Lecture 3 - Instruction Set - Al 16

PDL – level 2 continued

  • Initialize
    • Count= In_pointer := Start Out_pointer := Start End Initialize 9/20/6 Lecture 3 - Instruction Set - Al 17

PDL – level 3

  • Input_character
    • Store new character at in_pointer
    • In_pointer := In_pointer + 1
    • If In_pointer>End THEN In_pointer:=Start endif
    • If Count < Max THEN Count:=Count+
      • ELSE
      • BEGIN
      • Set overflow flag
      • Out_pointer := Out_pointer + 1 9/20/6 Lecture 3 - Instruction Set - Al 19

cont

  • IF Out_pointer>End Then Out_pointer:=Start
  • END IF
  • END
  • END IF
  • End Input_character
  • This can then be coded in assembler or even

HLL.

9/20/6 Lecture 3 - Instruction Set - Al 20