about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--subx/012elf.cc22
-rw-r--r--subx/028translate.cc2
-rw-r--r--subx/034compute_segment_address.cc34
-rw-r--r--subx/035labels.cc6
-rw-r--r--subx/036global_variables.cc2
-rwxr-xr-xsubx/apps/crenshaw2-1bin1905 -> 1905 bytes
-rwxr-xr-xsubx/apps/factorialbin1903 -> 1903 bytes
-rwxr-xr-xsubx/examples/ex1bin96 -> 96 bytes
-rwxr-xr-xsubx/examples/ex10bin165 -> 165 bytes
-rwxr-xr-xsubx/examples/ex11bin1125 -> 1125 bytes
-rwxr-xr-xsubx/examples/ex12bin167 -> 167 bytes
-rwxr-xr-xsubx/examples/ex2bin97 -> 97 bytes
-rwxr-xr-xsubx/examples/ex3bin114 -> 114 bytes
-rwxr-xr-xsubx/examples/ex4bin171 -> 171 bytes
-rwxr-xr-xsubx/examples/ex5bin139 -> 139 bytes
-rwxr-xr-xsubx/examples/ex6bin165 -> 165 bytes
-rwxr-xr-xsubx/examples/ex7bin313 -> 313 bytes
-rwxr-xr-xsubx/examples/ex8bin139 -> 139 bytes
-rwxr-xr-xsubx/examples/ex9bin129 -> 129 bytes
19 files changed, 32 insertions, 34 deletions
diff --git a/subx/012elf.cc b/subx/012elf.cc
index 85eb406a..2e10246e 100644
--- a/subx/012elf.cc
+++ b/subx/012elf.cc
@@ -80,7 +80,7 @@ void load_elf_contents(uint8_t* elf_contents, size_t size, int argc, char* argv[
       assert(overlap.find(argv_data) == overlap.end());  // don't bother comparing ARGV and STACK
       write_mem_u8(argv_data, argv[i][j]);
       argv_data += sizeof(char);
-      assert(argv_data < ARGV_DATA_SEGMENT + SEGMENT_SIZE);
+      assert(argv_data < ARGV_DATA_SEGMENT + INITIAL_SEGMENT_SIZE);
     }
   }
   push(argc-/*skip 'subx_bin' and 'run'*/2);
