Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. ;
  2. ;    Remote processing example (remote node) - vt
  3. ;
  4. ;    Compile with FASM for Menuet
  5. ;
  6.    
  7.    
  8. use32
  9.    
  10.                 org     0x0
  11.    
  12.                 db      'MENUET00'              ; 8 byte id
  13.                 dd      38                      ; required os
  14.                 dd      START                   ; program start
  15.                 dd      I_END                   ; program image size
  16.                 dd      0x100000                ; required amount of memory
  17.                 dd      0x00000000              ; reserved=no extended header
  18.    
  19. include 'lang.inc'
  20. include 'macros.inc'
  21. remote_ip  db  192,168,1,26
  22.    
  23.    
  24. START:                      ; start of execution
  25.    
  26.     mov  eax, 53                  ; open receiver socket
  27.     mov  ebx, 0
  28.     mov  ecx, 0x3000              ; local port
  29.     mov  edx, 0xffff              ; remote port
  30.     mov  esi, dword [remote_ip]   ; remote IP
  31.     int  0x40
  32.     mov  [socketNum],eax
  33.     mov  [0],eax                  ; save for remote code
  34.    
  35.     call draw_window            ; at first, draw the window
  36.    
  37. still:
  38.    
  39.     mov  eax,23                 ; wait here for event
  40.     mov  ebx,1
  41.     int  0x40
  42.    
  43.     cmp  eax,1                  ; redraw request ?
  44.     jz   red
  45.     cmp  eax,2                  ; key in buffer ?
  46.     jz   key
  47.     cmp  eax,3                  ; button in buffer ?
  48.     jz   button
  49.    
  50.     mov  eax,53                 ; data from cluster terminal ?
  51.     mov  ebx,2
  52.     mov  ecx,[socketNum]
  53.     int  0x40
  54.    
  55.     cmp  eax,0
  56.     jne  data_arrived
  57.    
  58.     jmp  still
  59.    
  60. red:
  61.     call draw_window
  62.     jmp  still
  63.    
  64. key:
  65.     mov  eax,2
  66.     int  0x40
  67.     jmp  still
  68.    
  69. button:
  70.    
  71.     mov  eax,53
  72.     mov  ebx,1
  73.     mov  ecx,[socketNum]
  74.     int  0x40
  75.     mov  eax,-1
  76.     int  0x40
  77.    
  78.    
  79. data_arrived:
  80.    
  81.     mov  eax,5                 ; wait a second for everything to arrive
  82.     mov  ebx,10
  83.     int  0x40
  84.    
  85.     mov  edi,I_END
  86.    
  87.   get_data:
  88.    
  89.     mov  eax,53
  90.     mov  ebx,3
  91.     mov  ecx,[socketNum]
  92.     int  0x40
  93.    
  94.     mov  [edi],bl
  95.     inc  edi
  96.    
  97.     mov  eax,53
  98.     mov  ebx,2
  99.     mov  ecx,[socketNum]
  100.     int  0x40
  101.    
  102.     cmp  eax,0
  103.     jne  get_data
  104.    
  105.     add  byte [I_END+14],48
  106.    
  107.     mov  eax,4
  108.     mov  ebx,10*65536+50
  109.     add  ebx,[y]
  110.     mov  ecx,0x000000
  111.     mov  edx,I_END
  112.     mov  esi,23
  113.     int  0x40
  114.    
  115.     add  [y],10
  116.    
  117.     cmp  byte [I_END+14],'1'   ; DATA PACKET ?
  118.     jne  no_packet
  119.     mov  esi,I_END+23
  120.     mov  edi,[I_END+15]
  121.     mov  ecx,[I_END+19]
  122.     cld
  123.     rep  movsb
  124.     jmp  still
  125.    no_packet:
  126.    
  127.     cmp  byte [I_END+14],'2'   ; EXECUTE ?
  128.     jne  no_execute
  129.     mov  eax,[I_END+15]
  130.     call eax
  131.     jmp  still
  132.    no_execute:
  133.    
  134.     jmp  still
  135.    
  136. y   dd   0x10
  137.    
  138.    
  139.    
  140. ;   *********************************************
  141. ;   *******  WINDOW DEFINITIONS AND DRAW ********
  142. ;   *********************************************
  143.    
  144.    
  145. draw_window:
  146.    
  147.     mov  eax,12                    ; function 12:tell os about windowdraw
  148.     mov  ebx,1                     ; 1, start of draw
  149.     int  0x40
  150.    
  151.                                    ; DRAW WINDOW
  152.     mov  eax,0                     ; function 0 : define and draw window
  153.     mov  ebx,100*65536+286         ; [x start] *65536 + [x size]
  154.     mov  ecx,100*65536+330         ; [y start] *65536 + [y size]
  155.     mov  edx,0x03ffffff            ; color of work area RRGGBB
  156.     mov  esi,0x80aabbcc            ; color of grab bar  RRGGBB,8->color gl
  157.     mov  edi,0x00aabbcc            ; color of frames    RRGGBB
  158.     int  0x40
  159.    
  160.     mov  eax,8
  161.     mov  ebx,(286-19)*65536+12
  162.     mov  ecx,4*65536+12
  163.     mov  edx,1
  164.     mov  esi,0xaabbcc
  165. ;    int  0x40
  166.    
  167.                                    ; WINDOW LABEL
  168.     mov  eax,4                     ; function 4 : write text to window
  169.     mov  ebx,8*65536+8             ; [x start] *65536 + [y start]
  170.     mov  ecx,0x00ffffff            ; color of text RRGGBB
  171.     mov  edx,labeltext             ; pointer to text beginning
  172.     mov  esi,lte-labeltext         ; text length
  173.     int  0x40
  174.    
  175.     ; Re-draw the screen text
  176.     cld
  177.     mov  ebx,10*65536+30           ; draw info text with function 4
  178.     mov  ecx,0x000000
  179.     mov  edx,text
  180.     mov  esi,40
  181.   newline:
  182.     mov  eax,4
  183.     int  0x40
  184.     add  ebx,16
  185.     add  edx,40
  186.     cmp  [edx],byte 'x'
  187.     jnz  newline
  188.    
  189.    
  190.     mov  eax,12                    ; function 12:tell os about windowdraw
  191.     mov  ebx,2                     ; 2, end of draw
  192.     int  0x40
  193.    
  194.     ret
  195.    
  196.    
  197. ; DATA AREA
  198.    
  199.    
  200. text:
  201.     db 'THIS NODE         : 192.168.1.22        '
  202.     db 'LISTENING TO PORT : 0x3000              '
  203.     db 'x <- END MARKER, DONT DELETE            '
  204.    
  205.    
  206. labeltext:  db  'CLUSTER REMOTE'
  207. lte:
  208.    
  209. socketNum   dd  0x0
  210.    
  211. send_data   db  'MenuetRemote00'  ; 00  header      ; -> remote port 0x3000
  212.             db  1                 ; 14  send
  213.             dd  0x0               ; 15  position
  214.             dd  0x0               ; 19  size
  215.                                   ; 23
  216.    
  217. execute     db  'MenuetRemote00'  ; 00  header      ; -> remote port 0x3000
  218.             db  2                 ; 14  execute
  219.             dd  0x0               ; 15  position
  220.                                   ; 19
  221.    
  222. I_END:
  223.    
  224.    
  225.    
  226.    
  227.    
  228.    
  229.