Binary Representation, Matrices, Algorithms, and Sorting
Binary Repartition
Binary Representation:
- Signed Magnitude: The first bit determines if the number is negative (the sign bit). The rest of the bits represent the magnitude (mantissa).
- One’s Complement: Similar to signed magnitude, but if the number is negative, all bits in the magnitude are inverted.
- Two’s Complement: Similar to one’s complement, but 1 is added to the inverted magnitude if the number is negative.
- Biased Representation: Similar to signed magnitude, but a bias is added to the target number.
C++ Operator Overloading and Polymorphism
Member Operators
Member operators are functions that define the behavior of operators when used with a class’s objects.
- Unary: One operand. Examples:
++i
,--i
,+value
,-value
. Declaration:return_type operator ++/--()
- Binary: Two operands. Examples:
=
,+=
,-
,*
,/
,==
,&&
. Declaration:return_type operator symbol (type [identifier])
- Ternary: Three operands. Example:
condition ? expression1 : expression2
Operators can be overloaded as:
- Member operators: Defined within the class, with access to
Assembly Code Examples: Periodic Interrupts and Keypad Access
Example 1: Periodic Interrupt and Counter
This program demonstrates a periodic interrupt that increments a counter (0 to 99) and prints its value to the text display.
JMP boot
JMP isr
stackTop EQU 0xFF
txtDisplayTens EQU 0x2E0
txtDisplayUnits EQU 0x2E1
counter: ; the counter
DW 0
boot:
MOV SP, stackTop ; Set SP
MOV A, 2 ; Set bit 1 of IRQMASK
OUT 0 ; Unmask timer IRQ
MOV A, 0x20 ; Set timer preload
OUT 3
STI
HLT
isr:
PUSH A
PUSH B
PUSH C
MOV A, [counter] ; Increment the
INC A ; counter
Read More
Oracle SQL and PL/SQL Quick Reference
UPPER() lower() InitCap() LENGTH() ROUND(num, 2) TRUNC(num,2)
SUBS/TR(string, initial (pos: from left, neg: from right), length (optional))
INSTR(string, lookup (case sensitive), starting pos, nth occurrence (optional))
LPAD(string, total length, fill), RPAD(string, total length, fill character)
REPLACE(‘original’, ‘find’, ‘replace’), TRIM(whattotrim FROM string)
MOD(number, divisor) -> return remainder
MONTHS_BETWEEN(date, date), ADD_MONTHS(date, # of months to add)
NEXT_DAY(date, ‘FRIDAY’)
Read MoreUnderstanding PC Components and Startup Processes
Understanding PC Components and Startup
What is the BIOS?
The BIOS (Basic Input/Output System) is what allows the computer to start. It controls the keyboard and floppy disk, and allows control to be passed to the operating system.
What is the CMOS?
The CMOS (Complementary Metal-Oxide-Semiconductor) is a small RAM chip that stores the system’s configuration.
What is Setup?
Setup is a crucial program recorded in the BIOS chip. It’s used to change the modes of transmission and the recognition (or non-recognition)
Read MoreUnderstanding Computer Capabilities: Diligence, Versatility, and Memory
Understanding Computer Capabilities
Diligence
Unlike humans, computers never tire of repetitive tasks. They can continually work for hours without creating errors. Even when a large number of executions are needed, each execution requires the same duration and is executed with the same accuracy.
Versatility
Versatility is the quality of being flexible. Today, computers are used in various fields of our daily lives. For example, they are used as personal computers (PCs) for home use, for business-oriented
Read More