summary refs log tree commit diff stats
path: root/doc/ranger.1
blob: 5b9d9df82e0797dd895e32e9c6ab7c1472f2b10a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
.TH RANGER 1 ranger-1.4.3
.SH NAME
ranger - visual file manager
.\"-----------------------------------------
.SH SYNOPSIS
.B ranger
.R [OPTIONS] [FILE]
.\"-----------------------------------------
.SH DESCRIPTION
Ranger is a file manager with an ncurses frontend written in Python.
.P
It is designed to give you a broader overview of the file system by displaying
previews and backviews, dividing the screen into several columns.
The keybindings are similar to those of other console programs like
.BR vim ", " mutt " or " ncmpcpp
so the usage will be intuitive and efficient.
.\"-----------------------------------------
.SH OPTIONS
.TP
--version
Print the version and exit.
.TP
-h, --help
Print a list of options and exit.
.TP
-d, --debug
Activate the debug mode:  Whenever an error occurs, ranger will exit and
print a full backtrace.  The default behaviour is to merely print the
name of the exception in the statusbar/log and to try to keep running.
.TP
-c, --clean
Activate the clean mode:  Ranger will not access or create any configuration
files nor will it leave any traces on your system.  This is useful when
your configuration is broken, when you want to avoid clutter, etc.
.TP
--copy-config=\fIwhich\fR
Create copies of the default configuration files in your local configuration
directory.  Existing ones will not be overwritten.  Possible values:
all, apps, commands, keys, options, scope.
.TP
--fail-unless-cd
Return the exit code 1 if ranger is used to run a file, for example with
`ranger --fail-unless-cd filename`.  This can be useful for scripts.
.TP
-r \fIdir\fR, --confdir=\fIdir\fR
Define a different configuration directory.  The default is
$XDG_CONFIG_HOME/ranger (which defaults to ~/.config/ranger)
.TP
-m \fIn\fR, --mode=\fIn\fR
When a filename is supplied, make it run in mode \fIn\fR. Check the
documentation for more information on modes.
.TP
-f \fIflags\fR, --flags=\fIflags\fR
When a filename is supplied, make it run with the flags \fIflags\fR. Check the
documentation for more information on flags.
.\"-----------------------------------------
.SH USAGE
.\"-----------------------------------------
.SS General Keybindings
Many keybindings take an additional numeric argument.  Type \fI5j\fR to move
down 5 lines, \fI10<Space>\fR to mark 10 files or \fI3?\fR to read the
third chapter of the documentation.
.TP
h, j, k, l
Move left, down, up, right
.TP
^D or J, ^U or K
Move a half page down, up
.TP
H, L
Move back and forward in the history
.TP
gg
Move to the top
.TP
G
Move to the bottom
.TP
^R
Reload everything
.TP
^L
Redraw the screen
.TP
S
Open a shell in the current directory
.TP
yy
Yank the selection to the "copy" buffer and mark them as to be copied
.TP
dd
Cut the selection to the "copy" buffer and mark them as to be moved
.TP
pp
Paste the files from the "copy" buffer here (by moving or copying, depending
on how they are marked.) By default, this will not overwrite existing files.
To overwrite them, use \fBpo\fR.
.TP
m\fIX\fR
Create a bookmark with the name \fIX\fR
.TP
`\fIX\fR
Move to the bookmark with the name \fIX\fR
.TP
n, N
Find the next file, the previous file.  You can define what to look for
by typing c\fIX\fR.  If nothing is specified, pressing n will get you to
the newest file in the directory.
.TP
o\fIX\fR
Change the sort method (like in mutt)
.TP
z\fIX\fR
Change settings
.TP
f
Quickly navigate by entering a part of the filename
.TP
Space
Mark a file
.TP
v, V
Toggle the mark-status of all files, unmark all files
.TP
/
Open the search console
.TP
:
Open the command console
.TP
?
Opens the help screen with more keybindings and documentation
.\"-----------------------------------------
.SS Keybindings for using Tabs
Tabs are used to work in different directories in the same Ranger instance.
.TP
g\fIN\fR
Open a tab. N has to be a number from 0 to 9. If the tab doesn't exist yet,
it will be created.
.TP
gn, ^N
Create a new tab.
.TP
gt, gT
Go to the next or previous tab.  You can also use TAB and SHIFT+TAB.
.TP
gc, ^W
Close the current tab.  The last tab cannot be closed.
.P
.\"-----------------------------------------
.SS Mouse Usage
.TP
Left Mouse Button
Click on something and you'll move there.
To run a file, "enter" it, like a directory, by clicking on the preview.
.TP
Right Mouse Button
Enter a directory
.TP
Scroll Wheel
Scroll
.\"-----------------------------------------
.SS Commands
.TP
:delete
Destroy all files in the selection with a roundhouse kick.  Ranger will
ask for a confirmation if you attempt to delete multiple (marked) files or
non-empty directories.
.TP
:rename \fInewname\fR
Rename the current file.  Also try the keybinding A for appending something
to a file name.
.TP
:quit
Quit ranger.  The current directory will be bookmarked as ' so you can
re-enter it by typing `` or '' the next time you start ranger.
.\"-----------------------------------------
.SH TIPS
.SS
Change the directory after exit
A script like this in your bashrc would make you change the directory
of your parent shell after exiting ranger:
.nf

ranger() {
    command ranger --fail-unless-cd $@ &&
    cd "$(grep \\^\\' ~/.config/ranger/bookmarks | cut -b3-)"
}
.\"-----------------------------------------
.SH CONFIGURATION
The files in
.B ranger/defaults/
can be copied into your configuration directory (by default, this is
~/.config/ranger) and customized according to your wishes.
Most files don't have to be copied completely though: Just define those
settings you want to add or change and they will override the defauls.
Colorschemes can be placed in ~/.config/ranger/colorschemes.
.P
All configuration is done in Python.
Each configuration file should contain sufficient documentation.
.\"-----------------------------------------
.SH COPYRIGHT
Copyright \(co
2009, 2010
Roman Zimbelmann
.P
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

There is NO warranty;
not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
.\"-----------------------------------------
.SH SEE ALSO
The project page:
.RB < http://savannah.nongnu.org/projects/ranger >
.P
The mailing list:
.RB < http://savannah.nongnu.org/mail/?group=ranger >
.\"-----------------------------------------
.SH BUGS
Please report them here and include as much relevant information
as possible:
.P
.RB < http://savannah.nongnu.org/bugs/?group=ranger >
s 3 bits 3 bits 2 bits 2 bits 0/1/2/4 bytes 0/1/2/4 bytes cd # int ?? +error: 'cd' (software interrupt): missing imm8 operand :(before "Pack Operands(segment code)") check_operands(code); if (trace_contains_errors()) return; :(code) void check_operands(const segment& code) { trace(99, "transform") << "-- check operands" << end(); for (int i = 0; i < SIZE(code.lines); ++i) { check_operands(code.lines.at(i)); if (trace_contains_errors()) return; // stop at the first mal-formed instruction } } void check_operands(const line& inst) { word op = preprocess_op(inst.words.at(0)); if (op.data == "0f") { check_operands_0f(inst); return; } if (op.data == "f3") { check_operands_f3(inst); return; } check_operands(inst, op); } word preprocess_op(word/*copy*/ op) { op.data = tolower(op.data.c_str()); // opcodes can't be negative if (starts_with(op.data, "0x")) op.data = op.data.substr(2); if (SIZE(op.data) == 1) op.data = string("0")+op.data; return op; } void test_preprocess_op() { word w1; w1.data = "0xf"; word w2; w2.data = "0f"; CHECK_EQ(preprocess_op(w1).data, preprocess_op(w2).data); } //: To check the operands for an opcode, we'll track the permitted operands //: for each supported opcode in a bitvector. That way we can often compute the //: bitvector for each instruction's operands and compare it with the expected. :(before "End Types") enum operand_type { // start from the least significant bit MODRM, // more complex, may also involve disp8 or disp32 SUBOP, DISP8, DISP16, DISP32, IMM8, IMM32, NUM_OPERAND_TYPES }; :(before "End Globals") vector<string> Operand_type_name; map<string, operand_type> Operand_type; :(before "End One-time Setup") init_op_types(); :(code) void init_op_types() { assert(NUM_OPERAND_TYPES <= /*bits in a uint8_t*/8); Operand_type_name.resize(NUM_OPERAND_TYPES); #define DEF(type) Operand_type_name.at(type) = tolower(#type), put(Operand_type, tolower(#type), type); DEF(MODRM); DEF(SUBOP); DEF(DISP8); DEF(DISP16); DEF(DISP32); DEF(IMM8); DEF(IMM32); #undef DEF } :(before "End Globals") map</*op*/string, /*bitvector*/uint8_t> Permitted_operands; const uint8_t INVALID_OPERANDS = 0xff; // no instruction uses all the operand types :(before "End One-time Setup") init_permitted_operands(); :(code) void init_permitted_operands() { //// Class A: just op, no operands // halt put(Permitted_operands, "f4", 0x00); // push put(Permitted_operands, "50", 0x00); put(Permitted_operands, "51", 0x00); put(Permitted_operands, "52", 0x00); put(Permitted_operands, "53", 0x00); put(Permitted_operands, "54", 0x00); put(Permitted_operands, "55", 0x00); put(Permitted_operands, "56", 0x00); put(Permitted_operands, "57", 0x00); // pop put(Permitted_operands, "58", 0x00); put(Permitted_operands, "59", 0x00); put(Permitted_operands, "5a", 0x00); put(Permitted_operands, "5b", 0x00); put(Permitted_operands, "5c", 0x00); put(Permitted_operands, "5d", 0x00); put(Permitted_operands, "5e", 0x00); put(Permitted_operands, "5f", 0x00); // return put(Permitted_operands, "c3", 0x00); //// Class B: just op and disp8 // imm32 imm8 disp32 |disp16 disp8 subop modrm // 0 0 0 |0 1 0 0 // jump put(Permitted_operands, "eb", 0x04); put(Permitted_operands, "74", 0x04); put(Permitted_operands, "75", 0x04); put(Permitted_operands, "7c", 0x04); put(Permitted_operands, "7d", 0x04); put(Permitted_operands, "7e", 0x04); put(Permitted_operands, "7f", 0x04); //// Class C: just op and disp16 // imm32 imm8 disp32 |disp16 disp8 subop modrm // 0 0 0 |1 0 0 0 put(Permitted_operands, "e9", 0x08); // jump //// Class D: just op and disp32 // imm32 imm8 disp32 |disp16 disp8 subop modrm // 0 0 1 |0 0 0 0 put(Permitted_operands, "e8", 0x10); // call //// Class E: just op and imm8 // imm32 imm8 disp32 |disp16 disp8 subop modrm // 0 1 0 |0 0 0 0 put(Permitted_operands, "cd", 0x20); // software interrupt //// Class F: just op and imm32 // imm32 imm8 disp32 |disp16 disp8 subop modrm // 1 0 0 |0 0 0 0 put(Permitted_operands, "05", 0x40); // add put(Permitted_operands, "2d", 0x40); // subtract put(Permitted_operands, "25", 0x40); // and put(Permitted_operands, "0d", 0x40); // or put(Permitted_operands, "35", 0x40); // xor put(Permitted_operands, "3d", 0x40); // compare put(Permitted_operands, "68", 0x40); // push // copy put(Permitted_operands, "b8", 0x40); put(Permitted_operands, "b9", 0x40); put(Permitted_operands, "ba", 0x40); put(Permitted_operands, "bb", 0x40); put(Permitted_operands, "bc", 0x40); put(Permitted_operands, "bd", 0x40); put(Permitted_operands, "be", 0x40); put(Permitted_operands, "bf", 0x40); //// Class M: using ModR/M byte // imm32 imm8 disp32 |disp16 disp8 subop modrm // 0 0 0 |0 0 0 1 // add put(Permitted_operands, "01", 0x01); put(Permitted_operands, "03", 0x01); // subtract put(Permitted_operands, "29", 0x01); put(Permitted_operands, "2b", 0x01); // and put(Permitted_operands, "21", 0x01); put(Permitted_operands, "23", 0x01); // or put(Permitted_operands, "09", 0x01); put(Permitted_operands, "0b", 0x01); // complement put(Permitted_operands, "f7", 0x01); // xor put(Permitted_operands, "31", 0x01); put(Permitted_operands, "33", 0x01); // compare put(Permitted_operands, "39", 0x01); put(Permitted_operands, "3b", 0x01); // copy put(Permitted_operands, "89", 0x01); put(Permitted_operands, "8b", 0x01); // swap put(Permitted_operands, "87", 0x01); // pop put(Permitted_operands, "8f", 0x01); //// Class O: op, ModR/M and subop (not r32) // imm32 imm8 disp32 |disp16 disp8 subop modrm // 0 0 0 |0 0 1 1 put(Permitted_operands, "ff", 0x03); // jump/push/call //// Class N: op, ModR/M and imm32 // imm32 imm8 disp32 |disp16 disp8 subop modrm // 1 0 0 |0 0 0 1 put(Permitted_operands, "c7", 0x41); // copy //// Class P: op, ModR/M, subop (not r32) and imm32 // imm32 imm8 disp32 |disp16 disp8 subop modrm // 1 0 0 |0 0 1 1 put(Permitted_operands, "81", 0x43); // combine // End Init Permitted Operands } :(code) #define HAS(bitvector, bit) ((bitvector) & (1 << (bit))) #define SET(bitvector, bit) ((bitvector) | (1 << (bit))) #define CLEAR(bitvector, bit) ((bitvector) & (~(1 << (bit)))) void check_operands(const line& inst, const word& op) { if (!is_hex_byte(op)) return; uint8_t expected_bitvector = get(Permitted_operands, op.data); if (HAS(expected_bitvector, MODRM)) { check_operands_modrm(inst, op); compare_bitvector_modrm(inst, expected_bitvector, op); } else { compare_bitvector(inst, expected_bitvector, op); } } //: Many instructions can be checked just by comparing bitvectors. void compare_bitvector(const line& inst, uint8_t expected, const word& op) { if (all_hex_bytes(inst) && has_operands(inst)) return; // deliberately programming in raw hex; we'll raise a warning elsewhere uint8_t bitvector = compute_operand_bitvector(inst); if (trace_contains_errors()) return; // duplicate operand type if (bitvector == expected) return; // all good with this instruction for (int i = 0; i < NUM_OPERAND_TYPES; ++i, bitvector >>= 1, expected >>= 1) { //? cerr << "comparing " << HEXBYTE << NUM(bitvector) << " with " << NUM(expected) << '\n'; if ((bitvector & 0x1) == (expected & 0x1)) continue; // all good with this operand const string& optype = Operand_type_name.at(i); if ((bitvector & 0x1) > (expected & 0x1)) raise << "'" << to_string(inst) << "'" << maybe_name(op) << ": unexpected " << optype << " operand\n" << end(); else raise << "'" << to_string(inst) << "'" << maybe_name(op) << ": missing " << optype << " operand\n" << end(); // continue giving all errors for a single instruction } // ignore settings in any unused bits } string maybe_name(const word& op) { if (!is_hex_byte(op)) return ""; if (!contains_key(name, op.data)) return ""; return " ("+get(name, op.data)+')'; } uint32_t compute_operand_bitvector(const line& inst) { uint32_t bitvector = 0; for (int i = /*skip op*/1; i < SIZE(inst.words); ++i) { bitvector = bitvector | bitvector_for_operand(inst.words.at(i)); if (trace_contains_errors()) return INVALID_OPERANDS; // duplicate operand type } return bitvector; } bool has_operands(const line& inst) { return SIZE(inst.words) > first_operand(inst); } int first_operand(const line& inst) { if (inst.words.at(0).data == "0f") return 2; if (inst.words.at(0).data == "f2" || inst.words.at(0).data == "f3") { if (inst.words.at(1).data == "0f") return 3; else return 2; } return 1; } // Scan the metadata of 'w' and return the bit corresponding to any operand type. // Also raise an error if metadata contains multiple operand types. uint32_t bitvector_for_operand(const word& w) { uint32_t bv = 0; bool found = false; for (int i = 0; i < SIZE(w.metadata); ++i) { const string& curr = w.metadata.at(i); if (!contains_key(Operand_type, curr)) continue; // ignore unrecognized metadata if (found) { raise << "'" << w.original << "' has conflicting operand types; it should have only one\n" << end(); return INVALID_OPERANDS; } bv = (1 << get(Operand_type, curr)); found = true; } return bv; } :(scenario conflicting_operand_type) % Hide_errors = true; == 0x1 cd/software-interrupt 80/imm8/imm32 +error: '80/imm8/imm32' has conflicting operand types; it should have only one //: Instructions computing effective addresses have more complex rules, so //: we'll hard-code a common set of instruction-decoding rules. :(scenario check_missing_mod_operand) % Hide_errors = true; == 0x1 81 0/add/subop 3/rm32/ebx 1/imm32 +error: '81 0/add/subop 3/rm32/ebx 1/imm32' (combine rm32 with imm32 based on subop): missing mod operand :(code) void check_operands_modrm(const line& inst, const word& op) { if (all_hex_bytes(inst)) return; // deliberately programming in raw hex; we'll raise a warning elsewhere check_metadata_present(inst, "mod", op); check_metadata_present(inst, "rm32", op); // no check for r32; some instructions don't use it; just assume it's 0 if missing if (op.data == "81" || op.data == "8f" || op.data == "ff") { // keep sync'd with 'help subop' check_metadata_present(inst, "subop", op); check_metadata_absent(inst, "r32", op, "should be replaced by subop"); } if (trace_contains_errors()) return; if (metadata(inst, "rm32").data != "4") return; // SIB byte checks uint8_t mod = hex_byte(metadata(inst, "mod").data); if (mod != /*direct*/3) { check_metadata_present(inst, "base", op); check_metadata_present(inst, "index", op); // otherwise why go to SIB? } else { check_metadata_absent(inst, "base", op, "direct mode"); check_metadata_absent(inst, "index", op, "direct mode"); } // no check for scale; 0 (2**0 = 1) by default } // same as compare_bitvector, with a couple of exceptions for modrm-based instructions // exception 1: ignore modrm bit since we already checked it above // exception 2: modrm instructions can use a displacement on occasion void compare_bitvector_modrm(const line& inst, uint8_t expected, const word& op) { if (all_hex_bytes(inst) && has_operands(inst)) return; // deliberately programming in raw hex; we'll raise a warning elsewhere uint8_t bitvector = compute_operand_bitvector(inst); if (trace_contains_errors()) return; // duplicate operand type expected = CLEAR(expected, MODRM); // exception 1 if (bitvector == expected) return; // all good with this instruction for (int i = 0; i < NUM_OPERAND_TYPES; ++i, bitvector >>= 1, expected >>= 1) { //? cerr << "comparing for modrm " << HEXBYTE << NUM(bitvector) << " with " << NUM(expected) << '\n'; if ((bitvector & 0x1) == (expected & 0x1)) continue; // all good with this operand if (i == DISP8 || i == DISP32) continue; // exception 2 const string& optype = Operand_type_name.at(i); if ((bitvector & 0x1) > (expected & 0x1)) raise << "'" << to_string(inst) << "'" << maybe_name(op) << ": unexpected " << optype << " operand\n" << end(); else raise << "'" << to_string(inst) << "'" << maybe_name(op) << ": missing " << optype << " operand\n" << end(); // continue giving all errors for a single instruction } // ignore settings in any unused bits } void check_metadata_present(const line& inst, const string& type, const word& op) { if (!has_metadata(inst, type)) raise << "'" << to_string(inst) << "' (" << get(name, op.data) << "): missing " << type << " operand\n" << end(); } void check_metadata_absent(const line& inst, const string& type, const word& op, const string& msg) { if (has_metadata(inst, type)) raise << "'" << to_string(inst) << "' (" << get(name, op.data) << "): unexpected " << type << " operand (" << msg << ")\n" << end(); } :(scenarios transform) :(scenario modrm_with_displacement) % Reg[EAX].u = 0x1; == 0x1 # just avoid null pointer 8b/copy 1/mod/lookup+disp8 0/rm32/EAX 2/r32/EDX 4/disp8 # copy *(EAX+4) to EDX $error: 0 :(scenarios run) :(scenario conflicting_operands_in_modrm_instruction) % Hide_errors = true; == 0x1 01/add 0/mod 3/mod +error: '01/add 0/mod 3/mod' has conflicting mod operands :(scenario conflicting_operand_type_modrm) % Hide_errors = true; == 0x1 01/add 0/mod 3/rm32/r32 +error: '3/rm32/r32' has conflicting operand types; it should have only one :(scenario check_missing_rm32_operand) % Hide_errors = true; == 0x1 81 0/add/subop 0/mod 1/imm32 +error: '81 0/add/subop 0/mod 1/imm32' (combine rm32 with imm32 based on subop): missing rm32 operand :(scenario check_missing_subop_operand) % Hide_errors = true; == 0x1 81 0/mod 3/rm32/ebx 1/imm32 +error: '81 0/mod 3/rm32/ebx 1/imm32' (combine rm32 with imm32 based on subop): missing subop operand :(scenario check_missing_base_operand) % Hide_errors = true; == 0x1 81 0/add/subop 0/mod/indirect 4/rm32/use-sib 1/imm32 +error: '81 0/add/subop 0/mod/indirect 4/rm32/use-sib 1/imm32' (combine rm32 with imm32 based on subop): missing base operand :(scenario check_missing_index_operand) % Hide_errors = true; == 0x1 81 0/add/subop 0/mod/indirect 4/rm32/use-sib 0/base 1/imm32 +error: '81 0/add/subop 0/mod/indirect 4/rm32/use-sib 0/base 1/imm32' (combine rm32 with imm32 based on subop): missing index operand :(scenario check_missing_base_operand_2) % Hide_errors = true; == 0x1 81 0/add/subop 0/mod/indirect 4/rm32/use-sib 2/index 3/scale 1/imm32 +error: '81 0/add/subop 0/mod/indirect 4/rm32/use-sib 2/index 3/scale 1/imm32' (combine rm32 with imm32 based on subop): missing base operand :(scenario check_base_operand_not_needed_in_direct_mode) == 0x1 81 0/add/subop 3/mod/indirect 4/rm32/use-sib 1/imm32 $error: 0 //:: similarly handle multi-byte opcodes :(code) void check_operands_0f(const line& inst) { assert(inst.words.at(0).data == "0f"); if (SIZE(inst.words) == 1) { raise << "opcode '0f' requires a second opcode\n" << end(); return; } word op = preprocess_op(inst.words.at(1)); if (!contains_key(name_0f, op.data)) { raise << "unknown 2-byte opcode '0f " << op.data << "'\n" << end(); return; } check_operands_0f(inst, op); } void check_operands_f3(const line& /*unused*/) { raise << "no supported opcodes starting with f3\n" << end(); } :(scenario check_missing_disp16_operand) % Hide_errors = true; == 0x1 # instruction effective address operand displacement immediate # op subop mod rm32 base index scale r32 # 1-3 bytes 3 bits 2 bits 3 bits 3 bits 3 bits 2 bits 2 bits 0/1/2/4 bytes 0/1/2/4 bytes 0f 84 # jmp if ZF to ?? +error: '0f 84' (jump disp16 bytes away if ZF is set): missing disp16 operand :(before "End Globals") map</*op*/string, /*bitvector*/uint8_t> Permitted_operands_0f; :(before "End Init Permitted Operands") //// Class C: just op and disp16 // imm32 imm8 disp32 |disp16 disp8 subop modrm // 0 0 0 |1 0 0 0 put(Permitted_operands_0f, "84", 0x08); put(Permitted_operands_0f, "85", 0x08); put(Permitted_operands_0f, "8c", 0x08); put(Permitted_operands_0f, "8d", 0x08); put(Permitted_operands_0f, "8e", 0x08); put(Permitted_operands_0f, "8f", 0x08); //// Class M: using ModR/M byte // imm32 imm8 disp32 |disp16 disp8 subop modrm // 0 0 0 |0 0 0 1 put(Permitted_operands_0f, "af", 0x01); :(code) void check_operands_0f(const line& inst, const word& op) { uint8_t expected_bitvector = get(Permitted_operands_0f, op.data); if (HAS(expected_bitvector, MODRM)) check_operands_modrm(inst, op); compare_bitvector_0f(inst, CLEAR(expected_bitvector, MODRM), op); } void compare_bitvector_0f(const line& inst, uint8_t expected, const word& op) { if (all_hex_bytes(inst) && has_operands(inst)) return; // deliberately programming in raw hex; we'll raise a warning elsewhere uint8_t bitvector = compute_operand_bitvector(inst); if (trace_contains_errors()) return; // duplicate operand type if (bitvector == expected) return; // all good with this instruction for (int i = 0; i < NUM_OPERAND_TYPES; ++i, bitvector >>= 1, expected >>= 1) { //? cerr << "comparing " << HEXBYTE << NUM(bitvector) << " with " << NUM(expected) << '\n'; if ((bitvector & 0x1) == (expected & 0x1)) continue; // all good with this operand const string& optype = Operand_type_name.at(i); if ((bitvector & 0x1) > (expected & 0x1)) raise << "'" << to_string(inst) << "' (" << get(name_0f, op.data) << "): unexpected " << optype << " operand\n" << end(); else raise << "'" << to_string(inst) << "' (" << get(name_0f, op.data) << "): missing " << optype << " operand\n" << end(); // continue giving all errors for a single instruction } // ignore settings in any unused bits } string tolower(const char* s) { ostringstream out; for (/*nada*/; *s; ++s) out << static_cast<char>(tolower(*s)); return out.str(); } #undef HAS #undef SET #undef CLEAR :(before "End Includes") #include<cctype>