//----------------------------------------------------------------- // address.s // // This program is not intended to be executed, but is only // for assembling with 'as' and then for disassembling with // the 'objdump' utility, in order to illustrate the syntax // you can use when forming memory-operand addresses within // your assembly language source-files. // // to assemble: $ as address.s -o address.o // disassemble: $ objdump -d address.o // // programmer: ALLAN CRUSE // written on: 31 JAN 2007 //----------------------------------------------------------------- .section .data ten: .int 10 # radix for decimal system hex: .ascii "0123456789ABCDEF" # list of the hex numerals .section .text #------------------------------------------------------------------ # Here are two examples of 'direct' memory-addressing mov ten, %edx # loads radix into EDX mov hex, %al # loads '0' into AL # preparation for doing 'indirect' memory-addressing mov $hex, %ebx # 'immediate' operand mov $5, %esi # 'immediate' operand mov $3, %ebp # 'immediate' operand #------------------------------------------------------- # Here are six examples of 'indirect' memory-addressing #------------------------------------------------------- mov (%ebx), %al # loads '0' into AL mov hex(%esi), %cl # loads '5' into CL mov (%ebx, %esi), %dl # loads '5' into DL mov (%ebx, %esi, 2), %dh # loads 'A' into DH mov 5(%ebx, %esi, 2), %ch # loads 'F' into CH mov hex(, %ebp, 4), %ah # loads 'C' into AH .end