Printing newlines
-
- Member
- Posts: 30
- Joined: Sat Dec 12, 2020 8:30 am
Printing newlines
Okay I promised I'd never come back to annoy people in this forum, but I have no idea what
"in terminal_putchar check if c == '\n' and increment terminal_row and reset terminal_column." means, so can someone help me get my OS to support newlines (\n)?
"in terminal_putchar check if c == '\n' and increment terminal_row and reset terminal_column." means, so can someone help me get my OS to support newlines (\n)?
Re: Printing newlines
So think about is this way. Let's say I call terminal_writestring("hello, world\n"), '\n' equals some sort of ASCII char code. So, to print a new line, before we actually print the character on screen (i.e., into the buffer 0xB8000), then we check if the current char equals '\n', and then increment terminal_row, and zero terminal_column. If you have no clue what I just said, then check out http://www.brokenthorn.com/Resources/OSDev10.html, which explains text mode. Note that it is is ASM, however.
Re: Printing newlines
Given the cursor at some location (row,column) on the screen, you move it to (row+1,0).
I hope you're familiar with Two-dimensional space?
The only difference here is that typically row=0 at the top of the screen and increases downwards while y=0 at the bottom and increases upwards.
I hope you're familiar with Two-dimensional space?
The only difference here is that typically row=0 at the top of the screen and increases downwards while y=0 at the bottom and increases upwards.
Re: Printing newlines
No offence intended, but this is elementary stuff... it only gets harder from here on!hausemaster wrote:Okay I promised I'd never come back to annoy people in this forum, but I have no idea what
"in terminal_putchar check if c == '\n' and increment terminal_row and reset terminal_column." means, so can someone help me get my OS to support newlines (\n)?
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
Discord:https://discord.gg/zn2vV2Su
- Schol-R-LEA
- Member
- Posts: 1925
- Joined: Fri Oct 27, 2006 9:42 am
- Location: Athens, GA, USA
Re: Printing newlines
This is a question which comes up about once a month here, as it understandably is confusing to new OS devs until they've had a chance to sit down and think it out. A quick search on the topic in the forum search bar should find several explanations for how to solve the issue. This recent post covers it in detail.
Rev. First Speaker Schol-R-LEA;2 LCF ELF JAM POEE KoR KCO PPWMTF
Ordo OS Project
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.
Ordo OS Project
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.
-
- Member
- Posts: 30
- Joined: Sat Dec 12, 2020 8:30 am
Re: Printing newlines
Thanks for not beating me up about basic stuff! I'm starting to get it now, but I'm sure you understand this can be hard for beginners.
-
- Member
- Posts: 30
- Joined: Sat Dec 12, 2020 8:30 am
Re: Printing newlines
Okay, so I figured out how to print newlines, it makes so much sense, but I still get the weird block character? It does the newline, but it also prints out the character before it switches lines.
Re: Printing newlines
Yeah... don’t write anything to the text buffer when you encounter the ‘\n’ character.hausemaster wrote:Okay, so I figured out how to print newlines, it makes so much sense, but I still get the weird block character? It does the newline, but it also prints out the character before it switches lines.
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
Discord:https://discord.gg/zn2vV2Su
-
- Member
- Posts: 30
- Joined: Sat Dec 12, 2020 8:30 am
Re: Printing newlines
Oh well yeah if I knew how to do that I would have already done it.
Re: Printing newlines
Well, if you look at the code you wrote which puts a character in the text buffer, don’t do that when the character is a newline.hausemaster wrote:Oh well yeah if I knew how to do that I would have already done it.
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
Discord:https://discord.gg/zn2vV2Su
-
- Member
- Posts: 30
- Joined: Sat Dec 12, 2020 8:30 am
Re: Printing newlines
yeah osdeving is probably pretty hard, atleast for a kid.
Re: Printing newlines
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.hausemaster wrote:yeah osdeving is probably pretty hard, atleast for a kid.
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)!
Last edited by bloodline on Tue Dec 22, 2020 7:12 pm, edited 1 time in total.
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
Discord:https://discord.gg/zn2vV2Su
-
- Member
- Posts: 30
- Joined: Sat Dec 12, 2020 8:30 am
Re: Printing newlines
yeah, I'm pretty good with C++ and alot of the popular high-level languages, but I'm not the best with C or Assembly.
Re: Printing newlines
If we look at it as a hobby, there's rarely something for which you'd need a college degree (some fundamental school math is mostly what there is), but there's plenty of knowledge overall that's needed nonetheless. And a lot of patience. The less you know the more patience you need. And time, of course.hausemaster wrote:yeah osdeving is probably pretty hard, atleast for a kid.
I'd seriously advise against doing osdev now if you have to ask the kind of question you did. But there's no harm in giving it a try. Just be aware that it may prove too heavy right now. There's nothing to be ashamed of if you fail now and get back to it later.
Re: Printing newlines
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.
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.
Skylight: https://github.com/austanss/skylight
I make stupid mistakes and my vision is terrible. Not a good combination.
NOTE: Never respond to my posts with "it's too hard".
I make stupid mistakes and my vision is terrible. Not a good combination.
NOTE: Never respond to my posts with "it's too hard".