Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[Asm] nasm assembler problem

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Thu Jun 25, 2009 5:34 am    Post subject: [Asm] nasm assembler problem Reply with quote

So i try to compile some code in nasm assembler
but it gives me an error at the same line always
i'm trying to print a message at dos window
so what i need to do is to get the effective address of the buffer
and then use dos interrupt 09h to print
here's my code
Code:

SECTION .DATA

message db 'Hello World','$'

SECTION .TEXT
   start:
   lea edx,message
   mov ah,09h
   int 21h
   mov ah, 07h
   int 21h
   mov eax,00004c00h
   int 21h
   ret

now the assembler tells me that there's problem at the line
mov edx,message
so i tried doing this
mov edx,[message]
but when i execute the program it prints me the message plus all kinds of characters
even though i added $ which means null terminated
any help?! thanks
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

Joined: 09 May 2003
Posts: 25821
Location: The netherlands

PostPosted: Thu Jun 25, 2009 6:20 am    Post subject: Reply with quote

"mov dx,message" should have worked

also, I recommend placing the .DATA section AFTER the .TEXT section if you assemble to a .com format

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Thu Jun 25, 2009 7:58 am    Post subject: Reply with quote

that's what i'm trying but it keep saying
Code:

invalid combination of opcode and operands

btw
what's the difference between .com and .exe files anyway?!
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Thu Jun 25, 2009 8:51 pm    Post subject: Reply with quote

1qaz wrote:
that's what i'm trying but it keep saying
Code:

invalid combination of opcode and operands

btw
what's the difference between .com and .exe files anyway?!


int 21, 9 expects you to use ds:dx

and yes, it may be a good idea to move your data section below (probably don't even really need sections?). horrible things will certainly happen should those bytes be executed as instructions.
Back to top
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Fri Jun 26, 2009 5:08 am    Post subject: Reply with quote

so what's that mean?
there's also edx register at data segment?
what is the difference between edx and ds:dx (or edx whatever) ?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

Joined: 09 May 2003
Posts: 25821
Location: The netherlands

PostPosted: Fri Jun 26, 2009 6:36 am    Post subject: Reply with quote

there's not much difference between edx and dx, edx is dx with 16 extra bits at the top (edx=32 bit, dx=16 bit, the address of message is 16-bit as well seeing you call dos commands)
So if you write a value to edx, you automatically write it to dx as well (but when writing to dx you don't alter edx completly)

perhaps mov dx,message will work while mov edx,message wont ? (Don't know why, it should work, but whatever)

and about stuff like ds, es, cs,ss,fs,gs: (WARNING, DON'T READ IF YOU'RE ALREADY CONFUSED)
those are segment registers. In 16-bit, they determine which physical address is used when combined with with an address.
e.g a ds of 0 and address 0x1234 , will get you to address 0x1234
but a ds of 0x1000 and address of 0x1234 will get you to 0x11234
(and a ds of 0x447 and address 0x1234 will get you to 0x56A4, but really, if you don't hate yourself, I recommend using segment registers of x000)

if you don't specify a segment register in a address specifier, it'll default to ds (except when you use the bp register in the address specifier, then the ss segment is used (in 16-bit only) )

what is meant with ds:dx, for ah=9, int 21 is that the routine will look at the DX register, and read the memory it specifies (using the default ds segment) till it encounters an $


anyhow,
Perhaps your version of nasm is broken or just acting weird.
First off, try it without those sections.
Second, coudl be it prefers "message:" instead of "message" ?

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Fri Jun 26, 2009 12:49 pm    Post subject: Reply with quote

i'm a little bit confused
well i understand what is 16 bits register and 32 bits
and plus when i move message to dx or edx it prints me all kind of unknown characters on the screen
and when i use lea using dx or edx i still get the same error but i don't know why ?!?
and thanks to you i know now that ds es cs ss fs gs are also registers lol i don't know what i thought they are until now
let me see if i get it straight
this registers have address that defines where the specific segment starts right?
but your example wasn't that much helper i'm not sure i understand it, if you can make it more clear it'd be great
and about my nasm version i googled for nasm download and download the first option i found
i think it's version 2.5 or something so if you know where can i get the best version of it
or maybe you can recommend me a better assembler
thanks :]
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites