Results 1 to 6 of 6

Thread: very basic assembly question

  1. #1

    very basic assembly question

    I've been reading a lot of assembly tutorials(though it wont probably sound like it), but the only question i have is how do you write to variables? I understand registers, and creating variables, but how can you change a variable's value?????
    You laugh because im different, i laugh because your all the same.

  2. #2
    Junior Member
    Join Date
    Jan 2004
    Posts
    3
    When you want to change a viriables value:
    a)if you have a variable on a register you just change the registers value
    b)if your variable is in memory then you store your value in the position of memory that your variable is.

  3. #3
    AO Curmudgeon rcgreen's Avatar
    Join Date
    Nov 2001
    Posts
    2,716
    I don't know all the ways to do it, but the simplest
    is the db (define byte) statement:

    Code:
    org 100h
    
    section .data
    
    string                                      ;put any string here
    db "hello, world!"
    string_length equ $ -string                 ;calculates the length
    
    section .text
    
    BEGIN:
    
    mov bx,0001h                                ;write to stdout
    mov ah,40h                                  ;write to file or device
    mov dx,string                               ;address of buffer 
    mov cx,string_length                        ;length
    int 21h                                     ;dos call
    mov ah,4ch                                  ;terminate
    int 21h                                     ;dos call
    see also
    I came in to the world with nothing. I still have most of it.

  4. #4
    How do you find the position of a variable?
    You laugh because im different, i laugh because your all the same.

  5. #5
    AO Curmudgeon rcgreen's Avatar
    Join Date
    Nov 2001
    Posts
    2,716
    You refer to it by name. mov dx,string puts its address into
    the dx register.
    I came in to the world with nothing. I still have most of it.

  6. #6
    so if i say:
    integer equ 1
    mov dx, integer
    mov dx, 7

    integer will then equal 7? If this is true, how do i remove the integer from the dx register?
    You laugh because im different, i laugh because your all the same.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •