.4 Some GCC library functions..
∗∗∗—accessible using theMFHIandMFLOinstructions.
.3.2 Instructions..
There are 3 kinds of instructions:
- R-type: those which have 3 registers. R-instruction usually have the following form:
instruction destination, source1, source2
One important thing to keep in mind is that when the first and second register are the same, IDA may
show the instruction in its shorter form:
instruction destination/source1, source2
That somewhat reminds us of the Intel syntax for x86 assembly language.
- I-type: those which have 2 registers and a 16-bit immediate value.
- J-type: jump/branch instructions, have 26 bits for encoding the offset.
Jump instructions
What is the difference between B- instructions (BEQ, B, etc.) and J- ones (JAL, JALR, etc.)?
The B-instructions have an I-type, hence, the B-instructions’ offset is encoded as a 16-bit immediate. JR
and JALR are R-type and jump to an absolute address specified in a register. J and JAL are J-type, hence
the offset is encoded as a 26-bit immediate.
In short, B-instructions can encode a condition (B is in fact pseudo instruction forBEQ $ZERO, $ZERO,
LABEL), while J-instructions can’t.
.4 Some GCC library functions
name meaning
__divdi3 signed division
__moddi3 getting remainder (modulo) of signed division
__udivdi3 unsigned division
__umoddi3 getting remainder (modulo) of unsigned division
.5 Some MSVC library functions..
llin function name stands for “long long”, e.g., a 64-bit data type.
name meaning
__alldiv signed division
__allmul multiplication
__allrem remainder of signed division
__allshl shift left
__allshr signed shift right
__aulldiv unsigned division
__aullrem remainder of unsigned division
__aullshr unsigned shift right
Multiplication and shift left procedures are the same for both signed and unsigned numbers, hence there
is only one function for each operation here..
The source code of these function can be found in the installedMSVS, inVC/crt/src/intel/.asm
VC/crt/src/intel/.asm.