Defining Variables with DC and DS For temporary storage of value Why we do not store it is registers? –Address & data registers are limited to 16 Initialize the memory DC – Define Constant DS – Define Storage DC.size This is particularly useful when we initialize an array of data or collection of identical data types. MNODC.B1, 2, 3, 4 STU DC.B‘Hello!’ When we want to reserve the space for the variable without initializing them then we use DS directive
Question How many bytes in total is reserved by the three statements below. SVALDS.B6 TVALDS.W2 UVALDS.BL3
Accessing 1-D Arrays EA : Effective Address Base: Base Address, The starting address of the array Index: Element Size Offset: Offset into array to element’s position EA = Base + Offset Offset = Size * Index Example: The starting address of a word array is 830C, What is the address of the word whose index value is 5
Accessing 2-D Arrays It is like a matrix containing row and column We can store the values using the keyword DC Example: –Sub DC.B6, 1, 8 – DC.B7, 5, 3 – DC.B2, 9, 4 – Val = sub [row] [column] Col: Column Number Row Offset: Offset into matrix to element’s row Column Offset: Offset into row to element’s position EA = Base + Rowoffset + ColumnOffset –RowOffset = Row * Size * NCols –ColumnOffset = Size * Col
Searching an Item from the DataBase ORG$8000 DATA DS.B100 ITEM DS.B1 ORG$8100 FINDBYTEMOVEA.L#DATA, A0 MOVE.W#99, D0 MOVE.BITEM, D1 COMPARE CMP.B(A0)+, D1 BEQFOUND DBRAD0, COMPARE ANDI#$FE, CCR RTS FOUND ORI#$01, CCR RTS
Your consent to our cookies if you continue to use this website.