1.

Solve : Regarding CPU registers?

Answer»

Do CPU-registers contain data, or just instructions for MANIPULATING data contained in the RAM?


I know they contain 'values' too, but I'm not sure what these are. Is a value a form of data? Could someone explain values in terms of the following scenario:

Quote

person opens a .txt FILE containing the following text: "hello hello"
The code you have is on a STORAGE device, like a Hard drive.
Humans write code in a 'high level' language that is easy for people to read.
I am human, so this is how I might try.

Suppose I call the registers I want to use:
AX, BX, CX, DX, EX
And say that print_cha  is a number
The code to say "hello hello" would consist of the following.
Quote
Initialize the program.
load a register DX with a pointer to a string.
load another register, CX  with the length of the string.
Loop here
load another register,  BX  with the value in the memory pointed by DX
Load AX with the function number print_char
Call the system
increment the pointer in DX
decrease   the number in CX
If it is not yet  went to zero, go back to loop here
Load AX with 75
Call system
String: hello hello
Oh my! I never used EX. No matter.
That is not real code, but close to what a human might write.
Forum rules prevent me from using real binary code.
Does that answer your QUESTION?

The above was for a CPU that has many registers. Would you like to see what can be done with CPU with not enough registers? Apple did that years ago with the Apple ][ PC way back when I can't remember. But I did have one, or two.

It was called the Apple ][ because I could not buy just one.  hey MAN thankyou! yes that does answer my question, seeing examples really helps


Discussion

No Comment Found