Learning Assembler on Amiga #6

By users' requests, I built an index page of previous lessons. It’s here.
As promised in lesson five, we would have addressed, all puns intended for that lesson, a way of storing and pointing to data in memory.
Information in the form of byteword or long-word can be stored and located using addressing. I made the table below to help you to understand how it works as a refresh of what explained in lesson 5.
An offset is a directive that means “addressing”. Just like in a battleship game where using row and column you identify a spot on a grid. An offset lets you pinpoint a place in memory. I made a grid below to help you to grasp the concept. An offset is made of 8 digits, I added the spaces for readability, normally you won’t find any. 
The column 0-F is expressed in hexadecimal and therefore they go from 0 to F. I made a few examples below for all data types that we have explored so far. 
The dollar sign indicates that the value (after the sign) must be interpreted as a hexadecimal value. The assembler will translate that value in binary. If for some reason you want to avoid any transliteration from hexadecimal to binary, then you can use the % sign followed by the binary value. When you want to operate between addresses in order to differentiate a value from an address you use the dollar sign.
Instead, if you want to pass an exact value you want to add the pound sign (#) ahead of the notation. Like #$10A10B. It behaves like a constant value passed on.
An example will make it even more obvious. To copy a value from 00000010 to 0000002D address, you use the following notation: 
move.b    $00000010,$0000002D
instead, if you want to write an exact value into an address (e.g. 0000001E) , you use:
move.b    #32,$0000001E
Naturally, you would use .w or .l if the values, part of the operation were bigger in size. These four methods aren’t the only ones available to the MC68000
processor, in fact there are a total of 12 which they are I a fashion or the other a combo of these three methods. To summarize:
# means direct addressing. You set a value into a data registry. Example: move #1,D0. This can be used only the source of an operation not the destination. Basically right after the move instruction, not after the comma.
$ means the value after me is a memory address. Example: move $00000010,$0000002D 
We are done for today. Practice makes better, enjoy your newly acquired knowledge and keep retroing.


Popular posts from this blog

Postgres on Synology

Zen-inification - The art of decluttering

Bring Boxee Box back to life