NASM - The Netwide Assembler
NASM Forum => Using NASM => Topic started by: ThatGuy22 on December 17, 2010, 02:52:13 PM
-
How would I use pointers in nasm, I tried this which seems like it should work but it doesn't:
mov bl, PointTo ;Make bl point to the variable PointTo
mov ah, 0x0e ;DOS function to print character.
mov al, [bl] ;Print character that bl points to ('H')
int 0x10 ;Print character
PointTo:
db 'H' ;char to print
What would make this code work or what am I doing wrong?
-
Read the error message. Then inform yourself about effective addresses somewhere else, and find out why the error message is displayed.
-
I will take a look at a tutorial or something on assembly pointers.
-
Ok, I have found out what I was doing wrong I was storing the address of the pointer in a 8 byte register I needed a 16 byte one - because I was doing this in real mode. I now have a different problem I wrote a program to use the pointer but I will not print out what is in the pointer. I think this is because I stored the Pointer in a 16 byte register and it needs to go to a 8 byte one for the DOS print char function. Here is my code, how do I get the whole value in my pointer into a 8 byte register. I think it is only trasfering half of the value to al in my program from which part of the register I do not know(What is the default part of the register that it transfers?). This is my test program:
AppMain:
mov bx, Pointer
mov ah, 0x0e
mov al, [bx] ;Here is where I don't think it is taking the whole value from bx, so how do I fix this?
int 0x10
jmp AppMain ; Hang the program with an infinite loop.
Pointer:
db 'H'
-
Please review the difference between bits and bytes.
-
Aren't bits within bytes, that make up the numbers?