public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: ElijaxApps <elijaxapps@gmail.com>
To: Paul Koning <paulkoning@comcast.net>
Cc: Mike Frysinger <vapier@gentoo.org>, Newlib <newlib@sourceware.org>
Subject: Re: Help porting newlib to a new CPU architecture (sorta)
Date: Wed, 7 Jul 2021 22:32:49 +0200	[thread overview]
Message-ID: <CAK=1Datiu29UGqFv8t9HEC-U0YBJdBJR+Ztp+7Csquneo2vBvA@mail.gmail.com> (raw)
In-Reply-To: <D60A5A57-6526-4A28-9B44-A6FF6824722E@comcast.net>

Hi all,

I started reading GCC Internals Book, chapter 16 & 17.

I am deciding how exactly define insn statements at this very right moment.
I am using pdp11 as a template. However, there are lots of things I don't
really need, in this config spec.

As far as I have understood, I can follow two paths:

a) Define instructions as my pseudo assy, and use my own "assembler".
b) Define instructions as Linux ASM and use GAS, GNU Assembler.

At first I decided to apart A and use it as a Fallback if B fails. But I
really think I am interested in both approaches. You see, I haven't coded
any in real ASM and I just mimic'ed what it looks like.
But I am a bit lost here, I feel like A is easier but it is not the
"correct" way, but it can be done perhaps in a week or two... And let B for
the long term, as I got practice and training with A.


See the full instruction set for the moment (at the end of the document).
What I would need for A is help writing the insn definition (for A this
moment)
I'll try to define the instructions BNF so you can help me to write insn
definitions:

*Offset*: [ 000000-ffffff ] [h] | <variable_name>
*1) LDx *(Load REG from the BUS):   [ LDA | LDB | LDC | LDD ]
offset_to_load
*2) STx *(Store REG in RAM):   [ STA | STB | STC | STD ]
offset_where_to_store
*3) ADD,SUB*: [ ADD | SUB ] offset (to whatever already there is in A REG)
*4) Jumps*: Always redirect to another direction in RAM, so they always are
followed by an offset.
*5) Branches*: Always redirect to another direction in RAM, this time a
function beginning offset. They return a 24 bit address, and continue
execution below where Branch was called.
*6)* *DEC *(Read char and store in A REG) *Is all hardwired, is just the
mnemonic - DEC - (cannot use another REG)
*7) OUTx *(Output REG on LCD Screen)   [ OUTA | OUTB | OUTC | OUTD ]
*8) NOP, HLT *are just the mnemonic.

MOV is not fully supported yet...
"Spawning" a value into any register is not supported yet. You have to
previously store the value you'll load into RAM. I have to encode ASCII
table in the firmware, yet I not had time.

So I need basically 2 TWO isns:


*[ LDx | STx | Bx | Jx | ADD | SUB ] <offset> (24 bit hexadecimal, or
variable name)[ DEC | OUTx | HLT | NOP ] - as is, just the mnemonic...*


So that way I could continue the reading and go on.

Thank You,
Elijax Apps.

