Compare commits
No commits in common. "5c91ace69b308c19d832603948e4bf485a3e97f0" and "57987228b0562792fb3e4f44c0ddafabe8740ee6" have entirely different histories.
5c91ace69b
...
57987228b0
@ -26,9 +26,9 @@ section .rodata
|
|||||||
|
|
||||||
home_cursor: db ESC_CHAR, "[H", 0
|
home_cursor: db ESC_CHAR, "[H", 0
|
||||||
|
|
||||||
statusbar: db ESC_CHAR, "[32;100m", "Use arrow keys to move cursor, enter to invert cell j/k to change simulation speed, p to simulation. Frame Delay multiplier:", 0
|
statusbar: db ESC_CHAR, "[32;100m", "Use arrow keys to move cursor, enter to invert cell j/k to change simulation speed, p to simulation. SPEED:", 0
|
||||||
statusbarLen: equ $-statusbar
|
statusbarLen: equ $-statusbar
|
||||||
START_STOP_pos: equ statusbarLen-42
|
START_STOP_pos: equ statusbarLen-25
|
||||||
|
|
||||||
|
|
||||||
start_str: db "START", 0
|
start_str: db "START", 0
|
||||||
|
46
src/main.asm
46
src/main.asm
@ -20,8 +20,6 @@ section .bss
|
|||||||
extern cursor_rows
|
extern cursor_rows
|
||||||
extern cursor_cols
|
extern cursor_cols
|
||||||
|
|
||||||
global running_in_tty
|
|
||||||
running_in_tty: RESB 1
|
|
||||||
|
|
||||||
section .rodata
|
section .rodata
|
||||||
extern resetLen
|
extern resetLen
|
||||||
@ -29,8 +27,6 @@ section .rodata
|
|||||||
hide_cursor: db ESC_CHAR, "[?25l", 0
|
hide_cursor: db ESC_CHAR, "[?25l", 0
|
||||||
show_cursor: db ESC_CHAR, "[?25h", 0
|
show_cursor: db ESC_CHAR, "[?25h", 0
|
||||||
|
|
||||||
help_text: db "asm-game-of-life [args]",0xA,"-h display this help menu",0xA,"Controls:",0xA,"use arrow keys to move around",0xA,"ENTER to invert cell",0xA,"p to START/STOP simulation",0xA,"k to increase simulation speed",0xA,"j to decrese simulation speed",0xA, 0
|
|
||||||
|
|
||||||
section .text
|
section .text
|
||||||
extern print_str
|
extern print_str
|
||||||
extern unsigned_int_to_ascii
|
extern unsigned_int_to_ascii
|
||||||
@ -62,50 +58,11 @@ _start:
|
|||||||
|
|
||||||
; handle args
|
; handle args
|
||||||
pop rcx; get argc (number of arguments)
|
pop rcx; get argc (number of arguments)
|
||||||
pop rax; get rid of program name arugument
|
|
||||||
cmp rcx, 1
|
cmp rcx, 1
|
||||||
jle .no_arguments_provided
|
jle .no_arguments_provided
|
||||||
dec rcx
|
; TODO hanndle arguments
|
||||||
.handle_arg:
|
|
||||||
pop rax
|
|
||||||
mov word di, [rax]
|
|
||||||
|
|
||||||
cmp di, 0x682D; check if -h was passed
|
|
||||||
jne .next_arg
|
|
||||||
lea rdi, [help_text]
|
|
||||||
call print_str
|
|
||||||
jmp .exit_program
|
|
||||||
|
|
||||||
.next_arg:
|
|
||||||
dec rcx
|
|
||||||
test rcx, rcx
|
|
||||||
jnz .handle_arg
|
|
||||||
|
|
||||||
.no_arguments_provided:
|
.no_arguments_provided:
|
||||||
|
|
||||||
|
|
||||||
pop rax; get rid of null termination of argv
|
|
||||||
; handle enviroment vars
|
|
||||||
|
|
||||||
.handle_env:
|
|
||||||
pop rax
|
|
||||||
test rax, rax; test if we reached end of envs
|
|
||||||
jz .no_envs
|
|
||||||
|
|
||||||
mov dword edi, [rax]
|
|
||||||
cmp edi, 0x4D524554; check for "TERM" inverted becose endiannes
|
|
||||||
jne .handle_env
|
|
||||||
mov qword rdi, [rax+5]; remove the TERM= part this should never segfault since there sould allwas be other data behind enviroment vars and i dont mind garbage
|
|
||||||
mov rsi, 0xffffffffff
|
|
||||||
and rdi, rsi
|
|
||||||
mov rsi, 0x78756e696c
|
|
||||||
cmp rdi, rsi; check for "linux"
|
|
||||||
jne .no_envs
|
|
||||||
mov byte [running_in_tty], 1
|
|
||||||
|
|
||||||
.no_envs:
|
|
||||||
|
|
||||||
|
|
||||||
call init_alloc
|
call init_alloc
|
||||||
|
|
||||||
xor rax, rax
|
xor rax, rax
|
||||||
@ -147,7 +104,6 @@ _start:
|
|||||||
lea rdi, [show_cursor]
|
lea rdi, [show_cursor]
|
||||||
call print_str
|
call print_str
|
||||||
|
|
||||||
.exit_program:
|
|
||||||
mov rax, SYS_EXIT
|
mov rax, SYS_EXIT
|
||||||
mov rdi, 0 ; return code
|
mov rdi, 0 ; return code
|
||||||
syscall
|
syscall
|
||||||
|
Loading…
x
Reference in New Issue
Block a user