Basic Binaries
(Redirected from BB)
Basic Binaries is a low-level Esolang made by User:A().
Commands
| Cmd | Op code | Explaination |
|---|---|---|
| sta | 00000001 | Starts program |
| end (or hlt) | 00000010 | Ends program |
| ltr | 00000011 | Load to register |
| lir | 00000100 | Load input to register |
| inc | 00000101 | Increments register |
| reg | 00000110 | Calls register |
| txt | 00000111 | Outputs Hex value |
| iri | 00001000 | If register is not [Value] then jump to [Loc] |
Programs
Truth-machine
1 sta 2 ltr 00000001 00000001 ;loads a 1 to register one 3 lir 00000010 ;Input 4 iri 00000010 00000000 00000110 ; If register two is not 0 then jump to line 6 5 iri 00000001 00000000 00001000 ; If register one is not 0 then jump to line 8 6 iri 00000010 00000001 00001001 ; If register 2 is not 1 then jump toline 9 7 txt reg 00000010 8 iri 00000010 00000000 00000111 ; if register 2 is not 0 then jump to line 7 9 end
Machine code:
00000001 00000011 00000001 00000001 00000100 00000010 00001000 00000010 00000000 00000110 00001000 00000001 00000000 00001000 00001000 00000010 00000001 00001001 00000111 00000110 00000010 00001000 00000010 00000000 00000111 00000010
00000001 00000011 00000001 00000001 00000100 00000010 00001000 00000010 00000000 00000110 00001000 00000001 00000000 00001000 00001000 00000010 00000001 00001001 00000111 00000110 00000010 00001000 00000010 00000000 00000111 00000010
Cat
sta ltr 00000001 00000001 lir 00000010 txt 00000010 iri 00000001 00000000 00000011 end
A+B problem
Dec
Because of the way integer over flow works, 256+n=n-1. To do this, we can modify the addition program to get substraction by 1.
sta lir 00000001 ; a ltr 00000010 11111111 ; -1 ltr 00000011 00000000 ; counter var inc 00000011 inc 00000001 iri 00000011 reg 00000010 00000101 txt reg 00000001 end
Subtraction
sta lir 00000001 ; a lir 00000101 ; b ltr 00000010 11111111 ; -1 ltr 00000011 00000000 ; counter var1 ltr 00000100 00000000 ; counter var2 inc 00000011 inc 00000001 iri 00000011 reg 00000010 00000110 ltr 00000011 00000000 inc 00000100 iri 00000100 reg 00000101 00000110 txt reg 00000001 end