flat assembler
Message board for the users of flat assembler.

Index > Windows > Strings and Local Variables

Goto page Previous  1, 2, 3  Next
Author
Thread Post new topic Reply to topic
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 12 Dec 2009, 23:53
Quote:

LODS should update ESI position and STODS the EDI. But they don't! (idon't know why) Sad so I did EDI update manually each loop.

crap, crap, crap! You're right, sorry, I looked too fast your code.

Look at this dump:
Code:
004010A0  40 60 60 00 5B 7B 7B 00 5C 7C 7C 00 5D 7D 7D 00  @``.[{{.\||.]}}.
004010B0  5E 7E 7E 00 5F 7F 7F 00 C0 E0 E0 00 C1 E1 E1 00  ^~~._.Ààà.Ááá.
004010C0  C2 E2 E2 00 C3 E3 E3 00 C4 E4 E4 00 C5 E5 E5 00  Âââ.Ããã.Äää.Ååå.
004010D0  C6 E6 E6 00 C7 E7 E7 00 C8 E8 E8 00 C9 E9 E9 00  Æææ.Ççç.Èèè.Ééé.
004010E0  CA EA EA 00 CB EB EB 00 CC EC EC 00 CD ED ED 00  Êêê.Ëëë.Ììì.Ííí.
004010F0  CE EE EE 00 CF EF EF 00 D0 F0 F0 00 D1 F1 F1 00  Îîî.Ïïï.Ððð.Ñññ.
00401100  D2 F2 F2 00 D3 F3 F3 00 D4 F4 F4 00 D5 F5 F5 00  Òòò.Óóó.Ôôô.Õõõ.
00401110  D6 F6 F6 00 D7 F7 F7 00 D8 F8 F8 00 D9 F9 F9 00  Ööö.×÷÷.Øøø.Ùùù.
00401120  DA FA FA 00 DB FB FB 00 DC FC FC 00 DD FD FD 00  Úúú.Ûûû.Üüü.Ýýý.
00401130  DE FE FE 00 DF FF FF 00                          Þþþ.ßÿÿ.    


It contains the difference in conversion of your code and my code (SUB/CMP), the format is <yours, mine, original_char, 0>.

In case I did something wrong, this is the code I used:
Code:
include 'win32ax.inc'


proc strToUpper str:dword

        mov   esi, [str]        ; define src
 .next: mov   edi, esi          ; define dest [and later, new dest]
        lodsb                   ; AX = a char
        cmp   al, 0             ; if end_of_string exit
        je   .exit
        mov   bl, al
        and   bl, 'a'
        and   bl, 'z'
        cmp   bl, 'a' - 1
        jnz  .next
        sub   al, 'a'-'A'       ; offset
        stosb                   ; loads AX to str
        jmp  .next
 .exit: ret
endp

proc strToUpper2 str:dword

        mov   esi, [str]        ; define src
 .next: mov   edi, esi          ; define dest [and later, new dest]
        lodsb                   ; AX = a char
        cmp   al, 0             ; if end_of_string exit
        je   .exit
        mov   bl, al
        sub   bl, 'a'
        cmp   bl, 'z' - 'a'
        ja    .next
        sub   al, 'a'-'A'       ; offset
        stosb                   ; loads AX to str
        jmp  .next
 .exit: ret
endp

start:
stdcall strToUpper, buff
stdcall strToUpper2, buff2

mov ecx, 256
mov esi, buff
mov edi, buff2
mov ebx, diffBuf

.loop:
test ecx, ecx
jz   .halt

repe cmpsb
je   .halt

lea  eax, [ecx-256]
not  eax

mov  dl, [buff+eax]
mov  [ebx], dl
mov  dl, [buff2+eax]
mov  [ebx+1], dl
inc  al
mov  [ebx+2], al
mov  byte [ebx+3], 0
add  ebx, 4

jmp .loop

