i want to use it...but how?
just a small example please... x86
i want to use it...but how?
just a small example please... x86
I think this is compiler specific. Im not even sure all compiler supports inline asm.
oh...that sucks....i guess i'll have to go find a real asm compiler if i want to play
Read the documentation for your compiler to learn how to do this. There is a good chance that it is one of the following ways though.
orCode:asm { ... }
Code:__asm { ... }
...say...i know it's the wrong forum, but i already have this post, so i guess i'll ask....
if i read a tutorial about 16 bit assembler would it still work with 32 bit assembler compiler granted i double up the memory values?
no...that doesn't work for my compiler.....the ide recognizes the keyword, but then it think i'm trying to declare 'system("PAUSE")'...stupid compiler
You're compiler's documentation is the best place to get a small example (if inline assembly is supported by your compiler).
Here are the docs for GNU and MSVC:
http://gcc.gnu.org/onlinedocs/gcc-3....l#Extended-Asm
http://msdn.microsoft.com/library/de...gref___asm.asp
gg
[Edit]Jeez, 4 replies in the time it took me to look up those links [/Edit]
You would probably have to make more changes that just using 32 bit registers vs 16 bit. Chances are the instruction sets would be different as well.if i read a tutorial about 16 bit assembler would it still work with 32 bit assembler compiler granted i double up the memory values?
Each processor family has its own machine / assembly language. Assembly is NOT portable*. The assembler is specific to the processor, and must be compatible with the compiler when included in a C++ program.
Assembly is essentially human-readable machine-code. It's WAY easier to write an assembler, than to write a compiler. I've heard old stories of hiring students to "assemble" code by hand! They just used a table to convert each assembly language instruction to it's associated (hex or binary) machine code instruction... No computer knowledge required!
The original 16-bit x86 processors had something like 30 - 60 instructions. Pentiums have something like 300 instructions.
*[EDIT]-
The 'interesting' thing is... the asm keyword IS part of the (portable) standard. But, as soon as you put ANYTHING inside the brackets, your code is no longer standard or portable!
From the standard
7.4 The asm declaration
1. An asm declaration has the form
asm-definition:
asm ( stringliteral) ;
The meaning of an asm declaration is implementation defined.
[Note: Typically it is used to pass information through the implementation to an assembler. ]
Last edited by DougDbug; 10-13-2004 at 03:17 PM.
At least on the Intel x86 platforms for IA-32 and IA-64, the only difference between 32 bit and 16 bit instructions is the size of the data type, and the memory address size.You would probably have to make more changes that just using 32 bit registers vs 16 bit. Chances are the instruction sets would be different as well.
These can both be overriden even in 16-bit code using 66h and 67h opcode prefixes.
I believe that 66h is operand size overide and 67h is memory operand size override.
But this code should work on all x86 systems regardless of whether or not you are in 16-bit or 32-bit. The problem comes when you want to run 32-bit code in a 16-bit environment - as I said you must use the prefixes to do that. The prefixes really are the syntactic equivalent of using the 32-bit version and in fact in the actual binary encoding that is exactly what is happening. But if your compiler does not allow access to EAX you would prefix a mov ax,[value] with a 66h.
db 66h
mov ax,[value32]
This should move value32 into eax if I understand the docs correctly.
Same with string instructions.
rep movsw
This is a 16 bit copy from DS:SI to ES:DI for CX size.
db 66h
rep movsw
This would be a 32-bit copy from DS:ESI to ES:EDI for ECX size.
Check the Intel manuals for more information.
I did not show examples for memory address operand size override prefix 67h.
Last edited by VirtualAce; 10-13-2004 at 04:37 PM.