FlierMate
Joined: 21 Jan 2021
Posts: 219
|
Hi, I just throw an interesting idea on here, to build a RAD (rapid application development) tool for MenuetOS 64!
Currently I have this very primitive "RAD" tool written in Linux x64, when you run "./m64-rad", it accepts a one-liner text string input from screen, and then generates a MSGBOX.ASM customized with the text string that user just entered.
I know this is far from an interesting RAD tool. Any more idea? We can start working on this together, hopefully a RAD tool on MenuetOS for MenuetOS.
Below is the "m64-rad.asm" (Linux ELF64) that I have just mentioned above.
format ELF64 executable 3
segment readable executable
entry $
mov rdx,48
mov rsi,buffer
xor edi,edi ; STDIN
xor eax,eax ; sys_read
syscall
cmp eax,-1
je _err
mov eax, 85 ;sys_creat
lea rdi, [fn]
mov rsi, 444 ;modes: u=rw, g=r, o=r
syscall
cmp eax, -1
je _err
mov dword [fd],eax
mov rdx,m64_1_len
lea rsi,[m64_1]
call sys_write
mov rdx,m64_2_len
lea rsi,[m64_2]
call sys_write
mov rdx,1
lea rsi,[quote]
call sys_write
mov edx,len
lea rsi,[title]
call sys_write
mov rdx,1
lea rsi,[quote]
call sys_write
mov rdx,1
lea rsi,[newline]
call sys_write
mov rdx,m64_3_len
lea rsi,[m64_3]
call sys_write
mov rdx,1
lea rsi,[quote]
call sys_write
lea rdi,[buffer]
mov ecx, 64
xor eax, eax
repnz scasb ; scan for null character to get length of buffer
mov edx, 64
sub edx, ecx
dec edx ; remove last null character
dec edx ; remove linefeed
lea rsi,[buffer]
call sys_write
mov rdx,1
lea rsi,[quote]
call sys_write
mov rdx,1
lea rsi,[newline]
call sys_write
mov rdx,m64_4_len
lea rsi,[m64_4]
call sys_write
mov edi,dword [fd]
mov eax,3 ; sys_close
syscall
_err:
xor edi,edi
mov eax,60 ; sys_exit
syscall
sys_write:
mov edi,dword [fd]
mov eax,1 ; sys_write
syscall
ret
segment readable writable
quote db 39
newline db 10
fd dd ?
fn db 'MSGBOX.ASM',0 ; Output filename for compilation with MenuetOS flat assembler
m64_1 db 'use64',10,\
' org 0x0',10,\
' db ',39,'MENUET64',39,10,\
' dq 0x01',10,\
' dq START',10,\
' dq image_end',10,\
' dq 0x100000',10,\
' dq 0xffff0',10,\
' dq 0x00',10,\
' dq 0x00',10,\
'START:',10,\
' call draw_window',10,\
'still:',10,\
' mov rax , 10 ; Wait here for event',10,\
' int 0x60',10,\
' test rax , 1 ; Window redraw',10,\
' jnz window_event',10,\
' test rax , 2 ; Keyboard press',10,\
' jnz key_event',10,\
' test rax , 4 ; Button press',10,\
' jnz button_event',10,\
' jmp still',10,\
'window_event:',10,\
' call draw_window',10,\
' jmp still',10,\
'key_event:',10,\
' mov rax , 2 ; Read the key and ignore',10,\
' int 0x60',10,\
' jmp still',10,\
'button_event:',10,\
' mov rax , 17',10,\
' int 0x60',10,\
' ; rax = status',10,\
' ; rbx = button id',10,\
' cmp rbx , 0x10000001',10,\
' jne no_application_terminate_button',10,\
' mov rax , 0x200',10,\
' int 0x60',10,\
' no_application_terminate_button:',10,\
' cmp rbx , 0x106',10,\
' jne no_application_terminate_menu',10,\
' mov rax , 0x200',10,\
' int 0x60',10,\
' no_application_terminate_menu:',10,\
' jmp still',10,\
'draw_window:',10,\
' mov rax , 12 ; Beginning of window draw',10,\
' mov rbx , 1',10,\
' int 0x60',10,\
' mov rax , 0 ; Draw window',10,\
' mov rbx , 256 shl 32 + 384 ; X start & size',10,\
' mov rcx , 128 shl 32 + 128 ; Y start & size',10,\
' mov rdx , 0x0000000000FFFFFF ; Type & border color',10,\
' mov r8 , 0x0000000000000001 ; Flags (set as 1)',10,\
' mov r9 , window_label ; 0 or label - asciiz',10,\
' mov r10 , 0 ; 0 or pointer to menu struct',10,\
' int 0x60',10,\
' mov rax , 4 ; Display text',10,\
' mov rbx , text ; Pointer to text',10,\
' mov rcx , 32 ; X position',10,\
' mov rdx , 64 ; Y position',10,\
' mov rsi , 0x000000 ; Color',10,\
' mov r9 , 1 ; Font',10,\
' int 0x60',10,\
' mov rax , 12 ; End of window draw',10,\
' mov rbx , 2',10,\
' int 0x60',10,\
' ret',10,\
'; Data area',10
m64_1_len = $ - m64_1
m64_2 db 'window_label:',10,\
' db ' ;'Title'
m64_2_len = $ - m64_2
m64_3 db ' db 0',10,\
'text:',10,\
' db ' ;'Message'
m64_3_len = $ - m64_3
m64_4 db ' db 0',10,\
'image_end:'
m64_4_len = $ - m64_4
title db ''
len = $ - title
buffer rb 64
Description: |
Generated and compiled MSGBOX.ASM |
Filesize: |
339.54 KB |
Viewed: |
3391 Time(s) |

|
|
|