diff --git a/nemu/src/device/timer.cc b/nemu/src/device/timer.cc
index 9fd1ea7256addfacb9b0026e089ea1d8e84304f9..e4e9127ea33afbbb312127c9431355fd876f6709 100644
--- a/nemu/src/device/timer.cc
+++ b/nemu/src/device/timer.cc
@@ -12,17 +12,24 @@ void timer_intr() {
 }
 
 static uint32_t *rtc_port_base;
+static uint32_t startup_milli = 0;
+
+uint32_t host_get_uptime_milli() {
+  struct timeval now;
+  gettimeofday(&now, NULL);
+  uint32_t seconds = now.tv_sec;
+  uint32_t useconds = now.tv_usec;
+
+  return seconds * 1000 + (useconds + 500) / 1000 - startup_milli;
+}
 
 void rtc_io_handler(ioaddr_t addr, int len, bool is_write) {
   if (!is_write) {
-    struct timeval now;
-    gettimeofday(&now, NULL);
-    uint32_t seconds = now.tv_sec;
-    uint32_t useconds = now.tv_usec;
-    rtc_port_base[0] = seconds * 1000 + (useconds + 500) / 1000;
+    rtc_port_base[0] = host_get_uptime_milli();
   }
 }
 
 void init_timer() {
   rtc_port_base = (uint32_t *)add_pio_map(RTC_PORT, 4, rtc_io_handler);
+  startup_milli = host_get_uptime_milli();
 }
diff --git a/nexus-am/am/arch/x86-nemu/src/devices/timer.c b/nexus-am/am/arch/x86-nemu/src/devices/timer.c
index 9fd970cbd575995ee63c88b49ac719fc156972dd..1c009e0b6382f1bf1acb7eca1317bf3afb1c73ac 100644
--- a/nexus-am/am/arch/x86-nemu/src/devices/timer.c
+++ b/nexus-am/am/arch/x86-nemu/src/devices/timer.c
@@ -2,16 +2,16 @@
 #include <x86.h>
 #include <amdev.h>
 
+#include <klib.h>
+
 size_t timer_read(uintptr_t reg, void *buf, size_t size) {
   const size_t rtc_port_id = 0x48;
-  uint64_t curr_time;
 
   switch (reg) {
     case _DEVREG_TIMER_UPTIME: {
       _UptimeReg *uptime = (_UptimeReg *)buf;
-      curr_time = inl(rtc_port_id);
-      uptime->hi = curr_time >> 32;
-      uptime->lo = (uint32_t) curr_time;
+      uptime->hi = 0;
+      uptime->lo = inl(rtc_port_id);
       return sizeof(_UptimeReg);
     }
     case _DEVREG_TIMER_DATE: {