Skip to content

IchigoJam/c4ij-r

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

c4ij-r

C language environment for IchigoJam R (C言語開発環境 for IchigoJam R)

__attribute__ ((section(".main")))
int main(int param) {
  return param + 1;
}

100 POKE#700,#05,#05,#82,#80

Setup (Mac)

Homebrew - 開発ツールインストール用ツール

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
==> Next steps:
- Run these two commands in your terminal to add Homebrew to your PATH:
    (echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> ~/.zprofile
    eval "$(/opt/homebrew/bin/brew shellenv)"

最後に表示される NextSteps の2行をコピーしてそのままターミナルに貼り付けて、エンター

Deno - JavaScript開発ツール

brew install deno

riscv-gnu-toolchain - RISC-V用Cコンパイラ

brew tap riscv-software-src/riscv
brew install riscv-gnu-toolchain

割と長く待つ

Build

  1. edit main.c
  2. build!
make
  1. type the dump in IchigoJam
  2. RUN on IchigoJam
?USR(#700,100)

Sample

add 1

__attribute__ ((section(".main")))
int main(int param) {
  return param + 1;
}

mul self

__attribute__ ((section(".main")))
int main(int param) {
  return param * param;
}

fibonacci

int fib(int n) {
  if (n < 2) {
    return n;
  }
  return fib(n - 1) + fib(n - 2);
}
__attribute__ ((section(".main")))
int main(int param) {
  return fib(param);
}

write to screen

__attribute__ ((section(".main")))
int main(int param, char* ram, char* rom) {
  ram[0x900] = (char)param;
  return param;
}

calc GCD([0], [1])

__attribute__ ((section(".main")))
int main(int param, char* ram, char* rom) {
  short* array = (short*)(ram + 0x800);
  short n = array[0];
  short m = array[1];
  for (;;) {
    short r = n % m;
    if (r == 0) {
      break;
    }
    n = m;
    m = r;
  }
  return m;
}

on IchigoJam

100 POKE#700,#85,#67,#BE,#95,#83,#96,#05,#80,#03,#97,#25,#80,#B3,#E7,#E6,#02
110 POKE#710,#3A,#85,#BA,#86,#13,#97,#07,#01,#41,#87,#ED,#FB,#82,#80
RUN

[0]=1071
[1]=1029
?USR(#700)
21

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages