Mercurial > sos > sos
annotate utility/fsGen.py @ 100:d8f21e4a75e3
Added a simple program that is just an infinite loop
The heap now starts at 8MB
I now try to set the context to the loaded program when it is called in the shell script
author | Jonathan Pevarnek <pevarnj@gmail.com> |
---|---|
date | Thu, 19 May 2011 09:40:10 -0400 |
parents | 2a0aa3efc228 |
children |
rev | line source |
---|---|
99
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
1 #!/usr/bin/env python |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
2 |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
3 import sys |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
4 import math |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
5 import random |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
6 |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
7 DEV_SIZE = 1024 |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
8 BLOCK_SIZE = 1024 |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
9 datafiles = sys.argv[1:] |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
10 blocks = {} |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
11 |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
12 SB_MAGIC = 0x42420374 |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
13 |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
14 def __word(i, l, s): |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
15 assert (i < (1<<s)) |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
16 ret = "" |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
17 for x in l: |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
18 ret = chr(i % 256) + ret |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
19 i /= 256 |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
20 return ret |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
21 |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
22 def hword(i): |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
23 return __word(i, (0,1), 16) |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
24 |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
25 def word(i): |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
26 return __word(i, (0,1,2,3), 32) |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
27 |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
28 def dword(i): |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
29 return __word(i, (0,1,2,3,4,5,6,7), 64) |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
30 |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
31 def tod(): |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
32 return 0 |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
33 |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
34 def pad_block(s=""): |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
35 assert (len(s) <= BLOCK_SIZE) |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
36 return s + ("\0" * (BLOCK_SIZE-len(s))) |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
37 |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
38 def use_block(x): |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
39 # update alloc map |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
40 blk = 2+(x/(BLOCK_SIZE*8)) |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
41 idx = (x/8)%BLOCK_SIZE |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
42 bit = x%8 |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
43 |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
44 d = blocks[blk] |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
45 a = d[idx] |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
46 b = chr(ord(a) | (0x80 >> bit)) |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
47 |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
48 blocks[blk] = d[0:idx] + b + d[(idx+1):BLOCK_SIZE] |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
49 |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
50 assert (a != b) |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
51 |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
52 lastb = 16 |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
53 def rand_block(): |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
54 while True: |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
55 # random |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
56 x = random.randint(0, DEV_SIZE-1) |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
57 |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
58 # or sequential |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
59 #global lastb |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
60 #x = lastb |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
61 #lastb += 1 |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
62 |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
63 if x in blocks.keys(): |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
64 continue |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
65 |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
66 blocks[x] = pad_block() |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
67 |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
68 use_block(x) |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
69 |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
70 return x |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
71 |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
72 def make_ipl_head(): |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
73 # allocation map |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
74 for x in range(2,2+int(math.ceil(DEV_SIZE/(BLOCK_SIZE*8.0)))): |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
75 blocks[x] = pad_block() |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
76 use_block(x) |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
77 |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
78 blocks[0] = pad_block() # ipl record |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
79 blocks[1] = pad_block() # sb record |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
80 |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
81 use_block(0) |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
82 use_block(1) |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
83 |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
84 def make_sb(rootinode): |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
85 blocks[1] = pad_block(word(SB_MAGIC) + word(rootinode) + word(DEV_SIZE)) |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
86 |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
87 def make_inode(l, blist): |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
88 i = word(l) + word(0) + dword(tod()) + dword(tod()) + hword(len(blist)) + hword(0) + word(0) |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
89 |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
90 for b in blist: |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
91 i += word(b) |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
92 |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
93 t = rand_block() |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
94 blocks[t] = pad_block(i) |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
95 return t |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
96 |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
97 make_ipl_head() |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
98 d = "" |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
99 for fn in datafiles: |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
100 x = file(fn).read() |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
101 fb = [] |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
102 l = len(x) |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
103 |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
104 while len(x) > 0: |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
105 if len(x) < BLOCK_SIZE: |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
106 y = pad_block(x) |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
107 x = "" |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
108 elif len(x) == BLOCK_SIZE: |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
109 y = x |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
110 x = "" |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
111 else: |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
112 y = x[0:BLOCK_SIZE] |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
113 x = x[BLOCK_SIZE:] |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
114 |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
115 t = rand_block() |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
116 fb.append(t) |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
117 blocks[t] = y |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
118 |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
119 i = make_inode(l, fb) |
100
d8f21e4a75e3
Added a simple program that is just an infinite loop
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
99
diff
changeset
|
120 foo, bar, fn = fn.rpartition('/') |
99
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
121 d += (fn + (" " * (28 - len(fn)))) + word(i) |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
122 |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
123 db = rand_block() |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
124 blocks[db] = pad_block(d) |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
125 ri = make_inode(len(d), [db,]) |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
126 make_sb(ri) |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
127 |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
128 #for k in range(0, DEV_SIZE): |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
129 # if k not in blocks: |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
130 # print k, "<empty>" |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
131 # else: |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
132 # assert (len(blocks[k]) == BLOCK_SIZE) |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
133 # print k, repr(blocks[k]) |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
134 for k in range(0, DEV_SIZE): |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
135 if k not in blocks: |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
136 sys.stdout.write(pad_block()) |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
137 else: |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
138 assert (len(blocks[k]) == BLOCK_SIZE) |
2a0aa3efc228
The shell script will now theroretically load the program into memory, will not run it.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
139 sys.stdout.write(blocks[k]) |
100
d8f21e4a75e3
Added a simple program that is just an infinite loop
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
99
diff
changeset
|
140 |
d8f21e4a75e3
Added a simple program that is just an infinite loop
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
99
diff
changeset
|
141 # vim: set noexpandtab: |