Posts

Showing posts with the label assembly

8-bit Computer: ALU

Image
With an "A" and "B" register in place for my 8-bit computer , I need to implement an Arithmetic Logic (ALU).  The ALU is the part of the computer where the interesting stuff happens - data is manipulated in some way, i.e. where the computer actually COMPUTES!  Ben Eater uses 2 x 74LS283 4-bit addition ICs in his ALU to perform 8-bit addition of an A and B register, and uses a control signal and some glue logic to implement subtraction by way of 2s complement addition .  Flags are then set based on the outcome of the ALU, and the program can branch (or not).  I considered a similar implementation with 74LS283 chips, but also adding some logic gate, i.e. an 8-bit NAND or NOR function to construct different logic functions.  The outputs from the addition/subtraction section and the NAND/NOR logic section would then need to be multiplexed to select the output of interest and latched into the flag register which I decided n...

Assembler for Ben Eater's 8-bit computer

Image
I've been thinking about 8-bit computers recently and came across the most excellent breadboard 8-bit computer series by Ben Eater .  Absolutely terrific stuff, fantastic break down of the subject and a clear and talented educator.  Like many, it got me pondering building my own 8-bit computer, modifying the original design to my specifications and writing custom opcodes and microcode.  Thinking about how to convert assembly language easily to machine code for such a custom computer, I wondered if there were any assemblers out there for assembling custom ASM.  It turns out there are, and the one I've been playing with is called... customasm .

Disassembling Arduino generated code

Image
Johnny Five... No disassemble! I recently had need to work out how many clock cycles certain functions in my code took to execute, so it was time to find the HEX file and disassemble back to the ASM instructions.  In the Arduino environment you are shielded from getting your hands dirty with the generated compiler files, but they can be located in a temporary directory in Windows, found under: C:\Users\ USERNAME \AppData\Local\Temp\build XYZ .tmp where " USERNAME " is your ... user name and XYZ is some long integer that Arduino comes up with.  Make sure you have recently compiled your code in Arduino - the folders are deleted or wiped when you exit Arduino.  In this folder you'll find some interesting files, among them the .HEX file and .ELF files are of particular interest.  Either make a .BAT file or use the CMD prompt to execute the following commands. Disassemble from HEX We'll use avr-objdump, but we need to specify the architecture.  Find ...