kolibrios-fun/programs/system/clip/trunk/cliptest.ASM
fedesco 8aeeb1b9b0 italian version
git-svn-id: svn://kolibrios.org@3587 a494cfbc-eb01-0410-851d-a64ba20cac60
2013-06-02 05:26:24 +00:00

241 lines
3.5 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.

; <--- description --->
; compiler: FASM
; name: Clipboard Client Demo
; version: 0.1
; author: barsuk
; <--- include all MeOS stuff --->
include "lang.inc"
include "..\..\..\macros.inc"
TEST_SIZE = 100000 ; ¤®«¦­® ¤¥«¨âìáï ­  4
IPC_buffer_size = TEST_SIZE + 0x10
MAX_BUFFER = TEST_SIZE + 0x10
SEND_DELAY = 10
RECV_DELAY = 100
ATTEMPT = 5 ; ç¨á«® ¯®¯ë⮪ ®â¯à ¢¨âì á®®¡é¥­¨¥ ¤¥¬®­ã, ¥á«¨
; ®­ § ­ïâ
; <--- start of MenuetOS application --->
MEOS_APP_START
define DEBUG TRUE
include "bdebug.inc"
include "clip.inc"
; <--- start of code --->
CODE
;;; This is the entry point of the program
begin:
print "clipboard testing module loaded"
mov eax, 5
mov ebx, 100 ; 5 sec
int 0x40
call clipboard_init
or eax, eax
jz .err
; put the data into clip_buffer
mov esi, test_line
mov edi, cb.data
mov ecx, cb.size
rep movsb
print "init ok. @clip found."
mov esi, cb
mov eax, 2
call clipboard_write
or eax, eax
jz .err
print "write test ok."
; á«¥£ª  ®ç¨á⨬ ¡ãä¥à, ¤«ï ­ ¤¥¦­®á⨠¯à®¢¥àª¨
mov dword [cb.data], 0
;jmp .exit
mov eax, 3 ; try to read bad data
mov esi, cb
mov edx, 7
call clipboard_read
or eax, eax
jz .bad2
cmp eax, -1
jz .err
.bad2:
print "unset data read ok 1."
mov eax, 88 ; -"-
mov esi, cb
mov edx, 7
call clipboard_read
or eax, eax
jz .bad3
cmp eax, -1
jz .err
.bad3:
print "unset data read ok 2."
.read:
mov eax, 2
mov esi, cb
mov edx, 7
call clipboard_read ; read the string we've written
or eax, eax
jz .err
cmp eax, -1
jz .err
print "read ok o_O, data:"
outs cb.data
print ""
mov eax, 5
mov ebx, 200
int 0x40
; ¯®á«¥¤­ïï ¯à®¢¥àª  - ­  à¥á ©§ ¡ãä¥à .   ¨¬¥­­®, ¢®§ì¬¥¬ ¬­®£® ¤ ­­ëå
; ¨ ¯à®ª ç ¥¬ ¨å ç¥à¥§ ¡ãä¥à
mov eax, 68
mov ebx, 11
int 0x40
mov eax, 68
mov ebx, 12
mov ecx, TEST_SIZE + 12
int 0x40
mov [mega_buf], eax
mov dword [eax], TEST_SIZE
lea edx, [eax + 12]
mov eax, 12131415
shr ecx, 2
.loop:
mov [edx], eax
add edx, 4
dec ecx
jnz .loop
print "mega buffer allocated and filled"
; now write it
mov esi, [mega_buf]
mov eax, 69
call clipboard_write
or eax, eax
jz .err
print "mega buffer written"
mov eax, 5
mov ebx, 100
int 0x40
; clear it.
mov edx, [mega_buf]
add edx, 12
xor eax, eax
mov ecx, TEST_SIZE/4
.loopc:
mov [edx], eax
add edx, 4
dec ecx
jnz .loopc
; now read
mov eax, 69
mov esi, [mega_buf]
mov edx, 7
call clipboard_read ; read the string we've written
or eax, eax
jz .err
cmp eax, -1
jz .err
print "mega buf read"
; now compare
mov edx, [mega_buf]
add edx, 12
mov eax, 12131415
mov ecx, TEST_SIZE/4
.loopm:
cmp eax, [edx]
jnz .err
add edx, 4
dec ecx
jnz .loopm
print "deleting mega buf"
mov eax, 69
call clipboard_delete
or eax, eax
jz .err
mov eax, 5
mov ebx, 100
int 0x40
print "if read error then all is ok"
mov eax, 69
mov esi, [mega_buf]
mov edx, 7
call clipboard_read ; read the string we've written
or eax, eax
jz .reading
jmp .err
.reading:
print "test complete!"
.exit:
or eax, -1
int 0x40
.err:
print "error!"
jmp .exit
; <--- initialised data --->
DATA
CLIP_BUFFER cb, 256
; in_buf db 256 dup(0)
; out_buf db 'Cthulhu Fhtagn',0
test_line db 'Cthulhu Fhtagn',0
mega_buf dd 0
; <--- uninitialised data --->
UDATA
MEOS_APP_END
; <--- end of MenuetOS application --->