Re: new from VB6



Thanks, Jim. (You seem to be in all the newsgroups!)
That does clear some things up. So registers are
variable/value storage that bypasses the RAM and
goes directly to the CPU. I guess, then, that they're
just used and reused one operation at a time? And
that's why you can get by with only the equivalent of
8 4-byte addresses for general use. I don't see why
the different registers would need to be used for different
uses if they're essentially CPU memory addresses, but I'm
beginning to see the basic idea.

So the stack is essentially my own storage area that I
pile pointers or literal values onto.....and that's *always*
where the processing looks to find function parameters?
So if I were to call, say: DoIt 5, 3, 2 - where the 3
parameters are all longs - I could conceivably look at the
top 12 bytes of the stack while that's running (assuming one
can look at the stack dynamically) and find the values
5, 3, 2 there? Or in the case of a string parameter I'd
find the string pointer? So I can go as deep with the stack
as I want to, but it always clears when a function returns?

Is the heap, then, just that....a pile of memory addresses
that represent my allocated variable space?

--
_____________________________

mayayXXana1a@xxxxxxxxxxxxxxxx
For return email remove XX and YY.
_____________________________
Jim Carlock <spamtrap@xxxxxxxxxx> wrote in message
news:YMZ9e.8935$716.6772@xxxxxxxxxxxxxxxxxxxxxxxxxx
> I think one of the easiest ways to really start out is to start
> with a simple DOS program.
>
> Here's the first program. The stuff below... the - (dash) is the
> debug.exe prompt (similar to the c: prompt for the DOS command
> line). It means debug is waiting for you to enter a command. The
> list of available commands can be seen by typing a question mark
> at a dash and then pressing the Enter key.
>
> Any line that starts with a semicolon represents my own comments.
> Do NOT type in those lines. They are just explanatory things. I'm
> using the ; character because it's the character used inside of
> various assemblers to indicate a comment.
>
> At a DOS prompt type in the following:
>
> ; We start out at the DOS command prompt and are going to use DEBUG
> ; to create a simple program that displays some text inside the DOS
> ; command prompt.
> C:\temp\>debug test.com
> File not found
>
> ; The dash is the debug prompt, don't type it in, type in the command
after
> ; it. rcx tells debug you want to see and edit the contents of the CX
register.
> - rcx
> CX 0000
> ; debug displays the current contents of the CX register above and then
> ; waits for you to type a number in. The number is the size of the file we
> ; are creating. The size for this program is 118 bytes in length.
> 118
> -a 100
> mov ah, 09
> mov dx, 109
> int 21
> int 20
>
> a 109 db 'Hello world.' 0d 0a 24
> w
> q
> C:\>
>
> Now for a brief explanation of what's going on...
>
> r is debug's command to display registers. The registers are
>
> rcx is the command to get debug to show you and allow you to modify
> the contents of the register.
>
> a 100 tells debug you want to start typing assembly language at
> address 100. DEBUG then waits for you to start typing assembly
> mnemonics.
>
> The mnemonics are those assembly language commands you entered
> starting at address 0100. ALL .com programs start at that there
> at that address.
>
> We use the rcx command to configure the size of the file. The
> w command (write to file) tells DEBUG to save the file and the
> CX register inside of the CPU holds the number (the size).
>
> There are 4 registers inside of the CPU that folks primarily
> use. EAX (the 32-bit register), EBX, ECX and EDX. We used the
> 16-bit register AX to store a number (09). That particular
> register stores what is called the Interrupt number (we used
> DOS Interrupt 21, Function 9). The DX register holds the other
> information required for Interrupt 21. Interrupt 21, Function 9
> is the simplest Interrupt I could think of that doesn't require
> too much effort to get you up to speed with what the registers
> do.
>
> One other important register, is the EIP (Instruction Pointer)
> register. This register tracks the memory address of the
> currently executing instruction. If you were to step through
> the Test.com program you created, after you type R at the debug
> prompt, you'll see that the EIP/IP register increments itself
> and points to the next instruction to be executed.
>
> The processor itself is a set of chips that mean nothing to us.
> However, there needs to be a way to move things around in the
> processor and memory and the disk. The registers take care of
> these things.
>
> The EAX/AX register is typically called the Accumulator and
> all it is is just a temporary storage facility for the CPU.
>
> The EBX/BX register is called a Base register. It has other
> uses, usually used to hold pointers to string information,
> as an index to arrays, and a few other things.
>
> The ECX/CX register is usually used to hold a count in for
> next loops.
>
> The EDX/DX register is called a Data Register. It typically
> holds pointers to strings, pointers to structures, etc.
>
> Registers are just storage locations inside of a CPU used to
> count, hold pointers to strings and structures, hold source
> and destination operands for various instructions.
>
> The Interrupt instruction is a DOS command and there are a
> ton of DOS Interrupt functions. We used Function 9 which
> simply displays a "$" dollar sign terminated string to the
> console. The AX register holds the Function number when calling
> Interrupt 21. The DX register holds the pointer to the string
> we want displayed. Character code 24 is the ASCII number for
> the "$" dollar sign symbol. 0D 0A is the CRLF combination to
> start a new line.
>
> There are more registers used for different things such as the
> math coprocessor registers and some others.
>
> As far as the stack goes, that is just an area of memory that
> holds parameters for functions. When a subroutine is called,
> the parameters for the subroutine get pushed onto the stack,
> and when the subroutine returns, the parameters are popped off
> the stack.
>
> It's really a big topic to cover because there are quite a few registers
> out there and I've only touched on 5 of them.
>
> If something is puzzling feel free to ask. Hope that helps.
>
> --
> Jim Carlock
> Please post replies to newsgroup.
>
> "mayayana" <spamtrap@xxxxxxxxxx> wrote:
> Could someone point me in the right
> direction for *very basic" beginner information?
> I'm coming from VB6, with experience in
> terms of Win32 API, dealing with memory
> addresses, data types, and that sort of
> thing. But I've never learned the real basics.
>
> I thought that maybe learning ASM would
> be a good way to do that. I've also used some
> inline assembly in VB and can see that it has
> a lot of potential.
>
> I just bought Randy Hyde's book, Art of Assembly
> Language. I've also looked at the FAQ. But it
> all assumes prior knowledge. On p. 9 of Randy's
> book he describes the "registers", but never explains
> what a "register" actually is. Likewise, I really don't
> understand stack and heap. I'm coming from the
> top down and seem to have missed out on learning
> something critical at ground level. I can understand
> something like mov as being similar to
> RTLMoveMemory, but don't understand the mechanics
> at this level.
> _____________________________
>
> mayayXXana1a@xxxxxxxxxxxxxxxx
> For return email remove XX and YY.
> _____________________________
>
>

.



Relevant Pages