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
52
53
54
55
56
57
58
59
|
/****************************************************************************************/
/* */
/* File : f_status.asm /_________/ */
/* Author : Joe | */
/* Date : 04/2020 | */
/* Info : Gets batt status | */
/* / | */
/* \ / */
/* \_____/ */
/* */
/****************************************************************************************/
/***************/
/* apm status */
/* ---------- */
/* 0: high */
/* 1: low */
/* 2: critical */
/* 3: charging */
/***************/
.text
.extern system
.globl f_status
f_status:
movq $f_cmd, %rdi
callq system
movq $st_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 $0x1, %dl
movb $0x3, %al /* sys_read */
syscall
jc err
xorq %rax, %rax
movb $0x6, %al /* sys_close */
syscall
xorq %rax, %rax
movb (%rsi), %al
subb $0x30, %al
retq
err:
xorq %rax, %rax
movb $0xfe, %al
retq
.data
f_cmd: .asciz "apm -b >/tmp/lowbat.status"
st_file: .asciz "/tmp/lowbat.status"
buff: .byte 0x0, 0x0
|