Professional Documents
Culture Documents
Tutorial 02
Tutorial 02
Important
CPUs also have a clock which ticks. Each tick, the flip flops change from
the previous state, which they currently have at their outputs, to the
next state, which the logic sends to their inputs.
to know the size of an instruction, we can perform substraction on the
hex code of instruction n and instruction n-1 , that gives us 1 byte.
CIR contains the address of the current instruction that needs to be
decoded.
3. The feature of the CPU that has a direct impact on the maximum
addressable space is the address bus width. It determines the maximum
amount of memory that can be addressed by the CPU. For example, a CPU
with a 32-bit address bus can address up to 232 (4 GB) of memory. (here
Mr.Lasla said it's word-size but google says otherwise,something
like "word size impacts memory and the width of the address bus
controls ADDRESSABLE memory" so i don't really know...)
4. Yes, if the operating system has the time-sharing feature.
Exercise 02:
Assembly : low-level programming language , it was created as a means of
humans not wanting to write machine code (0s and 1s or binary) instructions to
a computer.
Not always:
1. Jump instructions: Jumps modify the PC directly, bypassing the
increment.
2. Subroutines: Calls push the current PC onto the stack before jumping,
allowing return.
Therefore, the PC increments after instruction fetch and before decoding, but
its value can change due to other instructions like jumps and calls.
Exercise 03:
// 1
int ax = 1;
do {}
while (ax == 1)
// 2
int i = 1;
while (ax == 1) {}
Exercise 4:
The program will crash when the ALU will start to execute the instruction at
address 0x330F, because the previous instruction in address 0x330E involves the
call of XOR AX with itself which makes Ax now hold the value 0, thus in the
address 0x330F the instruction Div Ax is actually executing a division by 0 which
will cause an exception.
this happens in the following way:
Exercise 5 :
a)
explanation:
Exercise 6 :
section .data ; Data segment
msg db 'The National School of Artificial Intelligence!'
mov ah, 09h : This instruction moves the hexadecimal value 09h into the
AH register. In the context of DOS interrupts, AH often holds the function
code for various system calls. In this case, 09h typically represents the
function for printing a string to the console.
mov dx, OFFSET msg : This instruction loads the offset address of the
variable msg into the Dx register. This means Dx will contain the memory
address where the string message is stored.
int 21h : This is the software interrupt 21h, which is a DOS interrupt used
for various system services. In this context, it's typically used to invoke DOS
functions. The specific function to be executed is determined by the value in
the AH register, which in this case is 09h. When AH is set to 09h, it indicates
that the program intends to print a string to the console. The address of the
string to be printed is expected to be in the DX register
hlt : This instruction halts the processor. It's used to end the program
execution.
So, this code can be used to print the message "the national school of artificial
intelligent" to the console using DOS system calls.
2. Process Management
Exercise 01
Exercise 02
Exercise 03
Exercise 04
Exercise 05
Exercise 06