flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
revolution 12 Jan 2010, 18:16
Code: string_ordinals dd s1,s2,s3,s4,s5,0 s1 db 'New Project',0 s2 db 'release',0 s3 db 'doc',0 s4 db 'rc',0 s5 db 'src',0 |
|||
![]() |
|
Teehee 12 Jan 2010, 18:20
But I need get each item in a loop, how can I do using that?
|
|||
![]() |
|
Teehee 12 Jan 2010, 18:21
nvm.. i think i understand.
string_ordinals its 'dd', a pointer, right? |
|||
![]() |
|
revolution 12 Jan 2010, 18:23
Yes, an array of pointers.
|
|||
![]() |
|
Teehee 12 Jan 2010, 18:30
Code: LEN = $ - string_ordinals returns the array lenght? |
|||
![]() |
|
baldr 12 Jan 2010, 18:36
Teehee,
Not exactly. Depends on where you've placed it. ![]() Code: string_pointers dd s1, s2, s3 .byte_count = $ - string_pointers .count = .byte_count/4 |
|||
![]() |
|
Teehee 12 Jan 2010, 18:41
Code: arrayNewProject dd tvTxtRelease,tvTxtDoc,tvTxtRc,tvTxtSrc,0 tvTxtRelease db 'release',0 tvTxtDoc db 'doc',0 tvTxtRc db 'rc',0 tvTxtSrc db 'src',0 .bytes_count = $-arrayNewProject COUNT =.bytes_count /4 COUNT = 12 (=9 if /5) its wrong ![]() |
|||
![]() |
|
revolution 12 Jan 2010, 18:59
You put it in the wrong place!
Code: arrayNewProject dd tvTxtRelease,tvTxtDoc,tvTxtRc,tvTxtSrc,0 .bytes_count = $-arrayNewProject-4 COUNT =.bytes_count /4 tvTxtRelease db 'release',0 tvTxtDoc db 'doc',0 tvTxtRc db 'rc',0 tvTxtSrc db 'src',0 |
|||
![]() |
|
baldr 12 Jan 2010, 19:00
Teehee,
That's exactly what I wrote about: COUNT calculation should immediately follow arrayNewProject's definition. I made it in two steps to emphasize that $-label is number of bytes between label and current location, and you need number of dwords, right? By the way, terminating 0 will be taken into account as well. You may find useful to read FASM manual about local labels (those that start with dot). |
|||
![]() |
|
Teehee 12 Jan 2010, 19:04
Wooot!
now it works ![]() Code: arrayNewProject dd tvTxtRelease,tvTxtDoc,tvTxtRc,tvTxtSrc,0 COUNT = ($ - arrayNewProject - 4) /4 tvTxtRelease db 'release',0 tvTxtDoc db 'doc',0 tvTxtRc db 'rc',0 tvTxtSrc db 'src',0 Thanks guys. |
|||
![]() |
|
Borsuc 12 Jan 2010, 20:00
*ahem* why not just scan through the string until you find the specific ID you're looking for? i,e if ID is 5, it means you skip the first 5 strings (starts from 0).
Code: arrayTxt db 'release',0,'doc',0,'rc',0,'src',0 [...] ; ecx = ID mov esi, arrayTxt test ecx, ecx jz .first @@: lodsb test al, al jnz @b dec ecx jnz @b .first: ; esi points at the string now _________________ Previously known as The_Grey_Beast |
|||
![]() |
|
revolution 12 Jan 2010, 20:06
Borsuc wrote: *ahem* why not just scan through the string until you find the specific ID you're looking for? |
|||
![]() |
|
Borsuc 12 Jan 2010, 20:34
Fair enough. Alternatively for such a huge list I think building the list with the above method is better, avoids a huge executable (but putting the value of 'esi' in the current ordinal and looping again).
_________________ Previously known as The_Grey_Beast |
|||
![]() |
|
edfed 14 Jan 2010, 01:44
version by revolution have an interresting faculty.
it can be used with the algo from Borsuc. funny! but you can speed up searches if, for example, you do alpahbetical string lists, Alist, Blist, Clist etc... and maybe, if seeking for command interpretation is needed, another stuff is possible... a tree. but it will use a lot of memory. but it will be very fast (depend on the leng of the word to interpret. Code: list: .a: dd fork,@f-$-4,.aa,.ab,.ac,.ad....; fork is a pointer that means the item is a fork. @@: .b: dd fork,@f-$-4,.ba,.bb,.bc,.bd,0,.bf ; 0 means there are no pointers for 'be' @@: ... .ad: dd fork,@f-$-4,.ada,.adb,.adc,.add... ... .bb dd 0 ;means there are no command for this entry. .add dd addition ;means the function for this entry is addition... then, imagine, the result for edit command, or the support for commands up to 10 chars. it is a good thing if: you have enough memory to do that. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.