kolibrios-gitea/programs/develop/examples/example/trunk/example.asm
Kirill Lipatov (Leency) 16ef653fe4 example update
git-svn-id: svn://kolibrios.org@3064 a494cfbc-eb01-0410-851d-a64ba20cac60
2012-11-21 13:09:09 +00:00

173 lines
5.4 KiB
NASM
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

; <20>à®á⮩ ¯à¨¬¥à ¯à®£à ¬¬ë ¤«ï KolibriOS
; ®§¢ã稢 ¥â ª®¤ ­ ¦ â®© ª« ¢¨è¨
;
; Š®¬¯¨«¨à®¢ âì FASM'®¬
; Œ®¦­® ®âªàëâì example.asm ç¥à¥§ ¯à®£à ¬¬ã FASM (¥ñ ïà«ëª ¥áâì
; ­  à ¡®ç¥¬ á⮫¥)
; € ¬®¦­® ¯à®áâ® ­ ¦ âì F9 ¢ Tinypad'¥. ‹®£ ª®¬¯¨«ï樨
; ®â®¡à ¦ ¥âáï ­  ¤®áª¥ ®â« ¤ª¨ (¯à®£à ¬¬  BOARD)
;
; —â® ¢ ¦­® §­ âì ¯à¨ ¯à®£à ¬¬¨à®¢ ­¨¨ ¯®¤ Š®«¨¡à¨:
; <20>®¬¥à ä㭪樨 ¯®¬¥é ¥âáï ¢ ॣ¨áâà eax.
; ‚맮¢ á¨á⥬­®© ä㭪樨 ®áãé¥á⢫ï¥âáï ª®¬ ­¤®© "int 0x40".
; ‚ᥠॣ¨áâàë, ªà®¬¥ ® 㪠§ ­­ëå ¢ ¢®§¢à é ¥¬®¬ §­ ç¥­¨¨,
; ¢ª«îç ï ॣ¨áâà ä« £®¢ eflags, á®åà ­ïîâáï.
;
; <20>ਬ¥à:
; mov eax, 1 ;”ã­ªæ¨ï 1 - ¯®áâ ¢¨âì â®çªã ¢ ®ª­¥
; ;ᯨ᮪ á¨áä㭪権 á¬. ¢ DOCPACK - sysfuncr.txt
; mov ebx, 10 ; ª®®à¤¨­ â  x=10
; mov ecx, 20 ; ª®®à¤¨­ â  y=10
; mov edx, 0xFFFfff ;梥â â®çª¨
; int 0x40 ;¢ë§¢ âì äã­ªæ¨î
;
; ’®¦¥ á ¬®¥ á ¨á¯®«ì§®¢ ­¨¥¬ ¬ ªà®á :
; mcall 1, 10, 20, 0xFFFfff
;---------------------------------------------------------------------
use32 ; ¢ª«îç¨âì 32-¡¨â­ë© ०¨¬  áᥬ¡«¥à 
org 0x0 ;  ¤à¥á æ¨ï á ­ã«ï
db 'MENUET01' ; 8-¡ ©â­ë© ¨¤¥­â¨ä¨ª â®à MenuetOS
dd 0x01 ; ¢¥àá¨ï § £®«®¢ª  (¢á¥£¤  1)
dd START ;  ¤à¥á ¯¥à¢®© ª®¬ ­¤ë
dd I_END ; à §¬¥à ¯à®£à ¬¬ë
dd 0x1000 ; ª®«¨ç¥á⢮ ¯ ¬ïâ¨
dd 0x1000 ;  ¤à¥á ¢¥à設ë áâíª 
dd 0x0 ;  ¤à¥á ¡ãä¥à  ¤«ï ¯ à ¬¥â஢
dd 0x0 ; § à¥§¥à¢¨à®¢ ­®
include 'lang.inc'
include 'macros.inc' ; ¬ ªà®áë ®¡«¥£ç îâ ¦¨§­ì  áᥬ¡«¥à騪®¢!
;---------------------------------------------------------------------
;--- <20>€—€Ž <20><>Žƒ<C5BD>€ŒŒ ----------------------------------------------
;---------------------------------------------------------------------
START:
red: ; ¯¥à¥à¨á®¢ âì ®ª­®
call draw_window ; ¢ë§ë¢ ¥¬ ¯à®æ¥¤ãàã ®âà¨á®¢ª¨ ®ª­ 
;---------------------------------------------------------------------
;--- –ˆŠ‹ Ž<><C5BD><EFBFBD>ŽŠˆ Ž<E28098>ˆ‰ ----------------------------------------
;---------------------------------------------------------------------
still:
mcall 10 ; äã­ªæ¨ï 10 - ¦¤ âì ᮡëâ¨ï
cmp eax,1 ; ¯¥à¥à¨á®¢ âì ®ª­® ?
je red ; ¥á«¨ ¤  - ­  ¬¥âªã red
cmp eax,2 ; ­ ¦ â  ª« ¢¨è  ?
je key ; ¥á«¨ ¤  - ­  key
cmp eax,3 ; ­ ¦ â  ª­®¯ª  ?
je button ; ¥á«¨ ¤  - ­  button
jmp still ; ¥á«¨ ¤à㣮¥ ᮡë⨥ - ¢ ­ ç «® 横« 
;---------------------------------------------------------------------
key: ; ­ ¦ â  ª« ¢¨è  ­  ª« ¢¨ âãà¥
mcall 2 ; äã­ªæ¨ï 2 - áç¨â âì ª®¤ ᨬ¢®«  (¢ ah)
mov [Music+1], ah ; § ¯¨á âì ª®¤ ᨬ¢®«  ª ª ª®¤ ­®âë
; äã­ªæ¨ï 55-55: á¨á⥬­ë© ¤¨­ ¬¨ª ("PlayNote")
; esi -  ¤à¥á ¬¥«®¤¨¨
; mov eax,55
; mov ebx,eax
; mov esi,Music
; int 0x40
; ¨«¨ ª®à®âª®:
mcall 55, eax, , , Music
jmp still ; ¢¥à­ãâìáï ª ­ ç «ã 横« 
;---------------------------------------------------------------------
button:
mcall 17 ; 17 - ¯®«ãç¨âì ¨¤¥­â¨ä¨ª â®à ­ ¦ â®© ª­®¯ª¨
cmp ah, 1 ; ¥á«¨ <20>… ­ ¦ â  ª­®¯ª  á ­®¬¥à®¬ 1,
jne still ; ¢¥à­ãâìáï
.exit:
mcall -1 ; ¨­ ç¥ ª®­¥æ ¯à®£à ¬¬ë
;---------------------------------------------------------------------
;--- Ž<><C5BD>…„…<E280B9>ˆˆ Ž<C5BD>ˆŽŠ€ ŽŠ<C5BD>€ ----------------------------------
;---------------------------------------------------------------------
draw_window:
mcall 12, 1 ; äã­ªæ¨ï 12: á®®¡é¨âì Ž‘ ®¡ ®âà¨á®¢ª¥ ®ª­ 
; 1 - ­ ç¨­ ¥¬ à¨á®¢ âì
; ¤ «¥¥: á­ ç «  ¤«¨­­ë© ¢ à¨ ­â (§ ª®¬¬¥­â¨à®¢ ­­ë©)
; § â¥¬ ª®à®âª¨©  ­ «®£ á ¨á¯®«ì§®¢ ­¨¥¬ ¬ ªà®á®¢
; ‘Ž‡„€ðŒ ŽŠ<C5BD>Ž
; mov eax,0 ; äã­ªæ¨ï 0 : ®¯à¥¤¥«¨âì ¨ ®âà¨á®¢ âì ®ª­®
; mov ebx,200*65536+200 ; [x áâ àâ] *65536 + [x à §¬¥à]
; mov ecx,200*65536+50 ; [y áâ àâ] *65536 + [y à §¬¥à]
; mov edx,0x33aabbcc ; 梥â à ¡®ç¥© ®¡« á⨠RRGGBB,8->color gl
; mov edi,header ; ‡€ƒŽ‹Ž‚ŽŠ ŽŠ<C5BD>
; int 0x40
mcall 0, <200,200>, <200,50>, 0x33AABBCC,,title
; mov eax,4
; mov ebx,3 shl 16 + 8
; mov ecx,0
; mov edx,message
; mov esi,message.size
; int 0x40
mcall 4, <3, 8>, 0, message, message.size
mcall 12, 2 ; äã­ªæ¨ï 12: á®®¡é¨âì Ž‘ ®¡ ®âà¨á®¢ª¥ ®ª­ 
; 2, § ª®­ç¨«¨ à¨á®¢ âì
ret ; ¢ë室¨¬ ¨§ ¯à®æ¥¤ãàë
;---------------------------------------------------------------------
;--- „€<E2809E><E282AC><20><>Žƒ<C5BD>€ŒŒ ----------------------------------------------
;---------------------------------------------------------------------
; ‚®â â ª ï ¢®â ª®à®âª ï "¬¥«®¤¨ï".
; ‚â®à®© ¡ ©â ¨§¬¥­ï¥âáï ­ ¦ â¨¥¬ ª« ¢¨èë
Music:
db 0x90, 0x30, 0
;---------------------------------------------------------------------
; ¨­â¥àä¥©á ¯à®£à ¬¬ë ¬­®£®ï§ëç­ë©
; ‚ë ¬®¦¥â¥ § ¤ âì ï§ëª ¢ MACROS.INC (lang fix ï§ëª)
lsz message,\
ru,'<27> ¦¬¨â¥ «î¡ãî ª« ¢¨èã...',\
en,'Press any key...',\
fr,'Pressez une touche...'
lsz title,\
ru,'<27><>ˆŒ…<C592> <20><>Žƒ<C5BD>€ŒŒ',\
en,'EXAMPLE APPLICATION',\
fr,"L'exemplaire programme"
;---------------------------------------------------------------------
I_END: ; ¬¥âª  ª®­æ  ¯à®£à ¬¬ë