Skip to content

Commit

Permalink
Add fmemset in asm for OWC
Browse files Browse the repository at this point in the history
  • Loading branch information
ghaerr committed Jan 3, 2025
1 parent 394e8d3 commit 50e2fb4
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion elks/tools/objtools/ecc
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ CFLAGS="\

ASFLAGS="\
-0 \
-O \
-j \
-O \
-w- \
"

Expand Down
1 change: 1 addition & 0 deletions libc/include/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ int memcmp(const void*, const void*, size_t);
void * memmove(void*, const void*, size_t);

void __far *fmemset(void __far *buf, int c, size_t l);
int fmemcmp(void __far *s1, void __far *s2, size_t n); /* Watcom C only, in ASM */

/* Error messages */
char * strerror(int);
Expand Down
46 changes: 46 additions & 0 deletions libc/watcom/asm/fmemcmp.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
; int fmemcmp(void __far *s1, void __far *s2, size_t n)
; returns 0 on match, otherwise nonzero
;
; 2 Jan 2025 Greg Haerr

include mdef.inc
include struct.inc

modstart fmemcmp

xdefp "C",fmemcmp
defpe fmemcmp

; s1 in DX:AX, s2 in CX:BX, n on stack
push bp
mov bp,sp
push si
push di

mov ds,dx
mov si,ax
mov es,cx
mov di,bx
if _MODEL and _BIG_CODE
mov cx,6[bp] ; n
else
mov cx,4[bp] ; n
endif
cld
repz cmpsb
jz L1 ; equal

mov ax,1 ; not equal, returns nonzero
pop di
pop si
pop bp
ret 2
L1: xor ax,ax
pop di
pop si
pop bp
ret 2

fmemcmp endp
endmod
end

0 comments on commit 50e2fb4

Please sign in to comment.