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?????
Printable View
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?????
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.
I don't know all the ways to do it, but the simplest
is the db (define byte) statement:
see alsoCode: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
How do you find the position of a variable?
You refer to it by name. mov dx,string puts its address into
the dx register.
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?