Assembly Basics, hello world!


===This is the level 0 intro!===

There’s only two handfuls of assembly instructions you really need to know. Many others aren’t used as often. Most instructions are made up of three or four characters with an operand, a comma, then another operand.

To put some data into a register you use the MOV instruction.

Push puts data at the top of a stack. Pop moves the data from the top of the stack into a specified register. To exchange two registers, ax and cx:

But this could be done easier with the XCHG instruction:

To move data from one place to another, or copy, use MOV. To make the value of ax the same as what’s in bx:

To call a BIOS function that does some pre determined stuff such as printing something, you use INT. Most functions have multiple methods you can call so you’ll need to figure out which routine you want and put that number into the ah register first:

The EQU instruction creates absolute symbols and aliases by assigning an expression or value to the declared variable name. Everytime you call your custom alias, it gets replaced with the expression on the right hand side:

===The obligatory Hello World example:===

The END keyword informs the assembler that there are no more source statements for that section. By itself, it should be the very last instruction. You don’t have to call it “start”, you could name it whatever you want as long as you don’t use a word that the assembler will think is some sort of instruction. You can have multiple sections and allow jump points based on register comparisons also.


Posted on August 25th, by admica in Uncategorized.
Comments Off

Comments are closed.