Program Design Examples 9206 Lecture 3 Instruction Set
- Slides: 20
Program Design Examples 9/20/6 Lecture 3 - Instruction Set - Al 1
Lecture Overview o Have seen the initial part of n n o Today n o 9/20/6 Top down design Modular design Parameter Passing Stack and Local Variables Structured Programming continued Example Lecture 3 - Instruction Set - Al 2
Assembler for HLL Expressions o HLL: IF (cond L) THEN Action_S n Assume data, result of evaluating condition L, to be tested in D 0. It has a value of either 1 (true) or 0 (false). TST. B D 0 test low byte DO BEQ. S EXIT action_S EXIT n 9/20/6 The BEQ. S is a short 8 -bit branch where the target address displacement is <= what can be specified by 8 -bits Lecture 3 - Instruction Set - Al 3
Assembler for HLL Expressions 2 o HLL: IF (cond L) THEN S 1 ELSE S 2 n n n ELSE n n 9/20/6 TST. B D 0 BEQ. S ELSE S 1_actions BRA. S EXIT S 2_actions … EXIT Lecture 3 - Instruction Set - Al 4
Assembler for HLL Expressions 3 o HLL: FOR I = N 1 TO N 2 DO S n n NEXT n n 9/20/6 MOVE. B #N 1, D 1 d 1 lp cntr S_actions ADDQ. B #1, D 1 inc lp cntr CMP. B #N 2+1, D 1 test BNE NEXT EXIT Lecture 3 - Instruction Set - Al 5
Assembler for HLL Expressions 4 o HLL: WHILE L DO S n REPEAT n n n n o 9/20/6 TST. B DO BEQ. S EXIT if 0 quit S_actions within actions will perform a compare that leaves the TRUE(1) or FALSE(0) in D 0 BRA REPEAT EXIT NOTE: B Lecture 3 - Instruction Set - Al 6
Assembler for HLL Expressions 5 o HLL: REPEAT S UNTIL L n NEXT n n n 9/20/6 S_actions TST. B D 0 BEQ NEXT EXIT Lecture 3 - Instruction Set - Al 7
Assembler for HLL Expressions 6 o HLL: FOR I=N DOWNTO -1 DO S o MOVE. W #n, D 1 NEXT S_actions DBRA D 1, NEXT o o o 9/20/6 Decrement D 1 and loop if not -1 Lecture 3 - Instruction Set - Al 8
Testability o o In the real world $$$ come into play Could test to degree that errors never occur Test to degree that is rational Structured code is more testable than alternatives n n 9/20/6 Modules are units to be tested Interaction of modules is tests Lecture 3 - Instruction Set - Al 9
Recoverabiltiy o o o 9/20/6 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. Lecture 3 - Instruction Set - Al 10
Pseudocode (PDL) o PDL is a way to write down an algorithm n n n 9/20/6 A compromise between HLL and assembler Facilitates the production of reliable code Much like modern HLLs Lecture 3 - Instruction Set - Al 11
Program Specs o o D 0 used for character input and output – low order byte of D 0 D 1 contains code of 0, 1, or 2 n n n o 9/20/6 0 – clear the buffer and reset pointers 1 – place character in D 0 into buffer 2 – remove character from buffer to D 0 Buffer starts at $01 0000 and is 1, 024 bytes Lecture 3 - Instruction Set - Al 12
Program Specs 2 o o 9/20/6 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 D 0 is set to indicate overflow Underflow action – D 0. B set to 0 – msb set No other register modified Lecture 3 - Instruction Set - Al 13
Circular Buffer concept 9/20/6 Lecture 3 - Instruction Set - Al 14
PDL o Level 1 n n n Module: Circular_buffer Save working registers Select one of: o o o n n 9/20/6 Initialize System Input a character Output a character Restore working registers End Circular_buffer Lecture 3 - Instruction Set - Al 15
PDL o Level 2 n n n 9/20/6 Module: Circular_buffer Save working registers IF [D 1]=0 THEN Initialize END IF IF [D 2]=1 THEN Input_char END IF IF [D 1]=2 THEN Output_char END IF End Circular_buffer Lecture 3 - Instruction Set - Al 16
PDL – level 2 continued o Initialize n Count=0 In_pointer : = Start Out_pointer : = Start End Initialize 9/20/6 Lecture 3 - Instruction Set - Al 17
PDL – level 2 cont. o Input_character n Store new character Deal with any overflow End Input_character Routine is still a level too high to encode 9/20/6 Lecture 3 - Instruction Set - Al 18
PDL – level 3 o Input_character n n 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+1 o o 9/20/6 ELSE BEGIN Set overflow flag Out_pointer : = Out_pointer + 1 Lecture 3 - Instruction Set - Al 19
cont o o o 9/20/6 IF Out_pointer>End Then Out_pointer: =Start END IF End Input_character This can then be coded in assembler or even HLL. Lecture 3 - Instruction Set - Al 20
- Total set awareness set consideration set
- Training set validation set test set
- Instruction set architecture
- Clr c instruction in 8051
- 01:640:244 lecture notes - lecture 15: plat, idah, farad
- Instruction de lecture et d'écriture
- Differentiated instruction vs individualized instruction
- Direct instruction vs indirect instruction
- Cbw 8086
- Lmc instruction set
- Boolean processor of 8051
- Computer sic
- Set adalah
- Risc instruction set example
- Marie computer architecture
- If else statement in assembly language
- Intel simd instructions
- 8088 instruction set
- Ror instruction in 8086
- Classify instruction set of 8086
- Ibm 360 machine structure