Assembly / OS development...

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.
Post Reply
SteveA

Assembly / OS development...

Post by SteveA »

Hi.

About a year ago I got interested in OS development, but, there was one problem: I had no grasp on the assembly language. This problem still exists for me today.

Now, I don't want to learn assembly by coding things on the Win32 platform. Every tutorial I have found was related to Windows. I am looking for a large tutorial / information resource that doesn't deal with Windows but deals with 32bit and 16bit programming. So, I'm hoping somebody from here can point me in the right direction! (I'm looking for something that has in depth information on the instructions, terms, etc.)

Thanks,

- Steve :)

(Also, sorry if this is in the wrong section.)
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:Assembly / OS development...

Post by Solar »

Art of Assembly, DOS 16bit edition. Don't worry about the title, it's just what you are looking for: he low, nitty-gritty level of ASM coding. There are occasional mentions of DOS functions in there, but you can easily spot and skip them.
Every good solution is obvious once you've found it.
Dex4u

Re:Assembly / OS development...

Post by Dex4u »

For me this is one of the biggist draw backs with asm, 99% of tuts are written for dos realmode 16bit, which is great to start with, but you soon see the limits of realmode.
Than you move onto say win32 asm programming and you get a big shock, it totally differant, this is when most people move to C etc.
What you need to be-able to move from realmode, but not have to relearn most of what you have already learnt.

I was in the same position, that one of the reason i made my OS, for people like you.
So would learn the basics for dos assembly and then move onto a OS like Dex4u or MenuetOS
Dex4u now has it's own text editor and fasm port, along with asm tuts (but they do assume some knowledge of asm).
Dex4u hello world example

Code: Select all

use32
ORG 0x200000
start:
        mov   esi,msg1
        mov   ah,9
        int   40h

        ret

msg1:   db "Hello world! ", 0 
Note the int number is 40h instead of 21h, but the function number is the same as Dos "display string".

As for 32bit asm tut, here one that may help:
http://www.drpaulcarter.com/pcasm/
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:Assembly / OS development...

Post by Solar »

Hmm... my experience in IA32 assembler is very limited, so forgive me if I ask - but isn't it like, when you know how to code in real mode, that doing protected mode ASM is merely an extension on already-established principles? I.e., isn't real mode the more difficult to learn?

And I understood that the one thing Steve is actually not interested in is Win32 ASM...
Every good solution is obvious once you've found it.
distantvoices
Member
Member
Posts: 1600
Joined: Wed Oct 18, 2006 11:59 am
Location: Vienna/Austria
Contact:

Re:Assembly / OS development...

Post by distantvoices »

32 bit asm extends 16 bit asm. Some things work differently (f. ex. the int instruction triggers a completely different tree of micro code)

If you have understood the principle behind and that you have to walk more by foot than with a high level language, you can do quite nifty stuff in asm - just don't forget to check flags, keep in mind that you have more variants to do conditional jumps than in c (jne,je, jz,jnz etc...)

More important than "I wanna code in asm" is "I wanna create/implement an algorithm". the language you use is secondary if you can achieve THAT: Thinking in algorithms. Chosing the tool best suited to solve a given set of problems.

Stay safe.
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Assembly / OS development...

Post by Pype.Clicker »

well, it all depends:
- you can take the full power of your 32bit cpu in real mode -- for computing, i mean, that is "lea eax,[ebx+ecx*4]" is still permitted - it will just require extra opcode byte. If that's okay for you, 32-bit from DOS is just okay...
- you may not like to code 32bit asm with windows simply because you don't like windows, in which case any other OS (linux, menuet, dexu) is welcome.
- you may not like to code 32bit asm in windows because you like to toy directly with hardware, in which case you won't like 32bit asm under linux either ... don't know for menuet or dex4u, yet they might be nice "testing" environments.

In any case, The Art of Assembly Programming that Solar pointed out is _the_ reference unless you have better books at hand in your native language.
JAAman

Re:Assembly / OS development...

Post by JAAman »

