mipsym / MIPSym-issues

Issue tracker for MIPSym simulator for the MIPS R2000 assembly language
0 stars 0 forks source link

absu macro #4

Closed RogerDoering closed 3 years ago

RogerDoering commented 3 years ago

Is your feature request related to a problem? Please describe. I can crash a program while using abs macro.

Describe the solution you'd like another pair of macros that use subu instead of sub for absolute value (one for delay slots too)

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context There is only one value 0x80000000 that causes the exception.

ddalcino commented 3 years ago

This should be pretty easy to implement.

I would like your input on how to write the help text for absu and the updated help text for abs. Here's what I have so far:

abs Absolute Value Rf[rd] = abs(Rf[rs]) Note that if Rf[rs] == 0x80000000, an arithmetic overflow will occur, because 'positive 0x80000000' cannot be represented as a 32-bit signed integer. Use absu to prevent this.

absu Absolute Value Unsigned Rf[rd] = abs(Rf[rs]) Stores an unsigned 32-bit integer in Rf[rd]. Note that this can store 'positive 0x80000000' in Rf[rd], which is negative when interpreted as a signed integer. Use abs to prevent this.

ddalcino commented 3 years ago

Fixed in 2.05.1520