flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > work with string parts

Author
Thread Post new topic Reply to topic
Lion17



Joined: 30 May 2006
Posts: 5
Lion17 03 Jun 2006, 19:54
have string
Code:
'abcd'    

need string
Code:
'abc','d'+80h    


if there way to do it?
Post 03 Jun 2006, 19:54
View user's profile Send private message ICQ Number Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1150
Location: Russian Federation
comrade 03 Jun 2006, 20:32
in what context?
you can have it like this:
Code:
original db 'a','b','c','d'
modified db 'a','b','c','d'+80h    

or like this:
Code:
mov eax,'abcd'
mov eax,<'abc','d'+80h>    
Post 03 Jun 2006, 20:32
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1150
Location: Russian Federation
comrade 03 Jun 2006, 20:36
Last one doesn't work, it should be:
Code:
mov eax,'abcd' 
mov eax,('abc' shr 8) OR ('d'+80h)    
Post 03 Jun 2006, 20:36
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1150
Location: Russian Federation
comrade 03 Jun 2006, 20:38
Or rather like this:
Code:
mov eax,('a' shl 24) OR ('b' shl 16) or ('c' shl 8) OR ('d')    
Post 03 Jun 2006, 20:38
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1150
Location: Russian Federation
comrade 03 Jun 2006, 20:38
You can swap the order (abcd -> dcba), if you like.
Post 03 Jun 2006, 20:38
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
Lion17



Joined: 30 May 2006
Posts: 5
Lion17 04 Jun 2006, 06:55
the point is use ordinar string 'abc...def'
and I need modify only last character of it
how I can split string in mscro on two part:
header and last character?
Post 04 Jun 2006, 06:55
View user's profile Send private message ICQ Number Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1150
Location: Russian Federation
comrade 04 Jun 2006, 08:23
please provide more context

how/where are you trying to use this technique?
Post 04 Jun 2006, 08:23
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
Lion17



Joined: 30 May 2006
Posts: 5
Lion17 04 Jun 2006, 16:07
I use strings with end marked by hi bit of last character.
now I define string with next code:
Code:
db 'Sample strin','g'+80h    

but I want macro to define such strings by macro with code like:
Code:
EndBitString 'Sample string'    
Post 04 Jun 2006, 16:07
View user's profile Send private message ICQ Number Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8354
Location: Kraków, Poland
Tomasz Grysztar 04 Jun 2006, 16:29
Code:
macro EndBitString str
{
  db str
  local lastchr
  load lastchr byte from $-1
  lastchr=lastchr or 80h
  store byte lastchr at $-1
}    
Post 04 Jun 2006, 16:29
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 04 Jun 2006, 17:10
or
Code:
struc EndBitString str 
{ 
  . db str 
  local ..lastchr 
  load ..lastchr byte from $-1 
  ..lastchr=..lastchr or 80h 
  store byte ..lastchr at $-1 
}    


In case you want things like
Code:
aString EndBitString 'Hello World'    


Tomasz, is not better to use local names prefixed with two dots?
Post 04 Jun 2006, 17:10
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8354
Location: Kraków, Poland
Tomasz Grysztar 04 Jun 2006, 18:06
It matters when you use those names as labels, but here it is a numeric variable ("=" and "load" define numeric variables).
Post 04 Jun 2006, 18:06
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 04 Jun 2006, 18:19
Code:
.a = '0'
b = 1
c = .a + b
display c    


works Embarassed

Thanks for the info!!
Post 04 Jun 2006, 18:19
View user's profile Send private message 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.