flat assembler
Message board for the users of flat assembler.
Index
> Main > Incrementing counter variable |
Author |
|
Kenneth 07 Dec 2006, 23:57
Code: inc [buffer] |
|||
07 Dec 2006, 23:57 |
|
rhyno_dagreat 08 Dec 2006, 00:03
Wouldn't that increment the value that's inside the buffer as opposed to the memory address?
|
|||
08 Dec 2006, 00:03 |
|
Kenneth 08 Dec 2006, 00:33
Hmm, I suppose it would. My bad, didn't really read. Spent more time looking at your code.
|
|||
08 Dec 2006, 00:33 |
|
LocoDelAssembly 08 Dec 2006, 00:36
If you want the C code "*(pBuffer++) = al" then you need this
Code: mov bx, [pBuffer] mov [bx], al inc [pBuffer] pBuffer should be initialized somewhere with a pointer to the buffer memory area. |
|||
08 Dec 2006, 00:36 |
|
rhyno_dagreat 08 Dec 2006, 00:57
Thanks! When you do the move routine does it copy the actual value or the memory address though? That's what I'm wondering now from looking at that code
|
|||
08 Dec 2006, 00:57 |
|
Dex4u 08 Dec 2006, 01:04
Code: mov di,BufferStart: mov ah, 00h int 16h mov [es:di], al inc di cmp al,'q' jne Start |
|||
08 Dec 2006, 01:04 |
|
rhyno_dagreat 08 Dec 2006, 01:06
Thanks Dex
|
|||
08 Dec 2006, 01:06 |
|
LocoDelAssembly 08 Dec 2006, 01:07
Code: ; ASM | C mov bx, pBuffer ; bx = &pBuffer mov bx, [pBuffer] ; bx = pBuffer mov [bx], al ; *bx = al That answer you question? (no sure what you're asking actually ) |
|||
08 Dec 2006, 01:07 |
|
rhyno_dagreat 08 Dec 2006, 02:04
The question is how can I get the ASM version of this:
Code: pBuffer = bx //pBuffer contains memory address of bx |
|||
08 Dec 2006, 02:04 |
|
LocoDelAssembly 08 Dec 2006, 04:12
if pBuffer contains memory address of bx then why you want to store it again?
Anyway I'll "compile" what I'm seeing Code: mov [pBuffer], bx BTW, note that my previous C examples assumes bx as the register bx, if it were a memory operand then Code: ; *pBuffer = b mov bx, [pBuffer] mov ax, [b] mov [bx], ax |
|||
08 Dec 2006, 04:12 |
|
rhyno_dagreat 08 Dec 2006, 12:50
[quote = "LocoDelAssembly"]if pBuffer contains memory address of bx then why you want to store it again? [/quote]
It doesn't. I'm trying to get the address contained in bx to be the one of pBuffer |
|||
08 Dec 2006, 12:50 |
|
LocoDelAssembly 08 Dec 2006, 14:32
Well is the first code of the previous post. I think you are wanting to make something like "mov pBuffer, bx" which is imposible because pBuffer is a label, you need to have a variable that holds a pointer and do the second code.
To clarify I'll write again your code using 'q' as escape condition like Dex did Code: mov bx, [pBuffer] Start: cmp bx, buffer+256 je exit mov ah, 00h int 16h mov [bx], al inc bx cmp al, 'q' jne Start exit: mov [pBuffer], bx . . . pBuffer dw buffer buffer rb 256 ; 256 bytes buffer |
|||
08 Dec 2006, 14:32 |
|
rhyno_dagreat 08 Dec 2006, 14:42
That's what I was looking for! Thanks!
|
|||
08 Dec 2006, 14:42 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.