flat assembler
Message board for the users of flat assembler.

Index > Programming Language Design > I added some FlatAssembler-like capabilities to my assembler

Author
Thread Post new topic Reply to topic
UniverseIsASimulation



Joined: 23 Sep 2016
Posts: 34
UniverseIsASimulation 08 Aug 2023, 16:35
Xilinx PicoBlaze is a small computer we are using as an example of a simple computer at our Computer Architecture classes here (at the FERIT University). In 2020, my Computer Architecture professor Ivan Aleksi asked me to make a web-based assembler and emulator for PicoBlaze so that students can do laboratory exercises from home in case physical laboratory exercises need to be cancelled (due to the pandemic). So I did it, you can run it in a modern browser by clicking this link (I made sure it works in Firefox 52, the last version of Firefox to run on Windows XP, so that it can be run on all computers at our university).

A few weeks ago, I added some FlatAssembler-like capabilities to it, specifically the if-else-branching in the preprocessor, while-loops in the preprocessor, and the `display` preprocessor directive. I illustrated those new features using the Preprocessor Test example:
Code:
;This is a program to test the
;new features of the preprocessor,
;the `display` directive,
;`if`-`else` branching and
;`while` loops, by
;printing the Fibonacci numbers
;smaller than 100 on the terminal
;during the assembly time.

;WARNING: Please do not press
;         "Highlight Assembly"
;         before you assemble this program,
;         as there is a bug in the syntax
;         highlighter inserting a
;         semi-colon after the less-than
;         and greater-than characters,
;         causing syntax errors in programs
;         such as this one. I have opened
;         a GitHub issue about that.

display "We are about to display Fibonacci numbers smaller than 100 in the UART terminal..."
display a ;0xa=='\n', a new-line character.
constant first, 0
constant second, 1
while first < 100'd
        if first < 10'd
                display "0" + first
                display " " ;In case inserting a new-line character doesn't work...
                display a
        else
                constant remainder, first
                constant counter, 0
                while remainder > 10'd - 1
                        constant remainder, remainder - 10'd
                        constant counter, counter + 1
                endwhile
                display counter + "0"
                display remainder + "0"
                display " "
                display a
        endif
        constant second, first + second
        constant first, second - first
endwhile
    

Right now, only preprocessor directives (not mnemonics, or even the "address" command) can appear inside the if-branchings and while-loops, and there is no support for macros.
Post 08 Aug 2023, 16:35
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.