The extract_offset Utility Procedure

The extract_offset routine evaluates and addressing expression so that it can return an offset for a data item. This example assumes that the addressing expression uses addc, and returns the argument of the addc opcode. This argument is the offset being added.

proc extract_offset {addressing_expr} {
    if {[llength $addressing_expr] != 1} {
        return 0
    }
    
    # Unwind the list.
    set addressing_expr [lindex $addressing_expr 0]
    if {[lindex $addressing_expr 0] != "addc"} {
        return 0
    } else {
        # return addc's operand
        return [lindex $addressing_expr 1]
    }
}
 
 
 
 
support@etnus.com
Copyright © 2001, Etnus, LLC. All rights reserved.
Version 5.0