From 58ca78f1f180e00c00b495851f14f96d0c9d398e Mon Sep 17 00:00:00 2001 From: julianb0 Date: Thu, 30 May 2019 19:07:04 +0200 Subject: [PATCH] dos --- dos/main.k | 7 +++---- dos/str/strrev.k | 7 ++++++- pc/mem.c | 10 ++++++++++ 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/dos/main.k b/dos/main.k index 1a00300..1853574 100644 --- a/dos/main.k +++ b/dos/main.k @@ -9,21 +9,20 @@ main: mov ax0, .msg call print - break mov ax0, .buf mov ax1, .msg call strrev - break + prn 10 mov ax0, .buf call print leave ret -.msg = "Hello World :)\n" -.buf = " " +.msg = "Hello World :)" +.buf = "!!!!!!!!!!!!!!!!" ; ; Exit function diff --git a/dos/str/strrev.k b/dos/str/strrev.k index be2ff88..2f1b2f1 100644 --- a/dos/str/strrev.k +++ b/dos/str/strrev.k @@ -10,8 +10,11 @@ strrev: jz .4 ; save str's location - mov rdx, ax1 + ; xxx why is dec'ing needed? + lea rdx, b[ax1 + -1] + ; go to str's end, just before + ; the null terminator .1: test b[ax1+1], b[ax1+1] jz .2 @@ -19,6 +22,8 @@ strrev: inc ax1 jmp .1 + ; copy, going backward though str + ; and forward through buf .2: mov b[ax0], b[ax1] diff --git a/pc/mem.c b/pc/mem.c index d79849a..cf1d95c 100644 --- a/pc/mem.c +++ b/pc/mem.c @@ -94,6 +94,15 @@ void writemem8(ctx_t *ctx, ulong val, ulong addr) ushort v = ctx->mp[real]; + if (!(addr % 2)) { + ctx->mp[real] = ((v & 0xFF00) << 8) | (val & 0xFF); + } + + else { + ctx->mp[real] = (v & 0xFF) | (((val & 0xFF) << 8)); + } + +/* if (addr % 2) { ctx->mp[real] = (v & 0xFF00) | (val & 0xFF); } @@ -101,6 +110,7 @@ void writemem8(ctx_t *ctx, ulong val, ulong addr) else { ctx->mp[real] = (v & 0xFF) | (((val & 0xFF) << 8)); } +*/ } void writemem16(ctx_t *ctx, ulong val, ulong addr)