RISC code output

TODO: fix wrong order for conversion in cfgrisc
This commit is contained in:
elvis
2024-12-01 12:55:20 +01:00
parent 08f0eb5c91
commit 52cd7e7e13
7 changed files with 332 additions and 11 deletions

View File

@ -11,3 +11,12 @@ let rec powmod a d = function
| n ->
let b = (powmod a d (n / 2)) mod d in
(((b * b) mod d) * (if n mod 2 = 0 then 1 else a)) mod d
let rec fromIntToString (alphabet: string) (x: int) : string =
let base = String.length alphabet in
if x < 0 then
""
else if x < base then
String.get alphabet x |> String.make 1
else
(fromIntToString (alphabet) (x/base - 1)) ^ (String.get alphabet (x mod base) |> String.make 1)

View File

@ -1,3 +1,5 @@
val pow : int -> int -> int
val powmod : int -> int -> int -> int
val fromIntToString : string -> int -> string