OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Mar 19, 2024 12:11 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 13 posts ] 
Author Message
 Post subject: This is a tough nut to crack
PostPosted: Sat Feb 13, 2016 8:52 pm 
Offline
Member
Member

Joined: Tue Sep 23, 2014 6:12 pm
Posts: 144
I followed a tutorial on the wiki on Babysteps part 1 for creating a basic bootcode in ASM, and after I had that success I decided that maybe it was time to move on to learning about actual systems architecture to grasp more Assembly. Unfortunately, everything is still heavy reading at the moment, and not sure where is a good idea to move forward. I'm very intelligent, but I learn best when I learn things my own way.

Sure, I am pretty confident in the basic stuff (binary and hex notations, obviously, and little things like the bootsector starting at 0x07c0, or some hex number like that), but all I seem to be doing is running around in circles and viewing the same web pages over and over again, it's not helping me.

I know I need to be able to figure stuff on my own, but I'm just getting burned out. I feel how you guys must feel.


Top
 Profile  
 
 Post subject: Re: This is a tough nut to crack
PostPosted: Sat Feb 13, 2016 9:22 pm 
Offline
Member
Member
User avatar

Joined: Sun Sep 19, 2010 10:05 pm
Posts: 1074
Yes it's easy to get frustrated when things don't just work on the first try. There are threads on here with suggestions and such, but one thing I would suggest is to stay within you comfort zone as much as possible. When making changes to your code, make one minor change at a time, and recompile and test that everything is still working like you expect. Change too many things, and you'll find yourself spending hours trying to fix an issue that turns out to be a side effect from an earlier issue that you didn't even notice until now.

Good luck. Just reading this site keeps me pretty motivated to keep going. :)

_________________
Project: OZone
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott


Top
 Profile  
 
 Post subject: Re: This is a tough nut to crack
PostPosted: Sun Feb 14, 2016 5:55 am 
Offline
Member
Member

Joined: Sun Feb 01, 2009 6:11 am
Posts: 1070
Location: Germany
What you're describing sound a lot like you're trying to understand the full theory of everything before you start to put it to use. There are some people who learn very well this way; there are some members of the Lowlevel community who used to help newbies (successfully) without actually having written a kernel of their own.

However, this might not be your learning style. I see that when you set yourself the goal "hello world bootloader", you completed it in a short time. Maybe what you need is learning by doing, setting yourself the next goal for your "OS" and then implementing it. For example, you could try to extend your bootloader so that the user can enter their name and it says "Hello <name>". And then as the next step, let the user enter two numbers and print the sum. Just take small steps and implement the next thing that you view as the logical extension of what you already have.

_________________
Developer of tyndur - community OS of Lowlevel (German)


Top
 Profile  
 
 Post subject: Re: This is a tough nut to crack
PostPosted: Sun Feb 14, 2016 3:36 pm 
Offline
Member
Member

Joined: Sat Mar 01, 2014 2:59 pm
Posts: 1146
Kevin wrote:
there are some members of the Lowlevel community who used to help newbies (successfully) without actually having written a kernel of their own.
I think I'm a bit like that sometimes ;-) .

_________________
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.

Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing


Top
 Profile  
 
 Post subject: Re: This is a tough nut to crack
PostPosted: Sun Feb 14, 2016 4:59 pm 
Offline
Member
Member

Joined: Tue Sep 23, 2014 6:12 pm
Posts: 144
I think I'm just having problems understanding the structure and how the operands work of x86 Assembly more than the individual instructions. I'm still trying to wrap my head around registers. I know they are supposed to be on-CPU memory stores, but what exactly is the difference between all of them? The concept for them being copied to other registers sounds weird and confusing too. :?


Top
 Profile  
 
 Post subject: Re: This is a tough nut to crack
PostPosted: Sun Feb 14, 2016 7:32 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5069
Which registers are confusing you? What copying are you talking about?


Top
 Profile  
 
 Post subject: Re: This is a tough nut to crack
PostPosted: Sun Feb 14, 2016 7:40 pm 
Offline
Member
Member
User avatar

Joined: Wed Aug 05, 2015 5:33 pm
Posts: 159
Location: Drenthe, Netherlands
You might find this to be of your liking. It gives step by step insight into how a computer system works by building (a simple) one from the ground up. It'll give you a guided taste into many different aspects of computer science. I especially think you'll like the hardware part and that you'll get allot of new insights out of it besides answering allot of the questions you seem to have.

As a bonus you could write a emulator for the cpu in that course and get some solid programming experience.

_________________
"Always code as if the guy who ends up maintaining it will be a violent psychopath who knows where you live." - John F. Woods

Failed project: GoOS - https://github.com/nutterts/GoOS


Top
 Profile  
 
 Post subject: Re: This is a tough nut to crack
PostPosted: Sun Feb 14, 2016 7:46 pm 
Offline
Member
Member

Joined: Tue Sep 23, 2014 6:12 pm
Posts: 144
I'll check this one out.


Top
 Profile  
 
 Post subject: Re: This is a tough nut to crack
PostPosted: Wed Feb 17, 2016 7:43 am 
Offline
Member
Member

Joined: Wed Jun 03, 2015 5:03 am
Posts: 397
SeanMc wrote:
I'm still trying to wrap my head around registers. I know they are supposed to be on-CPU memory stores, but what exactly is the difference between all of them? The concept for them being copied to other registers sounds weird and confusing too. :?

