aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-04-28 19:49:45 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-04-28 19:49:45 +0200
commitfc39c234ddd2606e75468c490a776898cef84459 (patch)
tree8e80e16d2e4d978f842b566eda026f0ff9bbadcf
parentRewrote r_cpyhead (diff)
downloadlowbat-bsd-fc39c234ddd2606e75468c490a776898cef84459.tar.gz
lowbat-bsd-fc39c234ddd2606e75468c490a776898cef84459.tar.bz2
lowbat-bsd-fc39c234ddd2606e75468c490a776898cef84459.tar.xz
lowbat-bsd-fc39c234ddd2606e75468c490a776898cef84459.tar.zst
lowbat-bsd-fc39c234ddd2606e75468c490a776898cef84459.zip
r_loop rewrite in progress
-rw-r--r--asm/r_loop.asm109
-rw-r--r--src/n_notify.c2
-rw-r--r--src/n_notify.h2
-rw-r--r--src/n_speak.c2
-rw-r--r--src/n_speak.h2
5 files changed, 81 insertions, 36 deletions
diff --git a/asm/r_loop.asm b/asm/r_loop.asm
index d9f3d5e..a730efc 100644
--- a/asm/r_loop.asm
+++ b/asm/r_loop.asm
@@ -10,50 +10,95 @@
/* */
/****************************************************************************************/
-;; jo_r_loop(speak (0-1), *argv[])
-;; -------------------------------
+/***********************************/
+/* jo_r_loop(speak (0-1), *argv[]) */
+/* ------------------------------- */
+/***********************************/
-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
+.text
+.extern sleep
+.extern f_percent
+.extern f_status
+.extern n_speak
+.extern n_notify
+.extern r_cpyhead
+.globl r_loop
-jo_r_loop:
- push rbp
- push rbx
- mov rbx, rsi
- mov ebp, edi
+r_loop:
+ pushq %rbp
+ pushq %rbx
+ movq %rsi, %rbx
+ movq %edi, %ebp
jmp bigloop
bigloop:
- call jo_f_status ; check the status
- cmp rax, 0xfe ; in case we couldn't read
+ callq f_status /* check the status */
+ cmp $0xfe, %rax /* if sys_open/sys_read failed */
je err
- cmp rax, 0x3
+ cmp $0x3, %rax
je sleepalot
- call jo_f_percent ; check the capacity
- cmp rax, 0xfe ; in case we couldn't read
+ callq f_percent /* check the capacity */
+ cmp $0xfe, %rax /* if sys_open/sys_read failed */
je err
- cmp rax, 0xf
+ cmp $0xf, %rax
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)
+ movq %rax, %rdi
+ callq r_cpyhead /* notification head */
+ movq %rax, %rdi
+ movq $n_body, %rsi /* notification body */
+ movq $0x3, %rdx /* critical notification */
+ movq $0x3a98, %rcx /* 15000ms notification timeout */
+ callq n_notify /* n_notify(head: rdi, body: rsi, */
+ /* urgency: rdx, timeout: rcx */
speak:
- cmp ebp, 0x1
+ cmp $0x1, %ebp
jne sleepabit
- mov rdi, [rbx + 0x8 * 0x2]
- call jo_n_speak
+ movq (%rbx,0x8,0x2), %rdi
+ callq n_speak
+
+
+;; 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
diff --git a/src/n_notify.c b/src/n_notify.c
index 94efe75..3798986 100644
--- a/src/n_notify.c
+++ b/src/n_notify.c
@@ -13,7 +13,7 @@
#include <jo_n_notify.h>
void
-jo_n_notify
+n_notify
(const char head[],
const char body[],
NotifyUrgency u,
diff --git a/src/n_notify.h b/src/n_notify.h
index 32ccd41..9bd1c44 100644
--- a/src/n_notify.h
+++ b/src/n_notify.h
@@ -19,7 +19,7 @@
#define JO_LOWBAT "lowbat"
-void jo_n_notify(
+void n_notify(
const char[],
const char[],
NotifyUrgency,
diff --git a/src/n_speak.c b/src/n_speak.c
index 0146e82..a1266c7 100644
--- a/src/n_speak.c
+++ b/src/n_speak.c
@@ -13,7 +13,7 @@
#include <jo_n_speak.h>
void
-jo_n_speak(const char *msg)
+n_speak(const char *msg)
{
espeak_ERROR err;
int32_t samplerate;
diff --git a/src/n_speak.h b/src/n_speak.h
index 19d064c..3270292 100644
--- a/src/n_speak.h
+++ b/src/n_speak.h
@@ -29,6 +29,6 @@ enum
#define JO_ESPEAK_VOICE "English"
-void jo_n_speak(const char *);
+void n_speak(const char *);
#endif