0

i'm trying to print the UNIX time to the std output. Why is this code not working?

mov eax,13          ;sys call time; result is in ebx?
int 80h

mov ecx,ebx         ;copy sys-time from ebx to ecx
add ecx,30h         ;int to char
mov eax,4           ;std output
mov ebx,1
mov edx,10
int 80h

mov eax,1
mov ebx,0
int 80h
Kara
  • 6,115
  • 16
  • 50
  • 57
  • 1
    One problem with your code is that, to convert an integer to ASCII, you can't just add `30h`. That will only convert one decimal digit. You need an entire subroutine and/or a loop to convert the number in a register to ASCII. For example: http://stackoverflow.com/questions/9113772/assembly-numbers-to-ascii – lurker Feb 23 '14 at 12:11
  • 1
    Unless I'm mistaken, sys_time returns its value in `eax` and, if ebx is non-NULL(!), in `[ebx]`. If `ebx` is "random", I'd expect to see -EINVAL. Also, sys_write prints the buffer pointed to by `ecx`, not the value in `ecx`. – Frank Kotler Feb 23 '14 at 21:52

0 Answers0