diff options
author | Kartik Agaram <vc@akkartik.com> | 2019-07-25 22:55:21 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2019-07-25 22:55:21 -0700 |
commit | 0c7f08cea081644ef1f79cda065c716f76b7db32 (patch) | |
tree | c65d01a3a7834d69fe7c0981750e3926af104bf7 | |
parent | 68ccf4d3245e78c869f25ffc5078f267eb22a9ee (diff) | |
download | mu-0c7f08cea081644ef1f79cda065c716f76b7db32.tar.gz |
5479
-rw-r--r-- | subx/001help.cc | 9 | ||||
-rw-r--r-- | subx/010---vm.cc | 12 | ||||
-rw-r--r-- | subx/011run.cc | 2 | ||||
-rw-r--r-- | subx/030---operands.cc | 6 | ||||
-rw-r--r-- | subx/opcodes | 12 |
5 files changed, 22 insertions, 19 deletions
diff --git a/subx/001help.cc b/subx/001help.cc index 79589cf8..7236ca50 100644 --- a/subx/001help.cc +++ b/subx/001help.cc @@ -73,16 +73,15 @@ void init_help() { " subx --help\n" "- Convert a textual SubX program into a standard ELF binary that you can\n" " run on your computer:\n" - " subx translate input1.subx intput2.subx ... -o <output ELF binary>\n" + " subx translate input1.subx input2.subx ... -o <output ELF binary>\n" "- Run a SubX binary using SubX itself (for better error messages):\n" " subx run <ELF binary>\n" "\n" "== Debugging aids\n" - "- Add '--trace' to any of these commands to print a trace to stderr\n" - " for debugging purposes.\n" + "- Add '--trace' to any of these commands to save a trace.\n" "- Add '--debug' to add information to traces. 'subx --debug translate' will\n" - " save various mappings to files that 'subx --debug --trace run'\n" - " can use to make traces more informative.\n" + " save metadata to disk that 'subx --debug --trace run' uses to make traces\n" + " more informative.\n" "\n" "Options starting with '--' must always come before any other arguments.\n" "\n" diff --git a/subx/010---vm.cc b/subx/010---vm.cc index 52b6b597..3d60ab5c 100644 --- a/subx/010---vm.cc +++ b/subx/010---vm.cc @@ -57,15 +57,15 @@ put_new(Help, "registers", "to spend some time with it.\n" "\n" "-- flag registers\n" - "Various instructions (particularly 'compare') modify one or more of three 1-bit 'flag'\n" - "registers, as a side-effect:\n" + "Various instructions (particularly 'compare') modify one or more of four 1-bit\n" + "'flag' registers, as a side-effect:\n" "- the sign flag (SF): usually set if an arithmetic result is negative, or\n" " reset if not.\n" "- the zero flag (ZF): usually set if a result is zero, or reset if not.\n" "- the carry flag (CF): usually set if an arithmetic result overflows by just one bit.\n" " Useful for operating on unsigned numbers.\n" - "- the overflow flag (OF): usually set if an arithmetic result overflows by more than one bit.\n" - " Useful for operating on signed numbers.\n" + "- the overflow flag (OF): usually set if an arithmetic result overflows by more\n" + " than one bit. Useful for operating on signed numbers.\n" "The flag bits are read by conditional jumps.\n" "\n" "For complete details on how different instructions update the flags, consult the IA-32\n" @@ -73,8 +73,8 @@ put_new(Help, "registers", "though of course you'll need to be careful to ignore instructions and flag registers\n" "that SubX doesn't support.\n" "\n" - "It isn't simple, but if this is the processor you have running on your computer,\n" - "might as well get good at it.\n" + "It isn't simple, but if this is the processor you have running on your computer.\n" + "Might as well get good at it.\n" ); :(before "End Globals") diff --git a/subx/011run.cc b/subx/011run.cc index 1730c790..194676d8 100644 --- a/subx/011run.cc +++ b/subx/011run.cc @@ -28,8 +28,6 @@ put_new(Help, "syntax", "at runtime, but can be handy when rewriting macros.\n" "\n" "Check out the examples in the examples/ directory.\n" - "Programming in machine code can be annoying, but let's see if we can make\n" - "it nice enough to be able to write a compiler in it.\n" ); :(before "End Help Contents") cerr << " syntax\n"; diff --git a/subx/030---operands.cc b/subx/030---operands.cc index 9f40e949..5203201e 100644 --- a/subx/030---operands.cc +++ b/subx/030---operands.cc @@ -84,8 +84,10 @@ void init_operand_type_help() { " - sib.pdf: volume 2, table 2-3, \"32-bit addressing with the SIB byte.\".\n" ); put(Help, "subop", - "Additional 3-bit operand for determining the instruction when the opcode is 81, 8f or ff.\n" - "Can't coexist with operand of type 'r32' in a single instruction, because the two use the same bits.\n" + "Additional 3-bit operand for determining the instruction when the opcode\n" + "is 81, 8f, d3, f7 or ff.\n" + "Can't coexist with operand of type 'r32' in a single instruction, because\n" + "the two use the same bits.\n" ); put(Help, "r32", "3-bit operand specifying a register operand used directly, without any further addressing modes.\n" diff --git a/subx/opcodes b/subx/opcodes index d8e38a43..bebf3052 100644 --- a/subx/opcodes +++ b/subx/opcodes @@ -89,12 +89,16 @@ Opcodes currently supported by SubX: f4: halt (hlt) f7: negate/multiply/divide rm32 (with EAX and EDX if necessary) depending on subop (neg/mul/idiv) ff: increment/decrement/jump/push/call rm32 based on subop (inc/dec/jmp/push/call) + 0f 82: jump disp32 bytes away if lesser (unsigned), if CF is set (jcc/jb/jnae) + 0f 83: jump disp32 bytes away if greater or equal (unsigned), if CF is unset (jcc/jae/jnb) 0f 84: jump disp32 bytes away if equal, if ZF is set (jcc/jz/je) 0f 85: jump disp32 bytes away if not equal, if ZF is not set (jcc/jnz/jne) - 0f 8c: jump disp32 bytes away if lesser, if SF != OF (jcc/jl/jnge) - 0f 8d: jump disp32 bytes away if greater or equal, if SF == OF (jcc/jge/jnl) - 0f 8e: jump disp32 bytes away if lesser or equal, if ZF is set or SF != OF (jcc/jle/jng) - 0f 8f: jump disp32 bytes away if greater, if ZF is unset and SF == OF (jcc/jg/jnle) + 0f 86: jump disp8 bytes away if lesser or equal (unsigned), if ZF is set or CF is set (jcc/jbe/jna) + 0f 87: jump disp32 bytes away if greater (unsigned), if ZF is unset and CF is unset (jcc/ja/jnbe) + 0f 8c: jump disp32 bytes away if lesser (signed), if SF != OF (jcc/jl/jnge) + 0f 8d: jump disp32 bytes away if greater or equal (signed), if SF == OF (jcc/jge/jnl) + 0f 8e: jump disp32 bytes away if lesser or equal (signed), if ZF is set or SF != OF (jcc/jle/jng) + 0f 8f: jump disp32 bytes away if greater (signed), if ZF is unset and SF == OF (jcc/jg/jnle) 0f af: multiply rm32 into r32 (imul) Run `subx help instructions` for details on words like 'r32' and 'disp8'. For complete details on these instructions, consult the IA-32 manual (volume 2). |