Alright people, I am trying to write the outportb function using some inline assembly. However, (inline)assembly in VS2010 will not accept char variables as operands. What I want to do is created a pointer to the char input and then pass the memory address of the input character as an integer, and then copy data from that address to the destination address. If I create a char pointer and pass the address of the input char variable, how do I extract the memory address of data as a short integer to pass it as an asm operand?
0
votes
I know that you can use the cout function to print the address of a pointer to the screen but if I were to write: char data; char *c = &data; short i = c; then I get a compiler error so that approach clearly doesn't work.
- Mr X
Show the code you are trying and the error you are getting.
- Jonathan Wood
unsigned char data; _asm MOV dx, [data]
- Mr X
Or this: unsigned char data /*(input parameter)*/, unsigned char *c= &data. I want to get the memory address of data to pass it in brackets as asm operand.
- Mr X
If you solve the parameter problem, you will face the next problem - that you are not allowed to directly access the hardware under Windows.
- Bo Persson
1 Answers
0
votes
Since the unsigned char data type uses the ASCII code, the processor cannot distinguish it from an unsigned 8 bit integer. So the way I figured it out is to create a char pointer and pass the memory address of the input parameter to the pointer, then MOV the char pointer to a 16 bit register which can then be MOVd directly into a memory. Inline assembly code actually bypass Windows memory management; which is the beauty of it. ;-)