Phil 4 år sedan
förälder
incheckning
650421738b
1 ändrade filer med 11 tillägg och 29 borttagningar
  1. 11 29
      timer.asm

+ 11 - 29
timer.asm

@@ -9,10 +9,9 @@ SYS_READ equ 0x3
 ;struct timespec contains seconds as time_t (integer unixtimestamp?) and nanoseconds as long 
 
 section .bss
+	;timer filedescriptor
 	tfd RESB 4
-	tst RESB 8
-	tsr RESB 4
-	lt RESB 1
+	;target memory for sys_timerfd_gettime
 	ot RESB 16
 	;timer struct interval
 	itimer RESQ 2
@@ -31,8 +30,6 @@ section .text
 
 _start:
 
-	mov [lt], byte 0x0
-	
 	;prepeare sys_timerfd_create
 	mov eax, SYS_TIMERFD_CREATE
 	mov ebx, 1
@@ -43,12 +40,12 @@ _start:
 	mov [tfd], eax
 
 	;init timer
-	;interval		
-	mov [itimer], dword 0x05
-	mov [itimer + 4], dword 0x00
-	;value
-	mov [itimer + 8], dword 0x05
-	mov [itimer + 12], dword 0x0
+	;interval used for timer triggers
+	mov [itimer], dword 0x05 ;sec
+	mov [itimer + 4], dword 0x00 ;nanosecs
+	;value - initial value must bes set to arm timer
+	mov [itimer + 8], dword 0x05 ;secs
+	mov [itimer + 12], dword 0x0 ;nanosecs
 
 	;settime sys_timerfd_settime
 	mov eax, SYS_TIMERFD_SETTIME
@@ -58,19 +55,12 @@ _start:
 	mov esi, 0
 	int 0x80
 
-	;mov eax, 3
-	;mov ebx, [tfd]
-	;mov ecx, lt
-	;mov edx, 1
-	;int 0x80
-
-	;jmp exit
 
 poll:
-	;get time
+	;get time from fd 
+	;not used just for debugging with strace
 	mov eax, SYS_TIMERFD_GETTIME
 	mov ebx, [tfd]
-	;mov ecx, tst
 	mov ecx, ot
 	int 0x80
 	
@@ -81,19 +71,11 @@ poll:
 	mov edx, 0x20
 	int 0x80
 
-	;mov bx, [ot+13]
-	;sub bx, [lt] 
-	;cmp bx, tick 
-	;jg  poll		
-
-	;mov [lt], bx
-	
+	;print "tick"
 	mov eax, 4
 	mov ebx, 1
 	mov ecx, msg
-	;mov ecx, ot
 	mov edx, msgl
-	;mov edx, 16
 	int 0x80	
 
 	jmp poll