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]  | 
              |||
                  
  | 
              
| 
                  
                   rhyno_dagreat 08 Dec 2006, 00:03 
                  Wouldn't that increment the value that's inside the buffer as opposed to the memory address? 
                  
                 | 
              |||
                  
  | 
              
| 
                  
                   Kenneth 08 Dec 2006, 00:33 
                  Hmm, I suppose it would.  My bad, didn't really read.  Spent more time looking at your code. 
                  
                 | 
              |||
                  
  | 
              
| 
                  
                   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.  | 
              |||
                  
  | 
              
| 
                  
                   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 
                  
                 | 
              |||
                  
  | 
              
| 
                  
                   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  | 
              |||
                  
  | 
              
| 
                  
                   rhyno_dagreat 08 Dec 2006, 01:06 
                  Thanks Dex 
                  
                 | 
              |||
                  
  | 
              
| 
                  
                   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  | 
              |||
                  
  | 
              
| 
                  
                   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  | 
              |||
                  
  | 
              
| 
                  
                   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  | 
              |||
                  
  | 
              
| 
                  
                   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  | 
              |||
                  
  | 
              
| 
                  
                   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  | 
              |||
                  
  | 
              
| 
                  
                   rhyno_dagreat 08 Dec 2006, 14:42 
                  That's what I was looking for! Thanks!  
                  
                 | 
              |||
                  
  | 
              
< Last Thread | Next Thread >  | 
    
Forum Rules: 
  | 
    
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.