And again KolibriOS! And again assembler! / Hebrew

And again KolibriOS! And again assembler! / Hebrew

In the last article, I decided to test the assembler on this OS. But I never look for easy ways and that’s why I decided to dive into the world of KolibriOS and program using only this OS. All I was able to find out is that something was done a long time ago and at the moment, unfortunately, a lot has been abandoned.

But not everything is as bad as it seems! KolibriOS has a ready code editor with backlight CEdit, and it supports highlighting for multiple programming languages. But I’m not sure that it can compile for all these languages. But at least you can type the text. Fasm is fully supported and you can compile/run/debug programs “using” this editor (not really, the editor starts the compiler separately and also starts the debugger separately), which allows you to fully develop programs.

I would like to warn you right away, there will be practically no teaching in the article. Everything is calculated on the fact that you already know at least a little x86 assembler and have already created simple programs for this architecture (under Windows, Dos, Linux, and maybe MacOS).

Emerging issues

IN: Why learn assembly, especially x86 nowadays?
(the answer is not mine, this answer has been circulating on the Internet for years)
About: If you ask yourself such a question, then you do not need it (the answer is not mine, this answer has been circulating on the Internet for many years).

IN: Why did I choose to use assembler in KolibriOS and not in Windows or Dos? Or at the very least, Linux. After all, there is much more material for them.
About: I’ve already trained for the listed OSes, I’m interested in something new. And this allows me to delve a little into the development for different OSes, which means more understanding of how to work with different OSes. Where to look for information, without much resorting to Internet searches (although this is the main resource today). The use of different OS allows you to quickly navigate the technical literature and reference material.

IN: Should a beginner do assembler and learn it using KolibriOS?
About: I don’t think it’s worth it (but this is my subjective opinion), it’s better for a beginner to learn the assembler using those OS for which there is more information from the assembler, namely Windows, Dos and Linux.

IN: Should a beginner use Fasm to learn assembly
About: Yes, Fasm is a very good choice for learning assembler. There is enough material for Fasm and a lot of it is in Russian.

IN: Why assembler on the X86 architecture? Why are Arm32/64 not relevant now?
About: You choose which architecture you will develop programs for! It is better for a beginner to study the material with the most information, so as not to search for information all over the Internet and not to confuse himself. In the future, having studied one architecture, it is easier for you to switch to another.

IN: Which assembly language is best for a beginner to use? Nasm, Fasm, Tasm, Wasm or what else?
About: It is best for a beginner to find full assembly lessons. You don’t need to choose an assembler, usually the lessons include preparation for assembly language programming and therefore the lessons determine the initial choice of assembler. In the future, having learned the assembler and the shell for it, it will be easier for you to switch to another assembler.

If you have a desire to learn assembler using Fasmthen for you I can advise you to look at the material on these sites:

We launch KolibriOS

You can skip this part if you are already ready to program in KolibriOS.

FYI, I use Linux and Qemu! Therefore, the Windows commands encountered may differ by the presence of “.exe” at the end of the file. You can also do all the actions in your own way and using another emulator!

To begin with, let’s start the system, as I already described in the video, or by some of our own methods, for example, by installing it on my computer (by the way, I used this method, everything worked quite well).

The next step, no… stop… that should be the first step… if you’re running KolibriOS on a virtual machine. We must create an additional hard drive for ourselves, where we will store information (your programs). Open the terminal, write in it:
qemu-img create -f raw kol.img 500M
and… launch another emulator specifying the newly created disk. Why? Because KolibriOS does not know how to format disks itself, we need to format it in Fat32. I use the Windows 7 emulator for this, and there I format this drive. Windows may not see this drive in explorer and you will need to make it see this hard drive again and format it. After that, exit the emulator and “hook” the formatted KolibryOS hard drive, for example by adding to the file “.sh” (in Windows to the file “.bat”) line:
– hdb kol.img \

If you can create a formatted disk image in another way, then there is nothing shameful in this. I just gave an example of how it can be done.

Link to the video where I prepare the launch of KolibriOS, launch it and create another test application (more precisely, I have already created it, run through the code and try to finalize it).

Well, let’s hope you have KolibriOS up and running by now and we’re going straight to code generation. … almost …

Open it CEditgo to the tab “tools” and there choose “system functions“.

A file with the system functions of this OS will be opened. It is important to understand that most operating systems have their own system functions and you should be able to use the documentation. This is useful at least for simplifying your program creation and for not reinventing the wheel every time. After all, a lot of functionality has already been implemented and you just need to use it (somewhere more, somewhere less).

