flat assembler
Message board for the users of flat assembler.
Index
> MenuetOS > How to use copy/paste functions? |
Author |
|
Ville 31 Aug 2022, 14:53
Here is an example for copy/paste and application start. In this context your procedure works fine. Press c for copy/paste and h for httpc start.
Code: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; 64 bit Menuet copy/paste and application start example ; ; Compile with FASM 1.60 or above ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; use64 org 0x0 db 'MENUET64' ; Header identifier dq 0x01 ; Version dq START ; Start of code dq image_end ; Size of image dq 0x100000 ; Memory for app dq 0xffff0 ; Rsp dq 0x00 ; Prm dq 0x00 ; Icon START: call draw_window ; At first, draw the window still: mov rax , 10 ; Wait here for event int 0x60 test rax , 1 ; Window redraw jnz window_event test rax , 2 ; Keyboard press jnz key_event test rax , 4 ; Button press jnz button_event jmp still window_event: call draw_window jmp still key_event: mov rax , 2 ; Read key press int 0x60 cmp rbx , 0 jne still cmp cl , 'c' ; c - copy/paste jne nocopypaste call copypaste jmp still nocopypaste: cmp cl , 'h' ; h - application start jne nohttpcstart call httpcstart jmp still nohttpcstart: jmp still httpcstart: ; Unzip and start application mov rax , 256 mov rbx , string_unzip mov rcx , string_httpc int 0x60 ret copypaste: ; Copy from [copytext] -> clipboard -> [pastetext] mov rax , 142 ; Copy/paste system call mov rbx , 1 ; Write data mov rcx , 1 ; Ascii text mov rdx , 8 ; Overall text length mov r8 , 0 ; Ignored for text mov r9 , 0 ; Write position at copypaste (clipboard) area mov r10 , copytext ; Text to copy mov r11 , 8 ; Amount of text to copy int 0x60 xor edi , edi ; Clipboard has text ? mov eax , 142 mov ebx , 2 xor ecx , ecx xor edx , edx db 0x41,0x89,0xf8 int 0x60 cmp eax , 1 setz dl db 0x48 or ebx,ebx setnz dh and dl , dh mov al , dl cmp al , 1 jne nogettext ; Get text mov r8 , rbx ; text length from previous syscall mov rax , 142 ; Copy/paste system call mov rbx , 2 ; Read data mov rcx , 0 ; Read position at copypaste (clipboard) area mov rdx , pastetext ; Data return area at application side int 0x60 call draw_window nogettext: ret button_event: mov rax , 17 int 0x60 ; rax = status ; rbx = button id cmp rbx , 0x10000001 jne no_application_terminate_button mov rax , 0x200 int 0x60 no_application_terminate_button: cmp rbx , 0x106 jne no_application_terminate_menu mov rax , 0x200 int 0x60 no_application_terminate_menu: jmp still draw_window: mov rax , 12 ; Beginning of window draw mov rbx , 1 int 0x60 mov rax , 0 ; Draw window mov rbx , 256 shl 32 + 256 ; X start & size mov rcx , 128 shl 32 + 192 ; Y start & size mov rdx , 0x0000000000FFFFFF ; Type & border color mov r8 , 0x0000000000000001 ; Flags (set as 1) mov r9 , window_label ; 0 or label - asciiz mov r10 , menu_struct ; 0 or pointer to menu struct int 0x60 mov rax , 4 ; Display text mov rbx , copytext ; Pointer to text mov rcx , 30 ; X position mov rdx , 60 ; Y position mov rsi , 0x000000 ; Color mov r9 , 1 ; Font int 0x60 mov rax , 4 ; Display text mov rbx , pastetext ; Pointer to text mov rcx , 30+6*12 ; X position mov rdx , 60 ; Y position mov rsi , 0x000000 ; Color mov r9 , 1 ; Font int 0x60 mov rax , 12 ; End of window draw mov rbx , 2 int 0x60 ret ; Data area window_label: db 'EXAMPLE',0 ; Window label menu_struct: ; Menu Struct dq 0 ; Version dq 0x100 ; Start value of ID to return ( ID + Line ) ; Returned when menu closes and ; user made no selections. db 0,'FILE',0 ; ID = 0x100 + 1 db 1,'New',0 ; ID = 0x100 + 2 db 1,'Open..',0 ; ID = 0x100 + 3 db 1,'Save..',0 ; ID = 0x100 + 4 db 1,'-',0 ; ID = 0x100 + 5 db 1,'Quit',0 ; ID = 0x100 + 6 db 0,'HELP',0 ; ID = 0x100 + 7 db 1,'Contents..',0 ; ID = 0x100 + 8 db 1,'About..',0 ; ID = 0x100 + 9 db 255 ; End of Menu Struct string_unzip: db '\sysdir\unzip',0 string_httpc: db '\sysdir\httpc.zip http://flatassembler.net',0 copytext: db 'copythis -> ',0 pastetext: db ' ',0 image_end: Last edited by Ville on 01 Sep 2022, 15:26; edited 1 time in total |
|||
31 Aug 2022, 14:53 |
|
CandyMan 31 Aug 2022, 16:51
Is it possible to run a web browser in this way with a specific website address?
|
|||
31 Aug 2022, 16:51 |
|
Ville 31 Aug 2022, 17:16
The web-browser doesn't currently react to parameters, but I'll add it to next release.
|
|||
31 Aug 2022, 17:16 |
|
CandyMan 31 Aug 2022, 17:37
I see.
Here are some more questions. Do the functions #58.1 (Write file) and #58.2 (Delete file) with CD path return an error? Why does #58.3 (Read directory entries) behave like "/fd/1" with path "/fd/1/icons.txt" for example? |
|||
31 Aug 2022, 17:37 |
|
Ville 01 Sep 2022, 15:18
Version 1.44.50 has updates and fixes for the above. Also the httpc example above is updated with target page. However, /fd/1/icons.txt returns an error for me, like it should.
|
|||
01 Sep 2022, 15:18 |
|
CandyMan 01 Sep 2022, 17:29
Necromancer's Dos Navigator for x64 MenuetOS.
This is a test version. The "ndn" file is uncompressed and "ndnc" is LZMA compressed. Not everything can work 100% yet. Suggestions to improve something welcome. The program will soon be available on the website: http://ndn.muxe.com/download For now, you can download from here: https://megawrzuta.pl/download/1d9518ecf03a1309df94ca2b6093f6b7.html Thanks for your attention and help. PS: Is it possible to get the system version number somehow? Are you planning to add a system function - playing sounds through a PC speaker? _________________ smaller is better |
|||
01 Sep 2022, 17:29 |
|
CandyMan 02 Sep 2022, 19:17
Can you distinguish between the Pause and NumLock keys in MenuetOS? Pause send sequence E1 1D 45 but NumLock only 45 code.
|
|||
02 Sep 2022, 19:17 |
|
Ville 02 Sep 2022, 19:23
The program is impressive. And if you want me to include it to the Menuet CD, just let me know.
Currently kernel version is located only at the beginning of kernel.mnt -file. But I'll add also a system call to read a more accurate (three part) version. Do you mean a system call to play tunes from PC-speaker or a primitive D/A converter ? I'll take a look at the Pause/Numlock difference. |
|||
02 Sep 2022, 19:23 |
|
CandyMan 02 Sep 2022, 20:16
When the program will be ready, you can include it in the MenuetOS release.
There is a function in KolibriOS that plays a melody in the background via a PC-speaker. Unfortunately, it doesn't support pause at the moment (see below). You could add something similar to your system. Code: ====================================================================== == Function 18, subfunction 8 - disable/enable the internal speaker. = ====================================================================== If speaker sound is disabled, all calls to subfunction 55 of function 55 are ignored. If speaker sound is enabled, they are routed on builtin speaker. ------------------- Subsubfunction 1 - get status. ------------------- Parameters: * eax = 18 - function number * ebx = 8 - subfunction number * ecx = 1 - number of the subsubfunction Returned value: * eax = 0 - speaker sound is enabled; 1 - disabled ----------------- Subsubfunction 2 - toggle status. ------------------ Toggles states of disable/enable. Parameters: * eax = 18 - function number * ebx = 8 - subfunction number * ecx = 2 - number of the subsubfunction Returned value: * function does not return value ====================================================================== Function 55, subfunction 55 - begin to play data on built-in speaker. ====================================================================== Parameters: * eax = 55 - function number * ebx = 55 - subfunction number * esi = pointer to data Returned value: * eax = 0 - success * eax = 55 - error (speaker is off or busy) Data is an array of items with variable length. Format of each item is defined by first byte: * 0 = end of data * 1..0x80 = sets sound duration on 1/100 of second; sound note is defined by immediate value of frequency * following word (2 bytes) contains frequency divider; frequency is defined as 1193180/divider * 0x81 = invalid * 0x82..0xFF = note is defined by octave and number: * duration in 1/100 of second = (first byte)-0x81 * there is one more byte; * (second byte)=0xFF - delay * otherwise it looks like a*0x10+b, where b=number of the note in an octave from 1 to 12, a=number of octave (beginning from 0) Remarks: * Speaker play can be disabled/enabled by subfunction 8 of function 18. * Function returns control, having informed the system an information on request. Play itself goes independently from the program. * The data must be kept in the memory at least up to the end of play. What code is returned when I press the SysRq key? Are you sure 0xE0? Below you will find the codes that are being sent. Code: Alt-SysRq 54 D4 SysRq E0 2A E0 37 E0 B7 E0 AA Ctrl-SysRq E0 37 E0 B7 Shift-SysRq E0 37 E0 B7 Pause E1 1D 45 E1 9D C5 -- Ctrl-Pause E0 46 E0 C6 -- _________________ smaller is better |
|||
02 Sep 2022, 20:16 |
|
FlierMate1 03 Sep 2022, 01:05
CandyMan wrote: Necromancer's Dos Navigator for x64 MenuetOS. Out of curiosity, I create a ISO from your ndn folder, then load and run from within MenuetOS. Nice effort!
|
||||||||||
03 Sep 2022, 01:05 |
|
CandyMan 03 Sep 2022, 06:50
Does the use of the #64,1 (Memory manager) function with rcx=0x7FFFFFFF guarantee that then after calling the memory allocation function no address greater than this value will be returned?
My question is that NDN is 32-bit and will it work when you have more than 4GB of memory. |
|||
03 Sep 2022, 06:50 |
|
Ville 03 Sep 2022, 16:40
Function 64/1 changes the size of the main application area. It has the same effect as the fifth parameter in the app header - memory for application. When function 64/2 is called, it returns a pointer to the applications own paging table (above applications main memory). So it doesnt make a difference if the application is executed below or above the 32bit boundary in ram. The relative address for the new memory area is very likely to be below 32bit.
If the returned pointer is above 32bit, then the application itself has reserved more than 4gb of memory. I'll add the pause/numlock/sysrq fix to next release. I'll also take a look at the pc-speaker. |
|||
03 Sep 2022, 16:40 |
|
Ville 03 Sep 2022, 20:17
If you are looking for sound in QEMU (v.20220817) then the following command should work:
qemu-system-x86_64.exe -cdrom m64cd14450.iso -m 1024 -device ac97 From setup-icon select "autom. driver search" and then press Apply at Audio driver line. Now the menu->coding->audio example should work. For older QEMU versions, just replace the "device" -command with "soundhw" |
|||
03 Sep 2022, 20:17 |
|
Ville 05 Sep 2022, 12:34
1.44.60 has bugfixes for keymap and below is an improved key-tracking example with key-history and kernel version display. The pc-speaker requires reprogramming the timer interrupt, which will interfere with the internal time keeping, so I'll see what I can do about it.
Code: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; 64 bit Menuet event example ; ; Compile with FASM 1.60 or above ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; use64 org 0x0 db 'MENUET64' ; Header identifier dq 0x01 ; Version dq START ; Start of code dq image_end ; Size of image dq 0x100000 ; Memory for app dq 0xffff0 ; Rsp dq parameter ; Prm dq 0x00 ; Icon START: mov rax , 40 mov rbx , 100111b ; Events: mouse,button,keyboard,window int 0x60 call draw_window ; At first, draw the window still: mov rax , 10 ; Wait here for event int 0x60 test rax , 1 ; Window redraw jnz window_event test rax , 2 ; Keyboard press jnz key_event test rax , 4 ; Button press jnz button_event test rax , 32 ; Mouse event jnz mouse_event jmp still mouse_event: mov rax , 13 mov rbx , 30 shl 32 + 110 mov rcx , 230 shl 32 + 40 mov rdx , 0xf8f8f8 int 0x60 ; Mouse buttons mov rax , 37 mov rbx , 2 int 0x60 mov rcx , rax mov rax , 47 mov rbx , 8 shl 16 + 1 shl 8 mov rdx , 30 shl 32 + 240 mov rsi , 0 int 0x60 ; Mouse scroll wheel mov rax , 37 mov rbx , 3 int 0x60 mov rcx , rax mov rax , 47 mov rbx , 16 shl 16 + 1 shl 8 mov rdx , 30 shl 32 + 252 mov rsi , 0 int 0x60 jmp still window_event: call draw_window jmp still key_event: ; Space for new data mov rdi , text mov rsi , rdi add rsi , 10*8 mov rcx , 10*11*8 cld rep movsb ; Get key data mov rax , 2 int 0x60 mov rdi , text+10*11*8 mov [rdi+0],rax mov [rdi+8],rbx mov [rdi+16],rcx ; Pressed ctrl,menu,alt,.. keys ; Available without key event mov rax , 66 mov rbx , 3 int 0x60 mov [rdi+24],rax call draw_keys jmp still button_event: mov rax , 17 int 0x60 ; rax = status ; rbx = button id cmp rbx , 0x10000001 jne no_application_terminate_button mov rax , 0x200 int 0x60 no_application_terminate_button: cmp rbx , 0x106 jne no_application_terminate_menu mov rax , 0x200 int 0x60 no_application_terminate_menu: jmp still draw_window: mov rax , 12 ; Beginning of window draw mov rbx , 1 int 0x60 mov rax , 0 ; Draw window mov rbx , 100 shl 32 + 580 ; X start & size mov rcx , 100 shl 32 + 290 ; Y start & size mov rdx , 0x0000000000FFFFFF ; Type & border color mov r8 , 0x0000000000000001 ; Flags (set as 1) mov r9 , window_label ; 0 or label - asciiz mov r10 , menu_struct ; 0 or pointer to menu struct int 0x60 ; Startup parameter(s) mov rax , 4 ; Display text mov rbx , parameter+8 ; Pointer to text mov rcx , 130 ; X position mov rdx , 60 ; Y position mov rsi , 0x000000 ; Color mov r9 , 1 ; Font int 0x60 ; Display current application path/name mov rax , 111 mov rbx , 1 int 0x60 sub rsp , 1024 mov rcx , rax mov rax , 9 mov rbx , 2 mov rdx , rsp mov r8 , 1000 int 0x60 mov rax , 4 ; Display text mov rbx , rsp ; Pointer to text add rbx , 408 ; table 9-1 mov rcx , 30 ; X position mov rdx , 60 ; Y position mov rsi , 0x000000 ; Color mov r9 , 1 ; Font int 0x60 add rsp , 1024 ; Kernel version mov rax , 26 mov rbx , 11 mov rcx , 904 int 0x60 mov rcx , rax mov rax , 47 mov rbx , 8 shl 16 mov rdx , 230 shl 32 + 60 mov rsi , 0 int 0x60 ; Keys call draw_keys mov rax , 12 ; End of window draw mov rbx , 2 int 0x60 ret draw_keys: ; Draw pressed keys mov r15 , text mov r13 , 30 mov r14 , 80 newline: mov rax , 13 mov rbx , 30 shl 32+510 mov rcx , r14 shl rcx , 32 add rcx , 12 mov rdx , 0xf8f8f8 int 0x60 newcolumn: ; Hex values mov rax , 47 mov rbx , 16 shl 16+1 shl 8 mov rcx , [r15] mov rdx , r13 shl rdx , 32 add rdx , r14 mov rsi , 0 int 0x60 add r15 , 8 add r13 , 18*6 cmp r13 , 30+18*6*3 jb newcolumn ; Key string mov rax , [r15-8*1] mov [textkey+5],rax mov [textkey+5+8],byte 0 mov rax , 4 mov rbx , textkey mov rcx , r13 mov rdx , r14 mov rsi , 0x000000 mov r9 , 1 int 0x60 add r13 , 14*6 ; Shift,ctrl,alt,.. mov rax , 47 mov rbx , 16 shl 16+1 shl 8 mov rcx , [r15] mov rdx , r13 shl rdx , 32 add rdx , r14 mov rsi , 0 int 0x60 mov r13 , 30 add r15 , 8*7 add r14 , 12 cmp r14 , 80+12*12 jb newline ret ; Data area window_label: db 'EXAMPLE',0 menu_struct: ; Menu Struct dq 0 ; Version dq 0x100 ; Start value of ID to return ( ID + Line ) ; Returned when menu closes and ; user made no selections. db 0,'FILE',0 ; ID = 0x100 + 1 db 1,'New',0 ; ID = 0x100 + 2 db 1,'Open..',0 ; ID = 0x100 + 3 db 1,'Save..',0 ; ID = 0x100 + 4 db 1,'-',0 ; ID = 0x100 + 5 db 1,'Quit',0 ; ID = 0x100 + 6 db 0,'HELP',0 ; ID = 0x100 + 7 db 1,'Contents..',0 ; ID = 0x100 + 8 db 1,'About..',0 ; ID = 0x100 + 9 db 255 ; End of Menu Struct textkey: db 'Key: ' parameter: dq 255 ; area length rb 256 text: image_end: |
|||
05 Sep 2022, 12:34 |
|
CandyMan 05 Sep 2022, 15:22
Thanks.
In M$-WINDOWS systems since Windows 7, there is no longer a PC-speaker support. Nothing by force. |
|||
05 Sep 2022, 15:22 |
|
CandyMan 06 Sep 2022, 08:19
I improved the time and date get functions.
I think you can now add NDN to the MenuetOS release. You forgot to change the version number returned by function #26/11. |
|||
06 Sep 2022, 08:19 |
|
Ville 06 Sep 2022, 14:20
The fix for correct version is now uploaded.
|
|||
06 Sep 2022, 14:20 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.