0

Trying to shortcut the main part of a palindrome checking program see below:

li $t9, $t6($t5)

bne $t9, $t7($t5), no1

This throws a syntax error, is there not a way to use a variable as an offset in assembly? Using PLP software tool 5.2

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
  • 1
    In MIPS, no, only for floating-point load/store (in some later MIPS revisions). I assume this is MIPS? Also, perhaps you mean `lw` not `li`? And `bne` can never compare a memory operand; MIPS is a load-store machine (the only instructions that access memory are loads and stores, not memory operands for other instructions) – Peter Cordes Apr 15 '21 at 04:53
  • yes it is MIPS, thanks – Derpman5000 Apr 15 '21 at 04:54
  • 1
    To actually optimize your code, use pointer increments / decrements instead of actually adding to an array base address every iteration. e.g. `do { p++; q--; } while(p – Peter Cordes Apr 15 '21 at 04:56

0 Answers0