.halt:int3 ; Call OllyDbg Very Happy

align 16
diffBuf rb 256*4

buff:
  repeat 256
    db % and 255
  end repeat
buff2:
  repeat 256
    db % and 255
  end repeat

.end start    


[edit]Mmmh, Teehee's code did the appropriate transformation several times. Perhaps he only has some small flaw that can be corrected easily? I've always used a manually made table for converting chars above 128...
Post 12 Dec 2009, 23:53
View user's profile Send private message Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2465
Location: Bucharest, Romania
Borsuc 13 Dec 2009, 00:42
oh I get it now, sorry for the confusion and the al/bl mistake on my part. Razz
Post 13 Dec 2009, 00:42
View user's profile Send private message Reply with quote
Teehee



Joined: 05 Aug 2009
Posts: 570
Location: Brazil
Teehee 13 Dec 2009, 09:06
@Borsuc: Razz

@LocoDelAssembly: I don't know to read the dump Embarassed
what the dump is? how it works? what can I do with it? how can I learn to read it!? what your dump is telling us!? (sorry for many questions!) Smile

_________________
Sorry if bad english.
Post 13 Dec 2009, 09:06
View user's profile Send private message Reply with quote
Teehee



Joined: 05 Aug 2009
Posts: 570
Location: Brazil
Teehee 13 Dec 2009, 11:43
Teehee wrote:
I think that way you proposed can't work in characters like Ç â é ã... and the AND way it works.


err.. I was testing and seems the only exception is characteres between #123 and #127. They change.

_________________
Sorry if bad english.
Post 13 Dec 2009, 11:43
View user's profile Send private message Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2465
Location: Bucharest, Romania
Borsuc 13 Dec 2009, 16:44
The dump, the way I see it, is <your, Loco's, original, 0> sequence for every byte. e.g: first byte is your result, second is Loco's, third is original character, fourth a 0, then it repeats (4-byte sequence)
Post 13 Dec 2009, 16:44
View user's profile Send private message Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 796
Location: Massachusetts, USA
bitshifter 14 Dec 2009, 05:34
To explore new ways is always fun Smile
Here are some parts to help you...
http://dex.7.forumer.com/viewtopic.php?p=5278#5278
Post 14 Dec 2009, 05:34
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 14 Dec 2009, 15:16
Quote:

err.. I was testing and seems the only exception is characteres between #123 and #127. They change.

It mess with some characters from #64 to #126. Then chars #247 and #255 don't seem to be converted properly.

And there is one more problem with chars above 127, them are charset dependent. It is almost OK for Windows-1252, but will it do the correct translation for the other charsets? For the typical console application charset this will not work as the ñ and Ñ are consecutive.
Post 14 Dec 2009, 15:16
View user's profile Send private message Reply with quote
Teehee



Joined: 05 Aug 2009
Posts: 570
Location: Brazil
Teehee 15 Dec 2009, 12:43
oh well..

hopcode wrote:
Coding it yourself is the best solution

Ok, I decided to accept the challenge, and building my own syntax highlight. Mad

I already made the base code for the application*, and now I need some tips to start to work with text (like insert char). And all that memory management thing.

Can you guys help me?

** We have:

  • Main Window
  • Custom Control, where things will happen.
  • Custom Control and Main Window events working.
  • Custom Control Caret working.

** We need: (TODO list, step 1)

  • How to scan text. How will it works? etc;
  • Insert a char in a "index" position (for typing);
  • Remove a char in a 'index' position (for backspace and delete).
  • To decide how the draw text method will works.


Description: Inteface
Filesize: 10.06 KB
Viewed: 7006 Time(s)

interfacepreview00.jpg



_________________
Sorry if bad english.
Post 15 Dec 2009, 12:43
View user's profile Send private message Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2465
Location: Bucharest, Romania
Borsuc 15 Dec 2009, 23:48
hmm why are you mad? if you don't do it for educational purposes why not just use something like Notepad++ with custom highlighting?
Post 15 Dec 2009, 23:48
View user's profile Send private message Reply with quote
Teehee



