//: Core data structures for simulating the SubX VM (subset of an x86 processor), //: either in tests or debug aids. //:: registers //: assume segment registers are hard-coded to 0 //: no MMX, etc. :(before "End Types") enum { EAX, ECX, EDX, EBX, ESP, EBP, ESI, EDI, NUM_INT_REGISTERS, }; union reg { int32_t i; uint32_t u; }; :(before "End Globals") reg Reg[NUM_INT_REGISTERS] = { {0} }; uint32_t EIP = 1; // preserve null pointer :(before "End Reset") bzero(Reg, sizeof(Reg)); EIP = 1; // preserve null pointer :(before "End Types") const int NUM_XMM_REGISTERS = 8; float Xmm[NUM_XMM_REGISTERS] = { 0.0 }; const string Xname[NUM_XMM_REGISTERS] = { "XMM0", "XMM1", "XMM2", "XMM3", "XMM4", "XMM5", "XMM6", "XMM7" }; :(before "End Reset") bzero(Xmm, sizeof(Xmm)); :(before "End Help Contents") cerr << " registers\n"; :(before "End Help Texts") put_new(Help, "registers", "SubX supports 16 registers: eight 32-bit integer registers and eight single-precision\n" "floating-point registers. From 0 to 7, they are:\n" " integer: EAX ECX EDX EBX ESP EBP ESI EDI\n" " floating point: XMM0 XMM1 XMM2 XMM3 XMM4 XMM5 XMM6 XMM7\n" "ESP contains the top of the stack.\n" "\n" "-- 8-bit registers\n" "Some instructions operate on eight *overlapping* 8-bit registers.\n" "From 0 to 7, they are:\n" " AL CL DL BL AH CH DH BH\n" "The 8-bit registers overlap with the 32-bit ones. AL is the lowest signicant byte\n" "of EAX, AH is the second lowest significant byte, and so on.\n" "\n" "For example, if EBX contains 0x11223344, then BL contains 0x44, and BH contains 0x33.\n" "\n" "There is no way to access bytes within ESP, EBP, ESI or EDI.\n" "\n" "For complete details consult the IA-32 software developer's manual, volume 2,\n" "table 2-2, \"32-bit addressing forms with the ModR/M byte\".\n" "It is included in this repository as 'modrm.pdf'.\n" "The register encodings are described in the top row of the table, but you'll need\n" "to spend some time with it.\n" "\n" "-- flag registers\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\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" "manual (volume 2). There's various versions of it online, such as https://c9x.me/x86,\n" "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" ); :(before "End Globals") // the subset of x86 flag registers we care about bool SF = false; // sign flag bool ZF = false; // zero flag bool CF = false; // carry flag bool OF = false; // overflow flag :(before "End Reset") SF = ZF = CF = OF = false; //:: simulated RAM :(before "End Types") const uint32_t SEGMENT_ALIGNMENT = 0x1000000; // 16MB inline uint32_t align_upwards(uint32_t x, uint32_t align) { return (x+align-1) & -(align); } // Like in real-world Linux, we'll allocate RAM for our programs in disjoint // slabs called VMAs or Virtual Memory Areas. struct vma { uint32_t start; // inclusive uint32_t end; // exclusive vector _data; vma(uint32_t s, uint32_t e) :start(s), end(e) {} vma(uint32_t s) :start(s), end(align_upwards(s+1, SEGMENT_ALIGNMENT)) {} bool match(uint32_t a) { return a >= start && a < end; } bool match32(uint32_t a) { return a >= start && a+4 <= end; } uint8_t& data(uint32_t a) { assert(match(a)); uint32_t result_index = a-start; if (_data.size() <= result_index+/*largest word size that can be accessed in one instruction*/sizeof(int)) { const int align = 0x1000; uint32_t result_size = result_index + 1; // size needed for result_index to be valid uint32_t new_size = align_upwards(result_size, align); // grow at least 2x to maintain some amortized complexity guarantees if (new_size < _data.size() * 2) new_size = _data.size() * 2; // never grow past the stated limit if (new_size > end-start) new_size = end-start; _data.resize(new_size); } return _data.at(result_index); } void grow_until(uint32_t new_end_address) { if (new_end_address < end) return; // Ugly: vma knows about the global Memory list of vmas void sanity_check(uint32_t start, uint32_t end); sanity_check(start, new_end_address); end = new_end_address; } // End vma Methods }; :(code) void sanity_check(uint32_t start, uint32_t end) { bool dup_found = false; for (int i = 0; i < SIZE(Mem); ++i) { const vma& curr = Mem.at(i); if (curr.start == start) { assert(!dup_found); dup_found = true; } else if (curr.start > start) { assert(curr.start > end); } else if (curr.start < start) { assert(curr.end < start); } } } :(before "End Globals") // RAM is made of VMAs. vector Mem; :(code) :(before "End Globals") uint32_t End_of_program = 0; // when the program executes past this address in tests we'll stop the test // The stack grows downward. Can't increase its size for now. :(before "End Reset") Mem.clear(); End_of_program = 0; :(code) // These helpers depend on Mem being laid out contiguously (so you can't use a // map, etc.) and on the host also being little-endian. inline uint8_t read_mem_u8(uint32_t addr) { uint8_t* handle = mem_addr_u8(addr); // error messages get printed here return handle ? *handle : 0; } inline int8_t read_mem_i8(uint32_t addr)
.TH DWM 1 dwm-0.6
.SH NAME
dwm \- dynamic window manager
.SH SYNOPSIS
.B dwm
.RB [ \-v ]
.SH DESCRIPTION
.B dwm
is a dynamic window manager for X11. It manages windows in tiling and floating
modes. Either mode can be applied dynamically, depending on the application in
use and the task performed.
.P
In tiling mode windows are managed in a master and stacking column. The master
column contains the window which needs most attention at a time, whereas the
stacking column contains all other windows in a stack.  Dialog windows are
managed floating, however. In floating mode windows can be resized and moved
freely.
.P
Windows are grouped by tags. All windows with a specific tag can be viewed at a
time. But each window may contain more than one tag, which makes it visible in
several views.
.P
.B dwm
has a small status bar which reads the text displayed from standard
input, if written. It draws 1-pixel borders around windows to indicate the
focus state. Unfocused windows contain a small bar in front of the window
displaying the tags and the window title.
.SH OPTIONS
.TP
.B \-v
prints version information to standard output, then exits.
.SH USAGE
.TP
.B Mod1-Return
Zoom
.B window
to the 
.B master
column
.TP
.B Mod1-k
Focus previous
.B window