flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > my pathetic attempt at trying to write a substring macro

Author
Thread Post new topic Reply to topic
PuyaPuya



Joined: 21 Mar 2006
Posts: 3
PuyaPuya 21 Mar 2006, 19:46
I am trying to write a substring macro and this is the closest I have gotten.

Code:
macro substring source, start_index, sub_length
{
param db source
strt db start_index
mov dx, 00h
mov cx, start_index

check_substr:
cmp cx, sub_length
je end_substr
jb add_substr

add_substr:
push word [param + strt]
mov cx, strt
inc cx
mov word [strt], cx
jmp check_substr

end_substr:
charCount db 0
mov word [charCount], cx
return_substr db 0
substr_memcount db 0

make_subStr:
if charCount > 0
popw dx
mov word [return_substr + substr_memcount], dx
inc [substr_memcount]
dec cx
mov word [charCount], cx
jmp make_subStr
else
jmp clear_regs
end if

clear_regs:
mov cx, 00h
mov dx, return_substr


}    


Why is this not working.
Post 21 Mar 2006, 19:46
View user's profile Send private message Visit poster's website AIM Address Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 21 Mar 2006, 23:34
you wanted procedure, not macro
Post 21 Mar 2006, 23:34
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
PuyaPuya



Joined: 21 Mar 2006
Posts: 3
PuyaPuya 22 Mar 2006, 01:48
thanx
Post 22 Mar 2006, 01:48
View user's profile Send private message Visit poster's website AIM Address Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< 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-2023, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.