Printing newlines

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
moonchild
Member
Member
Posts: 73
Joined: Wed Apr 01, 2020 4:59 pm
Libera.chat IRC: moon-child

Re: Printing newlines

Post by moonchild »

bloodline wrote:Operating system development is probably second only to compiler writing in terms of difficulty
Having done both (though admittedly somewhat less on the osdev side), I'm not sure this is fair.

Compilers do get somewhat heavier on the math side; but that's par for the course, and the same is true of machine learning, graphics programming, etc. In terms of scope, I don't think anything beats os development.
StudlyCaps
Member
Member
Posts: 232
Joined: Mon Jul 25, 2016 6:54 pm
Location: Adelaide, Australia

Re: Printing newlines

Post by StudlyCaps »

rizxt wrote:You don't know how to conditionally not do something?
I think they know how to do it, they probably just forgot to make it not print the '\n' as a char. Still, I think hausemaster might be trying to learn how to swim by jumping in the ocean.
User avatar
iansjack
Member
Member
Posts: 4703
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Printing newlines

Post by iansjack »

rizxt wrote:I would suggest learning how to code before you write an OS.
O would some power the giftie gie us to see ourselves as others see us.
User avatar
bloodline
Member
Member
Posts: 264
Joined: Tue Sep 15, 2020 8:07 am
Location: London, UK

Re: Printing newlines

Post by bloodline »

iansjack wrote:
rizxt wrote:I would suggest learning how to code before you write an OS.
O would some power the giftie gie us to see ourselves as others see us.
=D> Very good sir! :lol:
CuriOS: A single address space GUI based operating system built upon a fairly pure Microkernel/Nanokernel. Download latest bootable x86 Disk Image: https://github.com/h5n1xp/CuriOS/blob/main/disk.img.zip
Discord:https://discord.gg/zn2vV2Su
hausemaster
Member
Member
Posts: 30
Joined: Sat Dec 12, 2020 8:30 am

Re: Printing newlines

Post by hausemaster »

rizxt wrote:You don't know how to conditionally not do something?

What????

I would give you some leeway in assembly land... but this is extremely beginner stuff, for basic programming.

I would suggest learning how to code before you write an OS.

Learn how to read before you write a book.
Don't tell me "learn how to code", this is something I already know. So **** off before you decide to insult me again. This is why I left the forum on my other account. You keep discouraging me, and raping me.
Doctor5555
Posts: 14
Joined: Sat Oct 10, 2020 4:05 pm

Re: Printing newlines

Post by Doctor5555 »

I'd recommend that you read http://www.catb.org/~esr/faqs/smart-questions.html before asking more questions here. That page is also linked in the "FORUM RULES" announcement post, item #4.
Doctor5555
Posts: 14
Joined: Sat Oct 10, 2020 4:05 pm

Re: Printing newlines

Post by Doctor5555 »

By the way, don't be discouraged by what has been said above. Programming an OS is difficult even for the best coders in the world, but it is just like coding anything else for the most part, with a little bit of added assembly and much more interesting problems.
If you are more comfortable with C++ than C, then you can use C++ without the standard library instead once you have implemented constructors and destructors, although it will take more effort to set up the standard library later.
hausemaster
Member
Member
Posts: 30
Joined: Sat Dec 12, 2020 8:30 am

Re: Printing newlines

Post by hausemaster »

I've fixed it, infact it was VERY easy. But terminal scrolling?

Edit: I have officially given up on this project, and realize I'm far too dumb to accomplish anything. glad you guys helped me come to my senses, probably gonna kill myself later, idk
User avatar
bloodline
Member
Member
Posts: 264
Joined: Tue Sep 15, 2020 8:07 am
Location: London, UK

Re: Printing newlines

Post by bloodline »

hausemaster wrote:I've fixed it, infact it was VERY easy. But terminal scrolling?

Edit: I have officially given up on this project, and realize I'm far too dumb to accomplish anything. glad you guys helped me come to my senses, probably gonna kill myself later, idk
Why not have a go at implementing a scroll algorithm? Try out a few different ideas, then you can present them here and we can explain where you have had some good ideas, and where you have made some bad decisions.

There isn’t any point one of us just telling you how to do it, as you won’t learn anything... you might as well just cut and paste from somewhere.
CuriOS: A single address space GUI based operating system built upon a fairly pure Microkernel/Nanokernel. Download latest bootable x86 Disk Image: https://github.com/h5n1xp/CuriOS/blob/main/disk.img.zip
Discord:https://discord.gg/zn2vV2Su
hausemaster
Member
Member
Posts: 30
Joined: Sat Dec 12, 2020 8:30 am

Re: Printing newlines

Post by hausemaster »

bloodline wrote:
hausemaster wrote:I've fixed it, infact it was VERY easy. But terminal scrolling?

Edit: I have officially given up on this project, and realize I'm far too dumb to accomplish anything. glad you guys helped me come to my senses, probably gonna kill myself later, idk
Why not have a go at implementing a scroll algorithm? Try out a few different ideas, then you can present them here and we can explain where you have had some good ideas, and where you have made some bad decisions.

There isn’t any point one of us just telling you how to do it, as you won’t learn anything... you might as well just cut and paste from somewhere.
blah blah fine fine, I'll try something.. that is if I didn't delete everything, I gotta redo my compiler and all that ****, honestly it's too much work, I'm not going to make any money off of it, so it's not worth it. I've wanted to do this for all my life, since I was a kid, but now it makes me want to die. Programming was always hard for me, but the payoff was amazing everytime, that's why I did it. But this, this is just pain. I've been sitting at my terminal for hours trying to figure out the most easiest thing ever. This truly helped me realize I'm far too stupid for anything in the world, It's not worth living if I know I'll never do anything great. I'm sorry everyone, you've been wonderful, I've been the bad person. I'm sorry. Goodbye.

