Subversion Repositories Kolibri OS

Rev

Rev 109 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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