Skip to content

Commit 003cdf0

Browse files
committed
Update readme tagline
1 parent f9e1944 commit 003cdf0

File tree

6 files changed

+39
-18
lines changed

6 files changed

+39
-18
lines changed

Makefile_many

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ set_profile_flags:
117117

118118
test: all
119119
@\
120-
if [ -x $(TEST) ]; then \
120+
if [ -x $(TEST) ]; then \
121121
./$(TEST) '$(OUT_EXT)' ;\
122122
else\
123123
fail=false ;\

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![Build Status](https://travis-ci.org/cirosantilli/cpp-cheat.svg?branch=master)](https://travis-ci.org/cirosantilli/cpp-cheat)
44

5-
C and C++ information, cheatsheets and mini-projects.
5+
C and C++ minimal examples. Asserts used wherever possible. Cheatsheet, tutorial and mini-projects.
66

77
Relies on [C++ boilerplate](https://github.com/cirosantilli/cpp-boilerplate) to factor code out. See [its documentation](https://github.com/cirosantilli/cpp-boilerplate/blob/master/README.md) for information on how to use this project.
88

cpp/constexpr.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@ int main() {
122122
//i = 1;
123123
}
124124

125+
{
126+
constexpr int i = 0;
127+
&i;
128+
}
129+
125130
// WARN: unitialized constexpr
126131
{
127132
//constexpr int i;

gcc/asm.c

+14-12
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
General syntax:
1919
2020
asm (
21-
"mov $1, %%eax;" //commands string
22-
: "=X" (y), //outputs
21+
"mov $1, %%eax;" // commands string
22+
: "=X" (y), // outputs
2323
"=X" (z)
24-
: "X" (x) //inputs
25-
: "%eax" //clobbered registers
24+
: "X" (x) // inputs
25+
: "%eax" // clobbered registers
2626
);
2727
2828
where:
@@ -86,9 +86,9 @@ int main() {
8686
/*
8787
# m constraint
8888
89-
Instructs gcc to store keep value of given expressions into RAM.
89+
Instructs GCC to keep value of given expressions into RAM.
9090
91-
This is the most basic way to get/set values of c variables in assembly code.
91+
This is the most basic way to get/set values of C variables in assembly code.
9292
*/
9393
{
9494
int in = 1;
@@ -99,7 +99,7 @@ int main() {
9999
"movl %%eax, %0"
100100
: "=m" (out)
101101
: "m" (in)
102-
: "%eax" /* eax will be modified, so we have to list it in the clobber list */
102+
: "%eax"
103103
);
104104
assert(out == 1);
105105
}
@@ -130,7 +130,7 @@ int main() {
130130
assert(out == -1.0);
131131
}
132132

133-
/* Input and ouput can be the same memory location. */
133+
/* Input and output can be the same memory location. */
134134
{
135135
float x = 1.0;
136136
/*x = -x*/
@@ -145,11 +145,13 @@ int main() {
145145
}
146146

147147
/*
148-
# register constraints
148+
# Register constraints
149149
150-
tell gcc to automatically read memory into registers or write registers into memory
150+
https://gcc.gnu.org/onlinedocs/gcc/Simple-Constraints.html
151151
152-
this is more precise and complicated than using `m`
152+
Tell GCC to automatically read memory into registers or write registers into memory
153+
154+
This is more precise and complicated than using `m`:
153155
154156
- r: gcc chooses any free register
155157
- a: %eax
@@ -170,7 +172,7 @@ int main() {
170172
note how we can do an `inc` operation directly on `%1` and `%0`
171173
so they must both already be inside a registers as expected
172174
173-
gcc just makes sure they are writen from/to memory before/after the operations
175+
GCC just makes sure they are written from/to memory before/after the operations.
174176
*/
175177
{
176178
int in = 0;

gdb/commands.md

+16-1
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ Like `si` by for `next`.
242242

243243
Don't enter `call`.
244244

245-
Does enter `int` in 16-bit code. In that case, you can use instead:
245+
Does enter `int` in 16-bit code. In that case, you can use instead: TODO <http://stackoverflow.com/questions/24491516/how-to-step-over-interrupt-calls-when-debugging-a-bootloader-bios-with-gdb-and-q> If only we could get the size of the current instruction automatically.
246246

247247
### until
248248

@@ -795,6 +795,21 @@ Useful for batch mode scripts that automatically check executables.
795795

796796
printf "rax = %d\n", $rax
797797

798+
### echo
799+
800+
Like `printf`, but:
801+
802+
- does not take `"`
803+
- does not take format strings
804+
805+
Backslash escapes are considered.
806+
807+
E.g.:
808+
809+
echo asdf\n
810+
811+
Just use the saner `printf` instead.
812+
798813
### disas
799814

800815
### disassemble

gdb/disassemble.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
Disassemble some instructions.
33
4-
https://sourceware.org/gdb/onlinedocs/gdb/Architectures-In-Python.html#Architectures-In-Python
4+
https://sourceware.org/gdb/onlinedocs/gdb/Architectures-In-Python.html
55
"""
66

77
gdb.execute('file big_function.out', to_string=True)
@@ -13,5 +13,4 @@
1313

1414
pc = gdb.selected_frame().pc()
1515

16-
# 1 instruction.
17-
print(arch.disassemble(pc)[0]['asm'])
16+
print(arch.disassemble(pc)[0])

0 commit comments

Comments
 (0)