aboutsummaryrefslogtreecommitdiffstats
path: root/asm
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-04-16 19:18:20 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-04-16 19:18:20 +0200
commit754010fba962a7fe859e7f2efb977ec4eff04920 (patch)
treec0fbd9dd5513d43f0bf0ba84bd91a3117409078f /asm
parentRead function is good (diff)
downloadlowbat-bsd-754010fba962a7fe859e7f2efb977ec4eff04920.tar.gz
lowbat-bsd-754010fba962a7fe859e7f2efb977ec4eff04920.tar.bz2
lowbat-bsd-754010fba962a7fe859e7f2efb977ec4eff04920.tar.xz
lowbat-bsd-754010fba962a7fe859e7f2efb977ec4eff04920.tar.zst
lowbat-bsd-754010fba962a7fe859e7f2efb977ec4eff04920.zip
Better read function
Diffstat (limited to 'asm')
-rw-r--r--asm/jo_f_status.asm34
1 files changed, 16 insertions, 18 deletions
diff --git a/asm/jo_f_status.asm b/asm/jo_f_status.asm
index cc1deb2..c4f517c 100644
--- a/asm/jo_f_status.asm
+++ b/asm/jo_f_status.asm
@@ -10,10 +10,16 @@
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; apm status
+;; ----------
+;; 0: high
+;; 1: low
+;; 2: critical
+;; 3: charging
+
section .text
extern system
- extern malloc
- extern printf
+ extern atoi
global jo_f_status
jo_f_status:
@@ -24,15 +30,9 @@ jo_f_status:
mov rax, 0x5
syscall
jc err
- push rax
- mov rdi, 0x5
- call malloc
- cmp rax, 0x0
- je err
- mov rsi, rax
- pop rax
mov rdi, rax
- mov rdx, 0x4
+ mov rsi, buff
+ mov rdx, 0x1
push rax
mov rax, 0x3
syscall
@@ -41,17 +41,15 @@ jo_f_status:
mov rdi, rax
mov rax, 0x6
syscall
- mov byte [rsi + 0x4], 0x0
- mov rax, rsi
+ mov rdi, rsi
+ call atoi
retq
err:
- mov rax, 0x0
+ mov rax, 0xff
retq
section .data
- f_cmd: db "apm | grep Status | awk -F ' ' '{print $3}' > /tmp/lowbat.status", 0x0
- st_file: db "/tmp/lowbat.status", 0x0
-
- ;; charging
- ;; discharg
+ f_cmd: db "apm -b > /tmp/lowbat.status", 0x0
+ st_file: db "/tmp/lowbat.status", 0x0
+ buff: db 0x0, 0x0