938e74edc1
git-svn-id: svn://kolibrios.org@7623 a494cfbc-eb01-0410-851d-a64ba20cac60
400 lines
16 KiB
Plaintext
400 lines
16 KiB
Plaintext
Š®¬¯¨«ïâ®à ï§ëª ¯à®£à ¬¬¨à®¢ ¨ï Oberon-07/16 ¤«ï i486
|
||
Windows/Linux/KolibriOS.
|
||
------------------------------------------------------------------------------
|
||
|
||
<20> à ¬¥âàë ª®¬ ¤®© áâப¨
|
||
|
||
‚室 - ⥪áâ®¢ë¥ ä ©«ë ¬®¤ã«¥© á à áè¨à¥¨¥¬ ".ob07", ª®¤¨à®¢ª ANSI ¨«¨
|
||
UTF-8 á BOM-ᨣ âãன.
|
||
‚ë室 - ¨á¯®ï¥¬ë© ä ©« ä®à¬ â PE32, ELF ¨«¨ MENUET01/MSCOFF.
|
||
<20> à ¬¥âàë:
|
||
1) ¨¬ï £« ¢®£® ¬®¤ã«ï
|
||
2) ¨¬ï १ã«ìâ¨àãî饣® ä ©«
|
||
3) ⨯ ¯à¨«®¦¥¨ï ¨ ¯« âä®à¬
|
||
"console" - Windows console
|
||
"gui" - Windows GUI
|
||
"dll" - Windows DLL
|
||
"kos" - KolibriOS
|
||
"obj" - KolibriOS DLL
|
||
"elfexe" - Linux ELF-EXEC
|
||
4) ¥®¡ï§ ⥫ìë¥ ¯ à ¬¥âàë-ª«îç¨
|
||
-stk <size> à §¬¥à áâíª ¢ ¬¥£ ¡ ©â å (¯® 㬮«ç ¨î 2 Œ¡)
|
||
-base <address> ¤à¥á § £à㧪¨ ¨á¯®«ï¥¬®£® ä ©« ¢ ª¨«®¡ ©â å
|
||
-ver <major.minor> ¢¥àá¨ï ¯à®£à ¬¬ë (⮫쪮 ¤«ï obj)
|
||
-nochk <"ptibcwra"> ®âª«îç¨âì ¯à®¢¥àª¨ ¯à¨ ¢ë¯®«¥¨¨ (á¬. ¨¦¥)
|
||
|
||
¯ à ¬¥âà -nochk § ¤ ¥âáï ¢ ¢¨¤¥ áâப¨ ¨§ ᨬ¢®«®¢:
|
||
"p" - 㪠§ ⥫¨
|
||
"t" - ⨯ë
|
||
"i" - ¨¤¥ªáë
|
||
"b" - ¥ï¢®¥ ¯à¨¢¥¤¥¨¥ INTEGER ª BYTE
|
||
"c" - ¤¨ ¯ §® à£ã¬¥â äãªæ¨¨ CHR
|
||
"w" - ¤¨ ¯ §® à£ã¬¥â äãªæ¨¨ WCHR
|
||
"r" - íª¢¨¢ «¥â® "bcw"
|
||
"a" - ¢á¥ ¯à®¢¥àª¨
|
||
|
||
<20>®à冷ª ᨬ¢®«®¢ ¬®¦¥â ¡ëâì «î¡ë¬. <20> «¨ç¨¥ ¢ áâப¥ ⮣® ¨«¨ ¨®£®
|
||
ᨬ¢®« ®âª«îç ¥â ᮮ⢥âáâ¢ãîéãî ¯à®¢¥àªã.
|
||
|
||
<20> ¯à¨¬¥à: -nochk it - ®âª«îç¨âì ¯à®¢¥àªã ¨¤¥ªá®¢ ¨ ®åà ã ⨯ .
|
||
-nochk a - ®âª«îç¨âì ¢á¥ ®âª«îç ¥¬ë¥ ¯à®¢¥àª¨.
|
||
|
||
<20> ¯à¨¬¥à:
|
||
|
||
Compiler.exe "C:\example.ob07" "C:\example.exe" console -stk 1
|
||
Compiler.exe "C:\example.ob07" "C:\example.dll" dll
|
||
Compiler.exe "C:\example.ob07" "C:\example.exe" gui -stk 4
|
||
Compiler.exe "C:\example.ob07" "C:\example.exe" console -nochk pti
|
||
Compiler.kex "/tmp0/1/example.ob07" "/tmp0/1/example.kex" kos -stk 2
|
||
Compiler.kex "/tmp0/1/example.ob07" "/tmp0/1/example.obj" obj -ver 2.7
|
||
Compiler.exe "C:\example.ob07" "C:\example" elfexe
|
||
|
||
‚ á«ãç ¥ ãᯥ让 ª®¬¯¨«ï樨, ª®¬¯¨«ïâ®à ¯¥à¥¤ ¥â ª®¤ § ¢¥à襨ï 0, ¨ ç¥ 1.
|
||
<EFBFBD>à¨ à ¡®â¥ ª®¬¯¨«ïâ®à ¢ KolibriOS, ª®¤ § ¢¥àè¥¨ï ¥ ¯¥à¥¤ ¥âáï.
|
||
|
||
------------------------------------------------------------------------------
|
||
Žâ«¨ç¨ï ®â ®à¨£¨ «
|
||
|
||
1. <20> áè¨à¥ ¯á¥¢¤®¬®¤ã«ì SYSTEM
|
||
2. ‚ ¨¤¥â¨ä¨ª â®à å ¤®¯ã᪠¥âáï ᨬ¢®« "_"
|
||
3. „®¡ ¢«¥ë á¨áâ¥¬ë¥ ä« £¨
|
||
4. “ᮢ¥àè¥á⢮¢ ®¯¥à â®à CASE (¤®¡ ¢«¥ë ª®áâ âë¥ ¢ëà ¦¥¨ï ¢
|
||
¬¥âª å ¢ ਠ⮢ ¨ ¥®¡ï§ ⥫ì ï ¢¥âª ELSE)
|
||
5. <20> áè¨à¥ ¡®à áâ ¤ àâëå ¯à®æ¥¤ãà
|
||
6. ‘¥¬ ⨪ ®åà ë/¯à®¢¥àª¨ ⨯ ãâ®ç¥ ¤«ï ã«¥¢®£® 㪠§ ⥫ï
|
||
7. ‘¥¬ ⨪ DIV ¨ MOD ãâ®ç¥ ¤«ï ®âà¨æ ⥫ìëå ç¨á¥«
|
||
8. „®¡ ¢«¥ë ®¤®áâà®çë¥ ª®¬¬¥â ਨ ( ç¨ îâáï á ¯ àë ᨬ¢®«®¢ "//")
|
||
9. <20> §à¥è¥® á«¥¤®¢ ¨¥ ®â ⨯ -㪠§ ⥫ï
|
||
10. „®¡ ¢«¥ á¨â ªá¨á ¤«ï ¨¬¯®àâ ¯à®æ¥¤ãà ¨§ ¢¥è¨å ¡¨¡«¨®â¥ª
|
||
11. "‘âப¨" ¬®¦® § ª«îç âì â ª¦¥ ¢ ®¤¨®çë¥ ª ¢ë窨: 'áâப '
|
||
12. „®¡ ¢«¥ ⨯ WCHAR
|
||
|
||
------------------------------------------------------------------------------
|
||
Žá®¡¥®á⨠ॠ«¨§ 樨
|
||
|
||
1. Žá®¢ë¥ ⨯ë
|
||
|
||
’¨¯ „¨ ¯ §® § 票© <20> §¬¥à, ¡ ©â
|
||
|
||
INTEGER -2147483648 .. 2147483647 4
|
||
REAL 4.94E-324 .. 1.70E+308 8
|
||
CHAR ᨬ¢®« ASCII (0X .. 0FFX) 1
|
||
BOOLEAN FALSE, TRUE 1
|
||
SET ¬®¦¥á⢮ ¨§ 楫ëå ç¨á¥« {0 .. 31} 4
|
||
BYTE 0 .. 255 1
|
||
WCHAR ᨬ¢®« ®¤ (0X .. 0FFFFX) 2
|
||
|
||
2. Œ ªá¨¬ «ì ï ¤«¨ ¨¤¥â¨ä¨ª â®à®¢ - 1024 ᨬ¢®«®¢
|
||
3. Œ ªá¨¬ «ì ï ¤«¨ áâப®¢ëå ª®áâ â - 1024 ᨬ¢®«®¢ (UTF-8)
|
||
4. Œ ªá¨¬ «ì ï à §¬¥à®áâì ®âªàëâëå ¬ áᨢ®¢ - 5
|
||
5. <20>à®æ¥¤ãà NEW § ¯®«ï¥â ã«ï¬¨ ¢ë¤¥«¥ë© ¡«®ª ¯ ¬ïâ¨
|
||
6. ƒ«®¡ «ìë¥ ¨ «®ª «ìë¥ ¯¥à¥¬¥ë¥ ¨¨æ¨ «¨§¨àãîâáï ã«ï¬¨
|
||
7. ‚ ®â«¨ç¨¥ ®â ¬®£¨å Oberon-ॠ«¨§ 権, á¡®à騪 ¬ãá®à ¨ ¤¨ ¬¨ç¥áª ï
|
||
¬®¤ã«ì®áâì ®âáãâáâ¢ãîâ
|
||
8. ’¨¯ BYTE ¢ ¢ëà ¦¥¨ïå ¢á¥£¤ ¯à¨¢®¤¨âáï ª INTEGER
|
||
9. Š®âà®«ì ¯¥à¥¯®«¥¨ï § 票© ¢ëà ¦¥¨© ¥ ¯à®¨§¢®¤¨âáï
|
||
10. Žè¨¡ª¨ ¢à¥¬¥¨ ¢ë¯®«¥¨ï:
|
||
|
||
- ASSERT(x), ¯à¨ x = FALSE
|
||
- à §ë¬¥®¢ ¨¥ ã«¥¢®£® 㪠§ ⥫ï
|
||
- 楫®ç¨á«¥®¥ ¤¥«¥¨¥ 0
|
||
- ¢ë§®¢ ¯à®æ¥¤ãàë ç¥à¥§ ¯à®æ¥¤ãàãî ¯¥à¥¬¥ãî á ã«¥¢ë¬ § 票¥¬
|
||
- ®è¨¡ª ®åà ë ⨯
|
||
- àã襨¥ £à ¨æ ¬ áᨢ
|
||
- ¥¯à¥¤ãᬮâ८¥ § 票¥ ¢ëà ¦¥¨ï ¢ ®¯¥à â®à¥ CASE
|
||
- ®è¨¡ª ª®¯¨à®¢ ¨ï ¬ áᨢ®¢ v := x, ¥á«¨ LEN(v) < LEN(x)
|
||
- ¥ï¢®¥ ¯à¨¢¥¤¥¨¥ x:INTEGER ª v:BYTE, ¥á«¨ (x < 0) OR (x > 255)
|
||
- CHR(x), ¥á«¨ (x < 0) OR (x > 255)
|
||
- WCHR(x), ¥á«¨ (x < 0) OR (x > 65535)
|
||
|
||
------------------------------------------------------------------------------
|
||
<20>ᥢ¤®¬®¤ã«ì SYSTEM
|
||
|
||
<20>ᥢ¤®¬®¤ã«ì SYSTEM ᮤ¥à¦¨â ¨§ª®ã஢¥¢ë¥ ¨ ¥¡¥§®¯ áë¥ ¯à®æ¥¤ãàë,
|
||
®è¨¡ª¨ ¯à¨ ¨á¯®«ì§®¢ ¨¨ ¯à®æ¥¤ãà ¯á¥¢¤®¬®¤ã«ï SYSTEM ¬®£ã⠯ਢ¥á⨠ª
|
||
¯®¢à¥¦¤¥¨î ¤ ëå ¢à¥¬¥¨ ¢ë¯®«¥¨ï ¨ ¢ ਩®¬ã § ¢¥àè¥¨î ¯à®£à ¬¬ë.
|
||
|
||
PROCEDURE ADR(v: «î¡®© ⨯): INTEGER
|
||
v - ¯¥à¥¬¥ ï ¨«¨ ¯à®æ¥¤ãà ;
|
||
¢®§¢à é ¥â ¤à¥á v
|
||
|
||
PROCEDURE SADR(x: áâப®¢ ï ª®áâ â (CHAR UTF-8)): INTEGER
|
||
¢®§¢à é ¥â ¤à¥á x
|
||
|
||
PROCEDURE WSADR(x: áâப®¢ ï ª®áâ â (WCHAR)): INTEGER
|
||
¢®§¢à é ¥â ¤à¥á x
|
||
|
||
PROCEDURE SIZE(T): INTEGER
|
||
¢®§¢à é ¥â à §¬¥à ⨯ T
|
||
|
||
PROCEDURE TYPEID(T): INTEGER
|
||
T - ⨯-§ ¯¨áì ¨«¨ ⨯-㪠§ ⥫ì,
|
||
¢®§¢à é ¥â ®¬¥à ⨯ ¢ â ¡«¨æ¥ ⨯®¢-§ ¯¨á¥©
|
||
|
||
PROCEDURE INF(): REAL
|
||
¢®§¢à é ¥â á¯¥æ¨ «ì®¥ ¢¥é¥á⢥®¥ § 票¥ "¡¥áª®¥ç®áâì"
|
||
|
||
PROCEDURE GET(a: INTEGER;
|
||
VAR v: «î¡®© ®á®¢®© ⨯, PROCEDURE, POINTER)
|
||
v := <20> ¬ïâì[a]
|
||
|
||
PROCEDURE PUT(a: INTEGER; x: «î¡®© ®á®¢®© ⨯, PROCEDURE, POINTER)
|
||
<20> ¬ïâì[a] := x;
|
||
…᫨ x: BYTE ¨«¨ x: WCHAR, â® § 票¥ x ¡ã¤¥â à áè¨à¥®
|
||
¤® 32 ¡¨â, ¤«ï § ¯¨á¨ ¡ ©â®¢ ¨á¯®«ì§®¢ âì SYSTEM.PUT8,
|
||
¤«ï WCHAR -- SYSTEM.PUT16
|
||
|
||
PROCEDURE PUT8(a: INTEGER; x: INTEGER, BYTE, CHAR, WCHAR)
|
||
<20> ¬ïâì[a] := ¬« ¤è¨¥ 8 ¡¨â (x)
|
||
|
||
PROCEDURE PUT16(a: INTEGER; x: INTEGER, BYTE, CHAR, WCHAR)
|
||
<20> ¬ïâì[a] := ¬« ¤è¨¥ 16 ¡¨â (x)
|
||
|
||
PROCEDURE MOVE(Source, Dest, n: INTEGER)
|
||
Š®¯¨àã¥â n ¡ ©â ¯ ¬ï⨠¨§ Source ¢ Dest,
|
||
®¡« á⨠Source ¨ Dest ¥ ¬®£ãâ ¯¥à¥ªàë¢ âìáï
|
||
|
||
PROCEDURE COPY(VAR Source: «î¡®© ⨯; VAR Dest: «î¡®© ⨯; n: INTEGER)
|
||
Š®¯¨àã¥â n ¡ ©â ¯ ¬ï⨠¨§ Source ¢ Dest.
|
||
<20>ª¢¨¢ «¥â®
|
||
SYSTEM.MOVE(SYSTEM.ADR(Source), SYSTEM.ADR(Dest), n)
|
||
|
||
PROCEDURE CODE(byte1, byte2,... : INTEGER)
|
||
‚áâ ¢ª ¬ 訮£® ª®¤ ,
|
||
byte1, byte2 ... - ª®áâ âë ¢ ¤¨ ¯ §®¥ 0..255,
|
||
¯à¨¬¥à:
|
||
SYSTEM.CODE(08BH, 045H, 008H) (* mov eax, dword [ebp + 08h] *)
|
||
|
||
’ ª¦¥ ¢ ¬®¤ã«¥ SYSTEM ®¯à¥¤¥«¥ ⨯ CARD16 (2 ¡ ©â ). „«ï ⨯ CARD16 ¥
|
||
¤®¯ã᪠îâáï ¨ª ª¨¥ ï¢ë¥ ®¯¥à 樨, § ¨áª«î票¥¬ ¯à¨á¢ ¨¢ ¨ï.
|
||
<EFBFBD>८¡à §®¢ ¨ï CARD16 -> INTEGER ¨ INTEGER -> CARD16 ¬®£ãâ ¡ëâì ॠ«¨§®¢ ë
|
||
â ª:
|
||
|
||
PROCEDURE Card16ToInt (w: SYSTEM.CARD16): INTEGER;
|
||
VAR i: INTEGER;
|
||
BEGIN
|
||
SYSTEM.PUT(SYSTEM.ADR(i), w)
|
||
RETURN i
|
||
END Card16ToInt;
|
||
|
||
PROCEDURE IntToCard16 (i: INTEGER): SYSTEM.CARD16;
|
||
VAR w: SYSTEM.CARD16;
|
||
BEGIN
|
||
SYSTEM.GET(SYSTEM.ADR(i), w)
|
||
RETURN w
|
||
END IntToCard16;
|
||
|
||
”ãªæ¨¨ ¯á¥¢¤®¬®¤ã«ï SYSTEM ¥«ì§ï ¨á¯®«ì§®¢ âì ¢ ª®áâ âëå ¢ëà ¦¥¨ïå.
|
||
|
||
------------------------------------------------------------------------------
|
||
‘¨áâ¥¬ë¥ ä« £¨
|
||
|
||
<20>ਠ®¡ê¥¨¨ ¯à®æ¥¤ãàëå ⨯®¢ ¨ £«®¡ «ìëå ¯à®æ¥¤ãà, ¯®á«¥ ª«î祢®£®
|
||
á«®¢ PROCEDURE ¬®¦¥â ¡ëâì 㪠§ ä« £ ᮣ« è¥¨ï ® ¢ë§®¢¥: [stdcall],
|
||
[ccall], [ccall16], [windows], [linux]. <20> ¯à¨¬¥à:
|
||
|
||
PROCEDURE [ccall] MyProc (x, y, z: INTEGER): INTEGER;
|
||
|
||
…᫨ 㪠§ ä« £ [ccall16], â® ¯à¨¨¬ ¥âáï ᮣ« 襨¥ ccall, ® ¯¥à¥¤
|
||
¢ë§®¢®¬ 㪠§ ⥫ì áâíª ¡ã¤¥â ¢ëà ¢¥ ¯® £à ¨æ¥ 16 ¡ ©â.
|
||
”« £ [windows] - ᨮ¨¬ ¤«ï [stdcall], [linux] - ᨮ¨¬ ¤«ï [ccall16].
|
||
‡ ª "-" ¯®á«¥ ¨¬¥¨ ä« £ ([stdcall-], [linux-], ...) ®§ ç ¥â, çâ®
|
||
१ã«ìâ â ¯à®æ¥¤ãàë ¬®¦® ¨£®à¨à®¢ âì (¥ ¤®¯ã᪠¥âáï ¤«ï ⨯ REAL).
|
||
|
||
<20>ਠ®¡ê¥¨¨ ⨯®¢-§ ¯¨á¥©, ¯®á«¥ ª«î祢®£® á«®¢ RECORD ¬®¦¥â ¡ëâì
|
||
㪠§ ä« £ [noalign]. ”« £ [noalign] ®§ ç ¥â ®âáãâá⢨¥ ¢ëà ¢¨¢ ¨ï ¯®«¥©
|
||
§ ¯¨á¨. ‡ ¯¨á¨ á á¨áâ¥¬ë¬ ä« £®¬ ¥ ¬®£ãâ ¨¬¥âì ¡ §®¢ë© ⨯ ¨ ¥ ¬®£ãâ ¡ëâì
|
||
¡ §®¢ë¬¨ ⨯ ¬¨ ¤«ï ¤àã£¨å § ¯¨á¥©.
|
||
„«ï ¨á¯®«ì§®¢ ¨ï á¨á⥬ëå ä« £®¢, âॡã¥âáï ¨¬¯®àâ¨à®¢ âì SYSTEM.
|
||
|
||
------------------------------------------------------------------------------
|
||
Ž¯¥à â®à CASE
|
||
|
||
‘¨â ªá¨á ®¯¥à â®à CASE:
|
||
|
||
CaseStatement =
|
||
CASE Expression OF ‘ase {"|" ‘ase}
|
||
[ELSE StatementSequence] END.
|
||
Case = [CaseLabelList ":" StatementSequence].
|
||
CaseLabelList = CaseLabels {"," CaseLabels}.
|
||
CaseLabels = ConstExpression [".." ConstExpression].
|
||
|
||
<20> ¯à¨¬¥à:
|
||
|
||
CASE x OF
|
||
|-1: DoSomething1
|
||
| 1: DoSomething2
|
||
| 0: DoSomething3
|
||
ELSE
|
||
DoSomething4
|
||
END
|
||
|
||
‚ ¬¥âª å ¢ ਠ⮢ ¬®¦® ¨á¯®«ì§®¢ âì ª®áâ âë¥ ¢ëà ¦¥¨ï, ¢¥âª ELSE
|
||
¥®¡ï§ ⥫ì . …᫨ § 票¥ x ¥ ᮮ⢥âáâ¢ã¥â ¨ ®¤®¬ã ¢ ਠâã ¨ ELSE
|
||
®âáãâáâ¢ã¥â, â® ¯à®£à ¬¬ ¯à¥àë¢ ¥âáï á ®è¨¡ª®© ¢à¥¬¥¨ ¢ë¯®«¥¨ï.
|
||
|
||
------------------------------------------------------------------------------
|
||
’¨¯ WCHAR
|
||
|
||
’¨¯ WCHAR ¤®¡ ¢«¥ ¢ ï§ëª ¤«ï 㤮¡®© ¯®¤¤¥¦ª¨ ®¤ . „«ï ⨯®¢ WCHAR ¨
|
||
ARRAY OF WCHAR ¤®¯ã᪠îâáï ¢á¥ â¥ ¦¥ ®¯¥à 樨, ª ª ¤«ï ⨯®¢ CHAR ¨
|
||
ARRAY OF CHAR, § ¨áª«î票¥¬ ¢áâ஥®© ¯à®æ¥¤ãàë CHR, ª®â®à ï ¢®§¢à é ¥â
|
||
⮫쪮 ⨯ CHAR. „«ï ¯®«ãç¥¨ï § 票ï ⨯ WCHAR, á«¥¤ã¥â ¨á¯®«ì§®¢ âì
|
||
¯à®æ¥¤ãàã WCHR ¢¬¥áâ® CHR. „«ï ¯à ¢¨«ì®© à ¡®âë á ⨯®¬, ¥®¡å®¤¨¬® á®åà ïâì
|
||
¨áå®¤ë© ª®¤ ¢ ª®¤¨à®¢ª¥ UTF-8 c BOM.
|
||
|
||
------------------------------------------------------------------------------
|
||
<20>஢¥àª ¨ ®åà ⨯ ã«¥¢®£® 㪠§ ⥫ï
|
||
|
||
Žà¨£¨ «ì®¥ á®®¡é¥¨¥ ® ï§ëª¥ ¥ ®¯à¥¤¥«ï¥â ¯®¢¥¤¥¨¥ ¯à®£à ¬¬ë ¯à¨
|
||
¢ë¯®«¥¨¨ ®åà ë p(T) ¨ ¯à®¢¥àª¨ ⨯ p IS T ¯à¨ p = NIL. ‚® ¬®£¨å
|
||
Oberon-ॠ«¨§ æ¨ïå ¢ë¯®«¥¨¥ â ª®© ®¯¥à 樨 ¯à¨¢®¤¨â ª ®è¨¡ª¥ ¢à¥¬¥¨
|
||
¢ë¯®«¥¨ï. ‚ ¤ ®© ॠ«¨§ 樨 ®åà ⨯ ã«¥¢®£® 㪠§ â¥«ï ¥ ¯à¨¢®¤¨â ª
|
||
®è¨¡ª¥, ¯à®¢¥àª ⨯ ¤ ¥â १ã«ìâ â FALSE. ‚ à拉 á«ãç ¥¢ íâ® ¯®§¢®«ï¥â
|
||
§ ç¨â¥«ì® ᮪à â¨âì ç áâ®â㠯ਬ¥¥¨ï ®åà ë ⨯ .
|
||
|
||
------------------------------------------------------------------------------
|
||
„®¯®«¨â¥«ìë¥ áâ ¤ àâë¥ ¯à®æ¥¤ãàë
|
||
|
||
DISPOSE (VAR v: «î¡®©_㪠§ ⥫ì)
|
||
Žá¢®¡®¦¤ ¥â ¯ ¬ïâì, ¢ë¤¥«¥ãî ¯à®æ¥¤ãன NEW ¤«ï
|
||
¤¨ ¬¨ç¥áª®© ¯¥à¥¬¥®© v^, ¨ ¯à¨á¢ ¨¢ ¥â ¯¥à¥¬¥®© v
|
||
§ 票¥ NIL.
|
||
|
||
COPY (x: ARRAY OF CHAR/WCHAR; VAR v: ARRAY OF CHAR/WCHAR);
|
||
v := x;
|
||
…᫨ LEN(v) < LEN(x), â® áâப x ¡ã¤¥â ᪮¯¨à®¢
|
||
¥ ¯®«®áâìî
|
||
|
||
LSR (x, n: INTEGER): INTEGER
|
||
‹®£¨ç¥áª¨© ᤢ¨£ x n ¡¨â ¢¯à ¢®.
|
||
|
||
MIN (a, b: INTEGER): INTEGER
|
||
Œ¨¨¬ã¬ ¨§ ¤¢ãå § 票©.
|
||
|
||
MAX (a, b: INTEGER): INTEGER
|
||
Œ ªá¨¬ã¬ ¨§ ¤¢ãå § 票©.
|
||
|
||
BITS (x: INTEGER): SET
|
||
ˆâ¥à¯à¥â¨àã¥â x ª ª § 票¥ ⨯ SET.
|
||
‚믮«ï¥âáï íâ ¯¥ ª®¬¯¨«ï樨.
|
||
|
||
LENGTH (s: ARRAY OF CHAR/WCHAR): INTEGER
|
||
„«¨ 0X-§ ¢¥à襮© áâப¨ s, ¡¥§ ãç¥â ᨬ¢®« 0X.
|
||
…᫨ ᨬ¢®« 0X ®âáãâáâ¢ã¥â, äãªæ¨ï ¢®§¢à é ¥â ¤«¨ã
|
||
¬ áᨢ s. s ¥ ¬®¦¥â ¡ëâì ª®áâ ⮩.
|
||
|
||
WCHR (n: INTEGER): WCHAR
|
||
<20>८¡à §®¢ ¨¥ ⨯ , «®£¨ç® CHR(n: INTEGER): CHAR
|
||
|
||
------------------------------------------------------------------------------
|
||
DIV ¨ MOD
|
||
|
||
x y x DIV y x MOD y
|
||
|
||
5 3 1 2
|
||
-5 3 -2 1
|
||
5 -3 -2 -1
|
||
-5 -3 1 -2
|
||
|
||
------------------------------------------------------------------------------
|
||
ˆ¬¯®àâ¨à®¢ ë¥ ¯à®æ¥¤ãàë
|
||
|
||
‘¨â ªá¨á ¨¬¯®àâ :
|
||
|
||
PROCEDURE [callconv, "library", "function"] proc_name (FormalParam): Type;
|
||
|
||
- callconv -- ᮣ« 襨¥ ® ¢ë§®¢¥
|
||
- "library" -- ¨¬ï ä ©« ¤¨ ¬¨ç¥áª®© ¡¨¡«¨®â¥ª¨
|
||
- "function" -- ¨¬ï ¨¬¯®àâ¨à㥬®© ¯à®æ¥¤ãàë
|
||
|
||
¯à¨¬¥à:
|
||
|
||
PROCEDURE [windows, "kernel32.dll", "ExitProcess"] exit (code: INTEGER);
|
||
|
||
PROCEDURE [stdcall, "Console.obj", "con_exit"] exit (bCloseWindow: BOOLEAN);
|
||
|
||
‚ ª®æ¥ ®¡ê¥¨ï ¬®¦¥â ¡ëâì ¤®¡ ¢«¥® (¥®¡ï§ ⥫ì®) "END proc_name;"
|
||
|
||
Ž¡ê¥¨ï ¨¬¯®àâ¨à®¢ ëå ¯à®æ¥¤ãà ¤®«¦ë à ᯮ« £ âìáï ¢ £«®¡ «ì®©
|
||
®¡« á⨠¢¨¤¨¬®á⨠¬®¤ã«ï ¯®á«¥ ®¡ê¥¨ï ¯¥à¥¬¥ëå, ¢¬¥áâ¥ á ®¡ê¥¨¥¬
|
||
"®¡ëçëå" ¯à®æ¥¤ãà, ®â ª®â®àëå ¨¬¯®àâ¨à®¢ ë¥ ®â«¨ç îâáï ⮫쪮 ®âáãâá⢨¥¬
|
||
⥫ ¯à®æ¥¤ãàë. ‚ ®á⠫쮬, ª â ª¨¬ ¯à®æ¥¤ãà ¬ ¯à¨¬¥¨¬ë ⥠¦¥ ¯à ¢¨« :
|
||
¨å ¬®¦® ¢ë§¢ âì, ¯à¨á¢®¨âì ¯à®æ¥¤ãன ¯¥à¥¬¥®© ¨«¨ ¯®«ãç¨âì ¤à¥á.
|
||
|
||
’ ª ª ª ¨¬¯®àâ¨à®¢ ï ¯à®æ¥¤ãà ¢á¥£¤ ¨¬¥¥â ¥ 㪠§ ¨¥ ᮣ« è¥¨ï ®
|
||
¢ë§®¢¥, ⮠ᮢ¬¥áâ¨¬ë© ¯à®æ¥¤ãàë© â¨¯ ⮦¥ ¤®«¦¥ ¡ëâì ®¡ê¥ á 㪠§ ¨¥¬
|
||
ᮣ« è¥¨ï ® ¢ë§®¢¥:
|
||
|
||
VAR
|
||
ExitProcess: PROCEDURE [windows] (code: INTEGER);
|
||
con_exit: PROCEDURE [stdcall] (bCloseWindow: BOOLEAN);
|
||
|
||
‚ KolibriOS ¨¬¯®àâ¨à®¢ âì ¯à®æ¥¤ãàë ¬®¦® ⮫쪮 ¨§ ¡¨¡«¨®â¥ª, à §¬¥é¥ëå
|
||
¢ /rd/1/lib. ˆ¬¯®àâ¨à®¢ âì ¨ ¢ë§ë¢ âì äãªæ¨¨ ¨¨æ¨ «¨§ 樨 ¡¨¡«¨®â¥ª
|
||
(lib_init, START) ¯à¨ í⮬ ¥ 㦮.
|
||
|
||
„«ï Linux, ¨¬¯®àâ¨à®¢ ë¥ ¯à®æ¥¤ãàë ¥ ॠ«¨§®¢ ë.
|
||
|
||
------------------------------------------------------------------------------
|
||
‘ªàëâë¥ ¯ à ¬¥âàë ¯à®æ¥¤ãà
|
||
|
||
<20>¥ª®â®àë¥ ¯à®æ¥¤ãàë ¬®£ãâ ¨¬¥âì áªàëâë¥ ¯ à ¬¥âàë, ®¨ ®âáãâáâ¢ãîâ ¢ ᯨ᪥
|
||
ä®à¬ «ìëå ¯ à ¬¥â஢, ® ãç¨âë¢ îâáï ª®¬¯¨«ïâ®à®¬ ¯à¨ âà á«ï樨 ¢ë§®¢®¢.
|
||
<EFBFBD>â® ¢®§¬®¦® ¢ á«¥¤ãîé¨å á«ãç ïå:
|
||
|
||
1. <20>à®æ¥¤ãà ¨¬¥¥â ä®à¬ «ìë© ¯ à ¬¥âà ®âªàëâë© ¬ áᨢ:
|
||
PROCEDURE Proc (x: ARRAY OF ARRAY OF REAL);
|
||
‚맮¢ âà ᫨àã¥âáï â ª:
|
||
Proc(LEN(x), LEN(x[0]), SYSTEM.ADR(x))
|
||
2. <20>à®æ¥¤ãà ¨¬¥¥â ä®à¬ «ìë© ¯ à ¬¥âà-¯¥à¥¬¥ãî ⨯ RECORD:
|
||
PROCEDURE Proc (VAR x: Rec);
|
||
‚맮¢ âà ᫨àã¥âáï â ª:
|
||
Proc(SYSTEM.TYPEID(Rec), SYSTEM.ADR(x))
|
||
|
||
------------------------------------------------------------------------------
|
||
Œ®¤ã«ì RTL
|
||
|
||
‚ᥠ¯à®£à ¬¬ë ¥ï¢® ¨á¯®«ì§ãîâ ¬®¤ã«ì RTL. Š®¬¯¨«ïâ®à âà ᫨àã¥â
|
||
¥ª®â®àë¥ ®¯¥à 樨 (¯à®¢¥àª ¨ ®åà ⨯ , áà ¢¥¨¥ áâப, á®®¡é¥¨ï ®¡
|
||
®è¨¡ª å ¢à¥¬¥¨ ¢ë¯®«¥¨ï ¨ ¤à.) ª ª ¢ë§®¢ë ¯à®æ¥¤ãà í⮣® ¬®¤ã«ï. <20>¥
|
||
á«¥¤ã¥â  ¢ë§ë¢ âì í⨠¯à®æ¥¤ãàë, § ¨áª«î票¥¬ ¯à®æ¥¤ãàë SetDll,
|
||
¥á«¨ ¯à¨«®¦¥¨¥ ª®¬¯¨«¨àã¥âáï ª ª Windows DLL:
|
||
|
||
PROCEDURE SetDll
|
||
(process_detach, thread_detach, thread_attach: DLL_ENTRY);
|
||
£¤¥ TYPE DLL_ENTRY =
|
||
PROCEDURE (hinstDLL, fdwReason, lpvReserved: INTEGER);
|
||
|
||
SetDll § ç ¥â ¯à®æ¥¤ãàë process_detach, thread_detach, thread_attach
|
||
¢ë§ë¢ ¥¬ë¬¨ ¯à¨
|
||
- ¢ë£à㧪¥ dll-¡¨¡«¨®â¥ª¨ (process_detach)
|
||
- ᮧ¤ ¨¨ ®¢®£® ¯®â®ª (thread_attach)
|
||
- ã¨ç⮦¥¨¨ ¯®â®ª (thread_detach)
|
||
|
||
„«ï ¯à®ç¨å ⨯®¢ ¯à¨«®¦¥¨©, ¢ë§®¢ ¯à®æ¥¤ãàë SetDll ¥ ¢«¨ï¥â
|
||
¯®¢¥¤¥¨¥ ¯à®£à ¬¬ë.
|
||
‘®®¡é¥¨ï ®¡ ®è¨¡ª å ¢à¥¬¥¨ ¢ë¯®«¥¨ï ¢ë¢®¤ïâáï ¢ ¤¨ «®£®¢ëå ®ª å
|
||
(Windows), ¢ â¥à¬¨ « (Linux), ¤®áªã ®â« ¤ª¨ (KolibriOS).
|
||
|
||
------------------------------------------------------------------------------
|
||
Œ®¤ã«ì API
|
||
|
||
‘ãé¥áâ¢ãî⠥᪮«ìª® ॠ«¨§ 権 ¬®¤ã«ï API (¤«ï à §«¨çëå Ž‘).
|
||
Š ª ¨ ¬®¤ã«ì RTL, ¬®¤ã«ì API ¥ ¯à¥¤ § ç¥ ¤«ï ¯àאַ£® ¨á¯®«ì§®¢ ¨ï.
|
||
Ž ®¡¥á¯¥ç¨¢ ¥â á¢ï§ì RTL á Ž‘.
|
||
|
||
------------------------------------------------------------------------------
|
||
ƒ¥¥à æ¨ï ¨á¯®«ï¥¬ëå ä ©«®¢ DLL
|
||
|
||
<20> §à¥è ¥âáï íªá¯®àâ¨à®¢ âì ⮫쪮 ¯à®æ¥¤ãàë. „«ï í⮣®, ¯à®æ¥¤ãà ¤®«¦
|
||
室¨âìáï ¢ £« ¢®¬ ¬®¤ã«¥ ¯à®£à ¬¬ë, ¨ ¥¥ ¨¬ï ¤®«¦® ¡ëâì ®â¬¥ç¥® ᨬ¢®«®¬
|
||
íªá¯®àâ ("*"). KolibriOS DLL ¢á¥£¤ íªá¯®àâ¨àãîâ ¨¤¥â¨ä¨ª â®àë "version"
|
||
(¢¥àá¨ï ¯à®£à ¬¬ë) ¨ "lib_init" - ¤à¥á ¯à®æ¥¤ãàë ¨¨æ¨ «¨§ 樨 DLL:
|
||
|
||
PROCEDURE [stdcall] lib_init (): INTEGER
|
||
|
||
<EFBFBD>â ¯à®æ¥¤ãà ¤®«¦ ¡ëâì ¢ë§¢ ¯¥à¥¤ ¨á¯®«ì§®¢ ¨¥¬ DLL.
|
||
<EFBFBD>à®æ¥¤ãà ¢á¥£¤ ¢®§¢à é ¥â 1.
|
||
|
||
„«ï Linux, £¥¥à æ¨ï ¤¨ ¬¨ç¥áª¨å ¡¨¡«¨®â¥ª ¥ ॠ«¨§®¢ . |