Hello. I'm kinda new to assembly and i've been using the general purpose registers as my variables although it's not enough cause the're only like 4 of them.. I need you to teach me how to declare a simple variable and how to access and use them. A simple example might help.

your resources didn't help... you were pointing to FUNCTIONS.. i want variables.. just a SIMPLE declaration of a variable and just how to store and retrieve values.

I understood what you want. Perhaps you should spend some more time reading through the theory links I gave you.

Variables have to exist somewhere, and the place for local variables is on the stack as part of a function's call frame. You can't separate functions and local variables.

High-level languages make creating variables deceptively simple --magical even. In assembly you've got to know a lot more about their storage. MASM and TASM make it easy with the LOCAL directive.

Global variables work the same way: they are located in the data segment and addressed with the EDS:[reg+n] syntax, just like local variables are [EBP+n].

Finally, I also gave you a link to a forum where people who eat and breathe this stuff all day frequent. They'll be able to tell you all sorts of little technical details that I'll have forgotten or would have to look up.

There is nothing simple about assembly language. You just have to dive in and expect a steeper learning curve than usual. I'll continue to check in now and again if you get stuck.

Good luck!

NO! you don't understand what I want.. what I wanted is a SIMPLE algorithm that makes use of a VARIABLE.. I knew you couldn't help so I went to do extra research and I got what I want and I'll make you understand what I want.

.model small
.stack
.data
	variable db ?
	
.code
start:

	mov ax, 3	; set the clear screen function
	int 10h		; clear the screen
	
	mov ah, 1	; set the character input function
	int 21h		; ask for input
	
	mov [variable], al	; store the entered character to a variable
	
	mov ah, 2			; set the character display function
	mov dl, [variable]	; get whatever we stored at our variable
	int 21h				; display the content of the variable
	
	mov ah, 4ch	; set the program termination function
	int 21h		; terminate the program

end start

There, got it?... simple huh?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.