diff options
author | Kartik Agaram <vc@akkartik.com> | 2018-07-16 22:18:18 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2018-07-16 22:18:18 -0700 |
commit | 6602c82f9f35235b998132f0adc54c852aa4e025 (patch) | |
tree | 8fbb5a3532c7cd279838b15f9149f3d39afda487 /subx/020elf.cc | |
parent | a50a95d21505148035ec8f08af414d663e9dad7e (diff) | |
download | mu-6602c82f9f35235b998132f0adc54c852aa4e025.tar.gz |
4363 - subx: first program using the stack segment
We allocate space for a local variable, read() a character from stdin to it, and write() it out to stdout.
Diffstat (limited to 'subx/020elf.cc')
-rw-r--r-- | subx/020elf.cc | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/subx/020elf.cc b/subx/020elf.cc index 88de65fd..85bda201 100644 --- a/subx/020elf.cc +++ b/subx/020elf.cc @@ -4,6 +4,7 @@ :(before "End Main") assert(argc > 1); if (is_equal(argv[1], "run")) { + START_TRACING_UNTIL_END_OF_SCOPE; assert(argc > 2); reset(); cerr << std::hex; @@ -59,9 +60,9 @@ void load_elf_contents(uint8_t* elf_contents, size_t size) { for (size_t i = 0; i < e_phnum; ++i) load_segment_from_program_header(elf_contents, size, e_phoff + i*e_phentsize, e_ehsize); - // TODO: need to set up real stack somewhere - - Reg[ESP].u = Reg[EBP].u = End_of_program; + // initialize code and stack + Reg[ESP].u = AFTER_STACK; + Reg[EBP].u = 0; EIP = e_entry; } |