I14R10
Full Member level 3
Can you recommend some literature about microprocessors? I know how to program them, but I don't know about their internal works. How can they be programmed, hot the microprocessor understands that code...
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
int A, B;
A=4;
B=5;
if(A<B){
do something
}
Now, how does it check if the number A is smaller or bigger than number B?
Code Verilog - [expand] 1 2 3 always @* begin if (a < b) do_something end
OK, it checks by using some combination of logic gates. What does that circuit looks like, that was my question? I assume that there are control bits that choose what operation is made - adding, substracting, logical OR, logical AND, logical IF...?
module cmp (
output c,
input [7:0] a,
input [7:0] b
);
assign c = a < b;
endmodule
It depends on which particular microcontroller you are using. They have different sets of instructions available. In general it would go something like
10 - Mov A to the working register
20 - Subtract B from the working register
30 - jump the next line if the negative flag bit is set (implying that A<B)
...
Again I recommend section 2 of https://cache.freescale.com/files/microcontrollers/doc/ref_manual/M68HC05AG.pdf It's a concise explanation of exactly what you are asking.