LINUX.ORG.RU

История изменений

Исправление MOPKOBKA, (текущая версия) :

Так кодят на ассемблере!

; declare some simple class
class TIndex

 field Index  : DWORD = 0 

 ; suppose we have 2 functions to work with Index
 function Inc
 ; just for example - let it be virtual
 virtual_function Dec

endclass

; code section
section '.flat' code readable executable

; implement TIndex functions

proc TIndex.Inc this

 ; increment our object index 
 mov eax,[this]
 inc [eax + TIndex.Index]
 ret
endp ; { TIndex.Inc } 

proc TIndex.Dec this

 ; decrement our object index
 mov eax,[this]
 dec [eax + TIndex.Index]
 
 ret
endp ; { TIndex.Dec } 

; ******************   PROGRAMM ENTRY POINT   ******************
proc Main

 ; make calls of both TIndex functions
 ; this is call of static function of object  
 objfcall IndObj->Inc() ; increment index
 ; make next call via supposed "untyped" pointer to object (just for example)
 ; this is call of virtual function of object
 mov eax,IndObj
 clsfcall TIndex(eax)->Dec() ; decrement index

 ; let see index value after calls
 ; it will be zero
 mov ecx,[IndObj.Index]

; exit process
 invoke ExitProcess, NULL
endp

В KolibriOS например много процедур, да почти в любом коде на ассемблере который я видел, их много.

Исходная версия MOPKOBKA, :

Так кодят на ассемблере!

; declare some simple class
class TIndex

 field Index  : DWORD = 0 

 ; suppose we have 2 functions to work with Index
 function Inc
 ; just for example - let it be virtual
 virtual_function Dec

endclass

; code section
section '.flat' code readable executable

; implement TIndex functions

proc TIndex.Inc this

 ; increment our object index 
 mov eax,[this]
 inc [eax + TIndex.Index]
 ret
endp ; { TIndex.Inc } 

proc TIndex.Dec this

 ; decrement our object index
 mov eax,[this]
 dec [eax + TIndex.Index]
 
 ret
endp ; { TIndex.Dec } 

; ******************   PROGRAMM ENTRY POINT   ******************
proc Main

 ; make calls of both TIndex functions
 ; this is call of static function of object  
 objfcall IndObj->Inc() ; increment index
 ; make next call via supposed "untyped" pointer to object (just for example)
 ; this is call of virtual function of object
 mov eax,IndObj
 clsfcall TIndex(eax)->Dec() ; decrement index

 ; let see index value after calls
 ; it will be zero
 mov ecx,[IndObj.Index]

; exit process
 invoke ExitProcess, NULL
endp