View Full Version : Asm
Shining Knights
2004-08-31, 03:04 PM
It matters not whether you win or lose; what matters is whether I win or lose.
WetWired
2004-08-31, 11:00 PM
Okay, in the old-style pointers, that is those using a 16-bit segment and a 16-bit address, you multiply the segment by 16 then add the address part to get the absolute address. This allows for the OS to locate the memory for a program anywhere in memory with a 16 byte granularity. In 286 mode, there are no checks for whether the proccess has permissions to use a given segment, so if you're accessing an absolute location in memory, it makes no difference if you access it with segment a+1 and address b or segment a and address b+16. When operating in 386 protected mode, however, the rules change.
Shining Knights
2004-09-01, 12:33 AM
It matters not whether you win or lose; what matters is whether I win or lose.
Demosthenes
2004-09-01, 04:50 AM
Get a book called Assembly Language Step-by-step by Jeff Dunteman. It's a little slow, but it's an awesome book.
WetWired
2004-09-01, 07:04 AM
I was telling the truth. I have no prior experience in hacking a datastream between a game and its server.
Personally, I just read my TASM manuals cover-to-cover, and I was good to go. The biggest hurdle is understanding how the computer works; if you don't have enough prior programming experience to have a pretty good idea of the way things are done, you may get lost when they are explained to you.
The x86 architecture provides 3 interfaces to the hardware: The data bus -- this connects the proccessor to RAM and ROM. ROM is mapped from 640k to 1M, and contains the low level drivers for interfacing for most of the hardware in your computer (at least it used to...). The "port" bus -- this is another data bus, but instead of interfacing with memory, it is connected to control and information registers within various pieces of hardware in your computer The interrupt lines -- when a piece of hardware needs attention from the system, it asserts an interrupt, and the processor automatically branches to the routine assigned to that interrupt. Interrupts can also be triggered manually with the interrupt instruction.When you're using assembly, you likely won't have a large library of routines already written for you to do basic things such as write stuff to the screen like you would if you were writing in a high level language. Instead, you will need to use interrupts to invoke system calls. The BIOS and DOS provide many system calls through the use of interrupts that don't have any physical interrupt hardware -- these interrupts can only be invoked with the interrupt instruction. The processor already knows where these routines are because the BIOS and DOS installed them in the interrupt table when they were starting up. This is way, the writers of the BIOS and DOS can allow the location of the various routines to be dynamiclly decided by the linker without needing a complicated process for the application programmer to find out where they are. These calls are used pretty much like any other function call except that instead of using the call instruction, you use the int instruction.
You can also write your own interrupt handlers. Mostly, this is only usefull if you want to bypass the system routines to work with a piece of hardware, or there are no system routines for that piece of hardware, however, there appear to be a few setup by the system for you to override, such as the system tick interrupt, which occurs at a fixed interval.
You may have problems with DOS assembly if you have Windows XP. Since XP runs on the NT kernal, much of the legacy support has been removed, such as allowing programs to directly access the port bus.
Shining Knights
2004-09-01, 12:30 PM
It matters not whether you win or lose; what matters is whether I win or lose.
Demosthenes
2004-09-01, 09:56 PM
Shinto, I just want to throw in my own two cents on assembly. I'm not an assembly master by any means, in fact I'm just learning, much like yourself, so don't take my word as absolute truth.
First off, to answer your original question, you have to know about the segment registers, which hold the location to the start of a segment (I believe). WW has already explained how to find the location in memory using in segmented-mode. Usually how it works is you have something in the following format:
segmentAddress:offset
The segmentAddress holds the address of the beginning of a segment and the offset holds how much to count into the segment. For instance, lets say you wanted to point to a certain instruction in memory. You would use the code segment (CS) register to hold the address of the segment and the instruction pointer (IP) register to hold the offset. It would look something like this
CS : IP
So lets say you wanted to point to something that is at the twentyth location in memory or something, you could use either:
0001:0004
or
0000:0014
Hopefully I didn't confuse you. If you need me to expand I can. I think that information is accurate for most part, but I'm not absolutely positive.
Now, when I started learning assembly, I read the beginnings of many tutorials, and learned the same introduction to computer science every time. That got irritating. If you get the book I suggested, and you know the basics of the computer, and number systems, then skip chapters 1, 2, 3 and 5. The other chapters should hopefully cover what you are looking for. It gives a really thorough introduction to computer science, though, as you don't see any real assembly code till about page 200 or so.
Another thing, if you get the chance, get Linux. It's easier to program in there, as it is protected mode flat model, instead of the segmented model I think you would be using under dos.
Again, if someone could confirm everything I said above, or correct it, it would be appreciated. I think it's alright though.
A good online link:
http://www.drpaulcarter.com/pcasm/
Shining Knights
2004-09-01, 10:32 PM
It matters not whether you win or lose; what matters is whether I win or lose.
Demosthenes
2004-09-01, 10:33 PM
Not too long. :p
Shining Knights
2004-09-01, 10:38 PM
It matters not whether you win or lose; what matters is whether I win or lose.
WetWired
2004-09-02, 06:37 AM
I started doing Assembly the summer of '98. I havn't done x86 assembly, however, for quite some time.
vBulletin® v3.8.2, Copyright ©2000-2025, Jelsoft Enterprises Ltd.