Load Halfword (ATTACK.OUT)

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
#   ROUTINE: LOAD HALFWORD (ATTACK.OUT)
#       Loads a halfword (2-byte) value from the specified memory address.
#       This appears to be the same as Load Halfword from BATTLE.BIN.  (Strange, because BATTLE.BIN routines should be available here...)
#       Parameters:
#           r4 = (ptr) Pointer to halfword value (potentially unaligned)

801c33a8: 90830001 lbu r3,0x0001(r4)                #   highByte = *(ptr + 1)
801c33ac: 90820000 lbu r2,0x0000(r4)                #   lowByte = *ptr
801c33b0: 00031a00 sll r3,r3,0x08                   #   highByte << 8
801c33b4: 00431025 or r2,r2,r3                      #   (highByte << 8) | lowByte
801c33b8: 00021400 sll r2,r2,0x10                   #   (sll/sra to apply sign extension)
801c33bc: 03e00008 jr r31                           #   return ((highByte << 8) | lowByte) << 16 >> 16
801c33c0: 00021403 sra r2,r2,0x10