Solar wrote: Hmm... my experience in IA32 assembler is very limited, so forgive me if I ask - but isn't it like, when you know how to code in real mode, that doing protected mode ASM is merely an extension on already-established principles? I.e., isn't real mode the more difficult to learn?
not really:
the way i look at it, RMode is actually much simple and therefore easier to learn, if you learn it first, PMode becomes little more than a minor extension and some extra flexability (nothing thats true in RMode truely stops being true in PMode)

a lot of people seam to have trouble with RMode segments, but they aren't that difficult, and if you cannot grasp them you stand no chance of understanding PMode segments -- the only difference is that the size and base can be modified, which is a natual extension to RMode, not a simpler replacement

i would recomend beginers start by learning RMode (which contains only the basics of ASM plus an introduction to segments), then PMode becomes simply an extension

though of course, it is quite possible to never learn what segments are (just use flat mode), then if you skip PMode, you never have to deal with (or learn) segments, which could be sean as easier (though paging is still tricky to learn -- esp at the start)
Dex4u

Re:Assembly / OS development...

Post by Dex4u »

I am not a windows person, but that is not the reason i do not like win32 ASM, i would like to program in ASM in windows, but it is just not Worth it.
If you take a look at 90% of non-windows asm code it will have about 10 instruction + regs used over and over again.

But win32 asm is more like a high level language
example win32 asm

Code: Select all

SaveChanges:
;******************************************
;               Save Changes   
;******************************************
   mov   eax, IDNO
   .IF (fFileStatus & CHANGEDbit)
      invoke   MessageBox, hMainWnd, ADDR szSaveChanges,
         ADDR szClassName, MB_YESNOCANCEL + MB_ICONWARNING
      .IF (eax == IDYES)
         call   CmdIDM_SAVE ; returns FALSE to CANCEL
         LocalReturn       ; or TRUE to continue
      .ELSEIF (eax == IDCANCEL)
         zero   eax   ; return FALSE to CANCEL
         LocalReturn
      .ENDIF
   .ENDIF
   mov   eax, TRUE
;******************************************************
   LocalReturn
Could be pascal code.
I think your best off using delphi, visual basic, c++ for win32.
And all things being = ,32bit pmode is easier to program for than realmode, but theres the problem, thinks do not stay =, you go from a environment that lets you have direct hardware access to a protected environment that does not.
llama-X

Re:Assembly / OS development...

Post by llama-X »

I learned assembly by learning on some old 8-bit processors first, 6502 and 6809. Once I had a good grasp on them, and on the theory of what those instructions were actually doing, then I started in Intel tutorials and on my shelf is the 32-bit PPC manual (that one I haven't gotten to yet :P)

...it may be unorthodox, but I found that older 8-bits gave me a firmer grasp on the theory of what I was doing with my instructions, rather than a specific hardware platform and how it works. The only drawback is that sometimes I find myself in the middle of writing C++, thinking about what instructions the compiler is going to turn my code into :P
dh

Re:Assembly / OS development...

Post by dh »

PCASM is a good book, though I've been lazy reading it :(. I recommend u make a "cheat sheet" of things as you go along to help remind yourself without searching (thus wasting time) for information. Not to mention that when you write type things out, your more prone to remember (or so says the papers I support :D).

Do yourself a favour and stay FAR FAR away from languages like Visual Basic and the like. I have used VB for about 5 years ("plain" basic 10 before that or so) and it WILL introduce many bad things into your style that ARE VERY HARD TO GET RID OF. I'm still making a migration to C++ (and ASM), but that's proven to be a bit of a task, as VB masks many "nasty" things from you.

Cheers, DH.
JAAman

Re:Assembly / OS development...

Post by JAAman »


But win32 asm is more like a high level language
example win32 asm
this is a matter of choice not design, this example you gave, is someones choice of method -- it is in no way related to "win32 asm", and could very easily represent programming under any OS, or even OS independant, while it is quite easy to program more traditional styles of ASM under windows without any problems


your right, that example code looks like a higher level language, -- and nothing like any win32 ASM i've ever seen in my life

i haven't done any win32 ASM programming (though i have looked at some, but none of it looked anything like what you have), but i do know this coding style has nothing to do with win32, and is simply the authors preference (though, by the looks of it, this author would be much more comfortable in VB)
Post Reply