@@ -111,7 +111,7 @@ void load_segment_from_program_header(uint8_t* elf_contents, int segment_index,
 
   if (p_offset + p_filesz > size)
     raise << "Invalid binary; segment at offset " << offset << " is too large: wants to end at " << p_offset+p_filesz << " but the file ends at " << size << '\n' << die();
-  if (p_memsz > INITIAL_SEGMENT_SIZE) {
+  if (p_memsz >= INITIAL_SEGMENT_SIZE) {
     raise << "Code segment too small for SubX; for now please manually increase INITIAL_SEGMENT_SIZE.\n" << end();
     return;
   }
@@ -129,16 +129,14 @@ void load_segment_from_program_header(uint8_t* elf_contents, int segment_index,
 
 :(before "End Includes")
 // Very primitive/fixed/insecure ELF segments for now.
-//   code: 0x08048000 -> 0x08048fff
-//   data/heap: 0x08050000 -> 0x08050fff
-//   stack: 0x08060fff -> 0x08060000 (downward)
-const int SEGMENT_SIZE = 0x1000;
-const int CODE_START = 0x08048000;
-const int DATA_SEGMENT = 0x08050000;
-const int HEAP_SEGMENT = DATA_SEGMENT;
-const int STACK_SEGMENT = 0x08060000;
-const int AFTER_STACK = 0x08060ffc;  // forget final word because of the off-by-one with INITIAL_SEGMENT_SIZE;
-const int ARGV_DATA_SEGMENT = 0x08070000;
+//   code: 0x09000000 -> 0x09ffffff
+//   data/heap: 0x0a000000 -> 0x0affffff
+//   stack: 0x0b000ffc -> 0x0b000000 (downward)
+const int CODE_SEGMENT = 0x09000000;
+const int DATA_SEGMENT = 0x0a000000;
+const int STACK_SEGMENT = 0x0b000000;
+const int AFTER_STACK = 0x0b000ffc;  // forget final word because of the off-by-one with INITIAL_SEGMENT_SIZE;
+const int ARGV_DATA_SEGMENT = 0x0c000000;
 :(code)
 inline uint32_t u32_in(uint8_t* p) {
   return p[0] | p[1] << 8 | p[2] << 16 | p[3] << 24;
diff --git a/subx/028translate.cc b/subx/028translate.cc
index 7330fa74..38f8a223 100644
--- a/subx/028translate.cc
+++ b/subx/028translate.cc
@@ -137,7 +137,7 @@ void write_elf_header(ostream& out, const program& p) {
     emit(p_start);
     // p_filesz
     uint32_t size = num_words(p.segments.at(i));
-    assert(p_offset + size < SEGMENT_SIZE);
+    assert(p_offset + size < INITIAL_SEGMENT_SIZE);
     emit(size);
     // p_memsz
     emit(size);
diff --git a/subx/034compute_segment_address.cc b/subx/034compute_segment_address.cc
index 587f25b4..28aab137 100644
--- a/subx/034compute_segment_address.cc
+++ b/subx/034compute_segment_address.cc
@@ -6,11 +6,11 @@
 == code
 05/add 0x0d0c0b0a/imm32  # add 0x0d0c0b0a to EAX
 # code starts at 0x08048000 + p_offset, which is 0x54 for a single-segment binary
-+load: 0x08048054 -> 05
-+load: 0x08048055 -> 0a
-+load: 0x08048056 -> 0b
-+load: 0x08048057 -> 0c
-+load: 0x08048058 -> 0d
++load: 0x09000054 -> 05
++load: 0x09000055 -> 0a
++load: 0x09000056 -> 0b
++load: 0x09000057 -> 0c
++load: 0x09000058 -> 0d
 +run: add imm32 0x0d0c0b0a to reg EAX
 +run: storing 0x0d0c0b0a
 
@@ -70,16 +70,16 @@ if (Currently_parsing_named_segment) {
 2d/subtract 0xddccbbaa/imm32  # subtract 0xddccbbaa from EAX
 +parse: new segment 'code'
 +parse: prepending to segment 'code'
-+load: 0x08048054 -> 2d
-+load: 0x08048055 -> aa
-+load: 0x08048056 -> bb
-+load: 0x08048057 -> cc
-+load: 0x08048058 -> dd
-+load: 0x08048059 -> 05
-+load: 0x0804805a -> 0a
-+load: 0x0804805b -> 0b
-+load: 0x0804805c -> 0c
-+load: 0x0804805d -> 0d
++load: 0x09000054 -> 2d
++load: 0x09000055 -> aa
++load: 0x09000056 -> bb
++load: 0x09000057 -> cc
++load: 0x09000058 -> dd
++load: 0x09000059 -> 05
++load: 0x0900005a -> 0a
++load: 0x0900005b -> 0b
++load: 0x0900005c -> 0c
++load: 0x0900005d -> 0d
 
 //: compute segment address
 
@@ -93,11 +93,11 @@ void compute_segment_starts(program& p) {
   for (size_t i = 0;  i < p.segments.size();  ++i) {
     segment& curr = p.segments.at(i);
     if (curr.start == 0) {
-      curr.start = CODE_START + i*SEGMENT_SIZE + p_offset;
+      curr.start = CODE_SEGMENT + i*SPACE_FOR_SEGMENT + p_offset;
       trace(99, "transform") << "segment " << i << " begins at address 0x" << HEXWORD << curr.start << end();
     }
     p_offset += size_of(curr);
-    assert(p_offset < SEGMENT_SIZE);  // for now we get less and less available space in each successive segment
+    assert(p_offset < INITIAL_SEGMENT_SIZE);  // for now we get less and less available space in each successive segment
   }
 }
 
diff --git a/subx/035labels.cc b/subx/035labels.cc
index c2965b2c..6461f88e 100644
--- a/subx/035labels.cc
+++ b/subx/035labels.cc
@@ -263,13 +263,13 @@ xz:
 //: ignore them.
 
 :(scenario segment_size_ignores_labels)
-== code  # 0x08048074
+== code  # 0x09000074
 05/add 0x0d0c0b0a/imm32  # 5 bytes
 foo:                     # 0 bytes
-== data  # 0x08049079
+== data  # 0x0a000079
 bar:
 00
-+transform: segment 1 begins at address 0x08049079
++transform: segment 1 begins at address 0x0a000079
 
 :(before "End num_bytes(curr) Special-cases")
 else if (is_label(curr))
diff --git a/subx/036global_variables.cc b/subx/036global_variables.cc
index e34c5b73..b29207bf 100644
--- a/subx/036global_variables.cc
+++ b/subx/036global_variables.cc
@@ -12,7 +12,7 @@ b9/copy x/imm32  # copy to ECX
 == data
 x:
 00 00 00 00
-+transform: global variable 'x' is at address 0x08049079
++transform: global variable 'x' is at address 0x0a000079
 
 :(before "End Level-2 Transforms")
 Transform.push_back(rewrite_global_variables);
diff --git a/subx/apps/crenshaw2-1 b/subx/apps/crenshaw2-1
index 5468a4cb..7ea3fe58 100755
--- a/subx/apps/crenshaw2-1
+++ b/subx/apps/crenshaw2-1
Binary files differdiff --git a/subx/apps/factorial b/subx/apps/factorial
index cad39e27..b15f8fc7 100755
--- a/subx/apps/factorial
+++ b/subx/apps/factorial
Binary files differdiff --git a/subx/examples/ex1 b/subx/examples/ex1
index f3c9730d..1c983c03 100755
--- a/subx/examples/ex1
+++ b/subx/examples/ex1
Binary files differdiff --git a/subx/examples/ex10 b/subx/examples/ex10
index 59cbc497..e6d8b3c4 100755
--- a/subx/examples/ex10
+++ b/subx/examples/ex10
Binary files differdiff --git a/subx/examples/ex11 b/subx/examples/ex11
index 78b7a6ae..cf0d0c85 100755
--- a/subx/examples/ex11
+++ b/subx/examples/ex11
Binary files differdiff --git a/subx/examples/ex12 b/subx/examples/ex12
index 236afe98..c13a86ed 100755
--- a/subx/examples/ex12
+++ b/subx/examples/ex12
Binary files differdiff --git a/subx/examples/ex2 b/subx/examples/ex2
index 24e81d3f..f7ddb783 100755
--- a/subx/examples/ex2
+++ b/subx/examples/ex2
Binary files differdiff --git a/subx/examples/ex3 b/subx/examples/ex3
index 5f8160d6..884da188 100755
--- a/subx/examples/ex3
+++ b/subx/examples/ex3
Binary files differdiff --git a/subx/examples/ex4 b/subx/examples/ex4
index 7721c94b..477dab46 100755
--- a/subx/examples/ex4
+++ b/subx/examples/ex4
Binary files differdiff --git a/subx/examples/ex5 b/subx/examples/ex5
index 906846db..090e1f60 100755
--- a/subx/examples/ex5
+++ b/subx/examples/ex5
Binary files differdiff --git a/subx/examples/ex6 b/subx/examples/ex6
index 10e38936..aa84591c 100755
--- a/subx/examples/ex6
+++ b/subx/examples/ex6
Binary files differdiff --git a/subx/examples/ex7 b/subx/examples/ex7
index d756271e..28c5bda9 100755
--- a/subx/examples/ex7
+++ b/subx/examples/ex7
Binary files differdiff --git a/subx/examples/ex8 b/subx/examples/ex8
index d447f676..dda61510 100755
--- a/subx/examples/ex8
+++ b/subx/examples/ex8
Binary files differdiff --git a/subx/examples/ex9 b/subx/examples/ex9
index 144cec89..dc9c0e3c 100755
--- a/subx/examples/ex9
+++ b/subx/examples/ex9
Binary files differ