Presentation is loading. Please wait.

Presentation is loading. Please wait.

 Instructor: Rob Nash  Readings: Chap 7-9  Midterm next Monday! ◦ Review this Wednesday ◦ You will see code again…

Similar presentations


Presentation on theme: " Instructor: Rob Nash  Readings: Chap 7-9  Midterm next Monday! ◦ Review this Wednesday ◦ You will see code again…"— Presentation transcript:

1  Instructor: Rob Nash  Readings: Chap 7-9  Midterm next Monday! ◦ Review this Wednesday ◦ You will see code again…

2  Lets declare a message to display to the world org $600 *start of data HMSGDC.B'Hello!' EOMDC.B0 *eom end $400

3  A way to get the attention of the CPU in an asynronous manner without polling  Also referred to as Traps, we’ll be interested in the following ◦ Trap #3 *prints out what is pointed to by A3 ◦ Trap #9 *ends the program (convention)

4 ORG$400 MOVEA.L #HMSG, A3 TRAP #3 TRAP #9 ORG$600 *start of data HMSGDC.B'Hello!' DC.B0 *eom END$400

5 FTOC SUBI.W #32, D0 MULS#5, D0 DIVS#9, D0 RTS

6  See p.28, section 2.6

7  If register D3 contains 100030FF and register D4 contains 8E552900, what is the result of  MOVE.W D3, D4?  8E5530FF  MOVE.L D3, D4?  What if I wanted to move the upper half?

8  A word op, so the upper half of D4 remains constant. The lower half will be loaded as follows: 8E5530FF

9  What will A2 contain after the execution of MOVEA.L A5,A2

10  Note that, even though the address registers are 32 bits long, only the lower 24 are used to address memory in the 68K ◦ There are no external address lines for the upper 8 bits!  So, if A0 contains 00007F00, what happens when executing: ◦ MOVE.B (A0), D7  0x007F00 holds “0009”  D7 contains 1234FEDC

11  D7 contains 1234FE09

12  This implements a pop ◦ Use the value, then increment (pop off stack) ◦ The stack grows to lower addresses, shrinks to higher addrs

13  A5 : 0x00007F00  D2 : 0x4E4F2000  0x007EFF : 3C  0x007F00 : 09  0x007F01 : BA  MOVE.W (A5)+, D2

14  Use what A5 is pointing to, then decrement ◦ A5 thus looks up 7F00  Since a word operation, post decrement by 2 ◦ A5 is now 0x007F02

15  This implements a push ◦ Decrement our stack first to make space ◦ Then overwrite this new location with our data  Stacks shrink “downwards”, or to higher addresses

16  Relocatable code is critically important today, and compilers provide this type of code automatically  Contrast this to code with all absolute memory locations specified – how do we shuffle this around in memory?

17  A2: 0x007F00  D4: F3052BC9  //Mem  0x007EFF : 3C  0x007F00 : 09  0x007F01 : BA  MOVE.B –(A2),D4  MOVE.B D4, -(A2) *push

18  Answer:  Decrement A2 first, so 0x007EFF  Copy from that location into the lower byte of D4

19  MOVE.BD3, (A5)+  00 01 101 011 000 011 => 0x1AC3  MOVE.B 5 for A5 Mode (An)+ Mode Dn 3 (D3) Dest (ea) Source (ea)

20  Trap #3, Address in A3 of string  Trap #15 ◦ D0 holds the “task number”  2 is for user input, A1 points to this for you  0 is for terminal output ◦ A1 holds the memory addr of the start of string ◦ D1 holds the length of the str to print

21  What does this code look like in ASM?  adder( int x, int y) { ◦ int z; ◦ z = x + y;  }

22  *assuming D0 holds x, D1 holds y, D2 is z  adderAND.W #0, D2 ADD.W D0, D2 ADD.W D1, D2 RTS

23  We wanted to compare two lists of bytes?  A1 points to the first list  A2 points to the second list  Each list is 5 elements long  D0 holds 0 if different, 1 if identical.  For 2 reapers!!

24  What does the asm look like for the following?  branch( int a, int b) { ◦ if( a > b ) {  b = a ◦ } else {  a = b ◦ }  }

25  Write an ASM module that defines two (3x3) matrices and sums up the first row  Data section:

26  What does the following code look like in ASM? ◦ for(int a = 0; a < 10; a++ ) {  nop ◦ }

27  Implement the overriding feature of inheritance at the ASM level  Data Section holds a VTable ◦ A table of function pointers ◦ To override a function, we’ll need to update its table entry ◦ I’ll give you the table in A0 ◦ The offset of the function to override in D0 (in longs) ◦ The address of the new function in A1

28  What is a good HW problem for us to consider?


Download ppt " Instructor: Rob Nash  Readings: Chap 7-9  Midterm next Monday! ◦ Review this Wednesday ◦ You will see code again…"

Similar presentations


Ads by Google