1 week coding challenge

Cool! Now decide how to program loops and conditionals.

By the way...

You do know, right, that real computers don't have an instruction that converts numbers into strings of decimal digits and prints them? I ask only because when I decided to teach myself machine language programming, about 60 years ago, I didn't know that, and couldn't figure out why my programs weren't working.

Which lines/functions are you talking about for this? Is it the ‘out’? If it is, then what I meant was that you can now have multiple items to be added to the output list. You still need the ‘comb’ (combine) to combine the items and ‘term x’ (output item x of output to terminal) to actually output it.

I only really know some Python and Snap!, have never really looked at Assembly or any machine language

You can take a look at the current version: ASM IDE

Yeah. I understand the multiple items, but what I'm saying is that a real assembly language won't have anything like OUT at all. Inside the computer, the numbers are, you know, ones and zeros, and you have to convert that number to decimal digit characters. Then you ask the operating system to print it.

But, that doesn't matter for your project; you can design whatever language you like.

Ok, I get it now.

I guess this language is a crossbreed of Python and assembly :joy:

If you are making an Assembly, a JMP or JMPZ would be a good idea for program flow.

ASM Functions

== Math Functions ==
ADD - Add cells together (ADD 1 2 3)
SUB - Subtract cells (SUB 2 1 3)
MUL - Multiply the cells (MUL 1 2 3)
DIV - Divide the cells (DIV 2 1 3)
ABS - Absolute value of a cell (ABS 1 2 3)
SIGN - Sign of a cell (SIGN 1 2 3)
FLR - Floor value of a cell (FLR 1 2 3)
CEIL - Ceiling value of a cell (CEIL 2 1 3)
SQRT - Square root of a cell (SQRT 3 4)
PI - Reports the value of PI at a cell (PI 3)

== Trig Functions ==
SIN - Sine of a cell (SIN 2 1)
COS - Cosine of a cell (COS 4 3)
TAN - Tangent of a cell (TAN 2 3)
ASIN - Arcsine of a cell (ASIN 4 1)
ACOS - Arccosine of a cell (ACOS 2 2)
ATAN - Arctangent of a cell (ATAN 4 2)

LN - Natural log of a cell (LN 2 1)
LOG - Log of a cell (LOG 3 3)
EXP - e^x of a cell (EXP 4 4)
RAD - Transform the value of a cell to radians (RAD 1 3)
DEG - Transform the value of a cell to degrees (DEG 4 2)

== Outputs ==
OUT - Output the following values (OUT 4 2 1 3 4 5 6)
OUTR - Output the range of values (OUTR 1 10)
DISP - Display the following values from the output list (DISP 3 1 2 4 6 1 2)
DISPR - Display the range of values from the output list (DISPR 5 18)
TERM - Output the following values to the terminal from the output list (TERM 1 2 5 3 6)
TERMR - Output the range of values to the terminal from the output list (TERMR 2 90)
STR - Add a string to the output list (STR Hello, world!)
COMB - Combine all values in the output list (COMB)
CHAR - Convert the cell into a character from the char map (CHAR 2 1 3 4 6 3 2 22)
CHARR - Convert the range of cells into a character from the char map (CHARR 1 22)
CLR - Clear the output list (CLR)
CLS - Clear the terminal (CLS)
RESET - Reset the cell memory (RESET)

== Boolean Functions ==
OR - Apply the OR function to 2 cells and store it (OR 1 4 2)
AND - Apply the AND function to 2 cells and store it (AND 4 2 1)
NOT - Apply the NOT function to a cell and store it (NOT 5 2)

== Data Functions ==
LOAD - Load a numerical value at the cell (LOAD 2 55
LOADR - Load a numerical value into a range of cells (LOADR 2 45 20)
DEL - Delete the value of a cell (DEL 23)
LSFT - Shift the value to the left (LSFT 5)
RSFT - Shift the value to the right (RSFT 3

== Loops & Functions == (In dev)
GOTO - Goto a label (GOTO label)
LBL - Define a label (LBL label)

Example Programs
Hello, world

str Hello, world!
term 1

Output: Hello, world!

Hello, world complex

load 1 34
load 2 5
load 3 12
load 4 12
load 5 15
load 6 98
load 7 23
load 8 15
load 9 18
load 10 12
load 11 4
charr 1 11
outr 1 11
comb
term 1

Output: Hello, world!

Random Numbers

load 1 -100
load 2 100
load 3 98
char 3 3

rand 1 2 4
str Random Number:
out 3 4
comb
cls
term 1
clr

Output: Random Number: number

Just wondering, is there an input command?

Not yet, need to figure out how to make it work with the terminal

You're going to need a conditional jump mechanism. Typical computers will have "jump if zero" "jump if negative" and so on, with two operands, so if the first one is zero or whatever, jump to the second one.

As it turns out, you can have a Turing-equivalent computer with just one instruction:
Subtract and Jump if Negative a,b,addr
It does a←a−b and if the result is negative go to address addr.

Thank you. That's what I meant by JMPZ.

Yeah, it was in your list, but not in @borkmaster's.

Added basic kernel extension (kext) support. You can now build your own rules and actions.


Sample RAND kext (not simplified).

Sample RAND kext simplified


Activate & deactivate kexts.


Running program when RAND kext is not loaded.


Running program when RAND kext is loaded.


Update:
Kexts can now be loaded directly from the editor if they exist.

Kext caller names must be one word only.


RAND kext successful run


Kext error


Added jump conditionals

  1. JMPP (listener) (jump if true) - Jump to line if listener is positive
  2. JMPN - Jump to line if listener is negative
  3. JMPZ - Jump to line if listener is 0

  1. JMPE (listener) (value) (jump if true) - Jump to line if listener is equal to value
  2. JMPLT - Jump to line if listener is less than value
  3. JMPLTE - Jump to line if listener is less than or equal to value
  4. JMPGT - Jump to line if listener is greater than value
  5. JMPGTE - Jump to line if listener is greater than or equal to value

Great! Now, try to make a fib calculator.


Fib calculator

Nice!

This is really shaping up into something usable! I'm impressed.

Added empty line skipping, and now infinite line wrapping (a lot of big letters like 'w' and 'm' will probably break things)

Nice!