Joined: 05 Aug 2009
Posts: 570
Location: Brazil
Teehee 15 Dec 2009, 23:51
ah, I like to code Smile
and it's a oportunity to learn more. Wink
Post 15 Dec 2009, 23:51
View user's profile Send private message Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2465
Location: Bucharest, Romania
Borsuc 15 Dec 2009, 23:59
sorry that I can't help, I have very limited experience with the Windows GUI and such (only with console apps I am ok).
Post 15 Dec 2009, 23:59
View user's profile Send private message Reply with quote
hopcode



Joined: 04 Mar 2008
Posts: 563
Location: Germany
hopcode 16 Dec 2009, 03:04
Teehee wrote:
...accept the challenge...

Is your boldness for sale ? Wink

- You can find a good example of sy-hili in the FASMW source by Tomasz
- Alternative, coded in c++ but a very clever coding from A-to-Z by James, here
http://catch22.net/tuts/neatpad
- Except for something good but very limited, i would not suggest you other code to study.
Most of them lack the most important thing:design.

Tips:
Imho One should begin from now:
- to think 64bit
- to think portable
- to think pluggable/modular

Teehee wrote:
...building my own syntax highlight.

mmmh...
Ok, if you get it, and you build it good stuff, in less than 100kb i would say,
i will be very glad to adopt it in my biberkopf.

Anyway, before starting, please read this credits note,the list
of contributors,... in more than 10 years of improvement
on an edit component. Here:

http://www.scintilla.org/ScintillaHistory.html

Regards, and Happy Coding!!!
hopcode
Post 16 Dec 2009, 03:04
View user's profile Send private message Visit poster's website Reply with quote
Teehee



Joined: 05 Aug 2009
Posts: 570
Location: Brazil
Teehee 16 Dec 2009, 10:09
hopcode wrote:
Is your boldness for sale ? Wink

Nah... just hobby. Smile

Quote:
- You can find a good example of sy-hili in the FASMW source by Tomasz

Yeah, I took a look and i'm trying to understand somethings. Unfortunately there is no comments in that code Sad

Quote:
Tips:
Imho One should begin from now:
- to think 64bit

Why should I? 32bit will disappear fast?

Quote:
...i will be very glad to adopt it in my biberkopf.

What is biberkopf?

However I'm a Asm beginner. I'll [try to] made to learn, mainly.
But, how I said before, I need some tips like how to alloc space to the text and realloc when needed. And how can I access the text, to insert and remove chars (bc i'm not using winApi for that, i'm drawing the text manually [drawtext])... The rest is with me Wink

_________________
Sorry if bad english.
Post 16 Dec 2009, 10:09
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20302
Location: In your JS exploiting you and your system
revolution 16 Dec 2009, 10:21
Teehee wrote:
32bit will disappear fast?
I guess it depends on your definition of fast, but I doubt that 32bit will give way to 64bit for quite some time yet. There is not yet any pressing need to adopt 64bit. And forcing adoption where it is not required can harm more than help for performance sensitive applications.

Even inside 64bit OSes the 32bit apps mostly run faster than the equivalent 64bit app. Depends upon the app of course, but in general 32bit is still the preferred choice.
Post 16 Dec 2009, 10:21
View user's profile Send private message Visit poster's website Reply with quote
Teehee



Joined: 05 Aug 2009
Posts: 570
Location: Brazil
Teehee 17 Dec 2009, 20:11
Hi ppl Smile

I'm doing a prototype in C# (bc it's fastest to code) of how the App will be. Later I just convert it to Asm.

Below, a preview image.

Features:

  • Very, very basic text operations.
  • Numbers bar, working.
  • Scroll bars, working.
  • Selection system, working.
  • Improvised No Flick system, working.
  • Syntax highlight, still implementing...


