Computer Systems Flashcards
What are the 3 main uses of symbols in Assembly Languages ?
1,2) Labels - Assembly programs can declare and use symbols that mark
various locations in the code, for example, LOOP and END.
3,4) Variables: Assembly programs can declare and use symbolic variables, for
example, i and sum.
5) Predefined symbols: Assembly programs can refer to special addresses in the computer’s memory using agreed-upon symbols, for example, SCREEN and KBD.
What does a Assembler Do ?
1,3) can translate symbolic programs
4,5) into binary code.
What does a Parser Do ?
1) reads a stream of tokens
2) (created by Lexer)
3,4) and checks if tokens conform to a specific grammer or syntax
5) (HACK = nand2tetris) (SAL = dj barnes)
What does a Lexical Analyser Do ?
1,3) break up the input code into a sequence of tokens
4,5)that can be processed by the parser.
Not gate
(1,2) CHIP Not {
IN in;
OUT out;
(3,5) PARTS:
Nand (a=in, b=in, out=out);
}
And gate
(1) CHIP And {
IN a, b;
OUT out;
PARTS:
(2,3) Nand (a=a, b=b, out=c);
(4,5) Nand (a=c, b=c, out=out);
}
Or Gate
CHIP Or {
IN a, b;
OUT out;
PARTS:
Nand (a=a, b=a, out=c)
Nand (a=b, b=b, out=d)
Nand (a=c, b=d, out=out)
}
Commutative Laws (Boolean Logic)
order in which we write logical operators ‘AND’ ‘OR’ we can switch the order of the perands without changing the outcome.
example: ‘AND’ operator, A AND B is the same as B AND A.
Associative Laws (Boolean Logic)
tell us the order in which group the logical operators ‘AND’ ‘OR’ does not effect final result of operation.
example: given expression A AND (B AND C) we can use associative law and AND group it as (A AND B) AND C or OR to (A OR B) OR C and the result will be same
Distributive Laws (Boolean Logic)
tell us how we can combine logically operators ‘AND’ ‘OR’ in different ways, law state that we can ‘distribute’ an operator over another to simplify complex logical expression.
example: if we have A AND (B OR C) we can use distributive law to rewrite it as (A AND B) OR (A AND C) another example A OR (B AND C) to rewrite it as (A OR B) AND (A OR C)
De Morgan’s Law (Boolean Logic)
two rules that help us negate complex boolean expressions
The negation of a logical “AND” is the same as the logical “OR” of the negations of the terms. In other words, NOT (A AND B) is the same as NOT A OR NOT B.
The negation of a logical “OR” is the same as the logical “AND” of the negations of the terms. In other words, NOT (A OR B) is the same as NOT A AND NOT B.
example: NOT (A AND B) use de morgan law to rewrite as NOT A OR NOT B
What is a subroutine?
can be eithera consturctor, method or function.
subroutine ‘constructor’
that create new objects
subroutine ‘method’
operate on the CURRENT object
subroutine’function’
that operate on no particular object.