From 18747ae31aad36a058330e350fcdbe36692e0d4a Mon Sep 17 00:00:00 2001 From: julianb0 Date: Thu, 30 May 2019 19:33:22 +0200 Subject: [PATCH] dos --- dos/main.k | 2 +- dos/str/strcpy.k | 21 +++++++++++++++++++++ dos/str/string.k | 1 + dos/str/strrev.k | 5 ++--- pc/instrs/instrs.h | 2 +- 5 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 dos/str/strcpy.k diff --git a/dos/main.k b/dos/main.k index 1853574..5c695a6 100644 --- a/dos/main.k +++ b/dos/main.k @@ -22,7 +22,7 @@ main: ret .msg = "Hello World :)" -.buf = "!!!!!!!!!!!!!!!!" +.buf = "!!!!!!!!!!!!!!!!!!!!!" ; ; Exit function diff --git a/dos/str/strcpy.k b/dos/str/strcpy.k new file mode 100644 index 0000000..8336202 --- /dev/null +++ b/dos/str/strcpy.k @@ -0,0 +1,21 @@ +; The OS/K Team licenses this file to you under the MIT license. +; See the LICENSE file in the project root for more information. + +; +; void strcpy(char *, const char *) +; +strcpy: + ret + +; +; void strncpy(char *, const char *, int) +; +strncpy: + ret + +; +; void strnzcpy(char *, const char *, int) +; +strnzcpy: + ret + diff --git a/dos/str/string.k b/dos/str/string.k index 9c90413..2e73c55 100644 --- a/dos/str/string.k +++ b/dos/str/string.k @@ -3,4 +3,5 @@ include "str/strlen.k" include "str/strrev.k" +include "str/strcpy.k" diff --git a/dos/str/strrev.k b/dos/str/strrev.k index 2f1b2f1..002afbd 100644 --- a/dos/str/strrev.k +++ b/dos/str/strrev.k @@ -10,8 +10,7 @@ strrev: jz .4 ; save str's location - ; xxx why is dec'ing needed? - lea rdx, b[ax1 + -1] + mov rdx, ax1 ; go to str's end, just before ; the null terminator @@ -23,7 +22,7 @@ strrev: jmp .1 ; copy, going backward though str - ; and forward through buf + ; and forward through buf .2: mov b[ax0], b[ax1] diff --git a/pc/instrs/instrs.h b/pc/instrs/instrs.h index ba84e9c..07dd1e5 100644 --- a/pc/instrs/instrs.h +++ b/pc/instrs/instrs.h @@ -31,7 +31,7 @@ void i_##name(ctx_t *ctx, acc_t *p1, acc_t *p2) \ assert(p1->type == A_REG || p1->mem); \ if (p1->mem) { \ ulong addr = p1->type == A_REG ? ctx->r[p1->val].val : p1->val; \ - writemem(ctx, v1, addr, p1->mlen); \ + writemem(ctx, v1, addr + p1->off, p1->mlen); \ } \ else ctx->r[p1->val].val = v1; \ } \