Subversion Repositories Kolibri OS

Rev

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

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