Assembly                      |   C
------------------------------|------------------------------------
; Use a name instead of a num |   /* Use a name instead of a num */
COUNT:  EQU  5                |   #define COUNT 5
;-----------------------------|   /*-----------------------------*/
;start a program              |   /* To start a program */
CODE:  section  .text         |   main()
       org   $0800            |   {
       lds   #0x0A00          |   }
;-----------------------------|   /*-----------------------------*/
;allocate two bytes for       |   /* Allocate two bytes for 
;a signed number              |    * a signed number */
                              |
DATA: section .data           |
      org     $0900           |
i:    ds.w    1               |   int i;
j:    dc.w    $1A00           |   int j = 0x1a00;
;-----------------------------|   /*-----------------------------*/
;allocate two bytes for       |   /* Allocate two bytes for 
;an unsigned number           |    * an unsigned number */
i:    ds.w    1               |   unsigned int i;
j     dc.w    $1A00           |   unsigned int j = 0x1a00;
;-----------------------------|   /*-----------------------------*/
;allocate one byte for        |   /* Allocate one byte for 
;an signed number             |    * an signed number */
                              |
i:    ds.b    1               |   signed char i;
j:    dc.b    $1F             |   signed char j = 0x1f;
;-----------------------------|   /*-----------------------------*/
;Get a value from an address  |   /* Get a value from an address */
                              |
i:  ds.b   1                  |   unsigned char i;
                              |
    ldx    $E000              |   i = (unsigned char *) 0xE000;
    ldaa   0,x                |  
    staa   i                  |
;-----------------------------|   /*-----------------------------*/
                              |   /* Use a variable as a pointer
							  |      (address) */
                              |  
                              |   unsigned char *ptr, i;  
                              |  
                              |   ptr = (unsigned char *) 0xE000;
                              |   i = *ptr;  
                              |   *ptr = 0x55;
;-----------------------------|   /*-----------------------------*/
;To call a subroutine         |   /* To call a function */
  ldaa  i                     |   sqrt(i);
  jsr   sqrt                  |
;-----------------------------|   /*-----------------------------*/
;To return from a subroutine  |   /* To return from a function */
  ldaa  j                     |   return j;
  rts                         |

;-----------------------------|   /*-----------------------------*/
;Flow control                 |   /* Flow control */
    blo                       |   if (i < j)
    blt                       |   if (i < j)
                              |
    bhs                       |   if (i >= j)
    bge                       |   if (i >= j)
                              |
