-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshell.htll
More file actions
124 lines (102 loc) · 2.94 KB
/
shell.htll
File metadata and controls
124 lines (102 loc) · 2.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
;#######################################################
;# HTLL Minimal Shell
;# Author: Mr. Compiler's Assistant
;# Philosophy: Zero Bloat. Manual String Compare.
;#######################################################
; --- Global Buffers ---
arr input_bufferr
arr prompt
arr cmd_help
arr cmd_exit
; --- Global Logic Variables ---
; Remember: No local variables allowed inside functions!
int is_match := 0
int input_lenn := 0
int cmd_len := 0
int val_input := 0
int val_cmd := 0
int i := 0
; --- Setup Helpers ---
func init_constants()
; Setup the prompt
arradd prompt [HTLL-Shell]
prompt.add 62 ; ASCII for '>'
prompt.add 32 ; ASCII for Space
; Setup the 'help' comparison buffer
arradd cmd_help help
; Setup 'exit' command
arradd cmd_exit exit
funcend
; --- String Comparison Function ---
; Compares 'input_bufferr' against 'cmd_help'
; Sets 'is_match' to 1 if equal, 0 if not
func check_if_help()
is_match := 1 ; Assume true initially
input_bufferr.size
input_lenn := rax
cmd_help.size
cmd_len := rax
; 1. optimization: Check length first
if (input_lenn != cmd_len)
is_match := 0
goto end_compare_help
ifend
; 2. Byte-by-byte comparison
Loop, input_lenn
i := A_Index
input_bufferr.index i
val_input := rax
cmd_help.index i
val_cmd := rax
if (val_input != val_cmd)
is_match := 0
goto end_compare_help
ifend
endloop
togo end_compare_help
funcend
; --- Echo Function ---
func echo_input()
print("Echo: ")
input_bufferr.size
Loop, rax
input_bufferr.index A_Index
print_rax_as_char
endloop
print("") ; Newline
funcend
;#######################################################
;# MAIN ENTRY
;#######################################################
main
init_constants()
print("Welcome to the Bear Den. Type 'help' or 'exit'.")
togo shell_loop
; 1. Clear buffer and get input
input_bufferr.clear
input input_bufferr, prompt
; 2. Check for "help"
check_if_help()
if (is_match = 1)
print("--- HELP MENU ---")
print("You are running on raw x86-64 assembly.")
print("This shell has 0 dependencies.")
print("Available commands: help, exit, [any text to echo]")
print("-----------------")
goto shell_loop
ifend
; 3. Check for "exit" (Manual check logic reused)
; (Simplified logic here just to break loop for demo)
input_bufferr.size
if (rax = 4)
; Quick dirty check for 'exit' to allow closing
input_bufferr.index 0
if (rax = 101) ; 'e'
print("Exiting to OS...")
goto shell_exit
ifend
ifend
; 4. Default behavior: Echo
echo_input()
goto shell_loop
togo shell_exit