1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
/* ************************************************************************************ */
/* */
/* File : f_percent.asm /_________/ */
/* Author : Joe | */
/* Date : 04/2020 | */
/* Info : Gets batt remaining capacity | */
/* / | */
/* \ / */
/* \_____/ */
/* */
/* ************************************************************************************ */
.text
.extern system
.extern atoi
.globl f_percent
.globl main
f_percent:
movq $f_cmd, %rdi
callq system
movq $pr_file, %rdi
xorq %rsi, %rsi
xorq %rax, %rax
movb $0x5, %al /* sys_open */
syscall
jc err
movq %rax, %rdi
movq $buff, %rsi
xorq %rdx, %rdx
xorq %rax, %rax
movb $0x3, %dl
movb $0x3, %al /* sys_read */
syscall
jc err
xorq %rax, %rax
movb $0x6, %al /* sys_close */
syscall
xorq %rax, %rax
movq %rsi, %rdi
callq atoi
retq
err:
movq $0xfe, %rax
retq
.data
f_cmd: .asciz "apm -l >/tmp/lowbat.percent"
pr_file: .asciz "/tmp/lowbat.percent"
buff: .byte 0x0, 0x0, 0x0, 0x0
|