• Forum
  • Lounge
  • when using low level programming, how do

 
when using low level programming, how does one understand registers and how does addng to them create text?

closed account (2EwbqMoL)
I know a bit about a lot of stuff related to programming and web design, but all too often the basics of computer science and how the machine technically processes information are lost on me and it makes it impossible for me to actually create working, complete applications in any language.


whether its an inventory system in a game, processing input correctly and parsing it, or any other task, I fail miserably when trying to solve the problems I am faced with using the tools at hand.

I attribute the same thing to not understanding what this topic is about -- and I intend to learn these basics and thought this was a good starting point.

I saw online the Ook Ook and brainfuck languages, and thought to myself -- turing complete or not -- this doesn't make any sense and is impossible to use for anything -- even if you were a supergenius it doesn't seem to have the capabilities of BASIC or C++ or java or anything...

but since it IS turing complete -- and ive seen this one and a dozen other languages create usable programs and even simple text ones... because of this I KNOW I am wrong and somehow the variables being modified can signify more to the machine.

how does it make sense to simply move around bytes in registers and have that turn into something more than just the number one in a hex address/register or whatever?

how is it possible to move bits between registers and know that since I added 2 here, 6 there, and 7 wherever that it will say hello world from this...

and furthermore, even if I WERE to figure out where each ASCII character were located in memory, how exactly would this be positioned on the screen? By another memory address somewhere I could add or subtract to?


is there a specific register for every available space for a character or number?

the base functionality of this is a mystery to me. Ive avoided all attempts at even bothering to go into lower level programming because of it.

I know I could send the processor direct messages, but it seems like any way of communicating with it would require me to utilize such a specific set of instruction as to be totally useless in all circumstances.

even if speed was an issue, it would simply be impossible to work with something as complex as a game in low level -- how would I be able to speed it up when I have so many layers of high level code on top that it would take 5 seconds to write it in high level code, but days to figure out how to simply manipulate one thing in lower level.


there must be some kind of simpler way to understand what registers do what and why -- to understand the basic functioning of the machine in order to allow me to figure out how to work WITH it rather than against it, and to be able to solve problems and have some idea where they are coming from.

because right now, all I'll ever be good for is copying tutorial code -- I've become of the mind after a long time of trying to learn to code, that knowing the basest ways in which this works is essential in the long term when trying to really make something work without knowing where to start.
It can be helpful to know the details of how computers work but I don't think it's a requirement. When programing in a programming language you only need to know the rules of the language. The compiler will handle the low-level details for you.

Ook Ook and brainfuck are just toy languages that are hard for humans to read. Yes, they are turing complete but so are C++ and most other programming languages so I see no reason to use them.

When programming in assembly it is necessary to know what registers are but in C++ you don't need to think about them. It is possible to mix assembly and C++ but it won't automatically make your code faster. C++ compilers are able to optimize the code so it will run fast. To write something better in assembly by hand you would have to think hard, spend a lot of time, and often it's not worth it.

The computer memory is simply a large collection of bytes. To make sense out of the bytes you need to know where things are stored, how large they are, etc. You can't just look at a sequence of bytes and know what it is (sometimes it's possible to guess).

ASCII text is a sequence of bytes in memory (usually terminated by a null character, i.e. zero byte). If you write a C++ program that outputs a simple text...
 
std::cout << "Lion\n";
... the output will be received by another program (on Windows this is usually the Command Prompt). This other program usually displays the text on the screen. Exactly how this is done is up to the program. Note that the receiving program assumes the output is text and it also has to assume what character encoding is used. If your program and the program that receives the output uses different encodings some characters might not be displayed correctly.
Last edited on
Its my opinion that everybody's mind is wired just a little different. A lot of folks just take for granted a lot of stuff, and are able to move on with what they do know and relegate to the unnecessary category what they don't know. In your case you do seem to want to know these lower level details (I'm the same way), so you might want to consider taking a shot at C coding and C books for a while. Now I fully realize a lot of C++ coders consider that unnecessary, but I'm recommending it due to the fact that tutorials, books, whatever, in C usually cover the sorts of things that seem to be holding you back. And whatever you learn in that context won't hurt you.

These things were perhaps easier to understand back in the old days of DOS. In that operating system a certain portion of RAM was mapped directly to the video display, and fonts didn't exist yet to complicate things (in early DOS). So if a certain quantity was in memory at the right place, it would show up on the screen as a text character. Stuff's a good bit trickier now!
These things were perhaps easier to understand back in the old days of DOS. In that operating system a certain portion of RAM was mapped directly to the video display

Nothing has changed, at least not at that level, and you still need to go through it if working at that low of a level. The operating system abstracts most of that now, and that is what makes it different.

There is nothing you can do in C that you cannot do in C++, so unless you are working with legacy code, there is no reason to take a step backwards. As far as I know, manipulating registers is not possible in either language, and even if it is, it is better to use assembly for those tasks.

and furthermore, even if I WERE to figure out where each ASCII character were located in memory, how exactly would this be positioned on the screen? By another memory address somewhere I could add or subtract to?

Assembly usually uses hex values. It has been a while, and I do not remember which registers determine position, color, or any of that. The high bit(or low?) determines foreground and background color, while the other determines position, if I remember right. A quick search brought this up:
https://www.youtube.com/watch?v=DBBYFYgvc0Y
He probably brings up positioning in a different video.

all I'll ever be good for is copying tutorial code

Copying code is fine, IF you understand what it is doing. Step through it with a debugger and look at what changes on each line. Once you understand why each change happened, you will understand what is happening.
all I'll ever be good for is copying tutorial code

You may be trying to run before you learn to walk. Try writing some simple programs by yourself. Pay careful attention to the syntax of the language. Some common examples of simple program are:
- determine if a given number is prime.
- Draw an ascii triangle with a given base size.
- Play high-low: have the computer pick a number between 1 and 100. You make a guess and the computer tells you if you are high, low, or correct. Count the number of guesses that it takes to get the right number.

If you've tried these sorts of things and still feel that you need to know some low level details, then consider getting an arduino kit. These small computers let you interact directly (more or less) with electrical devices and will give you a sense of how computers work at a low level.
Topic archived. No new replies allowed.