| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | strlen |
After I wrote that screed, I dug out the assembler and things and had a
look. This is what worked like strlen():-
.model small
.code
pointer dd string
string db 'this is a string',0
start: push es
pushf : preserve msw
push di
cld ; go up
les di,dword ptr pointer
xor ax,ax
mov cx,ax
dec cx ; set cx nonzero
repne scasb
inc cx ; compensate for earlier dec cx
sub ax,cx
dec ax ; discard '\0'
pop di
popf ; reclaim msw
pop es
ret
end
This returns the length of the string in AX.
Obviously it would need a C interface around it to be useful, but I
just wanted to confirm that I hadn't got it completely arse about face.
Best Wishes,
Bill.
---
* Origin: Escan BBS (2:25/200)SEEN-BY: 633/267 270 @PATH: 25/200 108 252/110 250/501 140/1 106/2000 633/267 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.