off-topic

https://github.com/clojurians/community-development/blob/master/Code-of-Conduct.md Clojurians Slack Community Code of Conduct. Searchable message archives are at https://clojurians-log.clojureverse.org/
Barbara Gatti 2021-05-04T09:00:47.438900Z

May the 4th Be With You! This is pretty cool, you can create audio messages through the API with Star Wars characters: https://docs.api.audio/recipes/may-the-4th-be-with-you-1 check this out

Barbara Gatti 2021-05-04T09:01:05.439Z

And this is Chewbacca saying “Never deploy on Friday!” :P

😂 4
2021-05-04T12:37:49.446300Z

I'm working on a toy assembly like language and I want to add an instruction rep which in following example will repeat inc :a 8 times.

5: rep 8
6:   inc :a
7: rp
I push 5 (line number) to the IP stack that rp will repeat back to. I also push 8 to the RP stack, and rp decrements this value. When it reaches 0 it stops repeating. However, say I had this:
5: rep 8
... stuff
12:    call foo
13: rp

18: foo:
19:   rp   ;; oh no! This is goign to return to call foo line, no line 5...
20:   ret  ;; this is a normal return from a function.... it should return to call site by popping IP stack.
Call instructions also push the current line to the IP stack. So in this instance once it hit lines 19, the rp pops the top item off the IP stack and returns to line 12, not line 5.. I'm thinking maybe that I could have a seperate RP stack for RP IP targets. What do you think would be intuitive syntax wise? Or just say that the second code block above is pretty much invalid code and expect strange behaviour?

Phil Shapiro 2021-05-04T13:00:51.450600Z

IMO loops like this are not very assembly-like. I would expect to use a more primitive form like pdp11’s BNE. Some assembler have macros, which let you write higher level loops, but they expand to lower level instructions like BNE. If you do want to have a loop like this, I think it would be better to make the second case invalid.

2021-05-04T13:05:52.450800Z

I have already implemented cmp :a :bwhich compares and b and stores result in a cmp register (either =, <, >) Then I have jmps which look at cmp register. e.g. jne foo (jumps to foo if cmp was < or >) je foo (jumps to foo if cmp was =) jge foo (jumps to fo foo if cmp was &gt; or = etc So maybe a rep / rp is just redundant

2021-05-04T13:08:44.451Z

I also have macro expansion, so maybe I can just implement loops using macros e.g. I can do this

.macros
  %sum-and-square
    mul %1 %1
    mul %2 %2
    add %1 %2
  %end
.code
   mov :a 2
   mov :b 3
   sum-and-square(:a, :b)
   prn :a
   end