Skip to content

Commit 49698fc

Browse files
kspalaiologosjonasgeiler
authored andcommitted
Small fixes regarding Assembly (#55)
* Make code C89 compiliant * Clarification Hand-crafted assembly can be more efficent than compiler-generated one, because as a human You know better, what does the code mean, making it easier to express, ultimatly reducing size or/and increasing efficency. * Assembly can be (but doesn't have to!) programmer ... ... friendly. * Hexadecimal is more readable and ... ... makes text less quack. Also, X86 assembly is more popular. * Linter is way too pedantic.
1 parent d379d79 commit 49698fc

3 files changed

Lines changed: 20 additions & 20 deletions

File tree

book/languages/assembly/advantages.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Since machine code and assembly are tied together, assembly can be used in appli
88
The assembly language can be used in these types of application:
99

1010
* To build software which requires serious machine level optimizations or to beat compilers in code optimization. \
11-
For e.g.: System software in an OS (not needed though as modern compilers do a pretty good job).
11+
For e.g.: System software in an OS.
1212

1313
* In embedded programming where space is limited to an extent that higher level languages
1414
(like C) can use more space than required or actually present.

book/languages/assembly/disadvantages.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
Consider the same example as in the previous section to add two numbers, lets say 1 and 2, but this time it is written in C.
44

55
```C
6-
#include<stdio.h>
7-
int main()
8-
{
6+
#include <stdio.h>
7+
8+
int main(void) {
99
int x = 1;
1010
int y = 2;
11-
int z = x+y;
11+
int z = x + y;
1212
return 0;
1313
}
1414
```
@@ -21,12 +21,12 @@ But there is a trade-off between the performance offered by assembly language an
2121
2222
* The entire code in assembly language could turn out to be monstrous in some stage cannot, because of which it can't be handled or maintained easily.
2323
24-
* Manually writing in assembly language for large programs such as an OS for instance can be frustrating.
24+
* Manually writing in assembly language for large programs such as an OS for instance can be frustrating (but doesn't have to).
2525
2626
## Birth of the higher-level languages
2727
28-
Even though assembly language offers high performance it cannot be effectively used to build user applications, because a higher abstraction is necessary to do so.
29-
Also, it is not “programmer friendly” in the sense that it still remains a low level language and can be difficult to grasp or understand.
28+
Even though assembly language offers high performance it cannot be effectively used to build user applications, because a higher abstraction is really helpful to do so.
29+
Also, it is not “programmer friendly” in the sense that it still remains a low level language and can be difficult to grasp or understand for casual programmers.
3030
Hence, a need for abstracting assembly language itself arises which is both understandable and “programmer friendly”.
3131
3232
From this need new assembly languages were born with a higher abstraction, which were more “programmer friendly” than the initial low level assembly languages, but they still remained assembly languages.

book/languages/assembly/what_it_solves.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,30 @@ Consider this instruction, where we have to add the two numbers 1 and 2.
55
## Assembly
66

77
```assembly
8-
addi x5 x0 1
9-
addi x6 x0 2
10-
add x7 x5 x6
8+
mov edx, 1
9+
mov eax, 2
10+
add eax, edx
1111
```
1212

13-
## Binary
13+
## Hexadecimal
1414

15-
```binary
16-
000000000001001010000000000100110000000000100011000000000001001100000000011100101000001101100011
15+
```hex
16+
ba01000000b80200000001d0
1717
```
1818

19-
## Binary in human readable format
19+
## More readable hexadecimal
2020

2121
```binary
22-
0000000 00001 00101 000 00000 0010011
23-
0000000 00010 00110 000 00000 0010011
24-
0000000 00111 00101 000 00110 1100011
22+
0: ba 01 00 00 00 mov edx,0x1
23+
5: b8 02 00 00 00 mov eax,0x2
24+
a: 01 d0 add eax,edx
2525
```
2626

27-
## Binary with a mistake. Happy debugging
27+
## Binary code with a mistake. Happy debugging
2828

2929
```binary
3030
000000000001001010000000000100110000000000100011000000000001001100000000010100101000001101100011
3131
```
3232

3333
The purpose of an assembly language can easily be seen with the help of the above example. Assembly language with the help of its syntax makes it easier to code and not worry about trivial tasks such as opcodes, address calculations, etc. Mistakes if any can easily identified in assembly
34-
rather than in binary. Imagine finding such mistakes in a pool of 0's and 1's!
34+
rather than in binary. Imagine finding such mistakes in a pool of just a numbers!

0 commit comments

Comments
 (0)