-Hausemaster
User avatar
eekee
Member
Member
Posts: 891
Joined: Mon May 22, 2017 5:56 am
Location: Kerbin
Discord: eekee
Contact:

Re: Printing newlines

Post by eekee »

Hausemaster: In programming, sooner or later, everyone finds themselves stuck for hours or days or weeks on something which turns out to be really simple in the end. IMO, you're not a real programmer until you've experienced that at least once. ;) I know a good kernel dev who has said "I am stupid" more than once over this sort of thing. Eventually, I think you learn tricks to get around the block, much like professional writers (or long-form webcomicers ) learn how to get around writers block.

I do think you have made a mistake: Someone told you to use an if condition, and you replied, "I don't know how to do that." Yeah, right! :lol: I'm certain you do know how to do it because you can write C++ and assembler. There are no if conditions in hello world, but any program of any interest at all has them, so I know you know how to know them! (In assembler, the equivalent is conditional jumps.) I think other forum posters were much too quick to tell you this is too hard for you instead of thinking about what you said you could do.

:evil: *glares at certain other forum posters* :evil:

I totally get that amazing payoff feeling when you succeed at programming. :D
Kaph — a modular OS intended to be easy and fun to administer and code for.
"May wisdom, fun, and the greater good shine forth in all your work." — Leo Brodie
User avatar
bloodline
Member
Member
Posts: 264
Joined: Tue Sep 15, 2020 8:07 am
Location: London, UK

Re: Printing newlines

Post by bloodline »

hausemaster wrote: blah blah fine fine, I'll try something..
That’s the spirit!
that is if I didn't delete everything, I gotta redo my compiler and all that ****, honestly it's too much work, I'm not going to make any money off of it, so it's not worth it.
That’s not how eduction works.
I've wanted to do this for all my life, since I was a kid, but now it makes me want to die. Programming was always hard for me, but the payoff was amazing everytime, that's why I did it. But this, this is just pain.
No pain, no gain.

The more difficult something is to do, the more rewarding the completion of the task.
I've been sitting at my terminal for hours trying to figure out the most easiest thing ever. This truly helped me realize I'm far too stupid for anything in the world, It's not worth living if I know I'll never do anything great. I'm sorry everyone, you've been wonderful, I've been the bad person. I'm sorry.
I cannot comment upon your intelligence, but I would err that you perhaps lack the temperament for computer programming.
CuriOS: A single address space GUI based operating system built upon a fairly pure Microkernel/Nanokernel. Download latest bootable x86 Disk Image: https://github.com/h5n1xp/CuriOS/blob/main/disk.img.zip
Discord:https://discord.gg/zn2vV2Su
Seasoft
Posts: 20
Joined: Wed Sep 02, 2020 3:09 am

Re: Printing newlines

Post by Seasoft »

bloodline wrote:
hausemaster wrote:yeah osdeving is probably pretty hard, atleast for a kid.
Operating system development is probably second only to compiler writing in terms of difficulty. Not only do you need to know your target hardware extremely intimately, you must also have a clear understanding of the programming language you plan to use, and to really muddy the waters you also need to understand the different operating system paradigms well enough to know which fits your use case.

From the questions you are asking, it seems like you are new to C, if this is true, you would do well to spend some time working through some c exercise projects. Perhaps buy an Arduino and learn more about low level hardware concepts, like interrupts and bitwise operations. These things you will need to know.

-edit- Don’t be discouraged, the rudiments of my OSDev project can trace their design roots back to my first kernel sketches written when I was 14 (which is why they are heavily 68k oriented)!
I'm actually having the same issue as hausemaster is having above, I incremented the row and zero'd the column part, but I wasn't able to get rid of the stragne ASCII block character. I don't know how to prevent a certain char from being rendered or its only on the tip of my tongue.
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: Printing newlines

Post by neon »

Hi,

General advice on debugging... Sometimes it can be helpful to write out and walk through a higher level logic flow of what you want the code to do. This can be writing pseudo code and literally reasoning to yourself by walking through it while feeding in different scenarios. Don't copy and paste code that you are not able to follow the control flow of; instead build it up and you'll see the problem and be able to correct it and any potential future bugs with it. Typically when it comes to more complicated code, I write a series of comments first following all potential cases and the expected control flow and work on it a bit at a time -- splitting it into more functions as needed and building it bottom-up. It can also be helpful with writing something in a userland test program first and porting it to facilitate debugging. Sometimes it can be helpful to write small unit tests as well for internal testing of bugs of code currently being worked on. Finally, quite possibly the very first thing you should be doing is enabling the serial port and redirecting output to a file (at first). You can send the characters as numbers whenever you are printing it out and you'll see the exact character that the code is trying to print as a []. It can be a newline, but if this is part of a string it can also be a carriage return depending on how new lines are being handled. It can also be a garbage character on the stack if it prints out something uninitialized or something results in the code entering on unexpected state. If it is indeed printing out the newline, then you must prevent it somehow -- a return, break, continue, whatever is needed depending on what the code looks like. If you aren't sure, follow the high level control logic of it -- some control path is allowing it.

In any case, I'd be interested to see what the code looks like for review. If this is indeed a common error, it might be helpful to discuss why and add it to the Wiki. In short...you prevent it from displaying by not displaying it.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
User avatar
iansjack
Member
Member
Posts: 4703
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Printing newlines

Post by iansjack »

Seasoft wrote:I don't know how to prevent a certain char from being rendered or its only on the tip of my tongue.
Well, in your print routine you just process control characters (such as CR and LF) but don't echo them to the screen. How much simpler can it be?
Post Reply