Subversion Repositories Kolibri OS

Rev

Rev 485 | 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.  org    0x0
  10.  db     'MENUET01'    ; header
  11.  dd     0x01          ; header version
  12.  dd     START         ; entry point
  13.  dd     I_END         ; image size
  14.  dd     I_END+0x10000 ; required memory
  15.  dd     I_END+0x10000 ; esp
  16.  dd     0x0 , 0x0     ; I_Param , I_Path
  17.    
  18. include 'lang.inc'
  19. include '..\..\..\macros.inc'
  20. remote_ip  db  192,168,1,26
  21.    
  22.    
  23. START:                      ; start of execution
  24.    
  25.     mov  eax, 53                  ; open receiver socket
  26.     mov  ebx, 0
  27.     mov  ecx, 0x3000              ; local port
  28.     mov  edx, 0xffff              ; remote port
  29.     mov  esi, dword [remote_ip]   ; remote IP
  30.     mcall
  31.     mov  [socketNum],eax
  32.     mov  [0],eax                  ; save for remote code
  33.  
  34. red:  
  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.     mcall
  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.     mcall
  54.    
  55.     cmp  eax,0
  56.     jne  data_arrived
  57.    
  58.     jmp  still
  59.    
  60. key:
  61.     mov  eax,2
  62.     mcall
  63.     jmp  still
  64.    
  65. button:
  66.    
  67.     mov  eax,53
  68.     mov  ebx,1
  69.     mov  ecx,[socketNum]
  70.     mcall
  71.     or  eax,-1
  72.     mcall
  73.    
  74.    
  75. data_arrived:
  76.    
  77.     mov  eax,5                 ; wait a second for everything to arrive
  78.     mov  ebx,10
  79.     mcall
  80.    
  81.     mov  edi,I_END
  82.    
  83.   get_data:
  84.    
  85.     mov  eax,53
  86.     mov  ebx,3
  87.     mov  ecx,[socketNum]
  88.     mcall
  89.    
  90.     mov  [edi],bl
  91.     inc  edi
  92.    
  93.     mov  eax,53
  94.     mov  ebx,2
  95.     mov  ecx,[socketNum]
  96.     mcall
  97.    
  98.     cmp  eax,0
  99.     jne  get_data
  100.    
  101.     add  byte [I_END+14],48
  102.    
  103.     mov  eax,4
  104.     mov  ebx,10*65536+50
  105.     add  ebx,[y]
  106.     mov  ecx,0x000000
  107.     mov  edx,I_END
  108.     mov  esi,23
  109.     mcall
  110.    
  111.     add  [y],10
  112.    
  113.     cmp  byte [I_END+14],'1'   ; DATA PACKET ?
  114.     jne  no_packet
  115.     mov  esi,I_END+23
  116.     mov  edi,[I_END+15]
  117.     mov  ecx,[I_END+19]
  118.     cld
  119.     rep  movsb
  120.     jmp  still
  121.    no_packet:
  122.    
  123.     cmp  byte [I_END+14],'2'   ; EXECUTE ?
  124.     jne  no_execute
  125.     mov  eax,[I_END+15]
  126.     call eax
  127.     jmp  still
  128.    no_execute:
  129.    
  130.     jmp  still
  131.    
  132. y   dd   0x10
  133.    
  134.    
  135.    
  136. ;   *********************************************
  137. ;   *******  WINDOW DEFINITIONS AND DRAW ********
  138. ;   *********************************************
  139.    
  140.    
  141. draw_window:
  142.    
  143.     mov  eax,12                    ; function 12:tell os about windowdraw
  144.     mov  ebx,1                     ; 1, start of draw
  145.     mcall
  146.    
  147.                                    ; DRAW WINDOW
  148.     mov  eax,0                     ; function 0 : define and draw window
  149.     mov  ebx,100*65536+286         ; [x start] *65536 + [x size]
  150.     mov  ecx,100*65536+330         ; [y start] *65536 + [y size]
  151.     mov  edx,0x14ffffff            ; color of work area RRGGBB
  152.     mov  edi,title                 ; WINDOW LABEL
  153.     mcall
  154.    
  155.    
  156.     ; Re-draw the screen text
  157.     cld
  158.     mov  eax,4
  159.     mov  ebx,10*65536+30           ; draw info text with function 4
  160.     mov  ecx,0x000000
  161.     mov  edx,text
  162.     mov  esi,40
  163.   newline:
  164.     mcall
  165.     add  ebx,16
  166.     add  edx,40
  167.     cmp  [edx],byte 'x'
  168.     jnz  newline
  169.    
  170.    
  171.     mov  eax,12                    ; function 12:tell os about windowdraw
  172.     mov  ebx,2                     ; 2, end of draw
  173.     mcall
  174.    
  175.     ret
  176.    
  177.    
  178. ; DATA AREA
  179.    
  180.    
  181. text:
  182.     db 'THIS NODE         : 192.168.1.22        '
  183.     db 'LISTENING TO PORT : 0x3000              '
  184.     db 'x' ;<- END MARKER, DONT DELETE
  185.    
  186.    
  187. title  db  'CLUSTER REMOTE',0
  188.    
  189. socketNum   dd  0x0
  190.    
  191. send_data   db  'MenuetRemote00'  ; 00  header      ; -> remote port 0x3000
  192.             db  1                 ; 14  send
  193.             dd  0x0               ; 15  position
  194.             dd  0x0               ; 19  size
  195.                                   ; 23
  196.    
  197. execute     db  'MenuetRemote00'  ; 00  header      ; -> remote port 0x3000
  198.             db  2                 ; 14  execute
  199.             dd  0x0               ; 15  position
  200.                                   ; 19
  201. I_END:
  202.    
  203.    
  204.    
  205.    
  206.    
  207.    
  208.