Tuesday, 15 March 2011

assembly - MIPS: Using the stack -



assembly - MIPS: Using the stack -

i reading in mips manual that: "notice utilize “unsigned” version of “add immediate” instruction because dealing address, unsigned binary number. wouldn’t want generate exception because computed address crossed on mid-point of memory space."

what mean exactly? crossing on mid-point of memory space.

and also, in next code, don't understand why skips 8($sp) 20($sp). code loads 12($sp) , 16($sp) later when doing these portions of memory. thinking possible in jal jill, there isn't much explanation given.

addiu $sp, $sp, -24 sw $t1, 0($sp) sw $t2, 4($sp) sw $t3, 8($sp) sw $ra, 20($sp) jal jill lw $ra, 20($sp) lw $t4, 12($sp) lw $t5, 16($sp) addiu $sp, $sp, 24

assumming mips32 architecture, has 32-bit address space, mid-point of memory space address 0x80000000 (that 2^31). in 32-bit signed (a2-compliment) arithmetics, integers 0 0x7fffffff reserved positive numbers, integers 0x80000000 0xffffffff reserved negative numbers.

when issue signed addition, overflow exception if result of add-on "crosses" midpoint. in example, dealing memory addresses, not signed numbers... hence sign of address (interpreted 32-bit number) meaningless should utilize unsigned addition.

regarding sec question, you'd have jill procedure see does... certainly procedure store info in 12($sp) , 16($sp)

assembly stack mips

No comments:

Post a Comment