From 7e831a1495736e3997502de43962d617b7218179 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Thu, 16 Apr 2020 18:44:48 +0200 Subject: Read function is good --- asm/jo_f_status.asm | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 asm/jo_f_status.asm (limited to 'asm') diff --git a/asm/jo_f_status.asm b/asm/jo_f_status.asm new file mode 100644 index 0000000..cc1deb2 --- /dev/null +++ b/asm/jo_f_status.asm @@ -0,0 +1,57 @@ +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; ;; +;; File : jo_f_status.asm /_________/ ;; +;; Author : Joe | ;; +;; Date : 04/2020 | ;; +;; Info : gets batt status | ;; +;; / | ;; +;; \ / ;; +;; \_____/ ;; +;; ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +section .text + extern system + extern malloc + extern printf + global jo_f_status + +jo_f_status: + mov rdi, f_cmd + call system + mov rdi, st_file + mov rsi, 0x0 + 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 + push rax + mov rax, 0x3 + syscall + jc err + pop rax + mov rdi, rax + mov rax, 0x6 + syscall + mov byte [rsi + 0x4], 0x0 + mov rax, rsi + retq + +err: + mov rax, 0x0 + 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 -- cgit v1.2.3