Assembly and Cracking From the Ground Up |
An Introduction by Greythorne the Technomancer |
Some Necessary Code Snippets |
I learn best by example.
These examples can be cut and pasted into your own programs rather painlessly.
I have been asked recently and often where is the best place to find assembly information. One place (rather unfair answer) is the net. My favorite info comes in hardcopy in the form of books however. Some of the best assembly books around are the oldest ones, with 8086 optimized code in them. I tend to pick up rather expensive manuals at less than a dollar at secondhand bookstores - with a wealth of code for all manner of needs.
Covered here is (will be) code to do several of the following: STRING BASICS The first thing any instructor will do to you in a programming course is teach you how to display a hello world message.
Well, this time i am going to give you a pair of them. message db 'hello world','$' mov dx, offset message call DisplayStringThe Routine: (Tiny because DOS takes care of most of the code) ; outputs string in dx using: int 21h, ah=9 DisplayString: mov ax,cs
message db 'hello world','$' mov dx, offset message call BiosDisplayStringThe Routine: ; outputs string in dx using: int 10h, ah=14 BiosDisplayString: mov si, dx ; bios wants si rather than dx really ; dx is used to make it act the same as ; the DOS system service int 21h,ah=9 mov ax, cs ; use current segment... mov ds, ax ; ...for the data to be displayed bnxtchar: lodsb ; get next character of message push ax ; preserve ax so it doesnt get clobbered cmp al, '$' ; end of string marker jz endbprtstr pop ax ; restore ax call BiosDisplayChar jmp bnxtchar endbprtstr: pop ax ; cleanup ret ; Notice that we have to display the string one character at a time BiosDisplayChar: ; outputs character in al mov ah, 0Eh ; BIOS FUNCTION: DISPLAY CHARACTER xor bx, bx xor dx, dx int 10h ; Call the BIOS interrupt ret
By no means is that all of them, there are other int 10h calls for text display,
AND THE NUMBERS! mov ax, 0402h call DisplayWordThe Routine: ; Displays a Word in AX DigitBase dw 010h ; using base 16 digits Note that in this above example, we could have |
+gthorne'97 |