Commit Graph

7 Commits

Author SHA1 Message Date
Kartik Agaram dd9ba09a7c 4888
We only can't use rm32=5 when mod=0. Totally fine when it's mod=1.
2018-12-29 13:36:06 -08:00
Kartik Agaram bccaa72227 4661
Make segment management a little more consistent between initial segments
and add-on segments (using `mmap`).
2018-10-04 23:23:48 -07:00
Kartik K. Agaram c5d9a32fe6 4516
More calling convention tweaks.

Use EBP to get consistently at parameters and locals.
Always put the first function argument closest to EBP.
2018-09-24 22:55:37 -07:00
Kartik Agaram e7d9351f52 4585 2018-09-21 23:34:12 -07:00
Kartik Agaram d47f3a8278 4584 - discrepancy between SubX and native x86
One of the more painful things I had to debug with machine code. Tricks
I used can be seen in ex10.subx:
- printing argv[1] in various places
- printing a single 'X' in various places to count how many times we get
  to different instructions
- exiting with the current value of EAX in various places

I repeatedly went down the wrong trail in several ways:
- forgetting that the problem lay in native runs, and accidentally switching
  to subx runs during debugging.
- forgetting to pass commandline args, because ex10 doesn't check its argv
- writing the wrong comment for an instruction, and then miscalculating
  the set of registers that need to be saved.
- forgetting that syscalls clobber EAX.

Debugging native runs is hard, because you have to write non-trivial code
to instrument the binary, and instrumentation can itself be buggy.

When we finally tracked it down, I recognized the problem immediately.
I'd meant to confirm the behavior of opcode 8a against bare metal, and
then forgot.
In any case, opcode 8a was inconsistent with 88. Sloppy.
2018-09-21 22:25:00 -07:00
Kartik Agaram c18634ac55 4582
subx/examples/ex10 doesn't currently run natively. Grr..
2018-09-21 17:06:15 -07:00
Kartik Agaram ddeed58f85 4579
New example program: ascii null-terminated string comparison

I'd hoped this would be a stepping stone to supporting general ascii comparison,
but we're planning to use size-prefixed rather than null-terminated arrays
everywhere. The only exception is commandline arguments, which will remain
null-terminated to interoperate with Linux.

So I'm going to need separate functions for "compare with argv" and for
general string comparison.
2018-09-21 16:38:35 -07:00