flat assembler
Message board for the users of flat assembler.
Index
> DOS > Case insesitive comparison |
Author |
|
eek 11 May 2007, 02:29
get program name
http://www.frontiernet.net/~fys/progname.htm |
|||
11 May 2007, 02:29 |
|
Picnic 11 May 2007, 17:18
thank you eek for the link, it's what i was looking for.
I change: Code: ax,es:[002Ch] to Code: mov ax,[es:002Ch] I found some more interesting scripts and articles there! If anyone can help me with my first question, hope it make sence, my English are not very good.. |
|||
11 May 2007, 17:18 |
|
rugxulo 24 May 2007, 05:51
This isn't directly an answer (sorry), but for a quick hack / hint, see my AV (.ZIP viewer) proggie.
Code: and al,0DFh ; uppercase or al,20h ; lowercase xor al,20h ; toggle case |
|||
24 May 2007, 05:51 |
|
Picnic 24 May 2007, 20:19
Thank you rugxulo.
Fasm forum has a lot of interesting stuff. It's great to explore. |
|||
24 May 2007, 20:19 |
|
Picnic 30 May 2007, 18:37
I came up to this so far, now comparison is case insensitive.
Code: ;BX = string to search inside ;DX = string to search for ;AX = return position, 0 if not found STRFIND: PUSH BX CX DX SI DI MOV CX,1 @1: MOV AL,BYTE [BX] TEST AL,AL JE @3 MOV SI,BX MOV DI,DX @2: MOV AH,BYTE [DI] TEST AH,AH JE @4 TEST AL,AL JE @3 CMP AH,AL JE @EQ AND AX,0DFDFH CMP AX,4141H JL @NE CMP AX,5A5AH JA @NE CMP AH,AL JNE @NE @EQ: INC DI INC SI MOV AL,BYTE [SI] JMP @2 @NE: INC CX INC BX JMP @1 @3: XOR CX,CX @4: MOV AX,CX POP DI SI DX CX BX RET |
|||
30 May 2007, 18:37 |
|
shoorick 31 May 2007, 04:17
do not forget: "or al,20h" will not help for national characters
|
|||
31 May 2007, 04:17 |
|
rugxulo 31 May 2007, 05:02
If you return 0 if not found, what will you return if the substring is found at position 0 (immediate start of string)? I had the same problem, actually. I just ended up using -1 for error (safer than 0, at least, right?).
P.S. shoorick is right, of course, so keep that in mind. |
|||
31 May 2007, 05:02 |
|
Picnic 31 May 2007, 16:51
Thank you both for your comments.
rugxulo i'm counting from 1 for that reason. |
|||
31 May 2007, 16:51 |
|
Picnic 23 Jul 2007, 17:26
A simple routine i wrote for a friend's school project.
It's a string read routine that stores user input on a variable as a null terminated string. It also handles the backspace key and returns on CX number of chars. Code: ORG 100H MOV DI,BUFFER CALL STRREAD INT 20H STRREAD: PUSH AX DI XOR CX,CX INPUT: MOV AH,01H INT 21H CMP AL,0DH JE EXIT CMP AL,08H JE BACKSPACE STOSB INC CX JMP INPUT BACKSPACE: CMP CX,0 JE ERROR MOV AL,20H INT 29H MOV AL,08H INT 29H DEC CX DEC DI JMP INPUT ERROR: MOV AL,20H INT 29H JMP INPUT EXIT: XOR AL,AL STOSB POP DI AX RET BUFFER DB 100 DUP (?) |
|||
23 Jul 2007, 17:26 |
|
rugxulo 25 Jul 2007, 03:31
thimis, try jcxz Error to save three bytes.
(Also, try indenting your instructions, easier to distinguish from labels. And using ' ' looks more readable than 20h.) |
|||
25 Jul 2007, 03:31 |
|
Picnic 25 Jul 2007, 16:17
nice tips, thanks rugxulo.
|
|||
25 Jul 2007, 16:17 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.