Developers Club geek daily blog

We neutralize a bomb with Radare2

1 year, 5 months ago

Hello, % %username! Today we will go to study uncountable opportunities of a framework for a reverser — radare2. In the form of experimental I took the first got bomb, it appeared from the website of University Carnegie Mellon.

Read more »


The digest following the results of 2015

1 year, 5 months ago
We decided to congratulate all readers of the blog with come New year and to sum up the past results. The end of 2015 was marked by round numbers — the 6000th bild in SVN and the 5000th participant of https://vk.com/kolibri_os group of a social network of VKontakte.

Read more »


The narration about the compressor which it is possible to call, but I do not remember how

1 year, 5 months ago
Not absolutely New Year's history in which there is a tie, an intrigue, detective investigation, a pursuit, insidiousness, wisdom ancient and the happy final is provided to your attention. Under a cat you are expected by archeological excavations of Habr of an era of reorganization and a pinch of the x86 assembler to taste.

Read more »


memset — the party of darkness

1 year, 6 months ago

Read more »


Get acquainted, loop fracking

1 year, 6 months ago
image
The purpose of this work is designation of one more technology of optimization of cycles.
At the same time there is no task to be guided by any existing architecture, and, on the contrary
let's try to act whenever possible abstractly, relying mainly on common sense.

The author called this equipment "loops fracking" by analogy with, for example, "loops unrolling"
or "loops nesting". Especially as the term reflects sense and is not occupied.

Read more »


Writing of the elementary program under Linux in machine codes

1 year, 7 months ago
All hi. I wanted to touch this subject long ago and to write something similar, but hands did not reach in any way. Today I decided, and we will sort structure of the ELF file (the performed file on * nix-like systems), and we will write the simple program under x86 Linux in machine codes which will display the message. But here not everything is so unambiguous, believe me.

I wanted to begin with the end. Namely from what will be done by our program. Our program — no other than a heap of machine code which, afterwards, will be performed by system. As the deputy of numeration system of Hex I will use "Wct" because it is much more convenient because there is online the compiler and an opportunity to insert lines on the run and to use decimal numbers. At us it will display one line of the text.

image

Read more »


Half a century to "universal machine languages" (1966 — 2016): last, this, future

1 year, 7 months ago
КДПВ

Past


The narration can be begun since 1962 when at the Cambridge university work on CPL ("Cambridge Programming Language") — "improved version" ALGOL-60 began. The graduate student Martin Richards was connected to work on language; in implementation of new YaP need of manual porting of the compiler for different computer platforms seemed it the main complexity. In particular, when the Cambridge EDSAC-2 was replaced with Atlas-2, the CPL developers spent a lot of time for porting of the compiler for a new platform.

Martin's thesis was devoted "to CPL which is most compiled": the compiler developed by Martin was written on strongly simplified CPL option which compiler was simple to be written on the macroassembler of that time. Transfer of CPL on a new platform could be executed in two steps now:
  1. Manually we write the compiler of "the simplified CPL";
  2. We compile it the compiler of "complete CPL".

On it Martin did not stop, and developed BCPL — system for development of transferable compilers. The compiler BCPL generated the pseudo-code named by Martin "OCODE".
OCODE looked approximately so:
OCODE "interpretation" ("procode")
94 5 L1 83 73 69 86 69
95 4
42 0
42 0 40 2 14
83
42 0 42 1 40 2 14 83
42 2
40 3 42 1 15
92
85 L5
90 L6
42 1 40 4 40 2 14 83
40 4 42 1 14 80 4 
90 5 40 4 40 5 88 L6
91 4
42 2 40 3 42 1 15 92
85 L7
90 L8 40 4 40 2 14
8 87 L9
40 4 42 2 11 92
85 L11
90 L10
42 0 40 6 40 2 14 83
40 4 40 6 14 80 6
90 L11
40 6 40 3 22 86 L10
91 6 90 L9
40 4 42 1 14 80 4
90 L7 40 4 40 5 88 L8
91 4 97 103 0
ENTRY 5 L1  'S' 'I' 'E' 'V' 'E'
SAVE 4
LN 0
LN 0 LP 2 PLUS
STIND
LN 0 LN 1 LP 2 PLUS STIND
LN 2
LP 3 LN 1 MINUS
STORE
JUMP L5
LAB L6
LN 1 LP 4 LP 2 PLUS STIND
LP 4 LN 1 PLUS SP 4
LAB L5 LP 4 LP 5 ENDFOR L6
STACK 4
LN 2 LP 3 LN 1 MINUS STORE
JUMP L7
LAB L8 LP 4 LP 2 PLUS
RV JF L9
LP 4 LN 2 MULT STORE
JUMP L11
LAB L10
LN 0 LP 6 LP 2 PLUS STIND
LP 4 LP 6 PLUS SP 6
LAB L11
LP 6 LP 3 LS JT L10
STACK 6 LAB L9
LP 4 LN 1 PLUS SP 4
LAB L7 LP 4 LP 5 ENDFOR L8
STACK 4 RTRN ENDPROC 0
; procedure heading
; stack frame (two parameters and two local variables)
; to place number 0 on a stack
; to place one more 0, to add to it the 2nd element of a stack
; to write in an array at stack top value under it
; the same for the 1st array cell
; to place number 2 on a stack
; to subtract unit from value of the 3rd element of a stack
; to write result in local variable
; to pass to L5 tag
; declaration of a tag of L6
; to take the 4th element of a stack, to write in an array on this index 1
; to add to the 4th element of a stack 1, to write result back
; L5: to pass to L6 tag if the 4th element of a stack <= to the 5th
; the declaration that on a stack now four elements
; to subtract unit from value of the 3rd element of a stack
; to pass to L7 tag
; L8: to put the 4th and 2nd elements of a stack
; to read value to this address; if it is 0, to pass to L9
; to increase the 4th element by two
; to pass to L11 tag
; declaration of a tag of L10
; to take the 6th element of a stack, to write in an array on this index 0
; to add the 4th to the 6th element of a stack, to write the machine cut t back
; declaration of a tag of L11
; to pass to L10 tag if the 7th element of a stack is less than 4th
; on a stack now six elements; declaration of a tag of L9
; to add to the 4th element of a stack 1, to write result back
; L10: to pass to L8 if the 4th element of a stack <= to the 5th
; on a stack four elements; end of procedure
(For economy of the place, sequence of commands are written in one line. Martin in the guide to BCPL arrives in the same way.)

