diff options
Diffstat (limited to 'asm')
-rw-r--r-- | asm/r_loop.asm | 82 | ||||
-rw-r--r-- | asm/r_lowbat.asm | 27 |
2 files changed, 19 insertions, 90 deletions
diff --git a/asm/r_loop.asm b/asm/r_loop.asm index b85fabe..a3a9126 100644 --- a/asm/r_loop.asm +++ b/asm/r_loop.asm @@ -28,7 +28,7 @@ r_loop: pushq %rbp pushq %rbx movq %rsi, %rbx - movq %edi, %ebp + movl %edi, %ebp jmp bigloop bigloop: @@ -54,7 +54,10 @@ bigloop: speak: cmp $0x1, %ebp jne sleepabit - movq (%rbx,0x8,0x2), %rdi + pushq %rcx + movq $0x8, %rcx + movq (%rbx,%rcx,0x2), %rdi + popq %rcx callq n_speak sleepabit: @@ -73,80 +76,13 @@ return: err: movq $0x2, %rdi /* stderr */ - leaq (rel $errmsg), %rsi - movq $errlen, %rdx + movq $errmsg, %rsi + movq $0x25, %rdx movq $0x4, %rax syscall /* write error message on stderr */ xorq %rax, %rax retq -;; section .text -;; extern sleep -;; extern jo_f_percent -;; extern jo_f_status -;; extern jo_n_speak -;; extern jo_n_notify -;; extern jo_r_cpyhead -;; global jo_r_loop - -;; jo_r_loop: -;; push rbp -;; push rbx -;; mov rbx, rsi -;; mov ebp, edi -;; jmp bigloop - -;; bigloop: -;; call jo_f_status ; check the status -;; cmp rax, 0xfe ; in case we couldn't read -;; je err -;; cmp rax, 0x3 -;; je sleepalot -;; call jo_f_percent ; check the capacity -;; cmp rax, 0xfe ; in case we couldn't read -;; je err -;; cmp rax, 0xf -;; jge sleepalot -;; mov rdi, rax -;; call jo_r_cpyhead -;; mov rdi, rax - ;; mov rsi, n_body ; notification body - ;; mov rdx, 0x3 ; ciritcal notification - ;; mov rcx, 0x3a98 ; 15000ms notification timeout - ;; call jo_n_notify ; jo_n_notify(head: rdi, body: rsi, - ;; ; urgency: rdx, timeout: rcx) - -;; speak: -;; cmp ebp, 0x1 -;; jne sleepabit -;; mov rdi, [rbx + 0x8 * 0x2] -;; call jo_n_speak - -;; sleepabit: -;; mov rdi, 0x14 -;; call sleep ; sleep 20 seconds before next check/notification -;; jmp bigloop - -;; sleepalot: -;; mov rdi, 0xf0 -;; call sleep ; sleep 240s (4m) if it's fine -;; jmp bigloop - -;; return: -;; xor rax, rax -;; retq - -;; err: -;; mov rdi, 0x2 ; stderr -;; lea rsi, [rel errmsg] -;; mov rdx, errlen -;; mov rax, 0x4 -;; syscall ; write error message on stderr -;; xor rax, rax -;; retq - .data - n_body: .asciz "Please plug in computer" - fmt: .asciz "%s", 0xa - errmsg: .asciz "Failed to read battery informations", 0xa - errlen: equ $ - errmsg + n_body: .asciz "Please plug in computer" + errmsg: .asciz "Failed to read battery informations\n" diff --git a/asm/r_lowbat.asm b/asm/r_lowbat.asm index 217efc3..a1da30b 100644 --- a/asm/r_lowbat.asm +++ b/asm/r_lowbat.asm @@ -10,24 +10,17 @@ /* */ /****************************************************************************************/ -;; Files prefixes -;; -------------- -;; f: fetch -;; n: notify -;; r: run -;; c: check - -section .text - extern jo_c_args - extern jo_r_loop - global main +.text +.extern c_args +.extern r_loop +.globl main main: - call jo_c_args - mov rdi, rax - call jo_r_loop ; jo_r_loop(speak: 0-1, *argv[]) + callq c_args + movq %rax, %rdi + callq r_loop /* jo_r_loop(speak: 0-1, *argv[]) */ - xor rax, rax - xor rdi, rdi - mov rax, 0x1 + xorq %rax, %rax + xorq %rdi, %rdi + mov $0x1, %rax syscall |