mipsy icon indicating copy to clipboard operation
mipsy copied to clipboard

Allow arithmetic in print

Open Dylan-Brotherston opened this issue 3 years ago • 3 comments

To allow easier printing of arrays, or other consecutive data, the cli print command should allow for the following features.

Arithmetic:

Print <Address | Label> < + | - > <Immediate>

This would allow for individual array elements to be printed more easily. Eg.

print array + 4

Repetition:

Print <Address | Label> # <N>

This would print the data at <Address | Label> us the next <N-1> memory locations

Useful for printing entire arrays Eg.

print array#10

Note: # chosen arbitrarily. But I think it's a good fit as : the repetition operation in mips directives is also used to represent a label.

Range

Print <Address | Label> ~ <Address | Label>

This would print all memory locations between and including a start a d and Address.

Again Useful for print large sections of or entire arrays Eg.

print array_row_1 ~ array_row_2 - 1

Note: ~ chosen arbitrarily. But I think it's a good fit as - is used for Arithmetic minus.

Dylan-Brotherston avatar Oct 12 '21 12:10 Dylan-Brotherston

this is probably going to be implemented with the const engine (see: https://github.com/insou22/mipsy/blob/main/crates/mipsy_parser/src/constant.rs#L57) where ~ is already used for bitwise negation

insou22 avatar Oct 12 '21 12:10 insou22

And it was such a nice symbol too. Really running on of long skinny symbol here.

Dylan-Brotherston avatar Oct 12 '21 12:10 Dylan-Brotherston

using the rust range syntax print array_row_1 .. array_row_2 perhaps? obvs not having the spaces would be ideal but would probably be a nightmare for implementation