1 / 2

Original situation

Original situation. Memory:{ n,i } n(VA1376) is used to store the “n” in test1 and test2 i (VA300) is used to store the code{+1,-1} Register:{R,A1,A2,B1,B2} Test1 and Test2 don’t share registers Therefore the result of test1 and test2 will be: Print integer:9

cianna
Download Presentation

Original situation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Original situation • Memory:{n,i} • n(VA1376) is used to store the “n” in test1 and test2 • i(VA300) is used to store the code{+1,-1} • Register:{R,A1,A2,B1,B2} • Test1 and Test2 don’t share registers • Therefore the result of test1 and test2 will be: • Print integer:9 • n=9, i=-1 A1 load n=9, B1 load i=-1 R=A1+B1=8n=8, i=-1 • … • n=7, i=-1 A1 load n=7, B1 load i=-1switch to test2n=20, i=1 • Note that B1 hasn’t been freed • Print integer:20 • n=20,i=1 A2 load n=20, B2 load i=1 R=A2+B2=21n=21, i=1 • … • n=23,i=1 A2 load n=23, B2 load i=1 R=A2+B2=23n=24, i=1 • Print integer:24 • switch to test1  R=A1+B1=6n=6, i=1 • this step is still correct because memory with wrong value hasn’t beet read • Print integer:6 • n=6,i=1 A1 load n=6, B1 load i=1 R=A1+B1=7n=7, i=1 • Print integer:7 • …

  2. After we fix the memory mapping • Memory:{n1,i1,n2,i2} • Register:{R,A1,A2,B1,B2} • Test1 and Test2 don’t share registers • Therefore the result of test1 and test2 will be: • Print integer:9 • n1=9, i1=-1 A1 load n1=9, B1 load i=-1 R=A1+B1=8n1=8, i1=-1 • … • n1=7, i1=-1 A1 load n1=7, B1 load i1=-1switch to test2n2=20, i2=1 • Note that B1 hasn’t been freed • Print integer:20 • n2=20,i2=1 A2 load n2=20, B2 load i=1 R=A2+B2=21n2=21, i2=1 • … • n=23,i=1 A2 load n=23, B2 load i=1 R=A2+B2=23n2=24, i2=1 • Print integer:24 • switch to test1  R=A1+B1=6n1=6, i1=-1 • Print integer:6 • n1=6,i1=-1 A1 load n1=6, B1 load i1=-1 R=A1+B1=5n1=5, i1=-1(leave for loop) • …

More Related