Extend CT
All checks were successful
Build Typst PDFs (Docker) / build-typst (push) Successful in 44s
All checks were successful
Build Typst PDFs (Docker) / build-typst (push) Successful in 44s
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
#import "../lib/styles.typ" : *
|
#import "../lib/styles.typ" : *
|
||||||
#import "../lib/common_rewrite.typ" : *
|
#import "../lib/common_rewrite.typ" : *
|
||||||
|
#import "../lib/bit_fields.typ" : *
|
||||||
#import "@preview/cetz:0.4.2"
|
#import "@preview/cetz:0.4.2"
|
||||||
|
|
||||||
#set page(
|
#set page(
|
||||||
@@ -24,8 +25,8 @@
|
|||||||
#let Allgemein = color.hsl(105.13deg, 92.13%, 75.1%)
|
#let Allgemein = color.hsl(105.13deg, 92.13%, 75.1%)
|
||||||
#let colorProgramming = color.hsl(330.19deg, 100%, 68.43%)
|
#let colorProgramming = color.hsl(330.19deg, 100%, 68.43%)
|
||||||
#let colorNumberSystems = color.hsl(202.05deg, 92.13%, 75.1%)
|
#let colorNumberSystems = color.hsl(202.05deg, 92.13%, 75.1%)
|
||||||
// #let colorVR = color.hsl(280deg, 92.13%, 75.1%)
|
#let colorMMIX = color.hsl(280deg, 92.13%, 75.1%)
|
||||||
// #let colorAbbildungen = color.hsl(356.92deg, 92.13%, 75.1%)
|
#let colorRandomShit = color.hsl(356.92deg, 92.13%, 75.1%)
|
||||||
// #let colorGruppen = color.hsl(34.87deg, 92.13%, 75.1%)
|
// #let colorGruppen = color.hsl(34.87deg, 92.13%, 75.1%)
|
||||||
|
|
||||||
|
|
||||||
@@ -48,7 +49,98 @@
|
|||||||
]
|
]
|
||||||
|
|
||||||
#bgBlock(fill: colorNumberSystems)[
|
#bgBlock(fill: colorNumberSystems)[
|
||||||
#subHeading(fill: colorNumberSystems)[Einer-Kompilment, Zweier-Kompliment, Float (IEEE 754)]
|
#subHeading(fill: colorNumberSystems)[Fixed Point]
|
||||||
|
|
||||||
|
#table(
|
||||||
|
columns: 17,
|
||||||
|
fill: (x, y) => if calc.rem(x, 2) == 1 { tableFillLow } else { tableFillHigh },
|
||||||
|
|
||||||
|
.. for i in range(0,17) {
|
||||||
|
([$2^#i$],)
|
||||||
|
},
|
||||||
|
.. for i in range(0,17) {
|
||||||
|
($#calc.pow(2,i)$,)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
#columns(2, [
|
||||||
|
*Vorzeichen und Betrag:*
|
||||||
|
|
||||||
|
#grid(
|
||||||
|
columns: (2fr, 1fr),
|
||||||
|
[
|
||||||
|
$x = (-1)^"sign-bit" dot "Betrag"$
|
||||||
|
|
||||||
|
$0 -> "positiv", 1 -> "negativ"$
|
||||||
|
|
||||||
|
Range: \ $(-2^(n-1) - 1) dot 2^r$ bis $(2^(n-1) - 1) dot 2^r$
|
||||||
|
|
||||||
|
Achtung: $plus.minus 0$
|
||||||
|
],
|
||||||
|
image("../images/ct/betragUndVorzeich.png", width: 2cm)
|
||||||
|
)
|
||||||
|
|
||||||
|
#line(length: 100%, stroke: (thickness: 0.2mm))
|
||||||
|
|
||||||
|
*Einer-Komplement*
|
||||||
|
|
||||||
|
#grid(
|
||||||
|
columns: (2fr, 1fr),
|
||||||
|
[
|
||||||
|
$x = (-1)^"sign-bit" dot "Betrag"$
|
||||||
|
|
||||||
|
$0 -> "positiv normaler Betrag"$
|
||||||
|
|
||||||
|
$1 -> "negativ INVERT. Betrag"$
|
||||||
|
|
||||||
|
Range: \
|
||||||
|
$(-2^(n-1) - 1) dot 2^r$ bis $(2^(n-1) - 1) dot 2^r$
|
||||||
|
|
||||||
|
Achtung: $plus.minus 0$
|
||||||
|
],
|
||||||
|
image("../images/ct/einerKomplement.png", width: 2cm)
|
||||||
|
)
|
||||||
|
#colbreak()
|
||||||
|
|
||||||
|
*Zweier-Komplement*
|
||||||
|
|
||||||
|
#grid(
|
||||||
|
columns: (2fr, 1fr),
|
||||||
|
[
|
||||||
|
$x = (-1)^"sign-bit" dot "Betrag"$
|
||||||
|
|
||||||
|
$0 -> "positiv"$
|
||||||
|
|
||||||
|
$1 -> "negativ"$
|
||||||
|
|
||||||
|
Range: \ $(-2^(n-1)) dot 2^r$ bis $(2^(n-1) - 1) dot 2^r$
|
||||||
|
|
||||||
|
Positiv: Normal Binär Kodierung
|
||||||
|
|
||||||
|
Negativ: #raw("Invertiert(Binär) + 1")
|
||||||
|
|
||||||
|
],
|
||||||
|
image("../images/ct/zweierKomplement.png", width: 2cm)
|
||||||
|
)
|
||||||
|
|
||||||
|
#line(length: 100%, stroke: (thickness: 0.2mm))
|
||||||
|
|
||||||
|
*Radix / Fixed Point*
|
||||||
|
|
||||||
|
$r = 0$ Normal Falle, nix änder sich
|
||||||
|
|
||||||
|
$r > 0$ : Komma nach Rechts und Nullen auffüllen \
|
||||||
|
Bsp. $r = 3 quad ->$ #raw("xxxxxxx000.")
|
||||||
|
|
||||||
|
$r < 0$ : Komma nach Links verschieben \
|
||||||
|
Bsp: $r = -4 quad ->$ #raw("xxxxx.xxxx")
|
||||||
|
|
||||||
|
])
|
||||||
|
]
|
||||||
|
|
||||||
|
#colbreak()
|
||||||
|
#bgBlock(fill: colorNumberSystems)[
|
||||||
|
#subHeading(fill: colorNumberSystems)[Float (IEEE 754)]
|
||||||
|
|
||||||
*Float (IEEE 754)*
|
*Float (IEEE 754)*
|
||||||
|
|
||||||
@@ -133,11 +225,46 @@
|
|||||||
|
|
||||||
content((cell_size*(total_bits), -0.2), anchor: "south", raw(str(0)), angle: 90deg)
|
content((cell_size*(total_bits), -0.2), anchor: "south", raw(str(0)), angle: 90deg)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
$x = (-1)^"sign" dot #raw("1.[mantisse]") dot 2^(("exponent" - k))$
|
||||||
|
|
||||||
|
#grid(
|
||||||
|
columns: (auto, auto),
|
||||||
|
column-gutter: 5mm,
|
||||||
|
row-gutter: 2mm,
|
||||||
|
$"float32"&, k = 127 &= #raw(" 111 1111") "(7 x Einser)" \
|
||||||
|
"float64"&, k = 1023 &= #raw("11 1111 1111") "(10 x Einser)"$
|
||||||
|
)
|
||||||
|
|
||||||
|
*Spezial Cases*
|
||||||
|
#table(
|
||||||
|
columns: (auto, auto),
|
||||||
|
[$0$], [exponent = 0 \ mantisse = 0],
|
||||||
|
[$plus.minus infinity$], [exponent = alle 1 \ mantisse = 0],
|
||||||
|
[NaN], [exponent = alle 1 \ mantisse > 0],
|
||||||
|
[denormalisierte Float], [exponent = 0 \ mantisse > 0],
|
||||||
|
[normalisierter Float], [0 < exponent < 255/2047]
|
||||||
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
#bgBlock(fill: colorProgramming)[
|
#bgBlock(fill: colorProgramming)[
|
||||||
#subHeading(fill: colorProgramming)[C]
|
#subHeading(fill: colorProgramming)[C]
|
||||||
|
|
||||||
|
#table(
|
||||||
|
columns: (auto, auto, auto),
|
||||||
|
fill: (x, y) => if calc.rem(y, 2) == 0 { tableFillLow } else { tableFillHigh },
|
||||||
|
|
||||||
|
[*C-Type*], [*min size*], [*typ. size*],
|
||||||
|
raw("char"), raw("1 byte"), raw("1 byte"),
|
||||||
|
raw("short (int)"), raw("2 byte"), raw("2 byte"),
|
||||||
|
raw("int"), raw("2 byte"), raw("4 byte"),
|
||||||
|
raw("long (int)"), raw("4 byte"), raw("8 byte"),
|
||||||
|
raw("long long"), raw("4 byte"), raw("8 byte"),
|
||||||
|
raw("float"), raw("4 byte"), raw("4 byte"),
|
||||||
|
raw("double"), raw("8 byte"), raw("8 byte"),
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
#table(
|
#table(
|
||||||
columns: (auto, 1fr),
|
columns: (auto, 1fr),
|
||||||
fill: white,
|
fill: white,
|
||||||
@@ -151,4 +278,99 @@
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
#bgBlock(fill: colorProgramming)[
|
||||||
|
#subHeading(fill: colorProgramming)[#raw("scanf/printf") Format Specifier]
|
||||||
|
|
||||||
|
#columns(2)[
|
||||||
|
*printf*
|
||||||
|
#table(
|
||||||
|
columns: (auto, auto),
|
||||||
|
fill: (x, y) => if calc.rem(y, 2) == 0 { tableFillLow } else { tableFillHigh },
|
||||||
|
raw("%s"), [*String*],
|
||||||
|
raw("%d"), [*Decimal: #raw("int/short/long"))*],
|
||||||
|
raw("%f"), [*Float*],
|
||||||
|
raw("%f"), [*Float*],
|
||||||
|
raw("%lf"), [*Double*],
|
||||||
|
raw("%x"), [* Hexdecimal #raw("int/short/long")*],
|
||||||
|
)
|
||||||
|
|
||||||
|
Allgemeiner Syntax: #raw("%[flags][width][.precision]type")
|
||||||
|
|
||||||
|
Flags:
|
||||||
|
- #raw("0") Prepend With left aligned
|
||||||
|
- #raw("-") Left-aligned
|
||||||
|
|
||||||
|
#table(columns: (auto, auto),
|
||||||
|
fill: (x, y) => if calc.rem(y, 2) == 0 { tableFillLow } else { tableFillHigh },
|
||||||
|
raw("\\n"), [New Line],
|
||||||
|
raw("\\t"), [Tab],
|
||||||
|
raw("\\0"), [Null Terminator],
|
||||||
|
raw("\\\\"), [#raw("\\")],
|
||||||
|
raw("\\\""), [#raw("\"")],
|
||||||
|
)
|
||||||
|
|
||||||
|
#colbreak()
|
||||||
|
|
||||||
|
*scanf*
|
||||||
|
#table(
|
||||||
|
columns: (auto, auto),
|
||||||
|
fill: (x, y) => if calc.rem(y, 2) == 0 { tableFillLow } else { tableFillHigh },
|
||||||
|
raw("%[size of String]s"), [*String* \ Size of String (without the #raw("\\0")) \ Terminates with Whitespace],
|
||||||
|
raw("%i"), [*#raw("int")*],
|
||||||
|
raw("%f"), [*#raw("float")*],
|
||||||
|
raw("%lf"), [*#raw("double")*],
|
||||||
|
raw("%x"), [*#raw("int")* als Hexadezimal],
|
||||||
|
raw("%c"), [*#raw("char")* ],
|
||||||
|
)
|
||||||
|
|
||||||
|
#raw("fgets(char * s, int count, stdin)")
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
#bgBlock(fill: colorMMIX)[
|
||||||
|
#subHeading(fill: colorMMIX)[MMIX]
|
||||||
|
- $32$ Speziel Register
|
||||||
|
- $256$ Allzwickregister
|
||||||
|
- $2^64$ Speicher
|
||||||
|
|
||||||
|
Wort: $64$ Bit
|
||||||
|
|
||||||
|
]
|
||||||
|
|
||||||
|
#bgBlock(fill: colorRandomShit)[
|
||||||
|
#subHeading(fill: colorRandomShit)[Register Register Magista]
|
||||||
|
|
||||||
|
*Zwei-Address-Maschine:* $quad X <-- X dot.o Y$, Parameter: $(X,Y)$ \
|
||||||
|
*Drei-Address-Maschine:* $quad X <-- Y dot.o Z$, Parameter: $(X,Y,Z)$ \
|
||||||
|
*Ein-Address-Maschine:* $quad "ACC" <-- X$, Parameter: $(X)$
|
||||||
|
|
||||||
|
*Register-Speicher-Architekture:* \
|
||||||
|
Operanden können Register und Addressen sein
|
||||||
|
|
||||||
|
*Register-Register-Archiektur/Load-Store-Architektur* \
|
||||||
|
Operanden nur Register. Extra Befehle fürs Laden aus Speicher
|
||||||
|
|
||||||
|
|
||||||
|
*CISC*: Complex Instruction Set Architecture
|
||||||
|
- Eine Befehl kann viel $->$ Wenige Befehle
|
||||||
|
- Befehlslänge Variable (meistens)
|
||||||
|
- z.B. x86
|
||||||
|
|
||||||
|
*RISC*: Reduced Instruction Set Architecture
|
||||||
|
- Eine Befehl kann wenig $->$ Viel Befehle
|
||||||
|
- Befehlslänge fix (meistens)
|
||||||
|
- z.B. Arm, RISC, MMIX
|
||||||
|
|
||||||
|
*Universal Rechner*
|
||||||
|
|
||||||
|
- M1: Ergebnis Qulle
|
||||||
|
- Input a,b,c oder ALU
|
||||||
|
- M2: ALU Operation
|
||||||
|
- M3,M4: Operanden
|
||||||
|
- R0-R7
|
||||||
|
- D: Ergebnis Register
|
||||||
|
- R0-R7
|
||||||
|
- K: Konstante für Operanden
|
||||||
|
]
|
||||||
]
|
]
|
||||||
BIN
src/images/ct/betragUndVorzeich.png
Normal file
BIN
src/images/ct/betragUndVorzeich.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 94 KiB |
BIN
src/images/ct/einerKomplement.png
Normal file
BIN
src/images/ct/einerKomplement.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 94 KiB |
BIN
src/images/ct/zweierKomplement.png
Normal file
BIN
src/images/ct/zweierKomplement.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 94 KiB |
40
src/lib/bit_fields.typ
Normal file
40
src/lib/bit_fields.typ
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
#import "@preview/cetz:0.4.2"
|
||||||
|
|
||||||
|
#let bitFieldField(name, color, total) = {
|
||||||
|
(name: name, color: color, total: total)
|
||||||
|
}
|
||||||
|
|
||||||
|
#let bitFieldGreen = rgb("#8fff57")
|
||||||
|
#let bitFieldYellow = rgb("#ffe057")
|
||||||
|
#let bitFieldBlue = rgb("#57a5ff")
|
||||||
|
#let bitFieldRed = rgb("#ff5757")
|
||||||
|
|
||||||
|
#let bitField(fields: (), BitHeight: 0.5, BitWidth: 0.25) = {
|
||||||
|
cetz.canvas({
|
||||||
|
import cetz.draw : *
|
||||||
|
let pos = 0;
|
||||||
|
|
||||||
|
let total = 0;
|
||||||
|
|
||||||
|
for f in fields {
|
||||||
|
total += f.at("total")
|
||||||
|
}
|
||||||
|
|
||||||
|
for f in fields {
|
||||||
|
content(((pos + 0.5)*BitWidth, -0.1), raw(str(total - pos - 1)), angle: 90deg, anchor: "east")
|
||||||
|
|
||||||
|
for i in range(f.at("total")) {
|
||||||
|
rect(((pos + i)*BitWidth, 0), ((pos+i+1)*BitWidth, BitHeight), fill: f.at("color", default: bitFieldBlue))
|
||||||
|
content(((pos+i+0.5)*BitWidth, BitHeight*0.5), raw("0"))
|
||||||
|
}
|
||||||
|
|
||||||
|
content(((pos*BitWidth + f.at("total")*BitWidth*0.5), BitHeight + 0.2), f.at("name"), anchor: f.at("anchor", default: "mid"))
|
||||||
|
|
||||||
|
pos += f.at("total")
|
||||||
|
|
||||||
|
content(((pos - 0.5)*BitWidth, -0.1), raw(str(total - pos)), angle: 90deg, anchor: "east")
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user