[libre-riscv-dev] Introduction

Luke Kenneth Casson Leighton lkcl at lkcl.net
Sun Feb 3 07:25:28 GMT 2019


On Sunday, February 3, 2019, Jacob Lifshay <programmerjake at gmail.com> wrote:

> I could write the calculator, shouldn't take very long. It will use
> integers for i/o, they will be bitcasted to the fp types. This way we avoid
> problems with decimal representations while still being simple enough to
> implement since not everything can read/write hex floats (like
> 0x1234.5678P+25).


Yeh definitely int representation, fscanf does the job.


>
> Should I use infix notation, lisp-like S expressions, or RPN?
> I think we should not use infix notation as it's harder to parse and not as
> clear which order operators are being applied.
>
> RPN is the easiest to parse.
> S expressions maintain the familiar operation nesting and is second easiest
> to parse.


I hadn't thought about it, basically needs to be dead simple, yet enough to
represent FMULADD.

even avoid stack, put operator first then operands, because operator can be
done as a switch statement then straight to read of num of ops, then print
result. Loop.

fscanf to read line up to \n to get operator.
switch statement
fscanf with %x's to read operands.





-- 
---
crowd-funded eco-conscious hardware: https://www.crowdsupply.com/eoma68


More information about the libre-riscv-dev mailing list