Again: I need someone explain me how can I work with text in Asm (alloc/realloc space, insert/remove char, etc.), so I can get start with Asm-side coding.

Thanks Smile


Description: Prototype's appearence :)
Filesize: 41.72 KB
Viewed: 6951 Time(s)

csharpPrototype00.JPG



_________________
Sorry if bad english.
Post 17 Dec 2009, 20:11
View user's profile Send private message Reply with quote
Teehee



Joined: 05 Aug 2009
Posts: 570
Location: Brazil
Teehee 19 Dec 2009, 16:57
Outlining toggle system working Smile (see video preview below)


Description:
Filesize: 13.87 KB
Viewed: 6932 Time(s)

outlining1.JPG


Description:
Filesize: 13.21 KB
Viewed: 6932 Time(s)

outlining2.JPG


Description: Video preview
Download
Filename: outlingin_prev.zip
Filesize: 374.6 KB
Downloaded: 160 Time(s)


_________________
Sorry if bad english.
Post 19 Dec 2009, 16:57
View user's profile Send private message Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2465
Location: Bucharest, Romania
Borsuc 19 Dec 2009, 17:05
Is reallocing fast if you're editing a large file? I don't know, it would be better (but much more complicated) to keep a linked list of edits (what you edit) and then in the background use a thread (with low priority) that converts the linked list into straight text (in a separate buffer obviously), and when it's done (i.e if the user is idle) then switch buffers (like double buffering in video), and start all over, but the old buffer because the "second" buffer and the new buffer being the active one.

ok that was off the top of my head.

that's probably how Hex Editors that can open extremely large files (not in RAM) and modify them work, except that they probably only use a linked list and no double buffering.
Post 19 Dec 2009, 17:05
View user's profile Send private message Reply with quote
Teehee



Joined: 05 Aug 2009
Posts: 570
Location: Brazil
Teehee 24 Dec 2009, 18:53
I'm trying to convert to plain text, but I'm having many problems, especially with Mouse Position to CharId function.

(just a comment Smile)
Post 24 Dec 2009, 18:53
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 24 Dec 2009, 19:49
Teehee,

No offence intended.

Is my monitor lying to me, or your selection's highlighting logic suffers from ubiquitous "off-by-one" mistake?

Why do you call that "outlining"? Maybe "collapsing" sequence of instructions to some descriptive comment?

Storage of arbitrarily long strings is performance vs. memory tradeoff. First decide how you will handle "undo" (you may store original file verbatim and dynamically apply consolidated changes, for example of memory-wise).
Post 24 Dec 2009, 19:49
View user's profile Send private message Reply with quote
Teehee



Joined: 05 Aug 2009
Posts: 570
Location: Brazil
Teehee 24 Dec 2009, 21:14
baldr wrote:
No offence intended.

Don't worry, man. I'm here to learn and I need to learn a lot. I know that what I'm trying to do is too much to a beginner. But i'm learning a lot just trying to do! Smile

Quote:
Is my monitor lying to me, or your selection's highlighting logic suffers from ubiquitous "off-by-one" mistake?

I don't understand. What do you mean?

Quote:
Why do you call that "outlining"? Maybe "collapsing" sequence of instructions to some descriptive comment?

Yeah, sorry, I mean collapsing! I said 'outlining' bc Visual Studio call that 'outlining' Confused

Quote:
Storage of arbitrarily long strings is performance vs. memory tradeoff. First decide how you will handle "undo" (you may store original file verbatim and dynamically apply consolidated changes, for example of memory-wise).

Why its so important to think about undo first?
And should I really think about memory in a Asm-code editor? bc working with strings don't spend too much memory (does it!?). Maybe 2 ~ 4Mb to store?
Well, this is my concept. But i bet i'm wrong. Smile

_________________
Sorry if bad english.
Post 24 Dec 2009, 21:14
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2, 3  Next

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.