Skip to content

iiriis/sap_assembler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

sap_assembler

an assembler for the 8bit breadboard cpu.

An assembler for the 8bit cpu with 256bytes of addressing capability. The assembler has two modes, 1 : "console to file"(c2f) where you write the mnemonics in the console and finaly the console gets terminated by ';', after that a ".o" file appears in the current directory which is basically an object file which can only be viewed by a hex editor. 2 : a "file to file" mode where you create a ".asm" file and edit it using your editor and finally use the assembler to assemble the code and again an object file generated, which can be opened by a hex editor and you get the opcodes for the program. It also features an hexdump option by which you can use it as a hex viewer. It can dump any file in raw hex code.

The syntax is simple, the instructions are listed below. To comment a line put "$" in starting of the line, to create a label(useful for loops) put a "*" before the label.

To get the list of options type "java sasm" without quotes.

You can try writing some assembly language programs using the below mnemonics :)

OPCODE (hex) Mnemonic Description
0x01 nop no operation
0x02 lda load accumulator from an 8 bit address
0x03 sta store accumulator to 8bit address
0x04 ldi load accumulator immidiate with 8bit data
0x05 addz add immidiate the data from th address specified after this instructruction
0x06 jmp unconditional jump
0x07 subz subtract immidiate the data from the address specified after this instructruction
0x08 adi add immidiate the data specified after this instructruction
0x09 subi subtract immidiate the data from th address specified after this instructruction
0x0A jz jump if the previous operation resulted to zero
0x0B jc jump if the previous operation resulted to a carry
0x0C ldax b load accumulator indirect from the address specified by the data in register b
0x0D ldax c load accumulator indirect from the address specified by the data in register c
0x0E ldax d load accumulator indirect from the address specified by the data in register d
0x0F stax b store accumulator indirect to the address specified by the data in register b
0x10 stax c store accumulator indirect to the address specified by the data in register c
0x11 stax d store accumulator indirect to the address specified by the data in register d
0x12 mvi b move 8bit data immidiate to the register b which is kept immidiate after this instruction
0x13 mvi c move 8bit data immidiate to the register c which is kept immidiate after this instruction
0x14 mvi d move 8bit data immidiate to the register d which is kept immidiate after this instruction
0x15 mov a,b move contents of accumulator to register b
0x16 mov a,c move contents of accumulator to register c
0x17 mov a,d move contents of accumulator to register d
0x18 mov b,a move contents of register b to accumulator
0x19 mov b,c move contents of register b to register c
0x1A mov b,d move contents of register b to register d
0x1B mov c,a move contents of register c to accumulator
0x1C mov c,b move contents of register c to register b
0x1D mov c,d move contents of register c to register d
0x1E mov d,a move contents of register d to accumulator
0x1F mov d,b move contents of register d to register b
0x20 mov d,c move contents of register d to register c
0x21 add a add the contents of accumulator with accumulator and keep the results in accumulator (double the accumulator same as << 1 )
0x22 add b add the contents of register b with accumulator and keep the results in accumulator
0x23 add c add the contents of register c with accumulator and keep the results in accumulator
0x24 add d add the contents of register d with accumulator and keep the results in accumulator
0x25 sub a subtract the contents of accumulator with accumulator and keep the results in accumulator( Nullify the accumulator ;) )
0x26 sub b subtract the contents of register b from accumulator and keep the results in accumulator
0x27 sub c subtract the contents of register c from accumulator and keep the results in accumulator
0x28 sub d subtract the contents of register d from accumulator and keep the results in accumulator
0x29 inr a increment the contents of accumulator by 1
0x2A inr b increment the contents of register b by 1
0x2B inr c increment the contents of register c by 1
0x2C inr d increment the contents of register d by 1
0x2D hlt halt or stop the cpu

About

an assembler for the 8bit breadboard cpu.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages