Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    HACK Assembly Ported to FUZE

    Creation share codes
    4
    18
    1194
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Doriphor
      Doriphor @LucasJG25 last edited by Doriphor

      @LucasJG25 oh! I remember writing a CPU and assembler for this (as part of the NAND to Tetris course). Great job!

      The book is pretty great btw for those who are interested.

      @toxibunny Yes but it can give you the impression that assembly is this arcane art that only code wizards can practice properly, when in fact, even in the 80s, assembly was relatively easy in comparison to this thanks to the magic of macros!

      1 Reply Last reply Reply Quote 3
      • L
        LucasJG25 last edited by LucasJG25

        Here is the same Hack Assembler but attached to a text editor. meaning you don't code in the FUZE editor anymore. But you instead code within the editor running in FUZE. Read the comments as to how to use the editor.

        TextEditor:
        Code: LVW53MND9K (pending)

        Make sure to use the delete key to erase characters from a line of text instead of backspace.

        To display pixels to the screen give RAM[21451] = 1.

        1 Reply Last reply Reply Quote 4
        • L
          LucasJG25 last edited by LucasJG25

          Due to memory constraints the ROM had to be reduced. From a whopping 30,000 lines of code to 583 lines. But this reminds me that in every decision when designing software or hardware. There are some sacrifices that have to be made. For example if I had stuck to 30,000 lines of code. Then only 1 file can be used to save and load from. That doesn't really sound to good in terms of saving your code and wanting to make a new project within the text editor without copying the entire text editor code into a new FUZE project.

          But now with less lines of code. More files can be used. And amazingly a whole 100 files can be accessed. That speaks volumes!!

          Also, I made the decision to reduce the lines of code to provide a challenge. Is it possible to write 583 lines of assembly code and make a game? And since we have 100 files at our disposal. 100 games!!!

          Here's the file system working in action

          I fixed that little bug which didn't show you the correct maximum of characters when loading and saving.

          1 Reply Last reply Reply Quote 6
          • JMM161437
            JMM161437 F last edited by

            Me: -works hard on my circuit designer and has bugs- LucasJG25:yeah Ima create a full computer that is functional and you can program it... you are really amazing at this stuff!

            1 Reply Last reply Reply Quote 4
            • L
              LucasJG25 last edited by

              @JMM161437 Thank you! I'm looking forward to your circuit designer. ;)

              So, I'm currently working on the language (Not updating it but rather learning to code in it.) and I'll post up a little tutorial concerning how to construct functions, if statements and while loops. The more I learn how to code in this assembly code the more tutorials I'll be able to post up which will give some help to those who don't know about assembly or who find it difficult to code in this language.

              The tutorial will take some time but it will be posted up soon.

              1 Reply Last reply Reply Quote 0
              • JMM161437
                JMM161437 F last edited by

                well I look forward to it... as for my circuit designer... yeah I'm keeping it DC Electric and keep this up... by the end of it you might be able to emulate Fuze inside of Fuze lol

                1 Reply Last reply Reply Quote 1
                • L
                  LucasJG25 last edited by

                  @JMM161437 hehe. We'll see. High level languages are more complex than assembly. But practice makes perfect.

                  1 Reply Last reply Reply Quote 0
                  • JMM161437
                    JMM161437 F last edited by JMM161437

                    @LucasJG25 yeah I like assembly, its fast when it runs and you can manipulate the CPU directly.

                    1 Reply Last reply Reply Quote 1
                    • L
                      LucasJG25 last edited by

                      Based on what I've tested so far. Functions are done by storing the return address before jumping to complete a task. It's much easier to plan assembly code when you think in line with functions and how they work. The code below goes into a bit of this as well as dealing with IF statements and While loops.

                      //THIS IS A IF STATEMENT AND WHILE LOOP TEST. 
                      //R0 IS THE REGISTER THAT HOLDS THE RETURN ADDRESS
                      //R1 HOLDS THE RETURN VALUE FROM A FUNCTION
                      //R2 AND R3 ARE USED FOR ARGUMENTS.
                      //ENTER VALUE INTO R2 OR R3 AND THE PROGRAM WILL EVALUATE
                      //WHETHER R2 IS GREATER THAN R3 OR VICE VERSA
                      
                      @MAIN
                      0;JMP
                      
                      (CALL_CHECK)
                      	@R2
                      	D=M
                      	@R3
                      	D=D-M
                      	@IF_TRUE0
                      	D;JGT
                      	@50
                      	D=A
                      	@R1
                      	M=D
                      	@IF_END0
                      	0;JMP
                      	(IF_TRUE0)
                      	@100
                      	D=A
                      	@R1
                      	M=D
                      	(IF_END0)
                      	@R0
                      	A=M
                      	0;JMP
                      	
                      (CALL_DRAW_PIXELS)
                      	@16
                      	D=A
                      	@COUNT
                      	M=D
                      	@SCREEN
                      	D=A
                      	@R2
                      	D=D+A
                      	@SCREEN_PTR
                      	M=D
                      	(WHILE_LOOP0)
                      	@SCREEN_PTR
                      	A=M
                      	M=-1
                      	D=A
                      	@32
                      	D=D+A
                      	@SCREEN_PTR
                      	M=D
                      	@COUNT
                      	M=M-1
                      	D=M
                      	@WHILE_LOOP0
                      	D;JGT
                      	@R0
                      	A=M
                      	0;JMP
                      	
                      (MAIN)
                      	@CC_RET0
                      	D=A
                      	@R0
                      	M=D
                      	@CALL_CHECK
                      	0;JMP
                      	(CC_RET0)
                      	@CDP_RET0
                      	D=A
                      	@R0
                      	M=D
                      	@R1
                      	D=M
                      	@R2
                      	M=D
                      	@CALL_DRAW_PIXELS
                      	0;JMP
                      	(CDP_RET0)
                      	```
                      1 Reply Last reply Reply Quote 0
                      • L
                        LucasJG25 last edited by

                        Text editor is now updated along with the Hack VM. VM can now take 1428 lines of code. So a much better chance of getting a game made now.

                        1 Reply Last reply Reply Quote 7
                        • First post
                          Last post