OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Apr 16, 2024 3:30 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 18 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: How do I use my Assembly for operating system developmen
PostPosted: Tue Aug 08, 2017 5:18 am 
Offline
Member
Member
User avatar

Joined: Sun Jul 14, 2013 6:01 pm
Posts: 442
SamTouraz: nobody questioned your knowledge, and nobody wanted to mislead you (do you realize how many approaches are exist to do a kernel), i dont really understand your reactions.

_________________
Operating system for SUBLEQ cpu architecture:
http://users.atw.hu/gerigeri/DawnOS/download.html


Top
 Profile  
 
 Post subject: Re: How do I use my Assembly for operating system developmen
PostPosted: Wed Aug 09, 2017 10:31 am 
Offline
Member
Member

Joined: Wed Aug 09, 2017 7:37 am
Posts: 80
OK, first of all, what architecture (x86, ARM or PowerPC) are you aiming at? If you want to understand about x86, read more of the Intel software developer manuals (if you have already). What assembler are you using? FASM is good if you want to make an OS fully in Assembly (MenuetOS and KolibriOS have used these).

The GDT can be explained at Global_Descriptor_Table. However, there are lots of resources. You will need the GDT (or Global Descriptor Table) to enter Protected_Mode. There is also https://en.wikipedia.org/wiki/Global_Descriptor_Table which looks good.

If you know Assembly, you'll be able to understand this.

If you want to know about 0xb800, check out Printing_To_Screen. I know it is written in C but this is what it does.

= Makes a variable containing 0xb800
= Does a while loop waiting for the character of the string to be 0x00 (null terminator).
= In the while loop, it copies the character to the variable and the color (the bytes).

I might add some Assembly code to the Wiki as a matter of fact. Here's some code (make sure you understand some of it).

Code:
BITS 16
org 0x7c00

jmp Main ; jump to main

Main:
mov dx, 0xb800 ; moves 0xb800 to the data register
mov es, dx ; moves the data register to the extra segment (a little address space)

mov si, msg
mov cx, 0

Print:
lodsb ; get byte from string (character) [SI -> AL]
cmp al, 0 ; is character 0x00? (null terminator)
je Done ; if yes, jump to Done!

mov di, cx
mov [es:di], al ; move character to destination index
inc cx

; these three lines will make all your characters have color (remove this if you want).
mov di, cx
mov [es:di], 0x07 ; you may be familiar with BIOS color attributes - change 0x07 to whatever you want
inc cx ; increment of count register

jmp Print

Done:
mov di, cx
ret

msg db 'Hello World!', 0



The BIOS Parameter Table is only required if you are using a device that is emulating a floppy (like a USB).

Here's a link for help on it which is https://social.technet.microsoft.com/wiki/contents/articles/6771.the-fat-file-system.aspx.

This explains things.

You should implement it like this:

Code:
BITS 16
jmp Start

nop

bpbThis db 0
bpbThis dw 1a49 ; warning - these numbers are examples.
bpbThat db 50


By the way, nobody is trolling you. People are just confused at what information you are giving.


Top
 Profile  
 
 Post subject: Re: How do I use my Assembly for operating system developmen
PostPosted: Thu Aug 17, 2017 6:17 pm 
Offline
Member
Member

Joined: Sat Feb 27, 2010 8:55 pm
Posts: 147
stevewoods1986 wrote:
Code:
BITS 16
org 0x7c00

jmp Main ; jump to main

Main:
mov dx, 0xb800 ; moves 0xb800 to the data register
mov es, dx ; moves the data register to the extra segment (a little address space)

mov si, msg
mov cx, 0

Print:
lodsb ; get byte from string (character) [SI -> AL]
cmp al, 0 ; is character 0x00? (null terminator)
je Done ; if yes, jump to Done!

mov di, cx
mov [es:di], al ; move character to destination index
inc cx

; these three lines will make all your characters have color (remove this if you want).
mov di, cx
mov [es:di], 0x07 ; you may be familiar with BIOS color attributes - change 0x07 to whatever you want
inc cx ; increment of count register

jmp Print

Done:
mov di, cx
ret

msg db 'Hello World!', 0




I want to point out a couple things for the OP, Steve, and anyone else who comes across this thread: The stack is not set up, ds is not initialized, and the direction flag is not cleared. Things things may sound like nit-picking -- and realistically, this code will probably work as expected 99% of the time -- but the 1% of the time it doesn't it'll be a huge pain in the a** to anyone using it, so I thought it was worthwhile to point them out.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ]  Go to page Previous  1, 2

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 606 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