Now go to the tab “language” and select “Fasm” (As I understand this syntax highlighting), and also in the tab “tools” Select “boardNow you don’t need this window, but when compiling/starting the program, debugging information will be displayed there, which will help you in case you encounter errors in the program, in case of errors, the information will be displayed exactly there. It is quite convenient that in KolibriOS everything is already prepared for programming, now you can definitely start writing a program.

include ""


; основной цикл
    call draw_window
    mcall 10 ; ожидание события.
    dec eax  ; 1 - перерисовка окна.
    jz  main_loop
    dec eax  ; 2 - обработка клавиатуры.
    jnz no_key
    call key
    dec eax  ; 3 - обработка созданных кнопок.
    jnz no_button
    call button_press
    jmp main_loop

    mcall 2  ; получаем код нажатой клавиши.
    ; здесь мы должны сделать обработку клавиатуры.
    mcall 17 ; получить код нажатой кнопки.
    cmp ah, 2; 2 - это код созданной нами кнопки.
    jne no_close
    mcall -1 ; закрываем программу, если была нажата созданная нами кнопка.

    mcall 12, 1 ; начинаем перерисовку окна.
      ; настройки окна
    mcall 0, <30,500>, <100,300>, 0x33808080, , header
      ; рисуем строку
    mcall 4, <200,20>, 0x800000FF, string
      ; рисуем кнопку. Обратите внимание на цифру 2, это и есть идентификатор кнопки.
    mcall 8, <400, 80>, <250, 20>, 2, 0x0000FF00
      ; рисуем линию. Просто для примера.
    mcall 1, 0, 0, 0x00FF0000
    mcall 1, 1, 1, 0x00FF0000
    mcall 1, 2, 2, 0x00FF0000
    mcall 1, 3, 3, 0x00FF0000
    mcall 12, 2 ; завершаем прорисовку окна.

header db 'test',0
string db 'It is text.',0

it’s time to check the code. Try running the program. And it is better to supplement it with some code to pump your skill.

I tried to comment everything and I hope I copied everything correctly. But if not, I think you can fix the mistakes yourself. Judging by my video, I had everything working. )))

As you can see, here I use macros a lot, although I wrote in the last article (if you haven’t read it, read it) that it is not very clear for beginners. But actually, many macros make development a lot easier if you use them.

Attention, it’s important! When compiling and running your application in KolibriOS, you may not get the result you expected! The point is that you must save your changes in the code. The compiler uses a file from disk and does not save your changes automatically when you compile your program.

Pay attention to calls mcall are system calls and you will need to look at the documentation for those calls and see what those calls do. Over time, it is clear that you will be able to remember a lot, and throw something away (for yourself) and use only what you need.

Also, pay attention to the created button. It is without text… the text should probably be written there yourself.

Also, if you are interested in this topic, I advise you to look at GitHub and go to the programs/develop/examples folder. There are many examples of programming under KolibriOS, but there is a high probability that they will have to be modified a little. And in general, I would advise you to look into the folder programs because there is a lot, a lot of different code and macros (and possibly more). It is quite possible that all this will interest you.

Let’s summarize.

At the moment, unfortunately, almost no one uses the assembler on KolibriOS. What’s even worse is that even programs in assembler are practically not created (I even wonder if there are people who still program in assembler for this OS?). This OS was advertised as being made in assembly, but at the moment it looks more like a lot of it is built using JVM, although the possibilities Fasm-a Pretty well pumped.

But let’s talk about the good! Fasm quite well pumped for this OS! There is a lot of documentation, even in Russian. Text editor with syntax highlighting and allows you to run and debug programs. Also, the editor has the ability to launch and debug TinyPad! Creating a window and drawing it is done with small subroutines, which is quite a big plus, because nowadays to make a native window you need to make a lot of effort and learn a lot (you would know how much time I had to study the MacOS documentation in order to properly make a native window there and its processing). It turns out very small programs, can you imagine that the code I offer for your review makes a working code of 300 bytes?! BYTE!!! )))

I think that KolibriOS – this is a very convenient working tool for learning, testing and developing your abilities. Using this OS with the help of a virtual machine, you can test some code without fear that it will harm your computer (and for beginners, this is quite an important factor). And I also think that this is exactly what I will use and will. After all, I will spend some time (already spent) on a blank into which I will simply insert the code that I want to test. And maybe I’ll throw in something else Hebrew. )))

Good luck to everyone!

Related posts