The source code on BCPL:
LET sieve(workvec, vecsize) BE
{
  workvec!0 := 0
  workvec!1 := 0
  FOR i = 2 TO vecsize-1 DO workvec!i := 1
  FOR i = 2 TO vecsize-1 DO
    IF workvec!i DO
    { LET j = 2 * i
      WHILE j < vecsize DO
      { workvec!j := 0
        j := j + i
      }
    }
}
In newer OCODE versions support of floating-point numbers (respectively, the set of the supported opkod almost doubled) was added, and also deleted opkod ENDFOR — instead of it couple is generated LE JT.

Among "universal machine languages" OCODE is unique the fact that tags in it are defined by special instructions — i.e. for interpretation of its program it is necessary to load at first all into memory and to find in it tags.
— and the separate program, a kodogenerator, turned the file with such pseudo-code into the feasible program for the final processor. OCODE remained in the form of the text file from the decimal numbers separated by spaces and transfers of lines: when OCODE was developed, the file format binding to the specific size of byte would limit portability of such file.

The compiler BCPL(1) was delivered in the form of OCODE and to transfer it to a new platform, it was necessary:
  1. To manually write the interpreter of a pseudo-code (2) (in any language though on the BASIC);
  2. To adapt a kodogenerator, (3) written on BCPL, for the platform;
  3. To start the compiler BCPL (1) under the interpreter (2), to feed to it a kodogenerator (3) and to receive on an output an executable file of a kodogenerator (4);
    • The interpreter (2) from this point is not necessary to us any more.
  4. To banish a pseudo-code of the compiler (1) through a kodogenerator (4) and to receive an executable file of the compiler on an output.

Such approach meant that transfer of the compiler on a new platform requires only the minimum of low-level programming; and it is valid, implementation of BCPL was complete by 1967 — earlier, than the implementation of CPL begun for several years earlier was complete!

BCPL advantages in relation to system programming inspired Ken Thompson on creation of language of Bee, and that is the colleague Ken, Dennis Ritchi, on Xi's creation. From BCPL the tradition went to designate {curly brackets} program blocks, and on wasit is writtenBCPL the first program "Hello, World!".
GET "libhdr"

LET start() = VALOF
{ writef("Hello*n")
  RESULTIS 0
}
More important to us the reason for which BCPL became history: OCODE — the first universal "architecture of command set" (ISA), i.e. the "virtual computer" which is not attached to any specific hardware platform with its features. BCPL, thus — the first programming language corresponding to a paradigm "Write once, run anywhere" (WORA): the program to BCPL can be distributed in the compiled type, and it can be started on any platform for which there is OCODE-kodogenerator.

Read more »


Flytouch 2/Superpad III and attempt to save bytes in a kernel Linux

1 year, 7 months ago
I was going to write this article for a long time, but in recent months could not find enough time in any way. While I reflected over article, did examples and checked the guesses, on Habré already discussed a konstantnost — [1][2].

For the sake of an entertainment we will try to do similar economy not with the spherical project in vacuum, and with the most live and grandiose project — with a kernel Linux!

Read more »


Digest of KolibriOS #10: shortly about collected

1 year, 7 months ago
Now not the end of the autumn period, but nevertheless was decided to release the tenth release of the digest about changes in Kolibrios. Reasons for that two: it is what is what to tell, and the second even more important, is that period of validity of our corporate blog comes to an end, and its future is foggy. Well, we will not be about sad. Especially as many made during the fall, both at the kernel level and libraries, and in applications, cannot but please.

Read more »


The Intel-4004 assembler — for entertainment

1 year, 8 months ago
intel-4004 cpu

Recently showed me assembler emulators for Intel-4004 and I for some time "hung up". This is "grandfather" of present processors — if to trust article of Wikipedia — the first commercially widespread microprocessor.

It is unlikely it can be used for some serious purposes now. And here it is simple to break the head (instead of brainf ** k) — well, this that in what I was engaged. The main thing it 4-bit and command set quite small (before I knew only a little bit the x86th-y, at a painful institute course).

There is free transfer retelling of this instruction on the assembler for Intel-4004 below — and short notes on my attempts to write something on it.

Read more »