Code tokenMeaningExamples
;; This is a comment. line will be ignored ;;This is a comment
LDA Basic load A register. Always followed by a variable name or an memory
address (up to 24 bit) LDA one
LDA ff0010h
LDB Same as LDA with B register
LDC Same as LDA with C register
LDD Same as LDA with D register
STA Store contents of register A into the following address memory (also up
to 24 bit) STA one
STA ff0010h
STB Same as STA with B register
STC Same as STA with C register
STD Same as STA with D register
OUTA Echoes the value of register A to LCD Screen LDA one
OUTA (prints value of variable "one")
OUTB Same as OUTA with B register
OUTC Same as OUTA with C register
OUTD Same as OUTA with D register
DEC Reads a byte from keyboard and stores in A register DEC
STA readChar
ADD Adds the value of the following address or variable to the contents of
register A DEC
ADD one
SUB Substracts the value of the following address or variable to the
contents of register A DEC
ADD one
JZ Jumps to the specified address or to specified address contained within
a variable if Zero Flag == 0 JZ addressToJumpTo, JZ 0000ffh
JNZ Jumps to the specified address or to specified address contained within
a variable if Zero Flag != 0 JNZ addressToJumpTo, JNZ 0000ffh
JC Jumps to the specified address or to specified address contained within
a variable if Carry Flag == 0 JC addressToJumpTo, JC 0000ffh
JNC Jumps to the specified address or to specified address contained within
a variable if Carry Flag != 0 JNC addressToJumpTo, JNC 0000ffh
J Jumps always J addressToJumpTo
BZ Creates a branch (calls a function) if Zero Flag == 0 BZ offsetOfFunction
BNZ Creates a branch (calls a function) if Zero Flag != 0 BNZ
offsetOfFunction
BC Creates a branch (calls a function) Carry Flag == 0 BC offsetOfFunction
BNC Creates a branch (calls a function) if Carry Flag != 0 BNC
offsetOfFunction
B Creates a branch (calls a function) always it is found B offsetOfFunction
BX Returns a value contained in the following address BX returnValueAddress
NOP No operation. Just reads the next operation NOP
HLT Halts the computer HLT
MOV Limited, not documented support for some MOV operations. SEE THE
CODE!!! MOV
A, C

El mar, 6 jul 2021 a las 15:05, Paul Koning (<paulkoning@comcast.net>)
escribió:

>
>
> > On Jul 6, 2021, at 12:35 AM, Mike Frysinger <vapier@gentoo.org> wrote:
> >
> > On 06 Jul 2021 02:49, ElijaxApps wrote:
> >> I designed a Logisim schematic of a full system, able to run programs in
> >> the simulation, as shown in this video:
> >>
> >> https://www.youtube.com/watch?v=UP6tO8x5I5A
> >>
> >> Is based on a SAP-1 (Simplest as Possible) basis, containing 4 GP
> registers
> >> (8 bit), stack for function operations (up to 256 depth levels of
> >> recursivity), 24bit plain RAM component, and a simple ALU able to echo
> >> strings and perform not floating point math.
> >>
> >> AFAIK, newlib is suitable for embedded devices, and I want to create the
> >> full toolchain for C/C++ language at least.
> >
> > i don't know that these would work that well (or at all) on an 8-bit CPU.
> > you'd really want a 32-bit CPU nowadays as a minimum if you want to
> support
> > modern software.
>
> Consider the AVR toolchain, used in Arduino.  Isn't that an 8-bit
> machine?  It certainly is small.
>
>         paul
>
>
>

  reply	other threads:[~2021-07-07 20:33 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-06  0:49 ElijaxApps
2021-07-06  4:35 ` Mike Frysinger
2021-07-06 13:05   ` Paul Koning
2021-07-07 20:32     ` ElijaxApps [this message]
2021-07-07 20:56       ` Orlando Arias
2021-07-06 14:02   ` Brian Inglis
2021-07-06 14:35     ` Orlando Arias
2021-07-06 18:08       ` Brian Inglis
2021-07-06 19:04         ` Orlando Arias
2021-07-06 20:01           ` Hans-Bernhard Bröker
2021-07-06 20:46             ` Orlando Arias
2021-07-07  5:45               ` Brian Inglis
2021-07-07 13:58                 ` Orlando Arias
2021-07-07 15:18                   ` Dave Nadler
2021-07-07 18:43               ` Hans-Bernhard Bröker
2021-07-07 20:23                 ` Orlando Arias
2021-07-06 21:08 ElijaxApps
2021-07-06 22:00 ` Joel Sherrill
2021-07-06 23:50   ` Paul Koning
2021-07-07  0:29     ` ElijaxApps
2021-07-07 15:09   ` Grant Edwards

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAK=1Datiu29UGqFv8t9HEC-U0YBJdBJR+Ztp+7Csquneo2vBvA@mail.gmail.com' \
    --to=elijaxapps@gmail.com \
    --cc=newlib@sourceware.org \
    --cc=paulkoning@comcast.net \
    --cc=vapier@gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).