flat assembler
Message board for the users of flat assembler.

Index > MenuetOS > More accurate data needed

Author
Thread Post new topic Reply to topic
CandyMan



Joined: 04 Sep 2009
Posts: 368
Location: film "CandyMan" directed through Bernard Rose OR Candy Shop
CandyMan 28 Aug 2022, 14:28
I need what exactly is in the system function return word:

function EAX = 37, EBX = 2 and EBX = 3
function EAX = 66, EBX = 3

and system function 2 - key scancodes.

How to get the ParamStr(0) or ArgV[0] of a running program?

What is temporary directory in MenuetOS?

Is there any function to set / get current directory?

What about exception handling? Is there any?

_________________
smaller is better
Post 28 Aug 2022, 14:28
View user's profile Send private message Reply with quote
Ville



Joined: 17 Jun 2003
Posts: 273
Ville 28 Aug 2022, 17:00
Here is an example for functions 2,37,66 and 9, which returns applications path/name.

Also startup parameters are displayed when the app is started with 'filename param1 param2' with CMD.

Menuet doesnt have a temporary directory.
And wanted events can be set with system call 40.

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 , 20 shl 32 + 120
    mov   rcx , 160 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 + 170
    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 + 180
    mov   rsi , 0
    int   0x60

    jmp   still


window_event:

    call  draw_window
    jmp   still


key_event:

    mov   rax , 13
    mov   rbx , 20 shl 32 + 120
    mov   rcx , 70 shl 32 + 80
    mov   rdx , 0xf8f8f8
    int   0x60

    ; Get key data

    mov   rax , 2
    int   0x60

    mov   r10 , rax
    mov   r11 , rbx
    mov   r12 , rcx

    ; Function result (rax)

    mov   rax , 47
    mov   rbx , 16 shl 16 + 1 shl 8
    mov   rcx , r10
    mov   rdx , 30 shl 32 + 80
    mov   rsi , 0
    int   0x60

    ; Key type (down/up,value/extended,ascii/unicode)

    mov   rcx , r11
    add   rdx , 12
    int   0x60

    ; Key value/extended

    mov   rcx , r12
    add   rdx , 12
    int   0x60

    mov   rax , 'Key: '
    mov   [text],rax
    mov   [text+5],r12
    mov   [text+5+8],byte 0

    add   rdx , 12
    and   rdx , 0xffff

    mov   rax , 4
    mov   rbx , text                     
    mov   rcx , 30                       
    mov   rsi , 0x000000                 
    mov   r9  , 1                        
    int   0x60

    ; Pressed ctrl,menu,alt,.. keys
    ; Available without key event

    mov   rax , 66
    mov   rbx , 3
    int   0x60

    mov   rcx , rax
    mov   rax , 47
    mov   rbx , 16 shl 16 + 1 shl 8
    mov   rdx , 30 shl 32 + 130
    mov   rsi , 0
    int   0x60

    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 , 256 shl 32 + 250             ; X start & size
    mov   rcx , 128 shl 32 + 230             ; 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 , 30                           ; X position
    mov   rdx , 45                           ; 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

    mov   rax , 12                           ; End of window draw
    mov   rbx , 2
    int   0x60

    ret


; Data area

window_label:

    db    'EXAMPLE',0     ; Window label

text:

    times 32 db ' '

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

parameter: dq  255 ; area length
           rb  256

image_end:

    
Post 28 Aug 2022, 17:00
View user's profile Send private message Reply with quote
Ville



Joined: 17 Jun 2003
Posts: 273
Ville 29 Aug 2022, 16:10
Menuet has ring-3 protection for applications. When memory is accessed beoynd applications memory area (2 MB paging), the application is removed by the OS. Same happens with other privelidged commands when executed at processes ring-3 level. See System -> Protection application. Application can program some interrupts to read data from defined I/O ports.
Post 29 Aug 2022, 16:10
View user's profile Send private message Reply with quote
CandyMan



Joined: 04 Sep 2009
Posts: 368
Location: film "CandyMan" directed through Bernard Rose OR Candy Shop
CandyMan 30 Aug 2022, 17:21
Thanks a lot. You helped me a lot.

I'll be in touch again.
Post 30 Aug 2022, 17:21
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.