Skip to content

Commit 3faa6e3

Browse files
committed
assembly is boring
1 parent 4741051 commit 3faa6e3

3 files changed

Lines changed: 38 additions & 11 deletions

File tree

docs/language/03-language_reference/01-basics.mdx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Whitespace
44

5-
In abstract, padding can be done with saces (` `) or tabs (`\t`).
5+
In abstract, padding can be done with spaces (` `) or tabs (`\t`).
66
However, we want to ensure a standard pattern of use tabs instead of
77
spaces as the use of the tab character is aways better for cases of
88
acessibility, slightly reduction in source code size and user size preference.
@@ -58,7 +58,8 @@ lines or blocks of code.
5858
The `#` character can be used to declare the section of a line on its right
5959
as a comment.
6060
```abs
61-
IAm.executeable() # I am a comment!
61+
# I am a comment!
62+
IAm.executeable() # Me too!
6263
```
6364

6465
### Multi-line comments

docs/language/03-language_reference/11-low_level.mdx

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,55 @@ Sometimes however, it is mandatory to communicate directly with the system.
1212
Embedded and bare-metal development, system programming and better memory
1313
managing are just some examples of why this access is needed.
1414

15+
---
16+
## Acessing CPU Registers
17+
18+
When compiled to some CPUs, the program binary has access to a set of CPU
19+
Registers that are used to do operations or controll the CPU behavior.
20+
1521
// TODO
1622

23+
---
1724
## Inline Assembly
1825

19-
The target will provide a library with interfaces to allow this
20-
connection.
26+
When read and write to the registers themselves are not enough, Abstract
27+
has a rich system that allow the user to write an entire assembly subroutine.
2128

2229
As a example of use, being targeted to x86_64 assemby:
2330

2431
```abs
2532
from Std.Console import
26-
from Std.System.Assembly.x86_64Assembly import {
27-
Instructions as opcode,
28-
ReferenceOperators as refas
29-
}
33+
from Std.System.Assembly.x86_64Assembly import { assemblyContext }
3034
3135
func foo()
3236
{
3337
3438
let string message = "Hello, World!";
3539
36-
opcode.MOV(.RDI, refas.memptr(message))
37-
opcode.CALL(refas.memptr(writeln))
40+
# Calling writeln(message) though assembly
41+
42+
# This will create the context object.
43+
# The context object is used to store the
44+
# entire assembly code in a tiny scope,
45+
# allowing that the code will be emited as
46+
# is and do not receive any optimizations.
47+
assemblyContext()
48+
49+
# The context return an instance that contains
50+
# diverse methods to write the assembly code.
51+
# See the example:
52+
53+
# The first argument must go in the RAX register
54+
# the mov instruction follows the order 'to <- from'
55+
.MOV().reg(.rax).ptr(message)
56+
# Then we can make a call to the function pointer
57+
.CALL().ptr(writeln)
58+
59+
#This is equivalent to
60+
###
61+
MOV $rax, message
62+
CALL Std.Console.writeln
63+
###
3864
3965
}
4066

docs/language/05-how_to/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# How to
22

33
The pages inside this category are designed to show examples of how to implement a diversity
4-
of features using the abtract language.
4+
of features using the abstract language.
55

66

0 commit comments

Comments
 (0)