program Ballistic /****************************************************************************** * Description: Simulates the height of a projectile, starting at a height of * mem[0C] with an initial velocity of mem[0B], until the * projectile no longer has a positive height. The acceleration * due to gravity is given as mem[0A]. * Input: a0, v0, and y0 in mem[0A], mem[0B], and mem[0C], respectively * Output: A plot of y over time starting at mem[20] ******************************************************************************/ 0A: FFF6 constant 0xFFF6 a0 = -10; // m/s^2 0B: 0012 constant 0x0012 v0 = 18; // m/s 0C: 0015 constant 0x0015 y0 = 21; // m 10: 7101 R[1] <- 0001 // We use R[1] as the constant 1 11: 7A20 R[A] <- 0020 yPlot = allocateArray(); 12: 7300 R[3] <- 0000 t = 0; 13: 820A R[2] <- M[0A] a = a0; // // A good estimate of delta is f'(.5) // // which is approximately v0 + a/2 14: 840B R[4] <- M[0B] delta = v0; 15: 6F21 R[F] <- R[2] >> R[1] temp = a >> 1; // that's a/2 16: 144F R[4] <- R[4] + R[F] delta += temp; 17: 850C R[5] <- M[0C] y = y0 18: B50A M[R[A]] <- R[5] yPlot[0] = y0 19: 1554 R[5] <- R[5] + R[4] do { y += delta 1A: 1442 R[4] <- R[4] + R[2] delta += a; 1B: 1331 R[3] <- R[3] + R[1] t++; 1C: 17A3 R[7] <- R[A] + R[3] ptr = &(yPlot[t]); 1D: B507 M[R[7]] <- R[5] *ptr = f(i); 1E: D519 if (R[5] > 0) goto 19 } while (y > 0); 1F: 0000 halt