2018-01-25
Computers only know them binary machine language using just 0(off) and 1(on).
How do we make binary number sequence? It's depends on computers.


"RUN the Arm machine language on IchigoJam RPi after 1.2b16 (Raspberry Pi 2)"

The computer of IchigoJam understands 16 bit words (0 or 1 x 16).

0011000000000001

This machine language means to add 1 to R0 register. (resisters are kind of memories in the computer)

First 5 bit means "to add", next 3 bit means the resister number, last 8 bit means number to add.

00110 000 00000001

Let's write to RAM using POKE command of IchigoJam BASIC. (*IchigoJam BASIC reference ver 1.2)

POKE#700,`00000001,`00110000

#700 is position of RAM. Number starts with ` means binary number. (# for hexadecimal number)
To write last 8 bit in the first is a rule of this computer. (little-endian)

You need an other machine language word to work, "return" to IchigoJam BASIC.

0100011101110000

Write this word to RAM in the same way.

POKE#702,`01110000,`01000111

You are ready to run!

?USR(#700,1)

Did you get a number 2 as a right result?

USR command needs an start address of the machine languages and a number as a parameter.
Please check using 100 as a parameter.

?USR(#700,100)

Try to make to add 5 program using the machine language.

POKE#700,5 ?USR(#700,100)

You did it!

Speed is the greatest advantage of using the machine language.
The disadvantage is wrong machine language program doesn't protect your system.
So, please save before run if you make long program with machine language.

IchigoJam will stop if you write wrong machine languages.
Try to freeze your IchigoJam.

?USR(#704,0)

Computers work with some machine language words such them.
CPU of IchigoJam (LPC1114 Arm Cortex-M0) knows only 56 words Arm Thumb machine language.
It's very simple to understand!

If you use IchigoJam RPi after 1.2b16 (Raspberry Pi2/3 Arm Cortex-A7/A53), it knows more words.

It's a sample code to use SIMD(single instruction multiple data) machine language.
QADD8 can calculate 4 number as parallel during just 1 CPU cycle.

POKE#700,#80,#FA,#10,#F0,#70,#47 ?HEX$(USR(#700,#1234)) 2468

*It can calculate 8bit x 4 numbers but variables of IchigoJam BASIC are 16bit.

To be continued!

references
- Cortex-M0 Technical Reference Manual - Instruction set summary / ARM Information Center
- Cortex-A7 MPCore Technical Reference Manual - About the programmers model / ARM Information Center

links (now in Japanese)
- asm15 - simple Arm assembly language and machine language table
- asm15 assembler for IchigoJam
- series of "My First Arm Assembly language"

Tweet
クリエイティブ・コモンズ・ライセンス
本ブログの記事や写真は「Creative Commons — CC BY 4.0」の下に提供します。記事内で紹介するプログラムや作品は、それぞれに記載されたライセンスを参照ください。
CC BY / @taisukef / アイコン画像 / プロフィール画像 / 「一日一創」画像 / RSS