MIPS Assembly Array of Pointers -
i'm trying create array of pointers correspond list of names, , parallel array keeps track of how many times names have been displayed. i'm not looking method display them, know how load pointer array, , load array of ints start 0's. define names in list of null terminated strings , set aside memory arrays, i'm not sure how put addresses of names array. here's have:
.data .space 5000 listofnames: .asciiz " jones \n" .asciiz " smith \n" .asciiz " johnson \n" .asciiz " davis \n" .asciiz " reid \n" .asciiz " foster \n" .asciiz "#" # indicates end of name list, can grow in size .space 400 .align 2 # should 2? thought should word aligned pointer_array: .space 400 .align 2 # should 2? thought should word aligned parallel_array:
as @jester suggests, can use labels assembler compute address of each name, , use labels define in array.
another possibility set aside same amount of space each name, location of each name can computed. done using .ascii
, specifying null terminator within string, , adding enough characters after fills out desired length. takes more space, avoids need array of pointers each individual name.
if must generate array of pointers names, , can't use labels, you'll have loop on characters in listofnames
, , each time find null character (indicating end of name), next location starts next name (unless contains #
, in case done).
Comments
Post a Comment