To have some information we need it to be perceptible. Until we can feel it the information doesn't exist. That's why machines have means of recording an information. Electrical machines (computers in particular) often use the electric potential level as a sign of "something is there" (an information about something). That's how computer's memory works. It sets one voltage level for the bit 0 (zero) and another level for the bit 1. But there's much more information in the world than one bit can hold. So, people invented bytes (8 bits), kilobytes, megabytes and so on. And every bit in those megabytes is one of the voltage levels - one level for 0 and another for 1.

Next goes memory structure. If we have enough memory it doesn't mean the memory fulfills all our needs. One particular need is the speed with which the computer does it's job. When there is a lot of memory the time required to access it increases significantly. That's why people decided to create another piece of memory, but with another name - the registers. The registers are small pieces of memory and because of the size it is possible to place them somewhere near the computer's processor. If something is near the access speed is increased. So, the registers can be viewed as a "fast" memory. And all that they are needed for is the speed. Would there be no need for speed there would be no registers.

Next goes computer's job. The job is about calculations and sending results to a device, where people can see it. So, there's a need for sending information. To send an information we need a piece of hardware with the same voltage levels as the another piece has. It is just a copy of the voltage levels. When there's no copy - the information wasn't sent. But when the copy is there - we just have sent the information from one device to another. It applies to every piece of the computer electronics. Also it applies to the registers. If we ordered the processor to execute a move instruction (register to register) it means the processor just connected it's internal lines between two registers. If the move instruction involves memory then the process is more complicated and involves additional chips and somewhat tricky algorithms. That's why processor to memory communication is slow (if to keep it simple).

Next goes the need for register to register information movement. It's partially the hardware issue. Internal processor's lines connect registers with processor's calculation unit (arithmetic logic unit or ALU). But in the process of processor evolution there was time when not all registers were connected to the ALU and some operations were possible only for a particular register. It means if we have our information in the register it doesn't mean we actually can use it and just have to copy it to another register. But sometime we need the copy because of the algorithm involved. For example - to calculate a square of a number we need to multiply the number with itself, so, we have a need for another copy of the number.

Well, now it should be simple enough - there's just some voltage levels and they just represent our information. When we want to use our information we often have to copy it because of the need for speed or hardware issues or just because of the algorithm involved. And the best way for a processor to access the information is to read it from processor's registers. That's why we need to copy our bits (voltage levels) from one register to another.

_________________
My previous account (embryo) was accidentally deleted, so I have no chance but to use something new. But may be it was a good lesson about software reliability :)


Top
 Profile  
 
 Post subject: Re: This is a tough nut to crack
PostPosted: Wed Feb 17, 2016 2:32 pm 
Offline
Member
Member

Joined: Mon Feb 02, 2015 7:11 pm
Posts: 898
SeanMc wrote:
I think I'm just having problems understanding the structure and how the operands work of x86 Assembly more than the individual instructions. I'm still trying to wrap my head around registers. I know they are supposed to be on-CPU memory stores, but what exactly is the difference between all of them? The concept for them being copied to other registers sounds weird and confusing too. :?


You can think of registers as simple variables. The CPU can only work directly with these variables (registers).

The CPU then needs a way to load values into these variables (registers). This looks like this:

Code:
mov eax, [some_memory_address]


The CPU also needs a way to stores the variables (registers) to memory. This looks like this:

Code:
mov [some_memory_address], eax


The CPU can also copy the value of a variable (register) to another variable (register). This looks like this:

Code:
mov ebx, eax


Certain registers also have special purposes / usages. For example, the stack pointer register (esp) is used for pushing/poping data on/off the stack. The instruction pointer register (EIP) tells the CPU where to find the next instruction to execute. And so on.

_________________
https://github.com/kiznit/rainbow-os


Top
 Profile  
 
 Post subject: Re: This is a tough nut to crack
PostPosted: Wed Feb 17, 2016 10:31 pm 
Offline
Member
Member

Joined: Tue Sep 23, 2014 6:12 pm
Posts: 144
What you listed was already clear to me, except for the last part about the special purpose registers.

So does this mean with the non-special registers, I can use any value or address I want in them?


Top
 Profile  
 
 Post subject: Re: This is a tough nut to crack
PostPosted: Thu Feb 18, 2016 5:36 am 
Offline
Member
Member

Joined: Sat Mar 01, 2014 2:59 pm
Posts: 1146
SeanMc wrote:
So does this mean with the non-special registers, I can use any value or address I want in them?
Yes. Or more accurately, you can put any value or address that you want in them.

_________________
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.

Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing


Top
 Profile  
 
 Post subject: Re: This is a tough nut to crack
PostPosted: Fri Feb 19, 2016 1:00 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
No.

Some of the special purpose registers cannot be written to directly. The most familiar examples would be the CS and EIP registers. Also note that although the other segment registers, the stack pointer, and the flags register are writeable putting random values into them is likely to crash the system. There are also control or error-reporting registers for which the same holds true.

Edit Oops - missed your qualification "non-special". You should still bear in mind that function-calling conventions mandate the use of particular registers. Also, some of the general-purpose registers have specific uses (e.g. the ECX register as a loop counter.)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 10 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group