├── samples ├── 1802 │ └── 1802.asm ├── 4004 │ └── 4004.asm ├── 6502 │ └── testing.asm ├── 6800 │ └── testing.asm ├── 6809 │ └── testing.asm ├── 8051 │ ├── Makefile │ ├── testing.asm │ └── blink_leds.asm ├── mips │ ├── testing.asm │ ├── n64_rsp.asm │ └── chipkit.asm ├── dotnet │ └── dotnet.asm ├── arm │ ├── add_numbers.asm │ └── testing.asm ├── arm64 │ ├── add_nums.asm │ ├── Makefile │ ├── test.c │ └── testing.asm ├── playstation2 │ ├── image.raw │ └── create_sin_table.py ├── propeller │ ├── flip_blink.spin │ ├── testing.asm │ └── flip_blink_code.asm ├── riscv_link │ ├── get_value.asm │ ├── Makefile │ └── test.c ├── library │ ├── sample.asm │ ├── Makefile │ └── test_lib.c ├── lc3 │ ├── testing.asm │ └── Makefile ├── webasm │ └── Makefile ├── raspberry_pi │ ├── c_module.c │ ├── asm_module.asm │ ├── Makefile │ └── test_arm.c ├── cp1610 │ ├── cp1610.asm │ └── Makefile ├── pic18 │ └── Makefile ├── 65c816 │ └── Makefile ├── tms1100 │ └── testing.asm ├── tms1000 │ └── testing.asm ├── nes │ ├── Makefile │ └── README.md ├── stm8 │ └── led.asm ├── propeller2 │ └── Makefile ├── xtensa │ └── Makefile ├── amiga │ └── copper.asm ├── java │ └── java.asm ├── nintendo64 │ ├── support │ │ ├── Test.java │ │ └── cos_table.py │ ├── picture.txt │ ├── README.md │ ├── picture.py │ └── Makefile ├── playstation3 │ ├── spe_test.asm │ └── Makefile ├── super_fx │ └── super_fx.asm ├── dspic │ ├── led_blink33.asm │ └── led_blink.asm ├── f8 │ └── testing.asm ├── tms9900 │ └── testing.asm ├── pdp11 │ └── pdp11.asm ├── epiphany │ ├── Makefile │ └── testing.asm ├── unsp │ └── unsp.asm ├── 68hc08 │ └── testing.asm ├── cell │ └── cell.asm ├── msp430 │ └── launchpad_blink.asm ├── f100_l │ └── f100_l.asm └── dreamcast │ ├── Makefile │ └── IP.asm ├── tests ├── simulator │ ├── README.md │ └── msp430 │ │ ├── immediate.asm │ │ ├── symbolic.asm │ │ ├── immediate_to_absolute.asm │ │ ├── immediate_to_symbolic.asm │ │ ├── absolute.asm │ │ ├── immediate_to_indexed.asm │ │ ├── symbolic_to_symbolic.asm │ │ ├── loop.asm │ │ └── cg.asm ├── disasm │ └── Makefile ├── regression │ ├── 8051.hex │ ├── tms9900.hex │ ├── avr8.hex │ ├── arm.hex │ ├── msp430.hex │ └── regression.sh ├── directives │ ├── endian.asm │ └── test.py ├── comparison │ ├── template │ │ ├── 8041.txt │ │ ├── lc3.txt │ │ ├── sweet16.txt │ │ ├── 4004.txt │ │ ├── 8008.txt │ │ ├── pic14.txt │ │ ├── 1802.txt │ │ └── f8.txt │ ├── 8041.txt │ ├── lc3.txt │ ├── build_dspic.sh │ ├── sweet16.txt │ └── scripts │ │ └── gen_8051.py ├── other │ ├── check_libstdcplusplus.sh │ └── Makefile ├── symbol_address │ ├── stm8_test.h │ ├── 68000_test.h │ ├── epiphany_test.h │ ├── Makefile │ ├── 65c816_test.h │ └── mips_test.h └── unit │ ├── memory │ └── Makefile │ ├── data │ └── Makefile │ ├── util │ └── Makefile │ ├── tokens │ └── Makefile │ ├── macros │ └── Makefile │ ├── eval_expression │ └── Makefile │ ├── symbols │ └── Makefile │ ├── eval_expression_ex │ └── Makefile │ └── common │ └── test_checks.h ├── docs ├── ARM.md ├── TMS9900.md ├── xtensa.md ├── 6502.md ├── 8051.md ├── 1802.md ├── disassembling.md ├── PowerPC.md ├── TMS1000.md ├── Playstation_2.md ├── credits.md ├── file_formats.md ├── SunPlus_unSP.md ├── TMS340.md ├── installing.md └── MSP430.md ├── scripts ├── dist │ ├── freebsd │ │ ├── pkg-plist │ │ ├── pkg-descr │ │ └── Makefile │ ├── rocky │ │ ├── Makefile │ │ └── Dockerfile │ ├── windows │ │ ├── Makefile │ │ ├── Dockerfile │ │ └── build.sh │ ├── snap │ │ ├── build.sh │ │ └── Dockerfile │ └── centos │ │ └── Dockerfile └── graveyard │ ├── mips_j.txt │ ├── mips_co.txt │ ├── gen_avr8.py │ ├── gen_z80.py │ ├── arm_alu.txt │ ├── lpc.py │ ├── multi.sh │ ├── make_propeller2_cz.py │ ├── mips_r.txt │ ├── create_hex.py │ ├── mips_i.txt │ └── lsfr.py ├── common ├── version.h ├── naken_util.h ├── ifdef_expression.h ├── directives.h ├── imports_get_int.h ├── directives_include.h ├── util_disasm.h ├── directives_if.h ├── util_sim.h ├── MemoryPool.h ├── imports_ar.h ├── add_bin.h └── directives_data.h ├── .gitignore ├── include ├── ti99 │ └── ti99.inc ├── amiga │ ├── translator.inc │ ├── diskfont.inc │ ├── timer.inc │ ├── potgo.inc │ ├── console.inc │ └── mathffp.inc ├── z80 │ └── ti84c.inc ├── propeller │ └── propeller.inc ├── riscv │ └── csr.inc ├── playstation2 │ ├── system_calls.inc │ └── registers_gs_priv.inc ├── nintendo64 │ └── audio_interface.inc └── sensors │ └── sgp30.inc ├── README.md ├── fileio ├── write_bin.h ├── write_hex.h ├── write_uf2.h ├── write_wdc.h ├── write_amiga.h ├── write_srec.h ├── read_hex.h ├── read_srec.h ├── read_ti_txt.h ├── read_uf2.h ├── read_wdc.h ├── read_amiga.h ├── read_bin.h ├── read_elf.h ├── read_macho.h ├── write_macho.h ├── write_bin.cpp └── uf2.h ├── asm ├── f8.h ├── arc.h ├── arm.h ├── lc3.h ├── m8c.h ├── sh4.h ├── template.h ├── z80.h ├── 1802.h ├── 4004.h ├── 6800.h ├── 6809.h ├── 8008.h ├── 8048.h ├── 8051.h ├── avr8.h ├── cell.h ├── ebpf.h ├── java.h ├── stm8.h ├── unsp.h ├── 68000.h ├── 86000.h ├── arm64.h ├── dspic.h ├── pdk13.h ├── pdk14.h ├── pdk15.h ├── pdk16.h ├── pdp11.h ├── pic14.h ├── pic18.h ├── riscv.h ├── sparc.h ├── thumb.h ├── 68hc08.h ├── copper.h ├── cp1610.h ├── dotnet.h ├── f100_l.h ├── powerpc.h ├── sweet16.h ├── tms340.h ├── tms9900.h ├── webasm.h ├── xtensa.h ├── epiphany.h ├── super_fx.h ├── propeller.h ├── ps2_ee_vu.h ├── propeller2.h ├── agc.h ├── 6502.h ├── pdp8.h ├── tms1000.h ├── 65816.h ├── mips.h ├── msp430.h ├── pdk_parse.h └── common.h ├── table ├── 6800.h ├── f100_l.h ├── pic14.h ├── 4004.h ├── tms1000.h ├── sweet16.h ├── pdp8.h ├── lc3.h ├── unsp.h ├── agc.h ├── ebpf.h ├── pdp11.h ├── 1802.h ├── 8008.h ├── propeller.h ├── pdk13.h ├── pdk14.h ├── pdk15.h ├── pic18.h ├── pdk16.h ├── sparc.h ├── tms9900.h └── m8c.h └── disasm ├── f8.h ├── arc.h ├── lc3.h ├── m8c.h ├── sh4.h ├── z80.h ├── 1802.h ├── 4004.h ├── 6800.h ├── 6809.h ├── 8008.h ├── 8051.h ├── cell.h ├── ebpf.h ├── java.h ├── stm8.h ├── unsp.h ├── 68000.h ├── 86000.h ├── arm64.h ├── pdk13.h ├── pdk14.h ├── pdk15.h ├── pdk16.h ├── pdp11.h ├── pic14.h ├── pic18.h ├── sparc.h ├── thumb.h ├── 68hc08.h ├── copper.h ├── cp1610.h ├── dotnet.h ├── f100_l.h ├── tms340.h ├── webasm.h ├── xtensa.h ├── powerpc.h ├── sweet16.h ├── tms9900.h ├── epiphany.h ├── super_fx.h ├── 8048.h ├── mips.h ├── propeller.h ├── agc.h ├── template.h ├── propeller2.h ├── avr8.h ├── 6502.h ├── pdp8.h ├── 65816.h └── ps2_ee_vu.h /samples/mips/testing.asm: -------------------------------------------------------------------------------- 1 | .mips32 2 | 3 | lw $t0, 0($gp) 4 | 5 | 6 | -------------------------------------------------------------------------------- /samples/dotnet/dotnet.asm: -------------------------------------------------------------------------------- 1 | .dotnet 2 | 3 | div 4 | sub.ovf.un 5 | cgt.un 6 | 7 | -------------------------------------------------------------------------------- /tests/simulator/README.md: -------------------------------------------------------------------------------- 1 | 2 | These tests do not run in CI. Run them manually. 3 | 4 | -------------------------------------------------------------------------------- /docs/ARM.md: -------------------------------------------------------------------------------- 1 | 2 | ARM 3 | === 4 | 5 | TODO: Add documentation for notes about ARM. 6 | 7 | -------------------------------------------------------------------------------- /scripts/dist/freebsd/pkg-plist: -------------------------------------------------------------------------------- 1 | /usr/local/bin/naken_asm 2 | /usr/local/bin/naken_util 3 | -------------------------------------------------------------------------------- /scripts/dist/rocky/Makefile: -------------------------------------------------------------------------------- 1 | 2 | default: 3 | docker build --tag build-naken_asm . 4 | 5 | -------------------------------------------------------------------------------- /tests/disasm/Makefile: -------------------------------------------------------------------------------- 1 | 2 | default: 3 | python3 pic32.py 4 | python3 ps2_ee.py 5 | 6 | -------------------------------------------------------------------------------- /scripts/dist/windows/Makefile: -------------------------------------------------------------------------------- 1 | 2 | default: 3 | docker build --tag build-naken_asm-win . 4 | 5 | -------------------------------------------------------------------------------- /docs/TMS9900.md: -------------------------------------------------------------------------------- 1 | 2 | TMS9900 3 | ======= 4 | 5 | TODO: Add documentation for notes about TM9900. 6 | 7 | -------------------------------------------------------------------------------- /samples/6502/testing.asm: -------------------------------------------------------------------------------- 1 | .6502 2 | 3 | lda #5 4 | ldx #5 5 | main: 6 | ldy #5 7 | bne main 8 | 9 | -------------------------------------------------------------------------------- /samples/arm/add_numbers.asm: -------------------------------------------------------------------------------- 1 | 2 | .arm 3 | 4 | add_numbers_asm: 5 | add r0, r0, r1 6 | bx lr 7 | 8 | -------------------------------------------------------------------------------- /samples/arm64/add_nums.asm: -------------------------------------------------------------------------------- 1 | .arm64 2 | .export add_nums 3 | 4 | add_nums: 5 | add w0, w0, w1 6 | ret 7 | 8 | -------------------------------------------------------------------------------- /tests/regression/8051.hex: -------------------------------------------------------------------------------- 1 | :10000000272D7B05410353320354645555B291208B 2 | :0200100092F468 3 | :00000001FF 4 | -------------------------------------------------------------------------------- /samples/playstation2/image.raw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikeakohn/naken_asm/HEAD/samples/playstation2/image.raw -------------------------------------------------------------------------------- /scripts/graveyard/mips_j.txt: -------------------------------------------------------------------------------- 1 | j label 000010 coded address of label 2 | jal label 000011 coded address of label 3 | -------------------------------------------------------------------------------- /samples/propeller/flip_blink.spin: -------------------------------------------------------------------------------- 1 | Pub Main 2 | cognew(@code, 0) 3 | 4 | DAT 5 | code file "flip_blink_code.bin" 6 | 7 | -------------------------------------------------------------------------------- /samples/riscv_link/get_value.asm: -------------------------------------------------------------------------------- 1 | .riscv64 2 | 3 | .export add_nums 4 | 5 | add_nums: 6 | add a0, a0, a1 7 | ret 8 | 9 | -------------------------------------------------------------------------------- /docs/xtensa.md: -------------------------------------------------------------------------------- 1 | 2 | Xtensa 3 | ====== 4 | 5 | This assembler supports Tensilica's Xtensa core used in ESP32 and ESP8266. 6 | 7 | -------------------------------------------------------------------------------- /common/version.h: -------------------------------------------------------------------------------- 1 | #ifndef NAKEN_ASM_VERSION_H 2 | #define NAKEN_ASM_VERSION_H 3 | 4 | #define VERSION "May 25, 2025" 5 | 6 | #endif 7 | 8 | -------------------------------------------------------------------------------- /scripts/dist/windows/Dockerfile: -------------------------------------------------------------------------------- 1 | 2 | FROM ubuntu 3 | RUN apt update 4 | RUN apt -y install git gcc make mingw-w64 zip vim 5 | ADD build.sh /root/ 6 | 7 | -------------------------------------------------------------------------------- /tests/directives/endian.asm: -------------------------------------------------------------------------------- 1 | .stm8 2 | 3 | dw 0x1234 4 | 5 | .little_endian 6 | 7 | dw 0x5678 8 | 9 | .big_endian 10 | 11 | dw 0x1234 12 | 13 | -------------------------------------------------------------------------------- /samples/library/sample.asm: -------------------------------------------------------------------------------- 1 | .msp430 2 | 3 | start: 4 | mov.w #5, r4 5 | mov.w r4, r10 6 | while_1: 7 | add.w #100, r10 8 | jmp while_1 9 | 10 | -------------------------------------------------------------------------------- /samples/lc3/testing.asm: -------------------------------------------------------------------------------- 1 | .lc3 2 | 3 | .org 0x3000 4 | 5 | main: 6 | ld r0, data 7 | 8 | loop: 9 | br loop 10 | 11 | data: 12 | dw 0x1234 13 | 14 | -------------------------------------------------------------------------------- /tests/simulator/msp430/immediate.asm: -------------------------------------------------------------------------------- 1 | .msp430 2 | 3 | 4 | .org 0xf800 5 | main: 6 | mov.w #165, r15 7 | ret 8 | 9 | .org 0xfffe 10 | .dc16 main 11 | 12 | -------------------------------------------------------------------------------- /samples/webasm/Makefile: -------------------------------------------------------------------------------- 1 | 2 | default: 3 | ../../naken_asm -l -type bin -dump_symbols -o math.wasm math.asm 4 | 5 | clean: 6 | @rm -f *.wasm *.lst 7 | @echo "Clean!" 8 | 9 | -------------------------------------------------------------------------------- /samples/raspberry_pi/c_module.c: -------------------------------------------------------------------------------- 1 | 2 | int add_numbers_c(int a, int b) 3 | { 4 | return a+b; 5 | } 6 | 7 | int counter(int a, int b) 8 | { 9 | return a+1; 10 | } 11 | 12 | 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | build/*.a 3 | config.mak 4 | naken_asm 5 | naken_util 6 | naken_prog 7 | *.hex 8 | *.lst 9 | *.swp 10 | *.bin 11 | *~ 12 | *.elf 13 | *.z64 14 | *.raw 15 | history 16 | -------------------------------------------------------------------------------- /docs/6502.md: -------------------------------------------------------------------------------- 1 | 2 | 6502 3 | ==== 4 | 5 | This assembler supports 6502, 65C02, 6507, 6510 and others. 6 | 7 | For more info: 8 | 9 | https://en.wikipedia.org/wiki/MOS_Technology_6502 10 | 11 | -------------------------------------------------------------------------------- /tests/simulator/msp430/symbolic.asm: -------------------------------------------------------------------------------- 1 | .msp430 2 | 3 | 4 | .org 0xf800 5 | main: 6 | mov.w #165, &0x0204 7 | mov.w 0x0204, r15 8 | ret 9 | 10 | .org 0xfffe 11 | .dc16 main 12 | 13 | -------------------------------------------------------------------------------- /docs/8051.md: -------------------------------------------------------------------------------- 1 | 2 | 8051 3 | ==== 4 | 5 | This assembler supports the MCS-51 family of CPU including 8051 and 8052. 6 | 7 | For more info: 8 | 9 | https://en.wikipedia.org/wiki/Intel_MCS-51 10 | 11 | -------------------------------------------------------------------------------- /samples/4004/4004.asm: -------------------------------------------------------------------------------- 1 | .4004 2 | 3 | main: 4 | rdm 5 | add 5 6 | blah: 7 | jin 4 8 | jcn 3 main 9 | jcn 2 blah 10 | jnz blah 11 | jun blah 12 | isz 8 skip 13 | fim 4 blah 14 | skip: 15 | -------------------------------------------------------------------------------- /tests/simulator/msp430/immediate_to_absolute.asm: -------------------------------------------------------------------------------- 1 | .msp430 2 | 3 | 4 | .org 0xf800 5 | main: 6 | mov.w #165, &0x0204 7 | mov.w &0x0204, r15 8 | ret 9 | 10 | .org 0xfffe 11 | .dc16 main 12 | 13 | -------------------------------------------------------------------------------- /tests/simulator/msp430/immediate_to_symbolic.asm: -------------------------------------------------------------------------------- 1 | .msp430 2 | 3 | 4 | .org 0xf800 5 | main: 6 | mov.w #165, 0x0204 7 | mov.w 0x0204, r15 8 | ret 9 | 10 | .org 0xfffe 11 | .dc16 main 12 | 13 | -------------------------------------------------------------------------------- /samples/riscv_link/Makefile: -------------------------------------------------------------------------------- 1 | 2 | default: 3 | ../../naken_asm -type elf -o get_value.o -l get_value.asm 4 | gcc -o test get_value.o test.c 5 | 6 | clean: 7 | @rm -f *.o *.lst test 8 | @echo "Clean!" 9 | 10 | -------------------------------------------------------------------------------- /tests/comparison/template/8041.txt: -------------------------------------------------------------------------------- 1 | out dbb, A 2 | in A, dbb 3 | main: jnibf main 4 | main: jobf main 5 | mov sts, A 6 | en dma 7 | en flags 8 | movx A, @R0 9 | movx A, @R1 10 | movx A, @R7 11 | movx @r3, A 12 | -------------------------------------------------------------------------------- /docs/1802.md: -------------------------------------------------------------------------------- 1 | 2 | RCA 1802 3 | ======== 4 | 5 | This assembler has support for the RCA 1802 / 1804 / 1805 / 1806 and 6 | compatible chips. 7 | 8 | For more info: 9 | 10 | https://en.wikipedia.org/wiki/RCA_1802 11 | 12 | -------------------------------------------------------------------------------- /include/ti99/ti99.inc: -------------------------------------------------------------------------------- 1 | 2 | ;; 256 bytes of RAM start here 3 | RAM equ 0x8300 4 | 5 | ;; VDP registers 6 | VDP_READ equ 0x8800 7 | VDP_STATUS equ 0x8802 8 | VDP_WRITE equ 0x8c00 9 | VDP_COMMAND equ 0x8c02 10 | 11 | 12 | -------------------------------------------------------------------------------- /samples/arm64/Makefile: -------------------------------------------------------------------------------- 1 | 2 | default: 3 | ../../naken_asm -l -type elf -o add_nums.o add_nums.asm 4 | gcc -o test test.c add_nums.o -Wall 5 | 6 | clean: 7 | @rm -f *.o *.lst *.elf *.hex test 8 | @echo "Clean!" 9 | 10 | -------------------------------------------------------------------------------- /samples/cp1610/cp1610.asm: -------------------------------------------------------------------------------- 1 | .cp1610 2 | 3 | hlt 4 | negr r1 5 | comr r3 6 | 7 | xorr r3, r4 8 | xor@ r5, r7 9 | 10 | mvo r5, 0x2000 11 | 12 | mvii #3, r5 13 | 14 | sll r1, 1 15 | sar r2, 2 16 | 17 | -------------------------------------------------------------------------------- /tests/simulator/msp430/absolute.asm: -------------------------------------------------------------------------------- 1 | .msp430 2 | 3 | 4 | .org 0xf800 5 | main: 6 | mov.w #165, &0x0204 7 | mov.w &0x0204, &0x0206 8 | mov.w &0x0206, r15 9 | ret 10 | 11 | .org 0xfffe 12 | .dc16 main 13 | 14 | -------------------------------------------------------------------------------- /tests/comparison/8041.txt: -------------------------------------------------------------------------------- 1 | out dbb, A|:0100000002FD 2 | in A, dbb|:0100000022DD 3 | main: jnibf main|:02000000D60028 4 | main: jobf main|:02000000860078 5 | mov sts, A|:01000000906F 6 | en dma|:01000000E51A 7 | en flags|:01000000F50A 8 | -------------------------------------------------------------------------------- /tests/simulator/msp430/immediate_to_indexed.asm: -------------------------------------------------------------------------------- 1 | .msp430 2 | 3 | 4 | .org 0xf800 5 | main: 6 | mov.w #0x0204, r4 7 | mov.w #165, 4(r4) 8 | mov.w &0x0208, r15 9 | ret 10 | 11 | .org 0xfffe 12 | .dc16 main 13 | 14 | -------------------------------------------------------------------------------- /docs/disassembling.md: -------------------------------------------------------------------------------- 1 | Disassembling 2 | ============= 3 | 4 | Disassembling and simulating is done with naken_util. 5 | 6 | To disassemble an MSP430 program: 7 | 8 | ./naken_util -disasm -msp430 launchpad_blink.hex 9 | 10 | -------------------------------------------------------------------------------- /samples/cp1610/Makefile: -------------------------------------------------------------------------------- 1 | 2 | default: 3 | ../../naken_asm -l -o cp1610.hex cp1610.asm 4 | ../../naken_asm -type bin -l -o intellivision.bin intellivision.asm 5 | 6 | clean: 7 | @rm *.lst *.hex *.bin 8 | @echo "Clean!" 9 | 10 | -------------------------------------------------------------------------------- /samples/propeller/testing.asm: -------------------------------------------------------------------------------- 1 | .propeller 2 | 3 | start: 4 | clkset 100 5 | if_a ror 80, 84 6 | if_ne ror 80, #84 7 | 8 | sub 80, #1, wc wz 9 | 10 | jmp #start 11 | abs 80, 84 12 | nop 13 | tjz 80, #start 14 | 15 | -------------------------------------------------------------------------------- /scripts/dist/snap/build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "Nothing to see here yet" 4 | 5 | cd /root/snaps/naken_asm 6 | #mkdir -p snaps/naken_asm/snap 7 | #cd snaps/naken_asm 8 | #cp snapcraft.yaml snap/ 9 | snapcraft 10 | 11 | -------------------------------------------------------------------------------- /tests/simulator/msp430/symbolic_to_symbolic.asm: -------------------------------------------------------------------------------- 1 | .msp430 2 | 3 | 4 | .org 0xf800 5 | main: 6 | mov.w #165, &0x0204 7 | mov.w 0x0204, 0x0206 8 | mov.w &0x0206, r15 9 | ret 10 | 11 | .org 0xfffe 12 | .dc16 main 13 | 14 | -------------------------------------------------------------------------------- /samples/1802/1802.asm: -------------------------------------------------------------------------------- 1 | .1802 2 | 3 | .org 0x8000 4 | sex 2 5 | ldi 0x00 6 | phi 2 7 | plo 2 8 | loop: 9 | seq 10 | out 1 11 | req 12 | br loop 13 | rnx 9 14 | xie 15 | dsmi 10 16 | dbnz 8, loop 17 | bci loop 18 | 19 | -------------------------------------------------------------------------------- /tests/simulator/msp430/loop.asm: -------------------------------------------------------------------------------- 1 | .msp430 2 | 3 | 4 | .org 0xf800 5 | main: 6 | mov.w #0, r15 7 | mov.w #10, r4 8 | loop: 9 | add.w #1, r15 10 | dec.w r4 11 | jnz loop 12 | ret 13 | 14 | .org 0xfffe 15 | .dc16 main 16 | 17 | -------------------------------------------------------------------------------- /samples/pic18/Makefile: -------------------------------------------------------------------------------- 1 | INCLUDE_PATH=../../include/pic18 2 | PROGRAM=p_star_blink 3 | 4 | default: 5 | ../../naken_asm -l -o $(PROGRAM).hex -I $(INCLUDE_PATH) $(PROGRAM).asm 6 | 7 | clean: 8 | @rm -f *.lst *.hex 9 | @echo "Clean!" 10 | 11 | -------------------------------------------------------------------------------- /docs/PowerPC.md: -------------------------------------------------------------------------------- 1 | 2 | PowerPC 3 | ========= 4 | 5 | naken_asm supports basic PowerPC instructions along with 6 | Altivec and FPU instructions. 7 | 8 | Support for 64 bit and some other instructions are not supported 9 | yet. Coming soon! 10 | 11 | -------------------------------------------------------------------------------- /samples/raspberry_pi/asm_module.asm: -------------------------------------------------------------------------------- 1 | 2 | .arm 3 | 4 | add_numbers_asm: 5 | add r0, r0, r1 6 | bx lr 7 | 8 | counter: 9 | mov r1, #10 10 | repeat: 11 | add r0, r0, #1 12 | subs r1, r1, #1 13 | bne repeat 14 | bx lr 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /samples/8051/Makefile: -------------------------------------------------------------------------------- 1 | 2 | default: 3 | ../../naken_asm -l -o blink_leds.hex -I ../../include/8051 blink_leds.asm 4 | ../../naken_asm -l -o sleepy_bee.hex -I ../../include/8051 sleepy_bee.asm 5 | 6 | clean: 7 | @rm -f *.hex *.lst 8 | echo "Clean!" 9 | 10 | -------------------------------------------------------------------------------- /samples/65c816/Makefile: -------------------------------------------------------------------------------- 1 | FLAGS=-l -I ../../include/65c816 2 | 3 | default: 4 | naken_asm $(FLAGS) -o bender_head.hex bender_head.asm 5 | naken_asm $(FLAGS) -o mensch_blink.hex mensch_blink.asm 6 | 7 | clean: 8 | @rm -f *.hex *.lst *.o 9 | @echo "Clean!" 10 | 11 | -------------------------------------------------------------------------------- /samples/tms1100/testing.asm: -------------------------------------------------------------------------------- 1 | .tms1100 2 | 3 | a6aac 4 | a7aac 5 | loop: 6 | br loop 7 | 8 | sbit 0 9 | rbit 1 10 | tbit1 1 11 | ldx 2 12 | call blah 13 | 14 | tcy 3 15 | tcmiy 3 16 | ldp 3 17 | ynec 3 18 | 19 | blah: 20 | ynec 3 21 | 22 | -------------------------------------------------------------------------------- /samples/lc3/Makefile: -------------------------------------------------------------------------------- 1 | 2 | 3 | default: 4 | ../../naken_asm -dump_symbols -l -type bin -o testing.bin testing.asm 5 | @printf '\060\000' > testing.obj 6 | @cat testing.bin >> testing.obj 7 | 8 | clean: 9 | @rm -f *.lst *.hex *.bin *.obj 10 | @echo "Clean!" 11 | 12 | 13 | -------------------------------------------------------------------------------- /tests/simulator/msp430/cg.asm: -------------------------------------------------------------------------------- 1 | .msp430 2 | 3 | 4 | .org 0xf800 5 | main: 6 | mov.w #0, r15 7 | add.w #1, r15 8 | add.w #-1, r15 9 | add.w #2, r15 10 | add.w #10, r15 11 | add.w #4, r15 12 | add.w #8, r15 13 | ret 14 | 15 | .org 0xfffe 16 | .dc16 main 17 | 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | naken_asm 3 | ========= 4 | 5 | A simple assembler, disassembler, and simulator for many CPUs. 6 | For full description, usage, and a list of supported CPUs, 7 | check the [documentation](docs/). 8 | 9 | Website: https://www.mikekohn.net/micro/naken_asm.php 10 | 11 | -------------------------------------------------------------------------------- /samples/6800/testing.asm: -------------------------------------------------------------------------------- 1 | .6800 2 | 3 | main: 4 | tap 5 | TPA 6 | clv 7 | sev 8 | cpx #blah 9 | 10 | bne main 11 | cpx blah+1, X 12 | 13 | blah: 14 | lds #main 15 | suba #-1 16 | ldx #$1000 17 | ldaa #$10 18 | jsr blah 19 | anda $1000 20 | anda $10 21 | 22 | -------------------------------------------------------------------------------- /samples/tms1000/testing.asm: -------------------------------------------------------------------------------- 1 | .tms1000 2 | 3 | a6aac 4 | ;a7aac 5 | loop: 6 | clo 7 | br loop 8 | 9 | sbit 0 10 | rbit 1 11 | tbit1 1 12 | ldx 2 13 | call blah 14 | 15 | tcy 3 16 | tcmiy 3 17 | ldp 3 18 | alec 3 19 | ynec 3 20 | 21 | blah: 22 | alec 3 23 | 24 | -------------------------------------------------------------------------------- /samples/nes/Makefile: -------------------------------------------------------------------------------- 1 | 2 | INCLUDE=../../include/6502 3 | 4 | default: 5 | ../../naken_asm -I $(INCLUDE) -l -b -o test.nes test.asm 6 | 7 | disassemble: 8 | ../../naken_util -6502 -disasm -bin -address 0x7ff0 test.nes > out.txt 9 | 10 | clean: 11 | @rm -f test.bin test.lst test.nes 12 | 13 | -------------------------------------------------------------------------------- /tests/regression/tms9900.hex: -------------------------------------------------------------------------------- 1 | :10000000C040A800004EA8D5004EAC63004EA92306 2 | :10001000004E004EA820004E004E25A0004E04C801 3 | :100020000458043805A0005005A5004E319535E070 4 | :10003000004E12F51B021DFB1E050A650206FFFF9E 5 | :100040000227FFFF02E003E802C6034003800064CA 6 | :0400500000C8012CB7 7 | :00000001FF 8 | -------------------------------------------------------------------------------- /samples/8051/testing.asm: -------------------------------------------------------------------------------- 1 | .8051 2 | 3 | .include "../../include/8051/8051.inc" 4 | 5 | start: 6 | add A, @r1 7 | add A, r5 8 | 9 | mov r3, #5 10 | ajmp 515 11 | 12 | repeat: 13 | anl 50, #3 14 | anl A, #100 15 | anl A, 0x55 16 | 17 | cpl P1.1 18 | 19 | jb P1.2, repeat 20 | 21 | -------------------------------------------------------------------------------- /samples/stm8/led.asm: -------------------------------------------------------------------------------- 1 | .stm8 2 | 3 | ;.big_endian 4 | 5 | PD_ODR equ 0x500F 6 | PD_IDR equ 0x5010 7 | PD_DDR equ 0x5011 8 | PD_CR1 equ 0x5012 9 | PD_CR2 equ 0x5013 10 | 11 | .org 0x8000 12 | ;.org 0x8080 13 | main: 14 | mov PD_ODR, #$00 15 | mov PD_DDR, #$01 16 | repeat: 17 | jp repeat 18 | 19 | -------------------------------------------------------------------------------- /tests/other/check_libstdcplusplus.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | a=`ldd ../../naken_asm | grep libstdc++` 4 | 5 | if [[ ${a} != "" ]] 6 | then 7 | echo "Error" 8 | fi 9 | 10 | a=`ldd ../../naken_util | grep libstdc++` 11 | 12 | if [[ "${a}" != "" ]] 13 | then 14 | echo "Error ${a}" 15 | fi 16 | 17 | -------------------------------------------------------------------------------- /samples/propeller2/Makefile: -------------------------------------------------------------------------------- 1 | 2 | default: 3 | ../../naken_asm -l -type bin -o mandelbrot_core.bin mandelbrot_core.asm 4 | ../../naken_asm -l -type bin -o lcd_code.bin lcd_code.asm 5 | 6 | testing: 7 | ../../naken_asm -l testing.asm 8 | 9 | clean: 10 | @rm -f *.lst *.bin *.hex 11 | @echo "Clean!" 12 | 13 | -------------------------------------------------------------------------------- /tests/symbol_address/stm8_test.h: -------------------------------------------------------------------------------- 1 | const char *stm8 = 2 | ".stm8\n" 3 | ".org 0x1000\n" 4 | "first:\n" 5 | " ld a, 0x10\n" 6 | "second:\n" 7 | " ld a, fifth\n" 8 | "third:\n" 9 | " ld a, (fifth,Y)\n" 10 | "fourth:\n" 11 | ".org 0xf0\n" 12 | "fifth:\n" 13 | " db 0x10, 0x20\n"; 14 | 15 | -------------------------------------------------------------------------------- /samples/xtensa/Makefile: -------------------------------------------------------------------------------- 1 | 2 | default: 3 | ../../naken_asm -l -o xtensa.hex xtensa.asm 4 | ../../naken_asm -l -type bin -o esp32.bin -I ../../include/xtensa esp32.asm 5 | 6 | program: 7 | esptool -c esp32 write_flash 0x40000 esp32.bin 8 | 9 | clean: 10 | @rm -f *.hex *.lst *.bin 11 | @echo "Clean!" 12 | 13 | -------------------------------------------------------------------------------- /samples/amiga/copper.asm: -------------------------------------------------------------------------------- 1 | .copper 2 | 3 | main: 4 | wait 50, 51, 0x7f, 0x7f 5 | wait 50, 50 6 | wait bfd, 50, 50, 0x7f, 0x7f 7 | wait bfd, 50, 50 8 | wait 9 | 10 | move 0xe2, 0x1000 11 | 12 | skip 50, 50, 0x7f, 0x7f 13 | skip 50, 50 14 | skip bfd, 50, 50, 0x7f, 0x7f 15 | skip bfd, 50, 50 16 | 17 | -------------------------------------------------------------------------------- /tests/symbol_address/68000_test.h: -------------------------------------------------------------------------------- 1 | const char *mc68000 = 2 | ".68000\n" 3 | ".org 0x1000\n" 4 | "first:\n" 5 | " move.l #fifth, d0\n" 6 | "second:\n" 7 | " add.l (fifth), d1\n" 8 | "third:\n" 9 | " sub.w #1, d5\n" 10 | "fourth:\n" 11 | ".org 0xf0\n" 12 | "fifth:\n" 13 | " db 0x10, 0x20\n"; 14 | 15 | -------------------------------------------------------------------------------- /samples/java/java.asm: -------------------------------------------------------------------------------- 1 | .java 2 | 3 | start: 4 | iadd 5 | iand 6 | getstatic 5 7 | lload 7 8 | lload 256 9 | lload test_1 10 | lload test_2 11 | 12 | newarray boolean 13 | newarray 3 14 | 15 | iinc 5, 3 16 | 17 | if_icmpeq test_2 18 | goto_w start 19 | 20 | test_1: 21 | .org 1000 22 | test_2: 23 | 24 | -------------------------------------------------------------------------------- /samples/raspberry_pi/Makefile: -------------------------------------------------------------------------------- 1 | 2 | 3 | default: 4 | ../../naken_asm -l -type elf -o asm_module.o asm_module.asm 5 | gcc -c c_module.c -Wall -g 6 | #gcc -o test_arm test_arm.c c_module.o asm_module.o -Wall 7 | gcc -o test_arm test_arm.c asm_module.o -Wall -g 8 | 9 | clean: 10 | @rm -f *.o test_arm *.lst 11 | @echo "Clean!" 12 | 13 | -------------------------------------------------------------------------------- /scripts/dist/centos/Dockerfile: -------------------------------------------------------------------------------- 1 | # syntax=docker/dockerfile:1 2 | 3 | FROM centos:7 4 | RUN /usr/sbin/useradd makerpm 5 | RUN yum -y install gcc-c++ git-all make readline-devel rpmdevtools wget 6 | RUN mkdir -p /storage/git 7 | ADD naken_asm.spec.templ /home/makerpm/ 8 | ADD build.sh /home/makerpm/ 9 | RUN chmod 777 /storage/git 10 | 11 | -------------------------------------------------------------------------------- /scripts/dist/rocky/Dockerfile: -------------------------------------------------------------------------------- 1 | # syntax=docker/dockerfile:1 2 | 3 | FROM rockylinux:9 4 | RUN /usr/sbin/useradd makerpm 5 | RUN yum -y install gcc-c++ git-all make readline-devel rpmdevtools wget 6 | RUN mkdir -p /storage/git 7 | ADD naken_asm.spec.templ /home/makerpm/ 8 | ADD build.sh /home/makerpm/ 9 | RUN chmod 777 /storage/git 10 | 11 | -------------------------------------------------------------------------------- /samples/nintendo64/support/Test.java: -------------------------------------------------------------------------------- 1 | 2 | public class Test 3 | { 4 | public static int[] triangle = 5 | { 6 | 150 << 4, (120 << 4) | 4, 7 | 170 << 4, (170 << 4) | 8, 8 | 110 << 4, (190 << 4) | 12, 9 | }; 10 | 11 | static public void main(String[] args) 12 | { 13 | Triangle.compute(triangle); 14 | } 15 | } 16 | 17 | -------------------------------------------------------------------------------- /scripts/graveyard/mips_co.txt: -------------------------------------------------------------------------------- 1 | add.s fd, fs, ft 000000 10000 2 | cvt.s.w fd, fs, ft 100000 10100 3 | cvt.w.s fd, fs, ft 100100 10000 4 | div.s fd, fs, ft 000011 10000 5 | mfc1 ft, fs 000000 00000 6 | mov.s fd, fs 000110 10000 7 | mtc1 ft, fs 000000 00100 8 | mul.s fd, fs, ft 000010 10000 9 | sub.s fd, fs, ft 000001 10000 10 | -------------------------------------------------------------------------------- /tests/comparison/template/lc3.txt: -------------------------------------------------------------------------------- 1 | add r3, r4, r5 2 | add r3, r4, #7 3 | add r3, r4, #-10 4 | and r7, r2, r5 5 | and r3, r1, #7 6 | ;br 8 7 | jmp r4 8 | ;jsr 100 9 | jsrr r4 10 | ;ld r3, 100 11 | ;ldi r7, 120 12 | ldr r4, r2, #-4 13 | ;lea r4, 100 14 | not r4, r2 15 | ret 16 | rti 17 | ;st r3, 100 18 | ;sti r7, 120 19 | str r4, r2, #-4 20 | trap 50 21 | -------------------------------------------------------------------------------- /tests/regression/avr8.hex: -------------------------------------------------------------------------------- 1 | :100000008894F1F7FF27FF23FE0F45704E7FA21C57 2 | :100010006F927F90F39503FDFBDFFACF0E940800FB 3 | :100020000C940800CF962F9838944FEF7FB69FBE60 4 | :100030008F01E895D080C9903A91388101900A37B4 5 | :100040009082A992FA93A882319208950A030E9F92 6 | :10005000E09000101092002047AEFD8B5F8080ACD6 7 | :08006000E2E3F0E03412214359 8 | :00000001FF 9 | -------------------------------------------------------------------------------- /samples/library/Makefile: -------------------------------------------------------------------------------- 1 | 2 | default: sample.hex sample.elf 3 | gcc -o test_lib test_lib.c -I../../library -Wall -g -lnaken_asm -L../.. 4 | 5 | sample.hex: 6 | ../../naken_asm -o sample.hex sample.asm 7 | 8 | sample.elf: 9 | ../../naken_asm -o sample.elf -type elf sample.asm 10 | 11 | clean: 12 | @rm -f sample.hex 13 | @echo "Clean!" 14 | 15 | -------------------------------------------------------------------------------- /samples/nintendo64/picture.txt: -------------------------------------------------------------------------------- 1 | RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR 2 | R R 3 | R GGGGG BBBBB YYYY PPPPP R 4 | R G B Y P R 5 | R G BBB YYYY P R 6 | R G B Y P R 7 | R G BBBBB YYYY P R 8 | R R 9 | RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR 10 | -------------------------------------------------------------------------------- /tests/symbol_address/epiphany_test.h: -------------------------------------------------------------------------------- 1 | const char *epiphany = 2 | ".epiphany\n" 3 | ".org 0x200\n" 4 | "first:\n" 5 | " add r1, r2, #fifth\n" 6 | "second:\n" 7 | " b fourth\n" 8 | "third:\n" 9 | " lsr r1, r2, r3\n" 10 | "fourth:\n" 11 | " mov r3, #fifth\n" 12 | ".org 2\n" 13 | "fifth:\n" 14 | " add r2, r3, #fourth\n\n"; 15 | 16 | -------------------------------------------------------------------------------- /tests/unit/memory/Makefile: -------------------------------------------------------------------------------- 1 | include ../../../config.mak 2 | 3 | INCLUDES=-I../../.. 4 | BUILDDIR=../../../build 5 | CFLAGS=-Wall -g -DUNIT_TEST $(INCLUDES) 6 | LD_FLAGS=-L../../../build 7 | 8 | default: 9 | $(CXX) -o memory_test memory_test.cpp ../../../build/naken_asm.a \ 10 | $(CFLAGS) 11 | 12 | clean: 13 | @rm -f memory_test 14 | @echo "Clean!" 15 | 16 | -------------------------------------------------------------------------------- /common/naken_util.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_430_UTIL_H 13 | #define NAKEN_430_UTIL_H 14 | 15 | // FIXME: Delete me? 16 | 17 | #endif 18 | 19 | -------------------------------------------------------------------------------- /tests/unit/data/Makefile: -------------------------------------------------------------------------------- 1 | include ../../../config.mak 2 | 3 | INCLUDES=-I../../.. 4 | BUILDDIR=../../../build 5 | CFLAGS=-Wall -g -DUNIT_TEST $(INCLUDES) 6 | LD_FLAGS=-L../../../build 7 | 8 | default: 9 | $(CXX) -o data_test data_test.cpp \ 10 | ../../../build/naken_asm.a \ 11 | $(CFLAGS) 12 | 13 | clean: 14 | @rm -f data_test 15 | @echo "Clean!" 16 | 17 | -------------------------------------------------------------------------------- /tests/unit/util/Makefile: -------------------------------------------------------------------------------- 1 | include ../../../config.mak 2 | 3 | INCLUDES=-I../../.. 4 | BUILDDIR=../../../build 5 | CFLAGS=-Wall -g -DUNIT_TEST $(INCLUDES) 6 | LD_FLAGS=-L../../../build 7 | 8 | default: 9 | $(CXX) -o util_test util_test.cpp \ 10 | ../../../build/naken_asm.a \ 11 | $(CFLAGS) 12 | 13 | clean: 14 | @rm -f util_test 15 | @echo "Clean!" 16 | 17 | -------------------------------------------------------------------------------- /tests/symbol_address/Makefile: -------------------------------------------------------------------------------- 1 | include ../../config.mak 2 | 3 | INCLUDES=-I../../ 4 | BUILDDIR=../../build 5 | CFLAGS=-Wall -g -DUNIT_TEST $(INCLUDES) 6 | LD_FLAGS=-L../../build 7 | 8 | default: 9 | $(CXX) -o symbol_address symbol_address.cpp \ 10 | ../../build/naken_asm.a \ 11 | $(CFLAGS) 12 | 13 | clean: 14 | @rm -f symbol_address 15 | @echo "Clean!" 16 | 17 | -------------------------------------------------------------------------------- /tests/unit/tokens/Makefile: -------------------------------------------------------------------------------- 1 | include ../../../config.mak 2 | 3 | INCLUDES=-I../../.. 4 | BUILDDIR=../../../build 5 | CFLAGS=-Wall -g -DUNIT_TEST $(INCLUDES) 6 | LD_FLAGS=-L../../../build 7 | 8 | default: 9 | $(CXX) -o tokens_test tokens_test.cpp \ 10 | ../../../build/naken_asm.a \ 11 | $(CFLAGS) 12 | 13 | clean: 14 | @rm -f tokens_test 15 | @echo "Clean!" 16 | 17 | -------------------------------------------------------------------------------- /tests/unit/macros/Makefile: -------------------------------------------------------------------------------- 1 | include ../../../config.mak 2 | 3 | INCLUDES=-I../../../ 4 | BUILDDIR=../../../build 5 | CFLAGS=-Wall -g -DUNIT_TEST $(INCLUDES) 6 | LD_FLAGS=-L../../../build 7 | 8 | default: 9 | $(CXX) -o macro_test macro_test.cpp \ 10 | ../../../build/naken_asm.a \ 11 | $(CFLAGS) 12 | 13 | clean: 14 | @rm -f macro_test 15 | @echo "Clean!" 16 | 17 | -------------------------------------------------------------------------------- /tests/unit/eval_expression/Makefile: -------------------------------------------------------------------------------- 1 | include ../../../config.mak 2 | 3 | INCLUDES=-I../../.. 4 | BUILDDIR=../../../build 5 | CFLAGS=-Wall -g -DUNIT_TEST $(INCLUDES) 6 | LD_FLAGS=-L../../../build 7 | 8 | default: 9 | $(CXX) -o unit_test unit_test.cpp \ 10 | ../../../build/naken_asm.a \ 11 | $(CFLAGS) 12 | 13 | clean: 14 | @rm -f unit_test 15 | @echo "Clean!" 16 | 17 | -------------------------------------------------------------------------------- /tests/unit/symbols/Makefile: -------------------------------------------------------------------------------- 1 | include ../../../config.mak 2 | 3 | INCLUDES=-I../../.. 4 | BUILDDIR=../../../build 5 | CFLAGS=-Wall -g -DUNIT_TEST $(INCLUDES) -g 6 | LD_FLAGS=-L../../../build 7 | 8 | default: 9 | $(CXX) -o symbols_test symbols_test.cpp \ 10 | ../../../build/naken_asm.a \ 11 | $(CFLAGS) 12 | 13 | clean: 14 | @rm -f symbols_test 15 | @echo "Clean!" 16 | 17 | -------------------------------------------------------------------------------- /scripts/dist/snap/Dockerfile: -------------------------------------------------------------------------------- 1 | 2 | FROM ubuntu 3 | RUN apt update 4 | RUN apt -y install g++ git make libreadline-dev wget snapcraft snapd autoconf automake autopoint autotools-dev libltdl-dev libltdl7 libsigsegv2 libtool m4 vim 5 | RUN mkdir -p /root/snaps/naken_asm/snap 6 | ADD snapcraft.yaml /root/snaps/naken_asm/snap 7 | ADD build.sh /root 8 | RUN cd /root 9 | RUN bash build.sh 10 | 11 | -------------------------------------------------------------------------------- /tests/unit/eval_expression_ex/Makefile: -------------------------------------------------------------------------------- 1 | include ../../../config.mak 2 | 3 | INCLUDES=-I../../.. 4 | BUILDDIR=../../../build 5 | CFLAGS=-Wall -g -DUNIT_TEST $(INCLUDES) 6 | LD_FLAGS=-L../../../build 7 | 8 | default: 9 | $(CXX) -o unit_test unit_test.cpp \ 10 | ../../../build/naken_asm.a \ 11 | $(CFLAGS) 12 | 13 | clean: 14 | @rm -f unit_test 15 | @echo "Clean!" 16 | 17 | -------------------------------------------------------------------------------- /docs/TMS1000.md: -------------------------------------------------------------------------------- 1 | 2 | TMS1000 3 | ======= 4 | 5 | This assembler should work with the whole TMS1000 series including the 6 | TMS1100. 7 | 8 | This chip was common in many small electronic devices in the early 9 | 1980's including the Speak & Spell series, the Big Trak, and 10 | Simon Says. 11 | 12 | For more info: 13 | 14 | https://en.wikipedia.org/wiki/Texas_Instruments_TMS1000 15 | 16 | -------------------------------------------------------------------------------- /fileio/write_bin.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_WRITE_BIN_H 13 | #define NAKEN_ASM_WRITE_BIN_H 14 | 15 | int write_bin(Memory *memory, FILE *out); 16 | 17 | #endif 18 | 19 | -------------------------------------------------------------------------------- /fileio/write_hex.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_WRITE_HEX_H 13 | #define NAKEN_ASM_WRITE_HEX_H 14 | 15 | int write_hex(Memory *memory, FILE *out); 16 | 17 | #endif 18 | 19 | -------------------------------------------------------------------------------- /fileio/write_uf2.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2024 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_WRITE_UF2_H 13 | #define NAKEN_ASM_WRITE_UF2_H 14 | 15 | int write_uf2(Memory *memory, FILE *out); 16 | 17 | #endif 18 | 19 | -------------------------------------------------------------------------------- /fileio/write_wdc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_WRITE_WDC_H 13 | #define NAKEN_ASM_WRITE_WDC_H 14 | 15 | int write_wdc(Memory *memory, FILE *out); 16 | 17 | #endif 18 | 19 | -------------------------------------------------------------------------------- /tests/regression/arm.hex: -------------------------------------------------------------------------------- 1 | :10000000FFFFFFFF010080E0000000EF000000BFE5 2 | :10001000910002E100000FE100104FE100F029E142 3 | :1000200044F029E302F929E301F829E380F129E307 4 | :10003000015CA0E38051A0E3015C86E3805186E38C 5 | :10004000075086E1175086E1E75286E1920301E00E 6 | :10005000924321E0C60116E8C60106E8C70106E89A 7 | :10006000C70126E8006097E4007088E40C708CE417 8 | :04007000F3FFFF0A91 9 | :00000001FF 10 | -------------------------------------------------------------------------------- /samples/playstation3/spe_test.asm: -------------------------------------------------------------------------------- 1 | .cell 2 | .entry_point main 3 | 4 | main: 5 | ;; Load #5 into 4 slots of the r2 register 6 | il r2, 5 7 | 8 | ;; Wait for data on channel 29 9 | rdch r1, 29 10 | 11 | ;; Add: r1 = r1 + r2 12 | a r1, r1, r2 13 | 14 | ;; Write back to PPE 15 | wrch 28, r1 16 | 17 | ;bra main 18 | 19 | ;; Stop the cell program 20 | sync 21 | stop 0 22 | 23 | -------------------------------------------------------------------------------- /fileio/write_amiga.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_WRITE_AMIGA_H 13 | #define NAKEN_ASM_WRITE_AMIGA_H 14 | 15 | int write_amiga(Memory *memory, FILE *out); 16 | 17 | #endif 18 | 19 | -------------------------------------------------------------------------------- /samples/super_fx/super_fx.asm: -------------------------------------------------------------------------------- 1 | .super_fx 2 | 3 | main: 4 | jmp r9 5 | inc r5 6 | getc 7 | link #1 8 | lms r5, (0x40) 9 | ibt r5, #0xf9 10 | iwt r5, #0xeef9 11 | nop 12 | ;lea r5, 23 13 | ;move r5, r6 14 | ;move r5, #5 15 | ;move r5, (0x40) 16 | ;move (0x40), r5 17 | ;moveb r5, (r6) 18 | ;moveb (r6), r5 19 | ;moves r5, r6 20 | ;movew r6, (r5) 21 | ;movew (r5), r6 22 | 23 | -------------------------------------------------------------------------------- /scripts/graveyard/gen_avr8.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | fp = open("table_avr8.c", "rb") 4 | 5 | for line in fp: 6 | if "{ \"" in line.strip(): 7 | line = line[:-1] 8 | instr = line.split("\"")[1] 9 | instr = "AVR8_" + instr.upper() 10 | #print instr 11 | print line.replace(" },", ", " + instr + " },") 12 | else: 13 | print line[:-1] 14 | pass 15 | 16 | fp.close() 17 | 18 | -------------------------------------------------------------------------------- /fileio/write_srec.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_WRITE_SREC_H 13 | #define NAKEN_ASM_WRITE_SREC_H 14 | 15 | int write_srec(Memory *memory, FILE *out, int srec_size); 16 | 17 | #endif 18 | 19 | -------------------------------------------------------------------------------- /common/ifdef_expression.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_IFDEF_EXPRESSION_H 13 | #define NAKEN_ASM_IFDEF_EXPRESSION_H 14 | 15 | int eval_ifdef_expression(AsmContext *asm_context); 16 | 17 | #endif 18 | 19 | -------------------------------------------------------------------------------- /samples/nes/README.md: -------------------------------------------------------------------------------- 1 | 2 | Just a simple Nintendo NES test that creates a couple tiles and draws 3 | them on the display. 4 | 5 | Currently recommend running with the fceux emulator due to its debugging 6 | features: 7 | 8 | fceux test.nes 9 | 10 | To run with mame: 11 | 12 | mame nes -window -cart test.nes 13 | 14 | To run with mame with the debugger: 15 | 16 | mame nes -window -debug -cart test.nes 17 | 18 | -------------------------------------------------------------------------------- /tests/comparison/template/sweet16.txt: -------------------------------------------------------------------------------- 1 | set r15, 0x1234 2 | set r3, 0x1234 3 | ld r5 4 | st r10 5 | ld @r7 6 | st @r13 7 | ldd @r1 8 | std @r14 9 | add r6 10 | sub r7 11 | popd @r9 12 | cpr r10 13 | inr r3 14 | dcr r4 15 | rtn 16 | main: br main 17 | main: bnc main 18 | main: bc main 19 | main: bp main 20 | main: bm main 21 | main: bz main 22 | main: bnz main 23 | main: bm1 main 24 | main: bnm1 main 25 | bk 26 | rs 27 | main: bs main 28 | -------------------------------------------------------------------------------- /asm/f8.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2024 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_F8_H 13 | #define NAKEN_ASM_ASM_F8_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_f8(AsmContext *asm_context, char *instr); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /fileio/read_hex.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_READ_HEX_H 13 | #define NAKEN_ASM_READ_HEX_H 14 | 15 | #include "common/Memory.h" 16 | 17 | int read_hex(const char *filename, Memory *memory); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /samples/riscv_link/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int add_nums(int a, int b); 5 | 6 | int main(int argc, char *argv[]) 7 | { 8 | if (argc != 3) 9 | { 10 | printf("Usage: ./test \n"); 11 | exit(0); 12 | } 13 | 14 | int a = atoi(argv[1]); 15 | int b = atoi(argv[2]); 16 | 17 | int c = add_nums(a, b); 18 | 19 | printf("%d + %d = %d\n", a, b, c); 20 | 21 | return 0; 22 | } 23 | 24 | -------------------------------------------------------------------------------- /scripts/graveyard/gen_z80.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | fp = open("table_z80.c", "rb") 4 | 5 | for line in fp: 6 | if "{ \"" in line.strip(): 7 | line = line[:-1] 8 | instr = line.split("\"")[1] 9 | instr = "Z80_" + instr.upper() 10 | tokens = line.split(",") 11 | print ",".join(tokens[0:4]) + ", " + instr + "," + ",".join(tokens[4:]) 12 | else: 13 | print line[:-1] 14 | pass 15 | 16 | fp.close() 17 | 18 | -------------------------------------------------------------------------------- /asm/arc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_ARC_H 13 | #define NAKEN_ASM_ASM_ARC_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_arc(AsmContext *asm_context, char *instr); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /asm/arm.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_ARM_H 13 | #define NAKEN_ASM_ASM_ARM_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_arm(AsmContext *asm_context, char *instr); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /asm/lc3.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_LC3_H 13 | #define NAKEN_ASM_ASM_LC3_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_lc3(AsmContext *asm_context, char *instr); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /asm/m8c.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_M8C_H 13 | #define NAKEN_ASM_ASM_M8C_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_m8c(AsmContext *asm_context, char *instr); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /asm/sh4.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_SH4_H 13 | #define NAKEN_ASM_ASM_SH4_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_sh4(AsmContext *asm_context, char *instr); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /asm/template.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM__H 13 | #define NAKEN_ASM_ASM__H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_NAME(AsmContext *asm_context, char *instr); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /asm/z80.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2024 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_Z80_H 13 | #define NAKEN_ASM_ASM_Z80_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_z80(AsmContext *asm_context, char *instr); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /fileio/read_srec.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_READ_SREC_H 13 | #define NAKEN_ASM_READ_SREC_H 14 | 15 | #include "common/Memory.h" 16 | 17 | int read_srec(const char *filename, Memory *memory); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /samples/nintendo64/README.md: -------------------------------------------------------------------------------- 1 | 2 | Some sample Nintendo 64 programs. 3 | 4 | To run with mame: 5 | 6 | mame n64 -window -rompath /path/to/roms -cart1 sample_rsp_triangle.z64 7 | 8 | To run with mame with the debugger: 9 | 10 | mame n64 -window -rompath /path/to/roms -debug -cart1 sample_rsp_triangle.z64 11 | 12 | Path to ROMs would be a path to a directory that has an n64/ directory 13 | that contains required machine ROMs. 14 | 15 | -------------------------------------------------------------------------------- /asm/1802.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_1802_H 13 | #define NAKEN_ASM_ASM_1802_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_1802(AsmContext *asm_context, char *instr); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /asm/4004.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_4004_H 13 | #define NAKEN_ASM_ASM_4004_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_4004(AsmContext *asm_context, char *instr); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /asm/6800.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_6800_H 13 | #define NAKEN_ASM_ASM_6800_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_6800(AsmContext *asm_context, char *instr); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /asm/6809.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_6809_H 13 | #define NAKEN_ASM_ASM_6809_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_6809(AsmContext *asm_context, char *instr); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /asm/8008.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_8008_H 13 | #define NAKEN_ASM_ASM_8008_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_8008(AsmContext *asm_context, char *instr); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /asm/8048.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_8048_H 13 | #define NAKEN_ASM_ASM_8048_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_8048(AsmContext *asm_context, char *instr); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /asm/8051.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_8051_H 13 | #define NAKEN_ASM_ASM_8051_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_8051(AsmContext *asm_context, char *instr); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /asm/avr8.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_AVR8_H 13 | #define NAKEN_ASM_ASM_AVR8_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_avr8(AsmContext *asm_context, char *instr); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /asm/cell.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_CELL_H 13 | #define NAKEN_ASM_ASM_CELL_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_cell(AsmContext *asm_context, char *instr); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /asm/ebpf.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_EBPF_H 13 | #define NAKEN_ASM_ASM_EBPF_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_ebpf(AsmContext *asm_context, char *instr); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /asm/java.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_JAVA_H 13 | #define NAKEN_ASM_ASM_JAVA_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_java(AsmContext *asm_context, char *instr); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /asm/stm8.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_STM8_H 13 | #define NAKEN_ASM_ASM_STM8_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_stm8(AsmContext *asm_context, char *instr); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /asm/unsp.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_UNSP_H 13 | #define NAKEN_ASM_ASM_UNSP_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_unsp(AsmContext *asm_context, char *instr); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /fileio/read_ti_txt.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_READ_TI_TXT_H 13 | #define NAKEN_ASM_READ_TI_TXT_H 14 | 15 | #include "common/Memory.h" 16 | 17 | int read_ti_txt(const char *filename, Memory *memory); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /samples/raspberry_pi/test_arm.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | //int add_numbers_c(int a, int b); 5 | int add_numbers_asm(int a, int b); 6 | int counter(int a, int b); 7 | 8 | int main(int argc, char *argv[]) 9 | { 10 | //printf("Hello from this program\n"); 11 | 12 | //printf("%d\n", add_numbers_c(5,6)); 13 | printf("%d\n", add_numbers_asm(7,8)); 14 | printf("%d\n", counter(9,8)); 15 | 16 | return 0; 17 | } 18 | 19 | -------------------------------------------------------------------------------- /asm/68000.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2024 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_68000_H 13 | #define NAKEN_ASM_ASM_68000_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_68000(AsmContext *asm_context, char *instr); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /asm/86000.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_86000_H 13 | #define NAKEN_ASM_ASM_86000_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_86000(AsmContext *asm_context, char *instr); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /asm/arm64.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2024 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_ARM64_H 13 | #define NAKEN_ASM_ASM_ARM64_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_arm64(AsmContext *asm_context, char *instr); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /asm/dspic.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_DSPIC_H 13 | #define NAKEN_ASM_ASM_DSPIC_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_dspic(AsmContext *asm_context, char *instr); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /asm/pdk13.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_PDK13_H 13 | #define NAKEN_ASM_ASM_PDK13_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_pdk13(AsmContext *asm_context, char *instr); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /asm/pdk14.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_PDK14_H 13 | #define NAKEN_ASM_ASM_PDK14_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_pdk14(AsmContext *asm_context, char *instr); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /asm/pdk15.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_PDK15_H 13 | #define NAKEN_ASM_ASM_PDK15_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_pdk15(AsmContext *asm_context, char *instr); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /asm/pdk16.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_PDK16_H 13 | #define NAKEN_ASM_ASM_PDK16_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_pdk16(AsmContext *asm_context, char *instr); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /asm/pdp11.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2025 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_PDP11_H 13 | #define NAKEN_ASM_ASM_PDP11_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_pdp11(AsmContext *asm_context, char *instr); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /asm/pic14.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_PIC14_H 13 | #define NAKEN_ASM_ASM_PIC14_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_pic14(AsmContext *asm_context, char *instr); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /asm/pic18.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_PIC18_H 13 | #define NAKEN_ASM_ASM_PIC18_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_pic18(AsmContext *asm_context, char *instr); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /asm/riscv.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2024 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_RISCV_H 13 | #define NAKEN_ASM_ASM_RISCV_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_riscv(AsmContext *asm_context, char *instr); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /asm/sparc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_SPARC_H 13 | #define NAKEN_ASM_ASM_SPARC_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_sparc(AsmContext *asm_context, char *instr); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /asm/thumb.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_THUMB_H 13 | #define NAKEN_ASM_ASM_THUMB_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_thumb(AsmContext *asm_context, char *instr); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /asm/68hc08.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_68HC08_H 13 | #define NAKEN_ASM_ASM_68HC08_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_68hc08(AsmContext *asm_context, char *instr); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /asm/copper.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_COPPER_H 13 | #define NAKEN_ASM_ASM_COPPER_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_copper(AsmContext *asm_context, char *instr); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /asm/cp1610.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_CP1610_H 13 | #define NAKEN_ASM_ASM_CP1610_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_cp1610(AsmContext *asm_context, char *instr); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /asm/dotnet.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_DOTNET_H 13 | #define NAKEN_ASM_ASM_DOTNET_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_dotnet(AsmContext *asm_context, char *instr); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /asm/f100_l.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2024 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_F100_L_H 13 | #define NAKEN_ASM_ASM_F100_L_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_f100_l(AsmContext *asm_context, char *instr); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /asm/powerpc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_POWERPC_H 13 | #define NAKEN_ASM_ASM_POWERPC_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_powerpc(AsmContext *asm_context, char *instr); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /asm/sweet16.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_SWEET16_H 13 | #define NAKEN_ASM_ASM_SWEET16_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_sweet16(AsmContext *asm_context, char *instr); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /asm/tms340.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_TMS340_H 13 | #define NAKEN_ASM_ASM_TMS340_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_tms340(AsmContext *asm_context, char *instr); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /asm/tms9900.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_TMS9900_H 13 | #define NAKEN_ASM_ASM_TMS9900_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_tms9900(AsmContext *asm_context, char *instr); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /asm/webasm.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_WEBASM_H 13 | #define NAKEN_ASM_ASM_WEBASM_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_webasm(AsmContext *asm_context, char *instr); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /asm/xtensa.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_XTENSA_H 13 | #define NAKEN_ASM_ASM_XTENSA_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_xtensa(AsmContext *asm_context, char *instr); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /asm/epiphany.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_EPIPHANY_H 13 | #define NAKEN_ASM_ASM_EPIPHANY_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_epiphany(AsmContext *asm_context, char *instr); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /asm/super_fx.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_SUPER_FX_H 13 | #define NAKEN_ASM_ASM_SUPER_FX_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_super_fx(AsmContext *asm_context, char *instr); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /asm/propeller.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_PROPELLER_H 13 | #define NAKEN_ASM_ASM_PROPELLER_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_propeller(AsmContext *asm_context, char *instr); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /asm/ps2_ee_vu.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_PS2_EE_VU_H 13 | #define NAKEN_ASM_ASM_PS2_EE_VU_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_ps2_ee_vu(AsmContext *asm_context, char *instr); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /docs/Playstation_2.md: -------------------------------------------------------------------------------- 1 | 2 | Playstation 2 3 | ============= 4 | 5 | There is support in naken_asm for all processors inside the Playstation 2. 6 | Both vector units and the R5900 core, including the SIMD instructions, 7 | are support. For examples how to write code: 8 | 9 | * https://www.mikekohn.net/software/playstation2.php 10 | * https://www.mikekohn.net/micro/playstation2_java.php 11 | 12 | For more documentation on the R5900 see the [MIPS](MIPS.md) page. 13 | 14 | -------------------------------------------------------------------------------- /fileio/read_uf2.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2024 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_READ_UF2_H 13 | #define NAKEN_ASM_READ_UF2_H 14 | 15 | #include 16 | 17 | #include "common/Memory.h" 18 | 19 | int read_uf2(const char *filename, Memory *memory); 20 | 21 | #endif 22 | 23 | -------------------------------------------------------------------------------- /fileio/read_wdc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_READ_WDC_H 13 | #define NAKEN_ASM_READ_WDC_H 14 | 15 | #include 16 | 17 | #include "common/Memory.h" 18 | 19 | int read_wdc(const char *filename, Memory *memory); 20 | 21 | #endif 22 | 23 | -------------------------------------------------------------------------------- /asm/propeller2.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_PROPELLER2_H 13 | #define NAKEN_ASM_ASM_PROPELLER2_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_propeller2(AsmContext *asm_context, char *instr); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /fileio/read_amiga.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_READ_AMIGA_H 13 | #define NAKEN_ASM_READ_AMIGA_H 14 | 15 | #include 16 | 17 | #include "common/Memory.h" 18 | 19 | int read_amiga(const char *filename, Memory *memory); 20 | 21 | #endif 22 | 23 | -------------------------------------------------------------------------------- /include/amiga/translator.inc: -------------------------------------------------------------------------------- 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2 | ;; 3 | ;; Amiga translator.library include file 4 | ;; Part of the naken_asm assembler 5 | ;; 6 | ;; Generated by: Michael Kohn (mike@mikekohn.net) 7 | ;; Date: 2019-Jan-01 8 | ;; 9 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 10 | 11 | ;; translator.library 12 | 13 | Translate equ -30 ; Translate (input String.input Length, output Buffer, bufferSize) (A0,D0,Al,Dl) 14 | 15 | -------------------------------------------------------------------------------- /include/z80/ti84c.inc: -------------------------------------------------------------------------------- 1 | 2 | ;; RAM 3 | appData equ 0x8000 4 | ramCode equ 0x8100 5 | curBGColor equ 0xa017 6 | curCol equ equ 0x8459 7 | curFGColor equ 0xa015 8 | curRow equ equ 0x845a 9 | fillRectColor equ 0xa5f4 10 | penBGColor equ equ 0xa036 11 | penFGColor equ equ 0xa038 12 | 13 | ;; Functions 14 | CenterPutS equ 0x55a5 15 | ClearRect equ 0x4d44 16 | DispHL equ 0x44fe 17 | FillRect equ 0x4d4a 18 | IPoint equ 0x47ce 19 | PutS equ 0x4501 20 | SetPenBG_White equ 0x563b 21 | 22 | -------------------------------------------------------------------------------- /asm/agc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2024 by Michael Kohn 9 | * 10 | */ 11 | 12 | // Apollo Guidance Computer. 13 | 14 | #ifndef NAKEN_ASM_ASM_AGC_H 15 | #define NAKEN_ASM_ASM_AGC_H 16 | 17 | #include "common/assembler.h" 18 | 19 | int parse_instruction_agc(AsmContext *asm_context, char *instr); 20 | 21 | #endif 22 | 23 | -------------------------------------------------------------------------------- /include/propeller/propeller.inc: -------------------------------------------------------------------------------- 1 | ;; 2 | ;; This is an include file for the Parallax Propeller 3 | ;; 4 | ;; For more info: 5 | ;; https://www.parallax.com/ 6 | ;; 7 | 8 | par equ 0x1f0 9 | cnt equ 0x1f1 10 | ina equ 0x1f2 11 | inb equ 0x1f3 12 | outa equ 0x1f4 13 | outb equ 0x1f5 14 | dira equ 0x1f6 15 | dirb equ 0x1f7 16 | ctra equ 0x1f8 17 | ctrb equ 0x1f9 18 | frqa equ 0x1fa 19 | frqb equ 0x1fb 20 | phsa equ 0x1fc 21 | phsb equ 0x1fd 22 | vcfg equ 0x1fe 23 | vscl equ 0x1ff 24 | 25 | -------------------------------------------------------------------------------- /tests/comparison/lc3.txt: -------------------------------------------------------------------------------- 1 | add r3, r4, r5|:0400000000001705E0 2 | add r3, r4, #7|:0400000000001727BE 3 | add r3, r4, #-10|:0400000000001736AF 4 | and r7, r2, r5|:0400000000005E8519 5 | and r3, r1, #7|:04000000000056673F 6 | jmp r4|:040000000000C1003B 7 | jsrr r4|:0400000000004100BB 8 | ldr r4, r2, #-4|:04000000000068BCD8 9 | not r4, r2|:04000000000098BFA5 10 | ret|:040000000000C1C07B 11 | rti|:04000000000080007C 12 | str r4, r2, #-4|:04000000000078BCC8 13 | trap 50|:040000000000F032DA 14 | -------------------------------------------------------------------------------- /common/directives.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DIRECTIVES_H 13 | #define NAKEN_ASM_DIRECTIVES_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_org(AsmContext *asm_context); 18 | int parse_directives(AsmContext *asm_context); 19 | 20 | #endif 21 | 22 | -------------------------------------------------------------------------------- /include/riscv/csr.inc: -------------------------------------------------------------------------------- 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2 | ;; 3 | ;; RISC-V CSR include. 4 | ;; Part of the naken_asm assembler 5 | ;; 6 | ;; Create by: Michael Kohn (mike@mikekohn.net) 7 | ;; Date: 2024-Dec-28 8 | ;; 9 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 10 | 11 | ; Vector unit config. 12 | vstart equ 0x008 13 | vxsat equ 0x009 14 | vxrm equ 0x00a 15 | vcsr equ 0x00f 16 | vl equ 0xc20 17 | vtype equ 0xc21 18 | vlenb equ 0xc22 19 | 20 | -------------------------------------------------------------------------------- /fileio/read_bin.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_READ_BIN_H 13 | #define NAKEN_ASM_READ_BIN_H 14 | 15 | #include 16 | 17 | #include "common/Memory.h" 18 | 19 | int read_bin(const char *filename, Memory *memory, uint32_t start_address); 20 | 21 | #endif 22 | 23 | -------------------------------------------------------------------------------- /scripts/graveyard/arm_alu.txt: -------------------------------------------------------------------------------- 1 | 0000 AND Rd = Rn AN 2 | 0001 EOR Rd = Rn EOR Op2 3 | 0010 SUB Rd = Rn - Op2 4 | 0011 RSB Rd = Op2 - Rn 5 | 0100 ADD Rd = Rn + Op2 6 | 0101 ADC Rd = Rn + Op2 7 | 0110 SBC Rd = Rn - Op2 8 | 0111 RSC Rd = Op2 - Rn 9 | 1000 TST Rn AND Op2 10 | 1001 TEQ Rn EOR Op2 11 | 1010 CMP Rn - Op2 12 | 1011 CMN Rn + Op2 13 | 1100 ORR Rd = Rn OR Op2 14 | 1101 MOV Rd = Op2 15 | 1110 BIC Rd = Rn AND ¬Op2 16 | 1111 MVN Rd = ¬Op2 17 | -------------------------------------------------------------------------------- /samples/arm64/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int add_nums(int a, int b); 5 | 6 | void nothing() 7 | { 8 | printf("nothing\n"); 9 | } 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | if (argc != 3) 14 | { 15 | printf("Usage: ./test \n"); 16 | exit(0); 17 | } 18 | 19 | int a = atoi(argv[1]); 20 | int b = atoi(argv[2]); 21 | int c = add_nums(a, b); 22 | 23 | printf("%d + %d = %d\n", a, b, c); 24 | 25 | return 0; 26 | } 27 | 28 | -------------------------------------------------------------------------------- /asm/6502.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn, Joe Davisson 9 | * 10 | * 6502 file by Joe Davisson 11 | * 12 | */ 13 | 14 | #ifndef NAKEN_ASM_ASM_6502_H 15 | #define NAKEN_ASM_ASM_6502_H 16 | 17 | #include "common/assembler.h" 18 | 19 | int parse_instruction_6502(AsmContext *asm_context, char *instr); 20 | 21 | #endif 22 | 23 | -------------------------------------------------------------------------------- /asm/pdp8.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn, Lars Brinkhoff 9 | * 10 | * PDP-8 by Lars Brinkhoff 11 | * 12 | */ 13 | 14 | #ifndef NAKEN_ASM_ASM_PDP8_H 15 | #define NAKEN_ASM_ASM_PDP8_H 16 | 17 | #include "common/assembler.h" 18 | 19 | int parse_instruction_pdp8(AsmContext *asm_context, char *instr); 20 | 21 | #endif 22 | 23 | -------------------------------------------------------------------------------- /include/amiga/diskfont.inc: -------------------------------------------------------------------------------- 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2 | ;; 3 | ;; Amiga diskfont.library include file 4 | ;; Part of the naken_asm assembler 5 | ;; 6 | ;; Generated by: Michael Kohn (mike@mikekohn.net) 7 | ;; Date: 2019-Jan-01 8 | ;; 9 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 10 | 11 | ;; diskfont.library 12 | 13 | OpenDiskFont equ -30 ; OpenDiskFont (textAttr)(A0) 14 | AvailFonts equ -36 ; AvailFonts (buffer,bufBytes,flags) (A0,D0,Dl) 15 | 16 | -------------------------------------------------------------------------------- /samples/mips/n64_rsp.asm: -------------------------------------------------------------------------------- 1 | .n64_rsp 2 | 3 | li $v1, 234 4 | add $v1, $v0, $t0 5 | lsv $v1[14], 16($1) 6 | lsv $v1[12], 16($1) 7 | lhv $v1[0], 256($1) 8 | slv $v1[0], 128($1) 9 | mtc2 $t5, $v4[4] 10 | mfc2 $t5, $v31[4] 11 | vnop 12 | vmov $v3[15], $v5[2] 13 | vmrg $v2, $v9, $v7 14 | vmrg $v9, $v8, $v4[1q] 15 | vmrg $v31, $v15, $v4[2h] 16 | vmrg $v7, $v9, $v4[1] 17 | vmrg $v7, $v9, $v0[1] 18 | vmrg $v1, $v5, $v3[1q] 19 | vadd $v0, $v5, $v0 20 | 21 | lsv $v16[8], -28($27) 22 | llv $v23[4], -20($7) 23 | 24 | -------------------------------------------------------------------------------- /include/amiga/timer.inc: -------------------------------------------------------------------------------- 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2 | ;; 3 | ;; Amiga timer.library include file 4 | ;; Part of the naken_asm assembler 5 | ;; 6 | ;; Generated by: Michael Kohn (mike@mikekohn.net) 7 | ;; Date: 2019-Jan-01 8 | ;; 9 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 10 | 11 | ;; timer.library 12 | 13 | AddTime equ -42 ; AddTime (dest,src) (A0,Al) 14 | SubTime equ -48 ; SubTime (dest.src) (A0,Al) 15 | CmpTime equ -54 ; CmpTime (dest,src) (A0,Al) 16 | 17 | -------------------------------------------------------------------------------- /scripts/dist/freebsd/pkg-descr: -------------------------------------------------------------------------------- 1 | Assembler, disassembler, and for select CPU's simulator for: 2 | 3 | 4004, 6502, 65816, 6809, 68HC08, 68000, 8051, ARM, AVR8 4 | Cell BE, dsPIC, MIPS, MSP430, PIC14, PIC24, PIC32, 5 | Playstation 2 EE, PowerPC, Propeller, RISC-V, STM8, SuperFX, THUMB, 6 | TMS1000, TMS1100, TMS9900, Z80. 7 | 8 | The purpose of naken_asm is to be as stripped down and simple as 9 | possible so it's easy to compile and easy to use. 10 | 11 | WWW: http://www.mikekohn.net/micro/naken_asm.php 12 | 13 | 14 | -------------------------------------------------------------------------------- /tests/directives/test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import os,sys 4 | 5 | p = os.popen("../../naken_asm endian.asm") 6 | while 1: 7 | line = p.readline() 8 | if line == "": break 9 | p.close() 10 | 11 | fp = open("out.hex", "r") 12 | line = fp.readline().strip() 13 | fp.close() 14 | 15 | os.remove("out.hex") 16 | 17 | print("Endian test: ", end = '') 18 | 19 | if line[9:21] == "123478561234": 20 | print("\x1b[32mPASS\x1b[0m") 21 | else: 22 | print("\x1b[31mFAIL\x1b[0m") 23 | sys.exit(-1) 24 | 25 | -------------------------------------------------------------------------------- /include/amiga/potgo.inc: -------------------------------------------------------------------------------- 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2 | ;; 3 | ;; Amiga potgo.library include file 4 | ;; Part of the naken_asm assembler 5 | ;; 6 | ;; Generated by: Michael Kohn (mike@mikekohn.net) 7 | ;; Date: 2019-Jan-01 8 | ;; 9 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 10 | 11 | ;; potgo.library 12 | 13 | AllocPotBits equ -6 ; AllocPotBits (bits)(DO) 14 | FreePotBits equ -12 ; FreePotBits (bits)(DO) 15 | WritePotgo equ -18 ; WritePotgo (word,mask) (DO,D1) 16 | 17 | -------------------------------------------------------------------------------- /samples/arm64/testing.asm: -------------------------------------------------------------------------------- 1 | .arm64 2 | 3 | abs v9.16b, v18.16b 4 | add w10, w17, w9, lsl #3 5 | add w31, w17, w9 6 | add w10, w17, w9, uxth 7 | add x10, x17, x9, sxtb 8 | add x10, x11, #0x123 9 | add x10, x11, #0x123000 10 | add w10, w11, #0x123, lsl #12 11 | add x11, x28, x1, lsl #3 12 | add x11, x28, x1, asr #10 13 | add v9.16b, v18.16b, v11.16b 14 | add v28.4h, v18.4h, v5.4h 15 | add d17, d1, d29 16 | addg x5, x9, #32, #5 17 | ;addp v3.d, v7.2d fixme 18 | ;addv fixme 19 | aese v7.16b, v13.16b 20 | at s1e0w, x13 21 | 22 | -------------------------------------------------------------------------------- /include/amiga/console.inc: -------------------------------------------------------------------------------- 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2 | ;; 3 | ;; Amiga console.library include file 4 | ;; Part of the naken_asm assembler 5 | ;; 6 | ;; Generated by: Michael Kohn (mike@mikekohn.net) 7 | ;; Date: 2019-Jan-01 8 | ;; 9 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 10 | 11 | ;; console.library 12 | 13 | CDInputHandler equ -42 ; CDInputHandler (event s,device) (A0,Al) 14 | RawKeyConvert equ -48 ; RawKeyConvert (events,buf fer,length, keyMap) (AO,A1,D1,A2) 15 | 16 | -------------------------------------------------------------------------------- /samples/nintendo64/picture.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/evn python3 2 | 3 | # rrrr_rggg_ggbb_bbba 4 | colors = { 5 | ' ': 0x0001, 6 | 'R': 0xf801, 7 | 'G': 0x07c1, 8 | 'B': 0x0031, 9 | 'Y': 0xffc1, 10 | 'P': 0xf83f, 11 | } 12 | 13 | fp = open("picture.txt", "r") 14 | out = open("picture.raw", "wb") 15 | 16 | for line in fp: 17 | line = line.strip() 18 | for i in range(0, len(line), 2): 19 | data = (colors[line[i]] << 16) | colors[line[i + 1]] 20 | out.write(data.to_bytes(4, 'big')) 21 | 22 | fp.close() 23 | 24 | -------------------------------------------------------------------------------- /include/playstation2/system_calls.inc: -------------------------------------------------------------------------------- 1 | ;; 2 | ;; Playstation 2 System Calls 3 | ;; 4 | ;; A part of the naken_asm assembler 5 | ;; 6 | ;; For more information: 7 | ;; https://www.mikekohn.net/ 8 | ;; 9 | 10 | ;; System calls 11 | _RFU000_FullReset equ 0 12 | _ResetEE equ 1 13 | _SetGsCrt equ 2 14 | _AddIntcHandler equ 16 15 | _RemoveIntcHandler equ 17 16 | __EnableIntc equ 20 17 | __DisableIntc equ 21 18 | _EnableCache equ 97 19 | _DisableCache equ 98 20 | _FlushCache equ 100 21 | _GsGetIMR equ 112 22 | _GsPutIMR equ 113 23 | 24 | -------------------------------------------------------------------------------- /asm/tms1000.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_TMS1000_H 13 | #define NAKEN_ASM_ASM_TMS1000_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_tms1000(AsmContext *asm_context, char *instr); 18 | int parse_instruction_tms1100(AsmContext *asm_context, char *instr); 19 | 20 | #endif 21 | 22 | -------------------------------------------------------------------------------- /common/imports_get_int.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_GET_INT_H 13 | #define NAKEN_ASM_GET_INT_H 14 | 15 | int get_int32_be(const uint8_t *buffer); 16 | int get_int16_be(const uint8_t *buffer); 17 | int get_int32_le(const uint8_t *buffer); 18 | int get_int16_le(const uint8_t *buffer); 19 | 20 | #endif 21 | 22 | -------------------------------------------------------------------------------- /fileio/read_elf.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2024 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_READ_ELF_H 13 | #define NAKEN_ASM_READ_ELF_H 14 | 15 | #include "common/Memory.h" 16 | #include "common/Symbols.h" 17 | 18 | int read_elf( 19 | const char *filename, 20 | Memory *memory, 21 | uint8_t *cpu_type, 22 | Symbols *symbols); 23 | 24 | #endif 25 | 26 | -------------------------------------------------------------------------------- /common/directives_include.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DIRECTIVES_INCLUDE_H 13 | #define NAKEN_ASM_DIRECTIVES_INCLUDE_H 14 | 15 | int binfile_parse(AsmContext *asm_context); 16 | int include_parse(AsmContext *asm_context); 17 | int include_add_path(AsmContext *asm_context, const char *paths); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /fileio/read_macho.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2024 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_READ_MACHO_H 13 | #define NAKEN_ASM_READ_MACHO_H 14 | 15 | #include "common/Memory.h" 16 | #include "common/Symbols.h" 17 | 18 | int read_macho( 19 | const char *filename, 20 | Memory *memory, 21 | uint8_t *cpu_type, 22 | Symbols *symbols); 23 | 24 | #endif 25 | 26 | -------------------------------------------------------------------------------- /docs/credits.md: -------------------------------------------------------------------------------- 1 | Credits 2 | ======= 3 | 4 | * Michael Kohn (http://www.mikekohn.net/) 5 | * Core assembler + assemblers, disassemblers, and simulators not mentioned below. 6 | * Joe Davisson (https://github.com/Mortis69) 7 | * 6502 assembler, disassembler, simulator. 8 | * 65C816 assembler, disassembler. 9 | * Lars Brinkhoff (https://github.com/larsbrinkhoff) 10 | * PDP-8 assembler, disassembler. 11 | * Zoltan Csahok (https://github.com/zcsahok) 12 | * D.L. Karmann 13 | * STM8 simulator 14 | * Malik Enes Safak 15 | * 1802 simulator 16 | 17 | -------------------------------------------------------------------------------- /common/util_disasm.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef UTIL_DISASM_H 13 | #define UTIL_DISASM_H 14 | 15 | #include "common/UtilContext.h" 16 | #include "common/util_disasm.h" 17 | 18 | void util_disasm(UtilContext *util_context, const char *token); 19 | void util_disasm_range(UtilContext *util_context, int start, int end); 20 | 21 | #endif 22 | 23 | -------------------------------------------------------------------------------- /samples/library/test_lib.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "naken_asm.h" 5 | 6 | int main(int argc, char *argv[]) 7 | { 8 | void *context; 9 | 10 | context = naken_util_create(); 11 | //naken_util_set_cpu_type(context, "msp430"); 12 | 13 | if (naken_util_open(context, "sample.elf") == -1) 14 | { 15 | printf("Couldn't open file.\n"); 16 | naken_util_destroy(context); 17 | return -1; 18 | } 19 | 20 | naken_util_disasm(context, "0-20"); 21 | naken_util_destroy(context); 22 | 23 | return 0; 24 | } 25 | 26 | -------------------------------------------------------------------------------- /docs/file_formats.md: -------------------------------------------------------------------------------- 1 | File Formats 2 | ============ 3 | 4 | naken_asm supports the following file formats: 5 | 6 | Writing 7 | ------- 8 | 9 | * Intel Hex 10 | * SREC 11 | * binary 12 | * WDC Binary 13 | * Amiga 14 | 15 | Reading 16 | ------- 17 | 18 | * Intel Hex 19 | * SREC 20 | * binary 21 | * TI txt 22 | * WDC Binary 23 | * Amiga 24 | 25 | The default output format is hex. To change the output format the 26 | -type option can be used: 27 | 28 | ./naken_asm -type bin -o sample.bin sample.asm 29 | ./naken_asm -type elf -o sample.elf sample.asm 30 | 31 | -------------------------------------------------------------------------------- /tests/comparison/template/4004.txt: -------------------------------------------------------------------------------- 1 | jnt 0xb2 2 | jc 0x7f 3 | jz 0xb9 4 | jt 0x1e 5 | jnc 0x96 6 | jnz 0x81 7 | nop 8 | jcn 11, 0xc2 9 | fim 8, 0x7e 10 | src 2 11 | fin 2 12 | jin 4 13 | jun 0xa35 14 | jms 0x829 15 | inc 14 16 | isz 10, 0x99 17 | add 15 18 | sub 14 19 | ld 10 20 | xch 11 21 | bbl 14 22 | ldm 9 23 | wrm 24 | wmp 25 | wrr 26 | wr0 27 | wr1 28 | wr2 29 | wr3 30 | sbm 31 | rdm 32 | rdr 33 | adm 34 | rd0 35 | rd1 36 | rd2 37 | rd3 38 | clb 39 | clc 40 | iac 41 | cmc 42 | cma 43 | ral 44 | rar 45 | tcc 46 | dac 47 | tcs 48 | stc 49 | daa 50 | kbp 51 | dcl 52 | -------------------------------------------------------------------------------- /samples/8051/blink_leds.asm: -------------------------------------------------------------------------------- 1 | .8051 2 | 3 | .include "8051.inc" 4 | 5 | .org 0 6 | start: 7 | mov P0, #0 8 | mov P1, #0xf0 9 | 10 | repeat: 11 | setb P0.0 12 | clr P0.1 13 | 14 | mov r1, 0 15 | loop_outer1: 16 | mov r0, 0 17 | loop_inner1: 18 | dec r0 19 | cjne r0, #0, loop_inner1 20 | dec r1 21 | cjne r1, #0, loop_outer1 22 | 23 | setb P0.1 24 | clr P0.0 25 | 26 | mov r1, 0 27 | loop_outer2: 28 | mov r0, 0 29 | loop_inner2: 30 | dec r0 31 | cjne r0, #0, loop_inner2 32 | dec r1 33 | cjne r1, #0, loop_outer2 34 | 35 | sjmp repeat 36 | 37 | -------------------------------------------------------------------------------- /samples/dspic/led_blink33.asm: -------------------------------------------------------------------------------- 1 | 2 | .dspic 3 | .include "p33fj06gs101a.inc" 4 | 5 | .org 0 6 | goto main 7 | 8 | .org 0x100 9 | main: 10 | clr w0 11 | mov wreg, TRISA 12 | repeat: 13 | mov #2, w0 14 | mov wreg, PORTA 15 | 16 | call delay 17 | 18 | mov #1, w0 19 | mov wreg, PORTA 20 | 21 | call delay 22 | 23 | bra repeat 24 | 25 | delay: 26 | mov #5, w5 27 | repeat_loop_outer: 28 | mov #0xffff, w4 29 | repeat_loop_inner: 30 | dec w4, w4 31 | bra nz, repeat_loop_inner 32 | dec w5, w5 33 | bra nz, repeat_loop_outer 34 | return 35 | 36 | 37 | -------------------------------------------------------------------------------- /common/directives_if.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DIRECTIVES_IF_H 13 | #define NAKEN_ASM_DIRECTIVES_IF_H 14 | 15 | int ifdef_ignore(AsmContext *asm_context); 16 | int parse_ifdef_ignore(AsmContext *asm_context, int ignore_section); 17 | int parse_ifdef(AsmContext *asm_context, int ifndef); 18 | int parse_if(AsmContext *asm_context); 19 | 20 | #endif 21 | 22 | -------------------------------------------------------------------------------- /scripts/graveyard/lpc.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | parts = {} 4 | 5 | fp = open("lpc.txt","rb") 6 | 7 | for line in fp: 8 | tokens = line.split() 9 | name = tokens[0] 10 | numbers = "".join(tokens[1:]) 11 | for number in numbers.split(";"): 12 | number = number.lower() 13 | if number in parts: 14 | parts[number] += "," + name 15 | else: 16 | parts[number] = name 17 | 18 | #print " { " + number.lower() + ", \"" + name + "\" }," 19 | 20 | for part in parts: 21 | print " { " + part + ", \"" + parts[part] + "\" }," 22 | fp.close() 23 | 24 | -------------------------------------------------------------------------------- /asm/65816.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn, Joe Davisson 9 | * 10 | * 65816 by Joe Davisson 11 | * 12 | */ 13 | 14 | #ifndef NAKEN_ASM_ASM_65816_H 15 | #define NAKEN_ASM_ASM_65816_H 16 | 17 | #include "common/assembler.h" 18 | 19 | int parse_directive_65816(AsmContext *asm_context, const char *directive); 20 | 21 | int parse_instruction_65816(AsmContext *asm_context, char *instr); 22 | 23 | #endif 24 | 25 | -------------------------------------------------------------------------------- /samples/f8/testing.asm: -------------------------------------------------------------------------------- 1 | .f8 2 | 3 | main: 4 | ins 8 5 | in 16 6 | bno label_1 7 | bt 2, label_1 8 | lm 9 | lr a, 4 10 | lr 4, a 11 | lr isar, a 12 | lr a, ku 13 | lr ql, a 14 | nop 15 | pop 16 | dci label_2 17 | li 120 18 | lis 7 19 | amd 20 | oi 0x23 21 | lr w, j 22 | lr j, w 23 | jmp label_2 24 | asd [3] 25 | asd [isar] 26 | lr dc0, q 27 | lr pc0, q 28 | lr pc1, k 29 | lr h, dc0 30 | 31 | label_1: 32 | lr a, s 33 | lr a, s+ 34 | lr a, s- 35 | lr [isar], a 36 | lr [isar]+, a 37 | lr [isar]-, a 38 | 39 | label_2: 40 | 41 | -------------------------------------------------------------------------------- /tests/symbol_address/65c816_test.h: -------------------------------------------------------------------------------- 1 | const char *w65c816_1 = 2 | ".65816\n" 3 | ".org 0x1000\n" 4 | "first:\n" 5 | " lda #10\n" 6 | "second:\n" 7 | " lda.b #10\n" 8 | "third:\n" 9 | " ldx fifth\n" 10 | "fourth:\n" 11 | ".org 0xf0\n" 12 | "fifth:\n" 13 | " db 0x10, 0x20\n"; 14 | 15 | const char *w65c816_2 = 16 | ".65816\n" 17 | ".org 0xff00\n" 18 | "first:\n" 19 | " lda fifth, x\n" 20 | "second:\n" 21 | " lda first, x\n" 22 | "third:\n" 23 | " bne first\n" 24 | "fourth:\n" 25 | ".org 0xfffc\n" 26 | "fifth:\n" 27 | " db 0x10, 0x20\n"; 28 | 29 | -------------------------------------------------------------------------------- /samples/tms9900/testing.asm: -------------------------------------------------------------------------------- 1 | .tms9900 2 | 3 | main: 4 | mov r0, r1 5 | a r0, @data 6 | a *r5, @data(r3) 7 | a @data(r3), *r1+ 8 | a @data(r3), @data(r4) 9 | a @data, @data 10 | 11 | czc @data, r6 12 | 13 | loop: 14 | clr r8 15 | b *r8 16 | blwp *r8+ 17 | inc @data+2 18 | inc @data(r5) 19 | 20 | ldcr *r5, 6 21 | stcr @data, 7 22 | 23 | jle loop 24 | jh skip 25 | 26 | sbo -5 27 | sbz 5 28 | skip: 29 | sla r5, 6 30 | 31 | li r6, 65535 32 | ai r7, -1 33 | 34 | lwpi 1000 35 | stst r6 36 | 37 | idle 38 | rtwp 39 | 40 | data: 41 | dw 100, 200, 300 42 | 43 | -------------------------------------------------------------------------------- /tests/regression/msp430.hex: -------------------------------------------------------------------------------- 1 | :10000000F24005006400D2405C006400925056004B 2 | :10001000000192820080000111420080091012113B 3 | :100020000001EE3F091209124912891189100013CB 4 | :1000300092120000E523E423E327E227E12FE02FDB 5 | :10004000DF33DE37DD3BA043BCFFB0400500B6FF29 6 | :1000500092601200000192800C0000019290060054 7 | :100060000001D2A000000001F2B005000001F2B3CF 8 | :100070000001F2D30001F2E30001F2F30001496351 9 | :10008000004312C322C222C382A300019283000153 10 | :10009000A283000132C232D292530001B2E30001C6 11 | :1000A00003433041925200010001926200010001BD 12 | :0C00B0008273000112D322D222D30693E7 13 | :00000001FF 14 | -------------------------------------------------------------------------------- /docs/SunPlus_unSP.md: -------------------------------------------------------------------------------- 1 | 2 | SunPlus unSP 3 | ============ 4 | 5 | This assembler has support for the SunPlus $\mu$SP (SPG2xx) compatible chips 6 | used in consoles such as the VTech V.Smile: 7 | 8 | https://en.wikipedia.org/wiki/V.Smile 9 | 10 | The syntax used here is differs from the official xasm16.exe assembler. 11 | Most of the instructions use the format of: 12 | 13 | instruction dest, src 14 | 15 | with an exception of the "st" instruction with uses: 16 | 17 | instruction src, dest 18 | 19 | A list of instructions that can be used can be found in: 20 | 21 | tests/comparison/unsp.txt 22 | 23 | -------------------------------------------------------------------------------- /scripts/graveyard/multi.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | a=' 4 | 00100bbb00010100FBBBCCCCCCAAAAAA 5 | 00100bbb01010100FBBBuuuuuuAAAAAA 6 | 00100bbb10010100FBBBssssssSSSSSS 7 | 00100bbb11010100FBBBCCCCCC0QQQQQ 8 | 00100bbb11010100FBBBuuuuuu1QQQQQ 9 | 0010011000010100F111CCCCCCAAAAAA 10 | 00100bbb00010100FBBB111110AAAAAA 11 | 00100bbb11010100FBBB1111100QQQQQ 12 | 01111bbbccc10100 13 | 00100bbb00010100FBBBCCCCCC111110 14 | 00100bbb01010100FBBBuuuuuu111110 15 | 00100bbb00010100FBBB111110111110 16 | 0010011011010100F111CCCCCC0QQQQQ' 17 | 18 | for b in ${a} 19 | do 20 | python arc_mask.py ${b} 21 | done 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /tests/comparison/build_dspic.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | PATH=/usbdisk/devkits/microchip/xc16/v1.11/bin:$PATH 4 | 5 | test_instr() 6 | { 7 | echo "building ${1} ..." 8 | 9 | cat >dspic.asm << EOF 10 | 11 | ${1} 12 | EOF 13 | 14 | xc16-as dspic.asm 15 | xc16-bin2hex a.out 16 | #xc16-objcopy -F ihex a.out dspic_gnu.hex 17 | #xc16-objdump -d a.out 18 | b=`egrep '^:04' a.hex | tr '[:lower:]' '[:upper:]' | tr -d '\r' | tr -d '\n'` 19 | 20 | echo "${1}|${b}" >> dspic.txt 21 | 22 | #rm -f a.hex a.out dspic.asm 23 | } 24 | 25 | echo -n > dspic.txt 26 | 27 | test_instr "push 0x1234" 28 | 29 | 30 | -------------------------------------------------------------------------------- /include/nintendo64/audio_interface.inc: -------------------------------------------------------------------------------- 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2 | ;; 3 | ;; Nintendo 64 system include file 4 | ;; Part of the naken_asm assembler 5 | ;; 6 | ;; Generated by: Michael Kohn (mike@mikekohn.net) 7 | ;; From: en64.shoutwiki.com 8 | ;; Date: 2022-Oct-31 9 | ;; 10 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 11 | 12 | AI_BASE_REG equ 0x0450_0000 13 | 14 | AI_DRAM_ADDR_REG equ 0x0000 15 | AI_LEN_REG equ 0x0004 16 | AI_CONTROL_REG equ 0x0008 17 | AI_STATUS_REG equ 0x000c 18 | AI_DACRATE_REG equ 0x0010 19 | AI_BITRATE_REG equ 0x0014 20 | 21 | -------------------------------------------------------------------------------- /tests/symbol_address/mips_test.h: -------------------------------------------------------------------------------- 1 | const char *mips_1 = 2 | ".mips32\n" 3 | ".org 0x1000\n" 4 | "first:\n" 5 | " li $v0, fifth\n" 6 | "second:\n" 7 | " li $v1, 0xf1220000\n" 8 | "third:\n" 9 | " li $a0, first\n" 10 | "fourth:\n" 11 | ".org 0xf1220000\n" 12 | "fifth:\n" 13 | " db 0x10, 0x20\n"; 14 | 15 | const char *mips_2 = 16 | ".mips32\n" 17 | ".org 0x1000\n" 18 | "first:\n" 19 | " li $v0, fifth\n" 20 | "second:\n" 21 | " li $v1, 0xff\n" 22 | "third:\n" 23 | " li $a0, first\n" 24 | "fourth:\n" 25 | ".org 0xf1220000\n" 26 | "fifth:\n" 27 | " db 0x10, 0x20\n"; 28 | 29 | -------------------------------------------------------------------------------- /scripts/graveyard/make_propeller2_cz.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | unique = { } 4 | 5 | fp = open("scripts/graveyard/propeller2_cz.txt", "r") 6 | 7 | for line in fp: 8 | tokens = line.strip().split("=") 9 | tokens[0] = tokens[0].lower().strip() 10 | tokens[1] = tokens[1].strip()[1:] 11 | 12 | code = int(tokens[1], 2) 13 | tokens.append(code) 14 | 15 | print(" { \"" + "%-12s" % (tokens[0] + "\",") + " " + "0x%x" % (tokens[2]) + " },") 16 | 17 | if not tokens[2] in unique: unique[tokens[2]] = tokens[0] 18 | 19 | fp.close() 20 | 21 | for n in range(0, 16): 22 | print(" \"" + unique[n] + "\",") 23 | 24 | -------------------------------------------------------------------------------- /fileio/write_macho.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2024 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_WRITE_MACHO_H 13 | #define NAKEN_ASM_WRITE_MACHO_H 14 | 15 | #include 16 | #include 17 | 18 | #include "common/Memory.h" 19 | #include "common/Symbols.h" 20 | 21 | int write_macho( 22 | Memory *memory, 23 | FILE *out, 24 | Symbols *symbols, 25 | const char *filename, 26 | int cpu_type, 27 | int alignment); 28 | 29 | #endif 30 | 31 | -------------------------------------------------------------------------------- /samples/pdp11/pdp11.asm: -------------------------------------------------------------------------------- 1 | .pdp11 2 | 3 | ;; Testing that instructions can be assembled. 4 | 5 | ; rts 6 | ; 0 000 000 010 000 xxx 7 | ; 0000 0000 1000 0xxx 8 | 9 | ; swab 10 | ; 0 000 000 011 xxx xxx 11 | ; 0000 0000 11xx xxxx 12 | 13 | main: 14 | mov r1, r2 15 | mov #5, r2 16 | mov @#5, r2 17 | ble label_1 18 | 19 | jsr r4, label_1 20 | 21 | mark 20 22 | 23 | mov (r1), r2 24 | mul #5, r2 25 | xor r1, 100 26 | rts r5 27 | bgt main 28 | 29 | label_1: 30 | nop 31 | sob r1, label_1 32 | 33 | trap 80 34 | 35 | sez 36 | cln 37 | 38 | cmp r2, #4 39 | cmpb r2, #4 40 | 41 | c 4 42 | s 6 43 | 44 | -------------------------------------------------------------------------------- /samples/dspic/led_blink.asm: -------------------------------------------------------------------------------- 1 | 2 | .dspic 3 | .include "p30f3012.inc" 4 | 5 | .org 0 6 | goto main 7 | 8 | .org 0x100 9 | main: 10 | clr w0 11 | mov.b wreg, TRISB 12 | repeat: 13 | mov #2, w0 14 | mov.b wreg, PORTB 15 | 16 | call delay 17 | 18 | mov #1, w0 19 | mov.b wreg, PORTB 20 | 21 | call delay 22 | 23 | bra repeat 24 | 25 | delay: 26 | ;; wow mike, wtf? Probably w4 needs to be 0xffff to create the same 27 | ;; delay. I don't have a dsPIC3012 hooked up to test this right now. 28 | ;mov w4, 1000 29 | mov #0xffff, w4 30 | repeat_loop: 31 | dec w4, w4 32 | bra nz, repeat_loop 33 | return 34 | 35 | 36 | -------------------------------------------------------------------------------- /tests/regression/regression.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | test_arch() 4 | { 5 | b=`../../naken_asm -o out.hex ../../samples/$1/testing.asm` 6 | 7 | if [ $? -ne 0 ] 8 | then 9 | echo "Failed $1 ... (assembler error)" 10 | exit -1 11 | fi 12 | 13 | a=`diff out.hex $1.hex` 14 | 15 | if [ "${a}" != "" ] 16 | then 17 | echo "Failed $1 ..." 18 | else 19 | echo "Passed $1 ..." 20 | fi 21 | 22 | rm -f out.hex out.lst 23 | } 24 | 25 | test_arch "8051" 26 | #test_arch "arm" 27 | test_arch "avr8" 28 | test_arch "dspic" 29 | test_arch "msp430" 30 | test_arch "stm8" 31 | test_arch "tms9900" 32 | test_arch "z80" 33 | 34 | -------------------------------------------------------------------------------- /scripts/dist/freebsd/Makefile: -------------------------------------------------------------------------------- 1 | # $FreeBSD$ 2 | 3 | PORTNAME= naken_asm 4 | PORTVERSION= 2017.04.07 5 | DISTNAME= naken_asm-2017-04-07 6 | CATEGORIES= devel 7 | MASTER_SITES= http://www.mikekohn.net/downloads/naken_asm/ 8 | PKGNAMEPREFIX= naken_asm- 9 | 10 | MAINTAINER= mike@mikekohn.net 11 | COMMENT= Assembler/disassembler multiple CPUs. 12 | 13 | #RUN_DEPENDS= libreadline.so:devel/readline 14 | USES= gmake readline 15 | GNU_CONFIGURE= yes 16 | 17 | do-install: 18 | @mkdir -p ${STAGEDIR}${PREFIX} 19 | @cp ${WRKSRC}/naken_asm ${STAGEDIR}${PREFIX}/bin/ 20 | @cp ${WRKSRC}/naken_util ${STAGEDIR}${PREFIX}/bin/ 21 | 22 | .include 23 | 24 | -------------------------------------------------------------------------------- /fileio/write_bin.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #include "common/Memory.h" 18 | #include "fileio/write_bin.h" 19 | 20 | int write_bin(Memory *memory, FILE *out) 21 | { 22 | uint32_t n; 23 | 24 | for (n = memory->low_address; n <= memory->high_address; n++) 25 | { 26 | putc(memory->read8(n), out); 27 | } 28 | 29 | return 0; 30 | } 31 | 32 | -------------------------------------------------------------------------------- /samples/epiphany/Makefile: -------------------------------------------------------------------------------- 1 | INCLUDES=-I${EPIPHANY_HOME}/tools/host/include 2 | LIBS=-L${EPIPHANY_HOME}/tools/host/lib 3 | CFLAGS=-Wall -O3 ${INCLUDES} -g 4 | LDFLAGS=${LIBS} -le-hal -le-loader 5 | 6 | mandel: 7 | ../../naken_asm -I ../../include/epiphany -l -type srec \ 8 | -o mandelbrot.srec mandelbrot.asm 9 | gcc -o test_mandelbrot test_mandelbrot.c \ 10 | ${CFLAGS} \ 11 | ${LDFLAGS} 12 | ../../naken_asm -l -type srec -o epiphany.srec epiphany.asm 13 | gcc -o test_parallella test_parallella.c \ 14 | ${CFLAGS} \ 15 | ${LDFLAGS} 16 | 17 | clean: 18 | @rm -f *.lst *.hex test_parallella *.elf *.srec test_mandelbrot 19 | @echo "Clean!" 20 | 21 | -------------------------------------------------------------------------------- /samples/propeller/flip_blink_code.asm: -------------------------------------------------------------------------------- 1 | .propeller 2 | 3 | .include "propeller.inc" 4 | 5 | main: 6 | mov dira, led_dir 7 | while_1: 8 | mov outa, led_state0 9 | mov counter, counter_top 10 | wait_1: 11 | sub counter, #1, wz 12 | if_nz jmp #wait_1 13 | ;tjnz counter, #wait_1 14 | 15 | mov outa, led_state1 16 | mov counter, counter_top 17 | wait_2: 18 | sub counter, #1, wz 19 | if_nz jmp #wait_2 20 | ;tjnz counter, #wait_2 21 | jmp #while_1 22 | 23 | led_dir: 24 | dc32 (1 << 26) | (1 << 27) 25 | led_state0: 26 | dc32 (1 << 27) 27 | led_state1: 28 | dc32 (1 << 26) 29 | counter: 30 | dc32 0 31 | counter_top: 32 | dc32 0xfffff 33 | 34 | -------------------------------------------------------------------------------- /samples/unsp/unsp.asm: -------------------------------------------------------------------------------- 1 | .unsp 2 | 3 | main: 4 | goto blah 5 | break 6 | int irq,fiq 7 | mul.ss r3, r4 8 | add r3, #23 9 | add r3, #1000 10 | add r3, r4 11 | add r2, [r3] 12 | add r2, [r3++] 13 | add r2, [r3--] 14 | add r2, [++r3] 15 | adc r2, d:[r3] 16 | and r2, d:[r3++] 17 | add r2, d:[r3--] 18 | add r2, d:[++r3] 19 | add r3, [0x1234] 20 | add r3, r2, [0x1234] 21 | add [0x1234], r3, r2 22 | add r2, r1 asr 4 23 | add r2, r1 lsl 2 24 | add r2, r1 lsr 1 25 | add r2, r1 rol 3 26 | add r2, r1 ror 4 27 | push r3, [sp] 28 | push r3-r5, [sp] 29 | push r5-r3, [sp] 30 | pop r3, [sp] 31 | pop r3-r5, [sp] 32 | blah: 33 | 34 | -------------------------------------------------------------------------------- /asm/mips.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_MIPS_H 13 | #define NAKEN_ASM_ASM_MIPS_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_mips(AsmContext *asm_context, char *instr); 18 | 19 | int link_function_mips( 20 | AsmContext *asm_context, 21 | Imports *imports, 22 | const uint8_t *code, 23 | uint32_t function_offset, 24 | int size, 25 | uint8_t *obj_file, 26 | uint32_t obj_size); 27 | 28 | #endif 29 | 30 | -------------------------------------------------------------------------------- /fileio/uf2.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2024 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_UF2_H 13 | #define NAKEN_ASM_UF2_H 14 | 15 | #include 16 | 17 | struct Uf2Block 18 | { 19 | uint32_t magic_0; 20 | uint32_t magic_1; 21 | uint32_t flags; 22 | uint32_t address; 23 | uint32_t byte_count; 24 | uint32_t sequence_block_number; 25 | uint32_t total_blocks; 26 | uint32_t board_family; 27 | uint8_t data[476]; 28 | uint32_t magic_2; 29 | }; 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /samples/playstation2/create_sin_table.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import math 4 | 5 | table_cos = [] 6 | table_sin = [] 7 | 8 | for i in range(0,512): 9 | table_cos.append(math.cos((i / float(512)) * 6.28)) 10 | table_sin.append(math.sin((i / float(512)) * 6.28)) 11 | 12 | print "_sin_table:" 13 | 14 | for i in range(0,512,4): 15 | s = " dc32" 16 | for j in range(i, i + 4): 17 | s += "%9s" % (" %.4f," % (table_sin[j])) 18 | print s 19 | 20 | print 21 | print "_cos_table:" 22 | 23 | for i in range(0,512,4): 24 | s = " dc32" 25 | for j in range(i, i + 4): 26 | s += "%9s" % (" %.4f," % (table_cos[j])) 27 | print s 28 | 29 | print 30 | 31 | -------------------------------------------------------------------------------- /samples/mips/chipkit.asm: -------------------------------------------------------------------------------- 1 | .mips32 2 | 3 | ; LED4 is RG6 (pin 4) 4 | ; LED5 is RF0 (pin 58) 5 | 6 | TRISF equ 0xbf886140 7 | PORTF equ 0xbf886150 8 | LATF equ 0xbf886160 9 | ODCF equ 0xbf886170 10 | TRISG equ 0xbf886180 11 | PORTG equ 0xbf886190 12 | LATG equ 0xbf8861a0 13 | ODCG equ 0xbf8861b0 14 | 15 | ;.org 0x1d000000 16 | .org 0x1d001000 17 | 18 | start: 19 | ;; Set as output 20 | li $t1, TRISG 21 | sw $0, ($t1) 22 | li $t1, TRISF 23 | sw $0, ($t1) 24 | 25 | ;; Set value to 1 26 | li $t0, 0x40 27 | li $t1, LATG 28 | sw $t0, ($t1) 29 | 30 | li $t0, 0x01 31 | li $t1, LATF 32 | sw $t0, ($t1) 33 | 34 | while_1: 35 | b while_1 36 | nop 37 | 38 | -------------------------------------------------------------------------------- /asm/msp430.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_MSP430_H 13 | #define NAKEN_ASM_ASM_MSP430_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_instruction_msp430(AsmContext *asm_context, char *instr); 18 | 19 | int link_function_msp430( 20 | AsmContext *asm_context, 21 | Imports *imports, 22 | const uint8_t *code, 23 | uint32_t function_offset, 24 | int size, 25 | uint8_t *obj_file, 26 | uint32_t obj_size); 27 | 28 | #endif 29 | 30 | -------------------------------------------------------------------------------- /samples/nintendo64/support/cos_table.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import math 4 | 5 | cos_table = [ ] 6 | 7 | pi = 3.14 8 | 9 | for i in range(0, 512): 10 | c = pi * 2 11 | d = math.cos((float(i) / 512) * c) 12 | 13 | if d >= 0: 14 | value = int(65536 * d) 15 | else: 16 | value = int(65536 * -d) 17 | value ^= 0xffffffff 18 | value += 1 19 | 20 | print(str(i) + " " + str(d) + (" %08x" % (value))) 21 | 22 | cos_table.append(value) 23 | 24 | count = 0 25 | 26 | for value in cos_table: 27 | if (count % 6) == 0: 28 | print("\n .dc32", end = "") 29 | print(" 0x%08x," % (value), end = "") 30 | 31 | count += 1 32 | 33 | print() 34 | 35 | -------------------------------------------------------------------------------- /tests/other/Makefile: -------------------------------------------------------------------------------- 1 | include ../../config.mak 2 | 3 | INCLUDES=-I../../ 4 | BUILDDIR=../../build 5 | CFLAGS=-Wall -g -DUNIT_TEST $(INCLUDES) 6 | LD_FLAGS=-L../../build 7 | 8 | default: 9 | $(CXX) -o n64_rsp_illegal_instr n64_rsp_illegal_instr.cpp \ 10 | ../../build/naken_asm.a \ 11 | $(CFLAGS) 12 | 13 | run: 14 | ./n64_rsp_illegal_instr 15 | #bash check_libstdcplusplus.sh 16 | 17 | check_libstdcplusplus: 18 | $(CXX) -o check_libstdcplusplus check_libstdcplusplus.cpp \ 19 | ../../build/naken_asm.a \ 20 | $(CFLAGS) 21 | ./check_libstdcplusplus 22 | 23 | clean: 24 | @rm -f n64_rsp_illegal_instr 25 | @rm -f check_libstdcplusplus 26 | @echo "Clean!" 27 | 28 | -------------------------------------------------------------------------------- /scripts/dist/windows/build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | FULLNAME=naken_asm-$1 4 | 5 | git clone https://github.com/mikeakohn/naken_asm.git 6 | cd naken_asm 7 | 8 | cat < common/version.h 9 | #ifndef _VERSION_H 10 | #define _VERSION_H 11 | 12 | #define VERSION "$VERSION_H" 13 | 14 | #endif 15 | EOF 16 | 17 | ./configure --compiler-prefix=i686-w64-mingw32- --cflags=-static --cflags=-static-libgcc --cflags=-static-libstdc++ 18 | make 19 | rm -rf build/asm build/common build/disasm build/fileio build/prog build/simulate build/table .git ${FULLNAME}.zip 20 | cd .. 21 | mv naken_asm ${FULLNAME} 22 | zip -r ${FULLNAME}.zip ${FULLNAME} 23 | 24 | cp ${FULLNAME}.zip /dist/ 25 | 26 | -------------------------------------------------------------------------------- /docs/TMS340.md: -------------------------------------------------------------------------------- 1 | 2 | TMS340 3 | ====== 4 | 5 | This assembler works with the Texas Instruments TMS340 series of 6 | chips including the TMS34010 used in Mortal Kombat, IBM 8514 graphics 7 | chip, and other arcade systems. 8 | 9 | There is currently some support for TMS34020, but a few instructions 10 | are missing. 11 | 12 | This chip is a bit awkward because it does bit addressing rather 13 | than byte. Currently any instruction that uses addresses is going 14 | to use a byte address by naken_asm. It might be that using symbols 15 | will require a multiply by 16 to get the correct address. 16 | 17 | For more info on this chip: 18 | 19 | https://en.wikipedia.org/wiki/TMS34010 20 | 21 | -------------------------------------------------------------------------------- /samples/68hc08/testing.asm: -------------------------------------------------------------------------------- 1 | .68hc08 2 | 3 | main: 4 | psha 5 | rts 6 | blah: 7 | adc #8 8 | cphx #8 9 | roar: 10 | cphx #$ff00 11 | bne roar 12 | 13 | cmp ,x 14 | 15 | mov roar, blah 16 | mov #8, blah 17 | cbeqa #8, blah 18 | cbeqx #8, main 19 | cbeq 8, X+, blah 20 | cbeq ,X+, blah 21 | dbnz ,X, blah 22 | dbnz 8, X, blah 23 | cbeq 9, blah 24 | cbeq main, SP, main 25 | 26 | sub #8 27 | sub roar 28 | sub $ff00 29 | sub roar, X 30 | sub $ff00, X 31 | sub X 32 | sub roar, SP 33 | sub $ff00, SP 34 | 35 | mov roar, X+ 36 | mov ,X+, roar 37 | 38 | addr: 39 | bset 3, addr 40 | bset 7, addr 41 | brset 7, addr, addr 42 | brset 0, addr, addr 43 | 44 | 45 | -------------------------------------------------------------------------------- /table/6800.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_TABLE_6800_H 13 | #define NAKEN_ASM_TABLE_6800_H 14 | 15 | enum 16 | { 17 | M6800_OP_UNDEF, 18 | M6800_OP_NONE, 19 | M6800_OP_IMM8, 20 | M6800_OP_IMM16, 21 | M6800_OP_DIR_PAGE_8, 22 | M6800_OP_ABSOLUTE_16, 23 | M6800_OP_NN_X, 24 | M6800_OP_REL_OFFSET, 25 | }; 26 | 27 | struct _table_6800 28 | { 29 | const char *instr; 30 | char operand_type; 31 | }; 32 | 33 | extern struct _table_6800 table_6800[]; 34 | 35 | #endif 36 | 37 | -------------------------------------------------------------------------------- /include/sensors/sgp30.inc: -------------------------------------------------------------------------------- 1 | ;; SGP30 - Gas Sensor 2 | ;; 3 | ;; Date: July 27, 2019 4 | ;; Author: Michael Kohn 5 | ;; Email: mike@mikekohn.net 6 | ;; Web: https://www.mikekohn.net/ 7 | ;; 8 | ;; Part of the naken_asm project 9 | 10 | ;; Sensor registers. 11 | 12 | SGP30_INIT_AIR_QUALITY equ 0x2003 13 | SGP30_MEASURE_AIR_QUALITY equ 0x2008 14 | SGP30_GET_BASELINE equ 0x2015 15 | SGP30_SET_BASELINE equ 0x201e 16 | SGP30_SET_HUMIDITY equ 0x2061 17 | SGP30_MEASURE_TEST equ 0x2032 18 | SGP30_GET_FEATURE_SET_VERSION equ 0x202f 19 | SGP30_MEASURE_RAW_SIGNALS equ 0x2050 20 | 21 | SGP30_SOFT_RESET equ 0x0006 22 | SGP30_GET_SERIAL_ID equ 0x3682 23 | 24 | -------------------------------------------------------------------------------- /samples/playstation3/Makefile: -------------------------------------------------------------------------------- 1 | 2 | #DUMP_MACROS=-dump_macros 3 | INCLUDES=-I../../include 4 | FLAGS=-l -type elf $(INCLUDES) $(DUMP_MACROS) 5 | 6 | default: 7 | ../../naken_asm $(FLAGS) -o mandelbrot_altivec.o mandelbrot_altivec.asm 8 | $(CC) -o mandelbrot mandelbrot.c mandelbrot_altivec.o -lspe2 \ 9 | -O3 -Wall -g 10 | 11 | mandel: 12 | ../../naken_asm $(FLAGS) -o mandelbrot_spe.elf mandelbrot_spe.asm 13 | chmod 755 mandelbrot_spe.elf 14 | 15 | cell: 16 | ../../naken_asm $(FLAGS) -o spe_test.elf spe_test.asm 17 | ppu-gcc -o host_to_cell host_to_cell.c -lspe2 18 | chmod 755 spe_test.elf 19 | 20 | clean: 21 | @rm -f *.o *.lst mandelbrot host_to_cell mandelbrot_spe.elf spe_test.elf 22 | @echo "Clean!" 23 | 24 | -------------------------------------------------------------------------------- /samples/cell/cell.asm: -------------------------------------------------------------------------------- 1 | .cell 2 | 3 | main: 4 | mpya r3, r4, r5, r6 5 | clz r5, r6 6 | ori r5, r6, 100 7 | shlhi r5, r6, 3 8 | orx r5, r6 9 | heq r5, r6 10 | heqi r5, 61 11 | heqi r5, -61 12 | 13 | clgthi r5, r6, 100 14 | 15 | branches: 16 | br main 17 | bra main 18 | brsl r15, main 19 | brasl r15, main 20 | bi r15 21 | 22 | blah: 23 | hbr branches, r10 24 | hbrp 25 | hbra branches, blah 26 | hbrr branches, blah 27 | 28 | csflt r10, r11, -2 29 | cflts r10, r11, 2 30 | 31 | fscrrd r12 32 | 33 | stop 0x1234 34 | stopd r11, r12, r13 35 | lnop 36 | nop r0 37 | 38 | mfspr r13, 81 39 | mtspr 77, r13 40 | 41 | rdch r13, 100 42 | rchcnt r13, 100 43 | wrch 100, r13 44 | 45 | 46 | -------------------------------------------------------------------------------- /table/f100_l.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_TABLE_F100_L_H 13 | #define NAKEN_ASM_TABLE_F100_L_H 14 | 15 | #include "common/assembler.h" 16 | 17 | enum 18 | { 19 | OP_NONE, 20 | OP_ALU, 21 | OP_BIT, 22 | OP_HALT, 23 | OP_INC, 24 | OP_COND_JMP, 25 | OP_SHIFT, 26 | OP_SHIFT_D, 27 | }; 28 | 29 | struct _table_f100_l 30 | { 31 | const char *instr; 32 | uint16_t opcode; 33 | uint16_t mask; 34 | uint8_t type; 35 | }; 36 | 37 | extern struct _table_f100_l table_f100_l[]; 38 | 39 | #endif 40 | 41 | -------------------------------------------------------------------------------- /table/pic14.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_TABLE_PIC14_H 13 | #define NAKEN_ASM_TABLE_PIC14_H 14 | 15 | #include "common/assembler.h" 16 | 17 | enum 18 | { 19 | OP_NONE, 20 | OP_F_D, 21 | OP_F, 22 | OP_F_B, 23 | OP_K8, 24 | OP_K11, 25 | }; 26 | 27 | struct _table_pic14 28 | { 29 | const char *instr; 30 | uint16_t opcode; 31 | uint16_t mask; 32 | uint8_t type; 33 | uint8_t cycles_min; 34 | uint8_t cycles_max; 35 | }; 36 | 37 | extern struct _table_pic14 table_pic14[]; 38 | 39 | #endif 40 | 41 | -------------------------------------------------------------------------------- /table/4004.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2022 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_TABLE_4004_H 13 | #define NAKEN_ASM_TABLE_4004_H 14 | 15 | #include "common/assembler.h" 16 | 17 | enum 18 | { 19 | OP_NONE, 20 | OP_R, 21 | OP_P, 22 | OP_ADDR12, 23 | OP_DATA, 24 | OP_P_DATA, 25 | OP_R_ADDR8, 26 | OP_COND, 27 | OP_COND_ALIAS, 28 | }; 29 | 30 | struct _table_4004 31 | { 32 | const char *instr; 33 | uint8_t opcode; 34 | uint8_t mask; 35 | uint8_t type; 36 | }; 37 | 38 | extern struct _table_4004 table_4004[]; 39 | 40 | #endif 41 | 42 | -------------------------------------------------------------------------------- /table/tms1000.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_TABLE_TMS1000_H 13 | #define NAKEN_ASM_TABLE_TMS1000_H 14 | 15 | #include "common/assembler.h" 16 | 17 | struct _table_tms1000 18 | { 19 | const char *instr; 20 | int16_t op1000; 21 | int16_t op1100; 22 | }; 23 | 24 | extern struct _table_tms1000 table_tms1000[]; 25 | extern int tms1000_reverse_constant[]; 26 | extern int tms1000_reverse_bit_address[]; 27 | extern uint8_t tms1000_address_to_lsfr[]; 28 | extern uint8_t tms1000_lsfr_to_address[]; 29 | 30 | #endif 31 | 32 | -------------------------------------------------------------------------------- /asm/pdk_parse.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_PDK_PARSE_H 13 | #define NAKEN_ASM_ASM_PDK_PARSE_H 14 | 15 | #include "common/assembler.h" 16 | 17 | #define MAX_OPERANDS 2 18 | 19 | enum 20 | { 21 | OPERAND_ADDRESS, 22 | OPERAND_IMMEDIATE, 23 | OPERAND_A, 24 | OPERAND_BIT_OFFSET, 25 | OPERAND_ADDRESS_BIT_OFFSET, 26 | }; 27 | 28 | struct _operand 29 | { 30 | int value; 31 | int type; 32 | int bit; 33 | }; 34 | 35 | int pdk_parse(AsmContext *asm_context, struct _operand *operands); 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /table/sweet16.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_TABLE_SWEET16_H 13 | #define NAKEN_ASM_TABLE_SWEET16_H 14 | 15 | #include 16 | 17 | enum 18 | { 19 | SWEET16_OP_ILLEGAL, 20 | SWEET16_OP_NONE, 21 | SWEET16_OP_REG, 22 | SWEET16_OP_AT_REG, 23 | SWEET16_OP_EA, 24 | SWEET16_OP_REG_VALUE, 25 | }; 26 | 27 | struct _table_sweet16 28 | { 29 | const char *instr; 30 | uint8_t opcode; 31 | uint8_t mask; 32 | uint8_t type; 33 | }; 34 | 35 | extern struct _table_sweet16 table_sweet16[]; 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /scripts/graveyard/mips_r.txt: -------------------------------------------------------------------------------- 1 | add rd, rs, rt 100000 2 | addu rd, rs, rt 100001 3 | and rd, rs, rt 100100 4 | break 001101 5 | div rs, rt 011010 6 | divu rs, rt 011011 7 | jalr rd, rs 001001 8 | jr rs 001000 9 | mfhi rd 010000 10 | mflo rd 010010 11 | mthi rs 010001 12 | mtlo rs 010011 13 | mult rs, rt 011000 14 | multu rs, rt 011001 15 | nor rd, rs, rt 100111 16 | or rd, rs, rt 100101 17 | sll rd, rt, sa 000000 18 | sllv rd, rt, rs 000100 19 | slt rd, rs, rt 101010 20 | sltu rd, rs, rt 101011 21 | sra rd, rt, sa 000011 22 | srav rd, rt, rs 000111 23 | srl rd, rt, sa 000010 24 | srlv rd, rt, rs 000110 25 | sub rd, rs, rt 100010 26 | subu rd, rs, rt 100011 27 | syscall 001100 28 | xor rd, rs, rt 100110 29 | -------------------------------------------------------------------------------- /table/pdp8.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn, Lars Brinkhoff 9 | * 10 | * PDP-8 by Lars Brinkhoff 11 | * 12 | */ 13 | 14 | #ifndef NAKEN_ASM_TABLE_PDP8_H 15 | #define NAKEN_ASM_TABLE_PDP8_H 16 | 17 | #include "common/assembler.h" 18 | 19 | enum 20 | { 21 | OP_NONE, 22 | OP_M, 23 | OP_IOT, 24 | OP_OPR, 25 | }; 26 | 27 | struct _table_pdp8 28 | { 29 | const char *instr; 30 | uint16_t opcode; 31 | uint16_t mask; 32 | uint8_t type; 33 | //uint8_t cycles_min; 34 | //uint8_t cycles_max; 35 | }; 36 | 37 | extern struct _table_pdp8 table_pdp8[]; 38 | 39 | #endif 40 | 41 | -------------------------------------------------------------------------------- /samples/msp430/launchpad_blink.asm: -------------------------------------------------------------------------------- 1 | .msp430 2 | .include "msp430x2xx.inc" 3 | 4 | .org 0xf800 5 | start: 6 | ;; Turn off watchdog timer. 7 | mov.w #WDTPW|WDTHOLD, &WDTCTL 8 | 9 | ;; Set P1.0 and P1.6 as outputs. 10 | mov.b #0x41, &P1DIR 11 | 12 | main: 13 | ;; Initial value for LEDs turns on the P1.0 LED and 14 | ;; keeps P1.6 turned off. 15 | mov.w #0x01, r8 16 | while_1: 17 | ;; Set LEDs to current value of r8 and toggle P1.0 and P1.6. 18 | mov.b r8, &P1OUT 19 | xor.b #0x41, r8 20 | 21 | ;; Delay by decrementing r9 60000 times. 22 | mov.w #60000, r9 23 | delay_loop: 24 | dec r9 25 | jnz delay_loop 26 | 27 | ;; Repeat loop. 28 | jmp while_1 29 | 30 | .org 0xfffe 31 | dw start ; set reset vector to 'init' label 32 | 33 | -------------------------------------------------------------------------------- /table/lc3.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_TABLE_LC3_H 13 | #define NAKEN_ASM_TABLE_LC3_H 14 | 15 | #include "common/assembler.h" 16 | 17 | enum 18 | { 19 | OP_NONE, 20 | OP_R_R_R, 21 | OP_R_R_IMM5, 22 | OP_BR, 23 | OP_BASER, 24 | OP_OFFSET11, 25 | OP_R_OFFSET9, 26 | OP_R_R_OFFSET6, 27 | OP_R_R, 28 | OP_VECTOR, 29 | }; 30 | 31 | struct _table_lc3 32 | { 33 | const char *instr; 34 | uint16_t opcode; 35 | uint16_t mask; 36 | uint8_t type; 37 | }; 38 | 39 | extern struct _table_lc3 table_lc3[]; 40 | 41 | #endif 42 | 43 | -------------------------------------------------------------------------------- /table/unsp.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_TABLE_UNSP_H 13 | #define NAKEN_ASM_TABLE_UNSP_H 14 | 15 | #include 16 | 17 | enum 18 | { 19 | UNSP_OP_NONE, 20 | UNSP_OP_GOTO, 21 | UNSP_OP_MUL, 22 | UNSP_OP_MAC, 23 | UNSP_OP_JMP, 24 | UNSP_OP_ALU, 25 | UNSP_OP_ALU_2, 26 | UNSP_OP_POP, 27 | UNSP_OP_PUSH, 28 | }; 29 | 30 | struct _table_unsp 31 | { 32 | const char *instr; 33 | uint16_t opcode; 34 | uint16_t mask; 35 | uint8_t type; 36 | }; 37 | 38 | extern struct _table_unsp table_unsp[]; 39 | 40 | #endif 41 | 42 | -------------------------------------------------------------------------------- /common/util_sim.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2025 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef UTIL_SIM_H 13 | #define UTIL_SIM_H 14 | 15 | #include "common/UtilContext.h" 16 | #include "common/String.h" 17 | 18 | void sim_show_info(UtilContext *util_context); 19 | int sim_set_register(UtilContext *util_context, String &arg); 20 | int sim_clear_flag(UtilContext *util_context, String &arg); 21 | int sim_set_speed(UtilContext *util_context, String &arg); 22 | int sim_stack_push(UtilContext *util_context, String &arg); 23 | int sim_set_breakpoint(UtilContext *util_context, String &arg); 24 | 25 | #endif 26 | 27 | -------------------------------------------------------------------------------- /table/agc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2024 by Michael Kohn 9 | * 10 | */ 11 | 12 | // Apollo Guidance Computer. 13 | 14 | #ifndef NAKEN_ASM_TABLE_AGC_H 15 | #define NAKEN_ASM_TABLE_AGC_H 16 | 17 | #include 18 | 19 | enum 20 | { 21 | AGC_OP_NONE, 22 | AGC_OP_K10, 23 | AGC_OP_K12, 24 | AGC_OP_IO, 25 | AGC_OP_NDX, 26 | }; 27 | 28 | struct _table_agc 29 | { 30 | const char *instr; 31 | uint16_t opcode; 32 | uint16_t mask; 33 | uint8_t type; 34 | bool is_extra_code; 35 | uint8_t cycles; 36 | }; 37 | 38 | extern struct _table_agc table_agc[]; 39 | 40 | #endif 41 | 42 | -------------------------------------------------------------------------------- /disasm/f8.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2024 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DISASM_F8_H 13 | #define NAKEN_ASM_DISASM_F8_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int disasm_f8( 18 | Memory *memory, 19 | uint32_t address, 20 | char *instruction, 21 | int length, 22 | int flags, 23 | int *cycles_min, 24 | int *cycles_max); 25 | 26 | void list_output_f8( 27 | AsmContext *asm_context, 28 | uint32_t start, 29 | uint32_t end); 30 | 31 | void disasm_range_f8( 32 | Memory *memory, 33 | uint32_t flags, 34 | uint32_t start, 35 | uint32_t end); 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /disasm/arc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DISASM_ARC_H 13 | #define NAKEN_ASM_DISASM_ARC_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int disasm_arc( 18 | Memory *memory, 19 | uint32_t address, 20 | char *instruction, 21 | int length, 22 | int flags, 23 | int *cycles_min, 24 | int *cycles_max); 25 | 26 | void list_output_arc( 27 | AsmContext *asm_context, 28 | uint32_t start, 29 | uint32_t end); 30 | 31 | void disasm_range_arc( 32 | Memory *memory, 33 | uint32_t flags, 34 | uint32_t start, 35 | uint32_t end); 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /disasm/lc3.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DISASM_LC3_H 13 | #define NAKEN_ASM_DISASM_LC3_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int disasm_lc3( 18 | Memory *memory, 19 | uint32_t address, 20 | char *instruction, 21 | int length, 22 | int flags, 23 | int *cycles_min, 24 | int *cycles_max); 25 | 26 | void list_output_lc3( 27 | AsmContext *asm_context, 28 | uint32_t start, 29 | uint32_t end); 30 | 31 | void disasm_range_lc3( 32 | Memory *memory, 33 | uint32_t flags, 34 | uint32_t start, 35 | uint32_t end); 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /disasm/m8c.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DISASM_M8C_H 13 | #define NAKEN_ASM_DISASM_M8C_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int disasm_m8c( 18 | Memory *memory, 19 | uint32_t address, 20 | char *instruction, 21 | int length, 22 | int flags, 23 | int *cycles_min, 24 | int *cycles_max); 25 | 26 | void list_output_m8c( 27 | AsmContext *asm_context, 28 | uint32_t start, 29 | uint32_t end); 30 | 31 | void disasm_range_m8c( 32 | Memory *memory, 33 | uint32_t flags, 34 | uint32_t start, 35 | uint32_t end); 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /disasm/sh4.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DISASM_SH4_H 13 | #define NAKEN_ASM_DISASM_SH4_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int disasm_sh4( 18 | Memory *memory, 19 | uint32_t address, 20 | char *instruction, 21 | int length, 22 | int flags, 23 | int *cycles_min, 24 | int *cycles_max); 25 | 26 | void list_output_sh4( 27 | AsmContext *asm_context, 28 | uint32_t start, 29 | uint32_t end); 30 | 31 | void disasm_range_sh4( 32 | Memory *memory, 33 | uint32_t flags, 34 | uint32_t start, 35 | uint32_t end); 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /disasm/z80.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2024 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DISASM_Z80_H 13 | #define NAKEN_ASM_DISASM_Z80_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int disasm_z80( 18 | Memory *memory, 19 | uint32_t address, 20 | char *instruction, 21 | int length, 22 | int flags, 23 | int *cycles_min, 24 | int *cycles_max); 25 | 26 | void list_output_z80( 27 | AsmContext *asm_context, 28 | uint32_t start, 29 | uint32_t end); 30 | 31 | void disasm_range_z80( 32 | Memory *memory, 33 | uint32_t flags, 34 | uint32_t start, 35 | uint32_t end); 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /table/ebpf.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_TABLE_EBPF_H 13 | #define NAKEN_ASM_TABLE_EBPF_H 14 | 15 | #include "common/assembler.h" 16 | 17 | enum 18 | { 19 | OP_NONE, 20 | OP_IMM, 21 | OP_REG, 22 | OP_REG_REG, 23 | OP_REG_IMM, 24 | }; 25 | 26 | enum 27 | { 28 | SIZE_NONE = 0, 29 | SIZE_EITHER = 1, 30 | SIZE_32 = 32, 31 | SIZE_64 = 64 32 | }; 33 | 34 | struct _table_ebpf 35 | { 36 | const char *instr; 37 | uint8_t opcode; 38 | uint8_t type; 39 | uint8_t size; 40 | }; 41 | 42 | extern struct _table_ebpf table_ebpf[]; 43 | 44 | #endif 45 | 46 | -------------------------------------------------------------------------------- /disasm/1802.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DISASM_1802_H 13 | #define NAKEN_ASM_DISASM_1802_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int disasm_1802( 18 | Memory *memory, 19 | uint32_t address, 20 | char *instruction, 21 | int length, 22 | int flags, 23 | int *cycles_min, 24 | int *cycles_max); 25 | 26 | void list_output_1802( 27 | AsmContext *asm_context, 28 | uint32_t start, 29 | uint32_t end); 30 | 31 | void disasm_range_1802( 32 | Memory *memory, 33 | uint32_t flags, 34 | uint32_t start, 35 | uint32_t end); 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /disasm/4004.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DISASM_4004_H 13 | #define NAKEN_ASM_DISASM_4004_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int disasm_4004( 18 | Memory *memory, 19 | uint32_t address, 20 | char *instruction, 21 | int length, 22 | int flags, 23 | int *cycles_min, 24 | int *cycles_max); 25 | 26 | void list_output_4004( 27 | AsmContext *asm_context, 28 | uint32_t start, 29 | uint32_t end); 30 | 31 | void disasm_range_4004( 32 | Memory *memory, 33 | uint32_t flags, 34 | uint32_t start, 35 | uint32_t end); 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /disasm/6800.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DISASM_6800_H 13 | #define NAKEN_ASM_DISASM_6800_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int disasm_6800( 18 | Memory *memory, 19 | uint32_t address, 20 | char *instruction, 21 | int length, 22 | int flags, 23 | int *cycles_min, 24 | int *cycles_max); 25 | 26 | void list_output_6800( 27 | AsmContext *asm_context, 28 | uint32_t start, 29 | uint32_t end); 30 | 31 | void disasm_range_6800( 32 | Memory *memory, 33 | uint32_t flags, 34 | uint32_t start, 35 | uint32_t end); 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /disasm/6809.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DISASM_6809_H 13 | #define NAKEN_ASM_DISASM_6809_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int disasm_6809( 18 | Memory *memory, 19 | uint32_t address, 20 | char *instruction, 21 | int length, 22 | int flags, 23 | int *cycles_min, 24 | int *cycles_max); 25 | 26 | void list_output_6809( 27 | AsmContext *asm_context, 28 | uint32_t start, 29 | uint32_t end); 30 | 31 | void disasm_range_6809( 32 | Memory *memory, 33 | uint32_t flags, 34 | uint32_t start, 35 | uint32_t end); 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /disasm/8008.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DISASM_8008_H 13 | #define NAKEN_ASM_DISASM_8008_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int disasm_8008( 18 | Memory *memory, 19 | uint32_t address, 20 | char *instruction, 21 | int length, 22 | int flags, 23 | int *cycles_min, 24 | int *cycles_max); 25 | 26 | void list_output_8008( 27 | AsmContext *asm_context, 28 | uint32_t start, 29 | uint32_t end); 30 | 31 | void disasm_range_8008( 32 | Memory *memory, 33 | uint32_t flags, 34 | uint32_t start, 35 | uint32_t end); 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /disasm/8051.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DISASM_8051_H 13 | #define NAKEN_ASM_DISASM_8051_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int disasm_8051( 18 | Memory *memory, 19 | uint32_t address, 20 | char *instruction, 21 | int length, 22 | int flags, 23 | int *cycles_min, 24 | int *cycles_max); 25 | 26 | void list_output_8051( 27 | AsmContext *asm_context, 28 | uint32_t start, 29 | uint32_t end); 30 | 31 | void disasm_range_8051( 32 | Memory *memory, 33 | uint32_t flags, 34 | uint32_t start, 35 | uint32_t end); 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /disasm/cell.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DISASM_CELL_H 13 | #define NAKEN_ASM_DISASM_CELL_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int disasm_cell( 18 | Memory *memory, 19 | uint32_t address, 20 | char *instruction, 21 | int length, 22 | int flags, 23 | int *cycles_min, 24 | int *cycles_max); 25 | 26 | void list_output_cell( 27 | AsmContext *asm_context, 28 | uint32_t start, 29 | uint32_t end); 30 | 31 | void disasm_range_cell( 32 | Memory *memory, 33 | uint32_t flags, 34 | uint32_t start, 35 | uint32_t end); 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /disasm/ebpf.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DISASM_EBPF_H 13 | #define NAKEN_ASM_DISASM_EBPF_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int disasm_ebpf( 18 | Memory *memory, 19 | uint32_t address, 20 | char *instruction, 21 | int length, 22 | int flags, 23 | int *cycles_min, 24 | int *cycles_max); 25 | 26 | void list_output_ebpf( 27 | AsmContext *asm_context, 28 | uint32_t start, 29 | uint32_t end); 30 | 31 | void disasm_range_ebpf( 32 | Memory *memory, 33 | uint32_t flags, 34 | uint32_t start, 35 | uint32_t end); 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /disasm/java.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DISASM_JAVA_H 13 | #define NAKEN_ASM_DISASM_JAVA_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int disasm_java( 18 | Memory *memory, 19 | uint32_t address, 20 | char *instruction, 21 | int length, 22 | int flags, 23 | int *cycles_min, 24 | int *cycles_max); 25 | 26 | void list_output_java( 27 | AsmContext *asm_context, 28 | uint32_t start, 29 | uint32_t end); 30 | 31 | void disasm_range_java( 32 | Memory *memory, 33 | uint32_t flags, 34 | uint32_t start, 35 | uint32_t end); 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /disasm/stm8.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DISASM_STM8_H 13 | #define NAKEN_ASM_DISASM_STM8_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int disasm_stm8( 18 | Memory *memory, 19 | uint32_t address, 20 | char *instruction, 21 | int length, 22 | int flags, 23 | int *cycles_min, 24 | int *cycles_max); 25 | 26 | void list_output_stm8( 27 | AsmContext *asm_context, 28 | uint32_t start, 29 | uint32_t end); 30 | 31 | void disasm_range_stm8( 32 | Memory *memory, 33 | uint32_t flags, 34 | uint32_t start, 35 | uint32_t end); 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /disasm/unsp.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DISASM_UNSP_H 13 | #define NAKEN_ASM_DISASM_UNSP_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int disasm_unsp( 18 | Memory *memory, 19 | uint32_t address, 20 | char *instruction, 21 | int length, 22 | int flags, 23 | int *cycles_min, 24 | int *cycles_max); 25 | 26 | void list_output_unsp( 27 | AsmContext *asm_context, 28 | uint32_t start, 29 | uint32_t end); 30 | 31 | void disasm_range_unsp( 32 | Memory *memory, 33 | uint32_t flags, 34 | uint32_t start, 35 | uint32_t end); 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /table/pdp11.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2025 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_TABLE_PDP11_H 13 | #define NAKEN_ASM_TABLE_PDP11_H 14 | 15 | #include "common/assembler.h" 16 | 17 | enum 18 | { 19 | OP_NONE, 20 | OP_REG, 21 | OP_SINGLE, 22 | OP_DOUBLE, 23 | OP_REG_D, 24 | OP_REG_S, 25 | OP_BRANCH, 26 | OP_SUB_BR, 27 | OP_JSR, 28 | OP_NN, 29 | OP_S_OPER, 30 | OP_NZVC, 31 | }; 32 | 33 | struct _table_pdp11 34 | { 35 | const char *instr; 36 | uint16_t opcode; 37 | uint16_t mask; 38 | uint8_t type; 39 | }; 40 | 41 | extern struct _table_pdp11 table_pdp11[]; 42 | 43 | #endif 44 | 45 | -------------------------------------------------------------------------------- /disasm/68000.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2024 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DISASM_68000_H 13 | #define NAKEN_ASM_DISASM_68000_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int disasm_68000( 18 | Memory *memory, 19 | uint32_t address, 20 | char *instruction, 21 | int length, 22 | int flags, 23 | int *cycles_min, 24 | int *cycles_max); 25 | 26 | void list_output_68000( 27 | AsmContext *asm_context, 28 | uint32_t start, 29 | uint32_t end); 30 | 31 | void disasm_range_68000( 32 | Memory *memory, 33 | uint32_t flags, 34 | uint32_t start, 35 | uint32_t end); 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /disasm/86000.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DISASM_86000_H 13 | #define NAKEN_ASM_DISASM_86000_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int disasm_86000( 18 | Memory *memory, 19 | uint32_t address, 20 | char *instruction, 21 | int length, 22 | int flags, 23 | int *cycles_min, 24 | int *cycles_max); 25 | 26 | void list_output_86000( 27 | AsmContext *asm_context, 28 | uint32_t start, 29 | uint32_t end); 30 | 31 | void disasm_range_86000( 32 | Memory *memory, 33 | uint32_t flags, 34 | uint32_t start, 35 | uint32_t end); 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /disasm/arm64.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2024 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DISASM_ARM64_H 13 | #define NAKEN_ASM_DISASM_ARM64_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int disasm_arm64( 18 | Memory *memory, 19 | uint32_t address, 20 | char *instruction, 21 | int length, 22 | int flags, 23 | int *cycles_min, 24 | int *cycles_max); 25 | 26 | void list_output_arm64( 27 | AsmContext *asm_context, 28 | uint32_t start, 29 | uint32_t end); 30 | 31 | void disasm_range_arm64( 32 | Memory *memory, 33 | uint32_t flags, 34 | uint32_t start, 35 | uint32_t end); 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /disasm/pdk13.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DISASM_PDK13_H 13 | #define NAKEN_ASM_DISASM_PDK13_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int disasm_pdk13( 18 | Memory *memory, 19 | uint32_t address, 20 | char *instruction, 21 | int length, 22 | int flags, 23 | int *cycles_min, 24 | int *cycles_max); 25 | 26 | void list_output_pdk13( 27 | AsmContext *asm_context, 28 | uint32_t start, 29 | uint32_t end); 30 | 31 | void disasm_range_pdk13( 32 | Memory *memory, 33 | uint32_t flags, 34 | uint32_t start, 35 | uint32_t end); 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /disasm/pdk14.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DISASM_PDK14_H 13 | #define NAKEN_ASM_DISASM_PDK14_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int disasm_pdk14( 18 | Memory *memory, 19 | uint32_t address, 20 | char *instruction, 21 | int length, 22 | int flags, 23 | int *cycles_min, 24 | int *cycles_max); 25 | 26 | void list_output_pdk14( 27 | AsmContext *asm_context, 28 | uint32_t start, 29 | uint32_t end); 30 | 31 | void disasm_range_pdk14( 32 | Memory *memory, 33 | uint32_t flags, 34 | uint32_t start, 35 | uint32_t end); 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /disasm/pdk15.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DISASM_PDK15_H 13 | #define NAKEN_ASM_DISASM_PDK15_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int disasm_pdk15( 18 | Memory *memory, 19 | uint32_t address, 20 | char *instruction, 21 | int length, 22 | int flags, 23 | int *cycles_min, 24 | int *cycles_max); 25 | 26 | void list_output_pdk15( 27 | AsmContext *asm_context, 28 | uint32_t start, 29 | uint32_t end); 30 | 31 | void disasm_range_pdk15( 32 | Memory *memory, 33 | uint32_t flags, 34 | uint32_t start, 35 | uint32_t end); 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /disasm/pdk16.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DISASM_PDK16_H 13 | #define NAKEN_ASM_DISASM_PDK16_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int disasm_pdk16( 18 | Memory *memory, 19 | uint32_t address, 20 | char *instruction, 21 | int length, 22 | int flags, 23 | int *cycles_min, 24 | int *cycles_max); 25 | 26 | void list_output_pdk16( 27 | AsmContext *asm_context, 28 | uint32_t start, 29 | uint32_t end); 30 | 31 | void disasm_range_pdk16( 32 | Memory *memory, 33 | uint32_t flags, 34 | uint32_t start, 35 | uint32_t end); 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /disasm/pdp11.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2025 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DISASM_PDP11_H 13 | #define NAKEN_ASM_DISASM_PDP11_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int disasm_pdp11( 18 | Memory *memory, 19 | uint32_t address, 20 | char *instruction, 21 | int length, 22 | int flags, 23 | int *cycles_min, 24 | int *cycles_max); 25 | 26 | void list_output_pdp11( 27 | AsmContext *asm_context, 28 | uint32_t start, 29 | uint32_t end); 30 | 31 | void disasm_range_pdp11( 32 | Memory *memory, 33 | uint32_t flags, 34 | uint32_t start, 35 | uint32_t end); 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /disasm/pic14.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DISASM_PIC14_H 13 | #define NAKEN_ASM_DISASM_PIC14_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int disasm_pic14( 18 | Memory *memory, 19 | uint32_t address, 20 | char *instruction, 21 | int length, 22 | int flags, 23 | int *cycles_min, 24 | int *cycles_max); 25 | 26 | void list_output_pic14( 27 | AsmContext *asm_context, 28 | uint32_t start, 29 | uint32_t end); 30 | 31 | void disasm_range_pic14( 32 | Memory *memory, 33 | uint32_t flags, 34 | uint32_t start, 35 | uint32_t end); 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /disasm/pic18.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DISASM_PIC18_H 13 | #define NAKEN_ASM_DISASM_PIC18_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int disasm_pic18( 18 | Memory *memory, 19 | uint32_t address, 20 | char *instruction, 21 | int length, 22 | int flags, 23 | int *cycles_min, 24 | int *cycles_max); 25 | 26 | void list_output_pic18( 27 | AsmContext *asm_context, 28 | uint32_t start, 29 | uint32_t end); 30 | 31 | void disasm_range_pic18( 32 | Memory *memory, 33 | uint32_t flags, 34 | uint32_t start, 35 | uint32_t end); 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /disasm/sparc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DISASM_SPARC_H 13 | #define NAKEN_ASM_DISASM_SPARC_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int disasm_sparc( 18 | Memory *memory, 19 | uint32_t address, 20 | char *instruction, 21 | int length, 22 | int flags, 23 | int *cycles_min, 24 | int *cycles_max); 25 | 26 | void list_output_sparc( 27 | AsmContext *asm_context, 28 | uint32_t start, 29 | uint32_t end); 30 | 31 | void disasm_range_sparc( 32 | Memory *memory, 33 | uint32_t flags, 34 | uint32_t start, 35 | uint32_t end); 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /disasm/thumb.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DISASM_THUMB_H 13 | #define NAKEN_ASM_DISASM_THUMB_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int disasm_thumb( 18 | Memory *memory, 19 | uint32_t address, 20 | char *instruction, 21 | int length, 22 | int flags, 23 | int *cycles_min, 24 | int *cycles_max); 25 | 26 | void list_output_thumb( 27 | AsmContext *asm_context, 28 | uint32_t start, 29 | uint32_t end); 30 | 31 | void disasm_range_thumb( 32 | Memory *memory, 33 | uint32_t flags, 34 | uint32_t start, 35 | uint32_t end); 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /samples/nintendo64/Makefile: -------------------------------------------------------------------------------- 1 | 2 | INCLUDES=-I ../../include 3 | PROGRAMS= \ 4 | sample_no_rsp.z64 \ 5 | sample_rsp_hardcoded.z64 \ 6 | sample_rsp_rectangle.z64 \ 7 | sample_rsp_rectangle_texture.z64 \ 8 | sample_rsp_rotation.z64 \ 9 | sample_rsp_rotation_z.z64 \ 10 | sample_rsp_triangle.z64 11 | 12 | default: rsp.bin picture.raw $(PROGRAMS) 13 | 14 | rsp: 15 | ../../naken_asm $(INCLUDES) -dump_symbols -l -type bin -o rsp.bin rsp.asm 16 | 17 | %.z64: %.asm rsp.asm 18 | ../../naken_asm $(INCLUDES) -dump_symbols -l -type bin -o $*.z64 $< 19 | ./n64crc $*.z64 20 | 21 | %.bin: %.asm 22 | ../../naken_asm $(INCLUDES) -dump_symbols -l -type bin -o $*.bin $< 23 | 24 | picture.raw: 25 | python3 picture.py 26 | 27 | clean: 28 | @rm -f *.lst *.z64 rsp.bin picture.raw 29 | @echo "Clean!" 30 | 31 | -------------------------------------------------------------------------------- /tests/unit/common/test_checks.h: -------------------------------------------------------------------------------- 1 | 2 | #define TEST_INT(a, b) \ 3 | if (a != b) \ 4 | { \ 5 | errors += 1; \ 6 | printf("Error: %d != %d %s:%d\n", a, b, __FILE__, __LINE__); \ 7 | } 8 | 9 | #define TEST_BOOL(a, b) \ 10 | if (a != b) \ 11 | { \ 12 | errors += 1; \ 13 | printf("Error: %s != %s %s:%d\n", \ 14 | a != 0 ? "true" : "false", \ 15 | b != 0 ? "true" : "false", \ 16 | __FILE__, __LINE__); \ 17 | } 18 | 19 | #define TEST_TEXT(a, b) \ 20 | if (strcmp(a,b) != 0) \ 21 | { \ 22 | errors += 1; \ 23 | printf("Error: %s != %s %s:%d\n", a, b, __FILE__, __LINE__); \ 24 | } 25 | 26 | #define TEST_PTR(a, b) \ 27 | if (a != b) \ 28 | { \ 29 | errors += 1; \ 30 | printf("Error: %p != %p %s:%d\n", a, b, __FILE__, __LINE__); \ 31 | } 32 | 33 | -------------------------------------------------------------------------------- /disasm/68hc08.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DISASM_68HC08_H 13 | #define NAKEN_ASM_DISASM_68HC08_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int disasm_68hc08( 18 | Memory *memory, 19 | uint32_t address, 20 | char *instruction, 21 | int length, 22 | int flags, 23 | int *cycles_min, 24 | int *cycles_max); 25 | 26 | void list_output_68hc08( 27 | AsmContext *asm_context, 28 | uint32_t start, 29 | uint32_t end); 30 | 31 | void disasm_range_68hc08( 32 | Memory *memory, 33 | uint32_t flags, 34 | uint32_t start, 35 | uint32_t end); 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /disasm/copper.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DISASM_COPPER_H 13 | #define NAKEN_ASM_DISASM_COPPER_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int disasm_copper( 18 | Memory *memory, 19 | uint32_t address, 20 | char *instruction, 21 | int length, 22 | int flags, 23 | int *cycles_min, 24 | int *cycles_max); 25 | 26 | void list_output_copper( 27 | AsmContext *asm_context, 28 | uint32_t start, 29 | uint32_t end); 30 | 31 | void disasm_range_copper( 32 | Memory *memory, 33 | uint32_t flags, 34 | uint32_t start, 35 | uint32_t end); 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /disasm/cp1610.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DISASM_CP1610_H 13 | #define NAKEN_ASM_DISASM_CP1610_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int disasm_cp1610( 18 | Memory *memory, 19 | uint32_t address, 20 | char *instruction, 21 | int length, 22 | int flags, 23 | int *cycles_min, 24 | int *cycles_max); 25 | 26 | void list_output_cp1610( 27 | AsmContext *asm_context, 28 | uint32_t start, 29 | uint32_t end); 30 | 31 | void disasm_range_cp1610( 32 | Memory *memory, 33 | uint32_t flags, 34 | uint32_t start, 35 | uint32_t end); 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /disasm/dotnet.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DISASM_DOTNET_H 13 | #define NAKEN_ASM_DISASM_DOTNET_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int disasm_dotnet( 18 | Memory *memory, 19 | uint32_t address, 20 | char *instruction, 21 | int length, 22 | int flags, 23 | int *cycles_min, 24 | int *cycles_max); 25 | 26 | void list_output_dotnet( 27 | AsmContext *asm_context, 28 | uint32_t start, 29 | uint32_t end); 30 | 31 | void disasm_range_dotnet( 32 | Memory *memory, 33 | uint32_t flags, 34 | uint32_t start, 35 | uint32_t end); 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /disasm/f100_l.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DISASM_F100_L_H 13 | #define NAKEN_ASM_DISASM_F100_L_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int disasm_f100_l( 18 | Memory *memory, 19 | uint32_t address, 20 | char *instruction, 21 | int length, 22 | int flags, 23 | int *cycles_min, 24 | int *cycles_max); 25 | 26 | void list_output_f100_l( 27 | AsmContext *asm_context, 28 | uint32_t start, 29 | uint32_t end); 30 | 31 | void disasm_range_f100_l( 32 | Memory *memory, 33 | uint32_t flags, 34 | uint32_t start, 35 | uint32_t end); 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /disasm/tms340.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DISASM_TMS340_H 13 | #define NAKEN_ASM_DISASM_TMS340_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int disasm_tms340( 18 | Memory *memory, 19 | uint32_t address, 20 | char *instruction, 21 | int length, 22 | int flags, 23 | int *cycles_min, 24 | int *cycles_max); 25 | 26 | void list_output_tms340( 27 | AsmContext *asm_context, 28 | uint32_t start, 29 | uint32_t end); 30 | 31 | void disasm_range_tms340( 32 | Memory *memory, 33 | uint32_t flags, 34 | uint32_t start, 35 | uint32_t end); 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /disasm/webasm.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DISASM_WEBASM_H 13 | #define NAKEN_ASM_DISASM_WEBASM_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int disasm_webasm( 18 | Memory *memory, 19 | uint32_t address, 20 | char *instruction, 21 | int length, 22 | int flags, 23 | int *cycles_min, 24 | int *cycles_max); 25 | 26 | void list_output_webasm( 27 | AsmContext *asm_context, 28 | uint32_t start, 29 | uint32_t end); 30 | 31 | void disasm_range_webasm( 32 | Memory *memory, 33 | uint32_t flags, 34 | uint32_t start, 35 | uint32_t end); 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /disasm/xtensa.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DISASM_XTENSA_H 13 | #define NAKEN_ASM_DISASM_XTENSA_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int disasm_xtensa( 18 | Memory *memory, 19 | uint32_t address, 20 | char *instruction, 21 | int length, 22 | int flags, 23 | int *cycles_min, 24 | int *cycles_max); 25 | 26 | void list_output_xtensa( 27 | AsmContext *asm_context, 28 | uint32_t start, 29 | uint32_t end); 30 | 31 | void disasm_range_xtensa( 32 | Memory *memory, 33 | uint32_t flags, 34 | uint32_t start, 35 | uint32_t end); 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /disasm/powerpc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DISASM_POWERPC_H 13 | #define NAKEN_ASM_DISASM_POWERPC_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int disasm_powerpc( 18 | Memory *memory, 19 | uint32_t address, 20 | char *instruction, 21 | int length, 22 | int flags, 23 | int *cycles_min, 24 | int *cycles_max); 25 | 26 | void list_output_powerpc( 27 | AsmContext *asm_context, 28 | uint32_t start, 29 | uint32_t end); 30 | 31 | void disasm_range_powerpc( 32 | Memory *memory, 33 | uint32_t flags, 34 | uint32_t start, 35 | uint32_t end); 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /disasm/sweet16.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DISASM_SWEET16_H 13 | #define NAKEN_ASM_DISASM_SWEET16_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int disasm_sweet16( 18 | Memory *memory, 19 | uint32_t address, 20 | char *instruction, 21 | int length, 22 | int flags, 23 | int *cycles_min, 24 | int *cycles_max); 25 | 26 | void list_output_sweet16( 27 | AsmContext *asm_context, 28 | uint32_t start, 29 | uint32_t end); 30 | 31 | void disasm_range_sweet16( 32 | Memory *memory, 33 | uint32_t flags, 34 | uint32_t start, 35 | uint32_t end); 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /disasm/tms9900.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DISASM_TMS9900_H 13 | #define NAKEN_ASM_DISASM_TMS9900_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int disasm_tms9900( 18 | Memory *memory, 19 | uint32_t address, 20 | char *instruction, 21 | int length, 22 | int flags, 23 | int *cycles_min, 24 | int *cycles_max); 25 | 26 | void list_output_tms9900( 27 | AsmContext *asm_context, 28 | uint32_t start, 29 | uint32_t end); 30 | 31 | void disasm_range_tms9900( 32 | Memory *memory, 33 | uint32_t flags, 34 | uint32_t start, 35 | uint32_t end); 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /disasm/epiphany.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DISASM_EPIPHANY_H 13 | #define NAKEN_ASM_DISASM_EPIPHANY_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int disasm_epiphany( 18 | Memory *memory, 19 | uint32_t address, 20 | char *instruction, 21 | int length, 22 | int flags, 23 | int *cycles_min, 24 | int *cycles_max); 25 | 26 | void list_output_epiphany( 27 | AsmContext *asm_context, 28 | uint32_t start, 29 | uint32_t end); 30 | 31 | void disasm_range_epiphany( 32 | Memory *memory, 33 | uint32_t flags, 34 | uint32_t start, 35 | uint32_t end); 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /disasm/super_fx.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DISASM_SUPER_FX_H 13 | #define NAKEN_ASM_DISASM_SUPER_FX_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int disasm_super_fx( 18 | Memory *memory, 19 | uint32_t address, 20 | char *instruction, 21 | int length, 22 | int flags, 23 | int *cycles_min, 24 | int *cycles_max); 25 | 26 | void list_output_super_fx( 27 | AsmContext *asm_context, 28 | uint32_t start, 29 | uint32_t end); 30 | 31 | void disasm_range_super_fx( 32 | Memory *memory, 33 | uint32_t flags, 34 | uint32_t start, 35 | uint32_t end); 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /samples/6809/testing.asm: -------------------------------------------------------------------------------- 1 | .6809 2 | 3 | start: 4 | asla 5 | aslb 6 | 7 | orcc #0x12 8 | lda #0xff 9 | cmpx #0xffff 10 | 11 | lda 0xffd2 12 | 13 | rol >0x30 14 | bne start 15 | lbne start 16 | 17 | puls x, y 18 | pulu pc, u, y, x, dp, b, a, cc 19 | pshs pc, x, dp, b, a, cc 20 | pshu cc 21 | 22 | tfr x, b 23 | tfr d, u 24 | 25 | lda ,x 26 | lda ,y 27 | lda ,u 28 | lda ,s 29 | 30 | lda a,x 31 | lda b,y 32 | lda d,s 33 | 34 | lda -1,x 35 | lda 100,y 36 | lda 300,s 37 | lda -300,u 38 | 39 | lda -300,pc 40 | lda -5,pc 41 | 42 | lda ,y+ 43 | lda ,s++ 44 | lda ,-y 45 | lda ,--s 46 | 47 | lda [,s++] 48 | lda [,--s] 49 | 50 | lda [-300,pc] 51 | lda [-5,pc] 52 | 53 | lda [-300,x] 54 | lda [-5,s] 55 | 56 | lda [,s] 57 | 58 | cmpd -2,s 59 | 60 | -------------------------------------------------------------------------------- /tests/comparison/sweet16.txt: -------------------------------------------------------------------------------- 1 | set r15, 0x1234|:030000001F341298 2 | set r3, 0x1234|:03000000133412A4 3 | ld r5|:0100000025DA 4 | st r10|:010000003AC5 5 | ld @r7|:0100000047B8 6 | st @r13|:010000005DA2 7 | ldd @r1|:01000000619E 8 | std @r14|:010000007E81 9 | add r6|:01000000A659 10 | sub r7|:01000000B748 11 | popd @r9|:01000000C936 12 | cpr r10|:01000000DA25 13 | inr r3|:01000000E31C 14 | dcr r4|:01000000F40B 15 | rtn|:0100000000FF 16 | main: br main|:0200000001FEFF 17 | main: bnc main|:0200000002FEFE 18 | main: bc main|:0200000003FEFD 19 | main: bp main|:0200000004FEFC 20 | main: bm main|:0200000005FEFB 21 | main: bz main|:0200000006FEFA 22 | main: bnz main|:0200000007FEF9 23 | main: bm1 main|:0200000008FEF8 24 | main: bnm1 main|:0200000009FEF7 25 | bk|:010000000AF5 26 | rs|:010000000BF4 27 | main: bs main|:020000000CFEF4 28 | -------------------------------------------------------------------------------- /tests/comparison/template/8008.txt: -------------------------------------------------------------------------------- 1 | mov e, b 2 | mov c, m 3 | mov m, d 4 | mvi b, 131 5 | mvi m, 232 6 | inr c 7 | dcr h 8 | add l 9 | add m 10 | adi 200 11 | adc a 12 | adc m 13 | aci 139 14 | sub h 15 | sub m 16 | sui 32 17 | sbb h 18 | sbb m 19 | sbi 100 20 | ana b 21 | ana m 22 | ani 129 23 | xra e 24 | xra m 25 | xri 99 26 | ora c 27 | ora m 28 | ori 199 29 | cmp h 30 | cmp m 31 | cpi 23 32 | rlc 33 | rrc 34 | ral 35 | rar 36 | jmp 0x1234 37 | jnc 0x1234 38 | jnz 0x1234 39 | jp 0x1234 40 | jpo 0x1234 41 | jc 0x1234 42 | jz 0x1234 43 | jm 0x1234 44 | jpe 0x1234 45 | call 0x1234 46 | cnc 0x1234 47 | cnz 0x1234 48 | cp 0x1234 49 | cpo 0x1234 50 | cc 0x1234 51 | cz 0x1234 52 | cm 0x1234 53 | cpe 0x1234 54 | ret 55 | rnc 56 | rnz 57 | rp 58 | rpo 59 | rc 60 | rz 61 | rm 62 | rpe 63 | rst 0x18 64 | in 6 65 | out 12 66 | hlt 67 | -------------------------------------------------------------------------------- /disasm/8048.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DISASM_8048_H 13 | #define NAKEN_ASM_DISASM_8048_H 14 | 15 | #include "common/assembler.h" 16 | #include "table/8048.h" 17 | 18 | int disasm_8048( 19 | Memory *memory, 20 | uint32_t address, 21 | char *instruction, 22 | int length, 23 | int flags, 24 | int *cycles_min, 25 | int *cycles_max); 26 | 27 | void list_output_8048( 28 | AsmContext *asm_context, 29 | uint32_t start, 30 | uint32_t end); 31 | 32 | void disasm_range_8048( 33 | Memory *memory, 34 | uint32_t flags, 35 | uint32_t start, 36 | uint32_t end); 37 | 38 | #endif 39 | 40 | -------------------------------------------------------------------------------- /disasm/mips.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2025 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DISASM_MIPS_H 13 | #define NAKEN_ASM_DISASM_MIPS_H 14 | 15 | #include "common/assembler.h" 16 | #include "table/mips.h" 17 | 18 | int disasm_mips( 19 | Memory *memory, 20 | uint32_t address, 21 | char *instruction, 22 | int length, 23 | int flags, 24 | int *cycles_min, 25 | int *cycles_max); 26 | 27 | void list_output_mips( 28 | AsmContext *asm_context, 29 | uint32_t start, 30 | uint32_t end); 31 | 32 | void disasm_range_mips( 33 | Memory *memory, 34 | uint32_t flags, 35 | uint32_t start, 36 | uint32_t end); 37 | 38 | #endif 39 | 40 | -------------------------------------------------------------------------------- /disasm/propeller.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DISASM_PROPELLER_H 13 | #define NAKEN_ASM_DISASM_PROPELLER_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int disasm_propeller( 18 | Memory *memory, 19 | uint32_t address, 20 | char *instruction, 21 | int length, 22 | int flags, 23 | int *cycles_min, 24 | int *cycles_max); 25 | 26 | void list_output_propeller( 27 | AsmContext *asm_context, 28 | uint32_t start, 29 | uint32_t end); 30 | 31 | void disasm_range_propeller( 32 | Memory *memory, 33 | uint32_t flags, 34 | uint32_t start, 35 | uint32_t end); 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /samples/f100_l/f100_l.asm: -------------------------------------------------------------------------------- 1 | .f100_l 2 | 3 | main: 4 | nop 5 | blah: 6 | add .0x1000 7 | add long 0x1000 8 | add ,0x400 9 | add 0x50 10 | add /0x60 11 | add /0x62+ 12 | add /0x63- 13 | 14 | add [0x63] 15 | add [0x63]+ 16 | add [0x63]- 17 | add [test+5] 18 | add [test]+ 19 | add [test*2]- 20 | 21 | clr #4, A 22 | clr c, A 23 | clrc 24 | clr #14, CR 25 | set #3, 0x1000 26 | 27 | halt 28 | halt 100 29 | 30 | icz /0x60, test 31 | 32 | jeq 0x1000 33 | jz 0x1000 34 | jne 0x1000 35 | jnz 0x1000 36 | jc 0x1000 37 | jnc 0x1000 38 | jn 0x1000 39 | jp 0x1000 40 | 41 | jbs #2, cr, 0x1000 42 | jcs #13, 0x50, 0x1000 43 | 44 | sra #2, a 45 | sla #13, 0x1000 46 | sre #7, 0x1020 47 | 48 | sra.d #7, a 49 | sll.d #29, cr 50 | sla.d #20, 0x1000 51 | 52 | test: 53 | 54 | -------------------------------------------------------------------------------- /disasm/agc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2024 by Michael Kohn 9 | * 10 | */ 11 | 12 | // Apollo Guidance Computer. 13 | 14 | #ifndef NAKEN_ASM_DISASM_AGC_H 15 | #define NAKEN_ASM_DISASM_AGC_H 16 | 17 | #include "common/assembler.h" 18 | 19 | int disasm_agc( 20 | Memory *memory, 21 | uint32_t address, 22 | char *instruction, 23 | int length, 24 | int flags, 25 | int *cycles_min, 26 | int *cycles_max); 27 | 28 | void list_output_agc( 29 | AsmContext *asm_context, 30 | uint32_t start, 31 | uint32_t end); 32 | 33 | void disasm_range_agc( 34 | Memory *memory, 35 | uint32_t flags, 36 | uint32_t start, 37 | uint32_t end); 38 | 39 | #endif 40 | 41 | -------------------------------------------------------------------------------- /disasm/template.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DISASM__H 13 | #define NAKEN_ASM_DISASM__H 14 | 15 | #include "common/assembler.h" 16 | 17 | Replace NAME with cpu arch 18 | 19 | int disasm_NAME( 20 | Memory *memory, 21 | uint32_t address, 22 | char *instruction, 23 | int length, 24 | int flags, 25 | int *cycles_min, 26 | int *cycles_max); 27 | 28 | void list_output_NAME( 29 | AsmContext *asm_context, 30 | uint32_t start, 31 | uint32_t end); 32 | 33 | void disasm_range_NAME( 34 | Memory *memory, 35 | uint32_t flags, 36 | uint32_t start, 37 | uint32_t end); 38 | 39 | #endif 40 | 41 | -------------------------------------------------------------------------------- /samples/dreamcast/Makefile: -------------------------------------------------------------------------------- 1 | 2 | default: 3 | ../../naken_asm -type bin -o IP.BIN IP.asm 4 | ../../naken_asm -I ../../include/dreamcast -type bin -l -o dreamcast.bin dreamcast.asm 5 | /tmp/scramble dreamcast.bin 1ST_READ.BIN 6 | mkisofs -l -C 0,11702 -V dreamcast -G IP.BIN -r -J -o dreamcast.iso 1ST_READ.BIN 7 | cdi4dc dreamcast.iso dreamcast.cdi 8 | 9 | iso: 10 | dd if=/dev/zero bs=2352 count=300 of=audio.raw 11 | mkisofs -l -C 0,11702 -o dreamcast.iso 1ST_READ.BIN 12 | ( cat IP.BIN ; dd if=dreamcast.iso bs=2048 skip=16 ) > data.raw 13 | 14 | record: iso 15 | cdrecord dev=4,0,0 -multi -audio audio.raw 16 | cdrecord dev=4,0,0 -msinfo 17 | cdrecord dev=4,0,0 -multi -xa1 -data data.raw 18 | 19 | clean: 20 | @rm -f audio.raw *.iso *.cdi *.lst *.raw dreamcast.bin IP.BIN 21 | @rm -f 1ST_READ.BIN 22 | @echo "Clean!" 23 | 24 | -------------------------------------------------------------------------------- /common/MemoryPool.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_MEMORY_POOL_H 13 | #define NAKEN_ASM_MEMORY_POOL_H 14 | 15 | #include 16 | 17 | /* 18 | address_heap buffer looks like this: 19 | struct 20 | { 21 | char name[]; 22 | int address; 23 | }; 24 | */ 25 | 26 | struct MemoryPool 27 | { 28 | MemoryPool *next; 29 | int len; 30 | int ptr; 31 | uint8_t buffer[]; 32 | }; 33 | 34 | struct NakenHeap 35 | { 36 | MemoryPool *memory_pool; 37 | }; 38 | 39 | MemoryPool *memory_pool_add(NakenHeap *heap, int heap_len); 40 | void memory_pool_free(MemoryPool *memory_pool); 41 | 42 | #endif 43 | 44 | -------------------------------------------------------------------------------- /disasm/propeller2.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DISASM_PROPELLER2_H 13 | #define NAKEN_ASM_DISASM_PROPELLER2_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int disasm_propeller2( 18 | Memory *memory, 19 | uint32_t address, 20 | char *instruction, 21 | int length, 22 | int flags, 23 | int *cycles_min, 24 | int *cycles_max); 25 | 26 | void list_output_propeller2( 27 | AsmContext *asm_context, 28 | uint32_t start, 29 | uint32_t end); 30 | 31 | void disasm_range_propeller2( 32 | Memory *memory, 33 | uint32_t flags, 34 | uint32_t start, 35 | uint32_t end); 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /disasm/avr8.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DISASM_AVR8_H 13 | #define NAKEN_ASM_DISASM_AVR8_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int get_register_avr8(const char *token); 18 | 19 | int disasm_avr8( 20 | Memory *memory, 21 | uint32_t address, 22 | char *instruction, 23 | int length, 24 | int flags, 25 | int *cycles_min, 26 | int *cycles_max); 27 | 28 | void list_output_avr8( 29 | AsmContext *asm_context, 30 | uint32_t start, 31 | uint32_t end); 32 | 33 | void disasm_range_avr8( 34 | Memory *memory, 35 | uint32_t flags, 36 | uint32_t start, 37 | uint32_t end); 38 | 39 | #endif 40 | 41 | -------------------------------------------------------------------------------- /docs/installing.md: -------------------------------------------------------------------------------- 1 | Installing 2 | ========= 3 | 4 | Compiling 5 | --------- 6 | 7 | By default the configure script will include support for all CPU's. If 8 | only a subset of CPU's is desired, the --enable- option can 9 | be added to the configure script. Type ./configure --help for all options. 10 | It's recommended that libreadline dev files are installed. If they are 11 | installed naken_util in interactive mode will allow the up-arrow to 12 | bring back previous commands. On Ubuntu/Debian this can be installed 13 | by typing: 14 | 15 | sudo apt install libreadline-dev 16 | 17 | To compile naken_asm and naken_util (the disassembler / simulator) type: 18 | 19 | ./configure 20 | make 21 | 22 | As of 2013-Feb-23 there is no installer yet. The binaries can be copied 23 | to /usr/local/bin. This will be fixed later. 24 | 25 | -------------------------------------------------------------------------------- /samples/arm/testing.asm: -------------------------------------------------------------------------------- 1 | .arm 2 | 3 | mov r0, #0xffffffff 4 | ;add r0, r0, #2 5 | add r0, r0, r1 6 | swi 7 | swilt 8 | 9 | swp r0, r1, [r2] 10 | mrs r0, cpsr 11 | mrs r1, spsr 12 | 13 | msr cpsr, r0 14 | msr cpsr, #68 15 | msr cpsr, #32768 16 | msr cpsr, #65536 17 | msr cpsr, #128, 2 18 | 19 | mov r5, #256 20 | mov r5, #128, 2 21 | orr r5, r6, #256 22 | orr r5, r6, #128, 2 23 | 24 | main: 25 | orr r5, r6, r7 26 | orr r5, r6, r7, lsl r0 27 | orr r5, r6, r7, ror #5 28 | 29 | mul r1, r2, r3 30 | mla r1, r2, r3, r4 31 | 32 | ldm r6, { r1, r2, r6-r8 } 33 | stm r6, { r1, r2, r6-r8 } 34 | stm r6, { r0, r1, r2, r6-r8 } 35 | stm r6!, { r0-r2, r6-r8 } 36 | 37 | ldr r6, [r7] 38 | str r7, [r8] 39 | str r7, 12 40 | 41 | b main 42 | 43 | ; FIXME 44 | ;str r7, [r1,r2, lsl #2] 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /disasm/6502.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn, Joe Davisson 9 | * 10 | * 6502 file by Joe Davisson 11 | * 12 | */ 13 | 14 | #ifndef NAKEN_ASM_DISASM_6502_H 15 | #define NAKEN_ASM_DISASM_6502_H 16 | 17 | #include "common/assembler.h" 18 | 19 | int disasm_6502( 20 | Memory *memory, 21 | uint32_t address, 22 | char *instruction, 23 | int length, 24 | int flags, 25 | int *cycles_min, 26 | int *cycles_max); 27 | 28 | void list_output_6502( 29 | AsmContext *asm_context, 30 | uint32_t start, 31 | uint32_t end); 32 | 33 | void disasm_range_6502( 34 | Memory *memory, 35 | uint32_t flags, 36 | uint32_t start, 37 | uint32_t end); 38 | 39 | #endif 40 | 41 | -------------------------------------------------------------------------------- /disasm/pdp8.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn, Lars Brinkhoff 9 | * 10 | * PDP-8 by Lars Brinkhoff 11 | * 12 | */ 13 | 14 | #ifndef NAKEN_ASM_DISASM_PDP8_H 15 | #define NAKEN_ASM_DISASM_PDP8_H 16 | 17 | #include "common/assembler.h" 18 | 19 | int disasm_pdp8( 20 | Memory *memory, 21 | uint32_t address, 22 | char *instruction, 23 | int length, 24 | int flags, 25 | int *cycles_min, 26 | int *cycles_max); 27 | 28 | void list_output_pdp8( 29 | AsmContext *asm_context, 30 | uint32_t start, 31 | uint32_t end); 32 | 33 | void disasm_range_pdp8( 34 | Memory *memory, 35 | uint32_t flags, 36 | uint32_t start, 37 | uint32_t end); 38 | 39 | #endif 40 | 41 | -------------------------------------------------------------------------------- /tests/comparison/template/pic14.txt: -------------------------------------------------------------------------------- 1 | addwf 0x13, w 2 | addwf 0x63, f 3 | andwf 0x34, w 4 | andwf 0x64, f 5 | clrf 0x23 6 | clrw 7 | comf 0x73, w 8 | comf 0x23, f 9 | decf 0x54, w 10 | decf 0x31, f 11 | decfsz 0x32, w 12 | decfsz 0x12, f 13 | incf 0x71, w 14 | incf 0x72, f 15 | incfsz 0x53, w 16 | incfsz 0x51, f 17 | iorwf 0x38, w 18 | iorwf 0x39, f 19 | movf 0x3b, w 20 | movf 0x3b, f 21 | movwf 0x7c 22 | nop 23 | rlf 0x1f, w 24 | rlf 0x1f, f 25 | rrf 0x5d, w 26 | rrf 0x5d, f 27 | subwf 0x6c, w 28 | subwf 0x6b, f 29 | swapf 0x4c, w 30 | swapf 0x4f, f 31 | xorwf 0x72, w 32 | xorwf 0x7a, f 33 | bcf 0x32, 7 34 | bsf 0x10, 1 35 | btfsc 0x7f, 2 36 | btfss 0x51, 4 37 | addlw 0x91 38 | andlw 0x93 39 | main: call main 40 | clrwdt 41 | main: goto main 42 | iorlw 0x34 43 | movlw 0x11 44 | retfie 45 | retlw 0x33 46 | return 47 | sleep 48 | sublw 0xff 49 | xorlw 0x23 50 | -------------------------------------------------------------------------------- /common/imports_ar.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_IMPORTS_AR_H 13 | #define NAKEN_ASM_IMPORTS_AR_H 14 | 15 | int imports_ar_verify(uint8_t *buffer, int file_size); 16 | 17 | int imports_ar_read(uint8_t *buffer, int file_size); 18 | 19 | int imports_ar_find_code_from_symbol( 20 | uint8_t *buffer, 21 | int file_size, 22 | const char *symbol, 23 | uint32_t *function_offset, 24 | uint32_t *function_size, 25 | uint32_t *file_offset, 26 | uint8_t **obj_file, 27 | uint32_t *obj_size); 28 | 29 | const char *imports_ar_find_name_from_offset( 30 | uint8_t *buffer, 31 | int file_size, 32 | uint32_t offset); 33 | 34 | #endif 35 | 36 | -------------------------------------------------------------------------------- /table/1802.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_TABLE_1802_H 13 | #define NAKEN_ASM_TABLE_1802_H 14 | 15 | #include 16 | 17 | enum 18 | { 19 | RCA1802_OP_ILLEGAL, 20 | RCA1802_OP_NONE, 21 | RCA1802_OP_REG, 22 | RCA1802_OP_NUM_1_TO_7, 23 | RCA1802_OP_IMMEDIATE, 24 | RCA1802_OP_BRANCH, 25 | RCA1802_OP_LONG_BRANCH, 26 | RCA1802_OP_REG_BRANCH, 27 | }; 28 | 29 | struct _table_1802 30 | { 31 | const char *instr; 32 | uint8_t opcode; 33 | uint8_t mask; 34 | uint8_t type; 35 | uint8_t cycles; 36 | }; 37 | 38 | extern struct _table_1802 table_1802[]; 39 | extern struct _table_1802 table_1802_16[]; 40 | 41 | #endif 42 | 43 | -------------------------------------------------------------------------------- /table/8008.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2022 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_TABLE_8008_H 13 | #define NAKEN_ASM_TABLE_8008_H 14 | 15 | #include "common/assembler.h" 16 | 17 | enum 18 | { 19 | OP_NONE, 20 | OP_SREG, 21 | OP_DREG, 22 | OP_DREG_NOT_A, 23 | OP_REG_REG, 24 | OP_REG_M, 25 | OP_M_REG, 26 | OP_M, 27 | OP_ADDRESS, 28 | OP_IMMEDIATE, 29 | OP_M_IMMEDIATE, 30 | OP_REG_IMMEDIATE, 31 | OP_SUB, 32 | OP_PORT_MMM, 33 | OP_PORT_MMM_NOT_0, 34 | }; 35 | 36 | struct _table_8008 37 | { 38 | const char *instr; 39 | uint8_t opcode; 40 | uint8_t mask; 41 | uint8_t type; 42 | }; 43 | 44 | extern struct _table_8008 table_8008[]; 45 | 46 | #endif 47 | 48 | -------------------------------------------------------------------------------- /table/propeller.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_TABLE_PROPELLER_H 13 | #define NAKEN_ASM_TABLE_PROPELLER_H 14 | 15 | #include 16 | 17 | enum 18 | { 19 | PROPELLER_OP_NONE, 20 | PROPELLER_OP_NOP, 21 | PROPELLER_OP_DS, 22 | PROPELLER_OP_DS_15_1, 23 | PROPELLER_OP_DS_15_2, 24 | PROPELLER_OP_S, 25 | PROPELLER_OP_D, 26 | PROPELLER_OP_IMMEDIATE, 27 | }; 28 | 29 | struct _table_propeller 30 | { 31 | const char *instr; 32 | uint32_t opcode; 33 | uint32_t mask; 34 | uint8_t type; 35 | int8_t cycles_min; 36 | int8_t cycles_max; 37 | }; 38 | 39 | extern struct _table_propeller table_propeller[]; 40 | 41 | #endif 42 | 43 | -------------------------------------------------------------------------------- /table/pdk13.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_TABLE_PDK13_H 13 | #define NAKEN_ASM_TABLE_PDK13_H 14 | 15 | #include "common/assembler.h" 16 | 17 | enum 18 | { 19 | OP_NONE, 20 | OP_A, 21 | OP_IO_A, 22 | OP_A_IO, 23 | OP_M, 24 | OP_M4, 25 | OP_K8, 26 | OP_A_M, 27 | OP_M_A, 28 | OP_A_M4, 29 | OP_M4_A, 30 | OP_IO_N, 31 | OP_M_N, 32 | OP_A_K, 33 | OP_K10, 34 | }; 35 | 36 | struct _table_pdk13 37 | { 38 | const char *instr; 39 | uint16_t opcode; 40 | uint16_t mask; 41 | uint8_t type; 42 | uint8_t cycles_min; 43 | uint8_t cycles_max; 44 | }; 45 | 46 | extern struct _table_pdk13 table_pdk13[]; 47 | 48 | #endif 49 | 50 | -------------------------------------------------------------------------------- /table/pdk14.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_TABLE_PDK14_H 13 | #define NAKEN_ASM_TABLE_PDK14_H 14 | 15 | #include "common/assembler.h" 16 | 17 | enum 18 | { 19 | OP_NONE, 20 | OP_A, 21 | OP_IO_A, 22 | OP_A_IO, 23 | OP_M6, 24 | OP_M, 25 | OP_A_M6, 26 | OP_M6_A, 27 | OP_A_M, 28 | OP_M_A, 29 | OP_A_K, 30 | OP_IO_N, 31 | OP_M_N, 32 | OP_K8, 33 | OP_K11, 34 | }; 35 | 36 | struct _table_pdk14 37 | { 38 | const char *instr; 39 | uint16_t opcode; 40 | uint16_t mask; 41 | uint8_t type; 42 | uint8_t cycles_min; 43 | uint8_t cycles_max; 44 | }; 45 | 46 | extern struct _table_pdk14 table_pdk14[]; 47 | 48 | #endif 49 | 50 | -------------------------------------------------------------------------------- /table/pdk15.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_TABLE_PDK15_H 13 | #define NAKEN_ASM_TABLE_PDK15_H 14 | 15 | #include "common/assembler.h" 16 | 17 | enum 18 | { 19 | OP_NONE, 20 | OP_A, 21 | OP_IO_A, 22 | OP_A_IO, 23 | OP_K8, 24 | OP_M7, 25 | OP_M8, 26 | OP_A_M8, 27 | OP_M8_A, 28 | OP_A_M7, 29 | OP_M7_A, 30 | OP_IO_N, 31 | OP_M_N, 32 | OP_A_K, 33 | OP_K12, 34 | }; 35 | 36 | struct _table_pdk15 37 | { 38 | const char *instr; 39 | uint16_t opcode; 40 | uint16_t mask; 41 | uint8_t type; 42 | uint8_t cycles_min; 43 | uint8_t cycles_max; 44 | }; 45 | 46 | extern struct _table_pdk15 table_pdk15[]; 47 | 48 | #endif 49 | 50 | -------------------------------------------------------------------------------- /common/add_bin.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ADD_BIN_H 13 | #define NAKEN_ASM_ADD_BIN_H 14 | 15 | #include 16 | 17 | #include "assembler.h" 18 | 19 | #define IS_DATA 0 20 | #define IS_OPCODE 1 21 | 22 | void add_bin8(AsmContext *asm_context, uint8_t b, int flags); 23 | void add_bin16(AsmContext *asm_context, uint16_t b, int flags); 24 | //void add_bin24(AsmContext *asm_context, uint32_t b, int flags); 25 | void add_bin32(AsmContext *asm_context, uint32_t b, int flags); 26 | int add_bin_varuint(AsmContext *asm_context, uint64_t b, int fixed_size); 27 | int add_bin_varint(AsmContext *asm_context, uint64_t b, int fixed_size); 28 | 29 | #endif 30 | 31 | -------------------------------------------------------------------------------- /disasm/65816.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn, Joe Davisson 9 | * 10 | * 65816 by Joe Davisson 11 | * 12 | */ 13 | 14 | #ifndef NAKEN_ASM_DISASM_65816_H 15 | #define NAKEN_ASM_DISASM_65816_H 16 | 17 | #include 18 | 19 | #include "common/assembler.h" 20 | 21 | int disasm_65816( 22 | Memory *memory, 23 | uint32_t address, 24 | char *instruction, 25 | int length, 26 | int flags, 27 | int *cycles_min, 28 | int *cycles_max); 29 | 30 | void list_output_65816( 31 | AsmContext *asm_context, 32 | uint32_t start, 33 | uint32_t end); 34 | 35 | void disasm_range_65816( 36 | Memory *memory, 37 | uint32_t flags, 38 | uint32_t start, 39 | uint32_t end); 40 | 41 | #endif 42 | 43 | -------------------------------------------------------------------------------- /scripts/graveyard/create_hex.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | fp = open("m8c_start.txt", "r") 4 | 5 | for line in fp: 6 | line = line.strip() 7 | 8 | instruction = line.split()[2:] 9 | data = line.split()[1] 10 | 11 | instruction = " ".join(instruction) 12 | 13 | #print(instruction + " " + data) 14 | 15 | opcodes = [] 16 | 17 | for a in range(0, len(data), 2): 18 | opcodes.append(data[a:a+2]) 19 | 20 | #print(instruction + " " + str(opcodes)) 21 | 22 | hex_line = ":%02X000000" % (len(opcodes)) 23 | 24 | checksum = len(opcodes) 25 | 26 | for opcode in opcodes: 27 | hex_line += opcode.upper() 28 | value = int(opcode, 16) 29 | checksum += value 30 | 31 | checksum = -(checksum & 0xff) 32 | checksum = checksum & 0xff 33 | 34 | hex_line += "%02X" % (checksum) 35 | 36 | print(instruction + "|" + hex_line) 37 | 38 | fp.close() 39 | 40 | -------------------------------------------------------------------------------- /table/pic18.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_TABLE_PIC18_H 13 | #define NAKEN_ASM_TABLE_PIC18_H 14 | 15 | #include "common/assembler.h" 16 | 17 | enum 18 | { 19 | OP_NONE, 20 | OP_F_D_A, 21 | OP_F_A, 22 | OP_FS_FD, 23 | OP_F_B_A, 24 | OP_BRANCH_8, 25 | OP_BRANCH_11, 26 | OP_CALL, 27 | OP_GOTO, 28 | OP_S, 29 | OP_K8, 30 | OP_F_K12, 31 | OP_K4, 32 | }; 33 | 34 | struct _table_pic18 35 | { 36 | const char *instr; 37 | uint16_t opcode; 38 | uint16_t mask; 39 | uint8_t type; 40 | uint8_t default_a; 41 | int8_t cycles_min; 42 | int8_t cycles_max; 43 | }; 44 | 45 | extern struct _table_pic18 table_pic18[]; 46 | 47 | #endif 48 | 49 | -------------------------------------------------------------------------------- /tests/comparison/template/1802.txt: -------------------------------------------------------------------------------- 1 | idl 2 | ldn 9 3 | inc D 4 | dec 8 5 | br 191 6 | bq 106 7 | bz 61 8 | bdf 8 9 | b1 216 10 | b2 244 11 | b3 124 12 | b4 194 13 | skp 14 | bnq 157 15 | bnz 6 16 | bnf 221 17 | bn1 146 18 | bn2 237 19 | bn3 100 20 | bn4 161 21 | lda 7 22 | str 9 23 | irx 24 | out 3 25 | inp 1 26 | ret 27 | dis 28 | ldxa 29 | stxd 30 | adc 31 | sdb 32 | shrc 33 | smb 34 | sav 35 | mark 36 | req 37 | seq 38 | adci 14 39 | sdbi 54 40 | shlc 41 | smbi 7 42 | glo D 43 | ghi 4 44 | plo D 45 | phi F 46 | lbr 49782 47 | lbq 62210 48 | lbz 34093 49 | lbdf 36255 50 | nop 51 | lsnq 52 | lsnz 53 | lsnf 54 | lskp 55 | lbnq 10321 56 | lbnz 21195 57 | lbnf 18890 58 | lsie 59 | lsq 60 | lsz 61 | lsdf 62 | sep C 63 | sex 8 64 | ldx 65 | or 66 | and 67 | xor 68 | add 69 | sd 70 | shr 71 | sm 72 | ldi 164 73 | ori 99 74 | ani 214 75 | xri 91 76 | adi 247 77 | sdi 154 78 | shl 79 | smi 12 80 | -------------------------------------------------------------------------------- /tests/comparison/template/f8.txt: -------------------------------------------------------------------------------- 1 | ins 4 2 | in 129 3 | outs 3 4 | out 230 5 | lm 6 | st 7 | lr a, 3 8 | lr s, a 9 | lr a, ql 10 | lr kl, a 11 | lr h, dc0 12 | lr q, dc0 13 | lr dc0, h 14 | lr dc0, q 15 | lr k, pc1 16 | lr pc1, k 17 | lr pc0, q 18 | pk 19 | as I 20 | asd 4 21 | ns 5 22 | xs 1 23 | ds 8 24 | am 25 | amd 26 | nm 27 | om 28 | xm 29 | cm 30 | lisu 4 31 | lisl 5 32 | dci 500 33 | lis 9 34 | li 127 35 | ai 129 36 | ni 131 37 | oi 155 38 | xi 201 39 | ci 23 40 | pi 1025 41 | main: br main 42 | jmp 2033 43 | main: bt 3, main 44 | main: bf 5, main 45 | main: bp main 46 | main: bc main 47 | main: bz main 48 | main: bm main 49 | main: bnc main 50 | main: bnz main 51 | main: bno main 52 | main: br7 main 53 | xdc 54 | lr a, is 55 | lr is, a 56 | pop 57 | adc 58 | sr 1 59 | sr 4 60 | sl 1 61 | sl 4 62 | com 63 | lnk 64 | inc 65 | clr 66 | di 67 | ei 68 | lr w, j 69 | lr j, w 70 | nop 71 | -------------------------------------------------------------------------------- /scripts/graveyard/mips_i.txt: -------------------------------------------------------------------------------- 1 | addi rt, rs, immediate 001000 2 | addiu rt, rs, immediate 001001 3 | andi rt, rs, immediate 001100 4 | beq rs, rt, label 000100 5 | bgez rs, label, rt=00001 000001 6 | bgtz rs, label, rt=00000 000111 7 | blez rs, label, rt=00000 000110 8 | bltz rs, label, rt=00000 000001 9 | bne rs, rt, label 000101 10 | lb rt, immediate(rs) 100000 11 | lbu rt, immediate(rs) 100100 12 | lh rt, immediate(rs) 100001 13 | lhu rt, immediate(rs) 100101 14 | lui rt, immediate 001111 15 | lw rt, immediate(rs) 100011 16 | lwc1 rt, immediate(rs) 110001 17 | ori rt, rs, immediate 001101 18 | sb rt, immediate(rs) 101000 19 | slti rt, rs, immediate 001010 20 | sltiu rt, rs, immediate 001011 21 | sh rt, immediate(rs) 101001 22 | sw rt, immediate(rs) 101011 23 | swc1 rt, immediate(rs) 111001 24 | xori rt, rs, immediate 001110 25 | -------------------------------------------------------------------------------- /samples/dreamcast/IP.asm: -------------------------------------------------------------------------------- 1 | .org 0 2 | 3 | .binfile "/tmp/IP.TMPL" 4 | 5 | .org 0 6 | 7 | ;; Hardware ID 8 | .db "SEGA SEGAKATANA " 9 | 10 | ;; Maker ID 11 | .db "SEGA ENTERPRISES" 12 | 13 | ;; Device Information 14 | .db "0000 GD-ROM1/1 " 15 | 16 | ;; Area Symbols (J=Japan, U=USA/Canada, E=Europe) 17 | .db "JUE " 18 | 19 | ;; Peripherals 20 | .db "1fff000 " 21 | 22 | ;; Product number / Product version 23 | .db "HDR-0000 " 24 | .db " " 25 | 26 | ;; Release date 27 | .db "20200307 " 28 | 29 | ;; Boot filename 30 | .db "1ST_READ.BIN " 31 | 32 | ;; Name of the company that produced the disc 33 | .db "naken_asm " 34 | 35 | ;; Name of the software 36 | .db "Dreamcast Test " 37 | .db " " 38 | .db " " 39 | .db " " 40 | .db " " 41 | .db " " 42 | .db " " 43 | .db " " 44 | 45 | -------------------------------------------------------------------------------- /samples/epiphany/testing.asm: -------------------------------------------------------------------------------- 1 | .epiphany 2 | 3 | main: 4 | add r5,r6,r7 5 | bne blah 6 | beq main 7 | blah: 8 | 9 | ldr r5,[r6,#3] 10 | str r5,[r6] 11 | ldrb r5,[r7,#-3] 12 | ldrd r5,[r7,#8] 13 | 14 | ldr r5,[r6,r6] 15 | ldr r5,[r6,r1] 16 | ldr r5,[r6,-r6] 17 | ldr r5,[r6,r8] 18 | 19 | ldr r5,[r6],r2 20 | ldr r5,[r6],r3 21 | ldr r5,[r6],r8 22 | ldr r5,[r6],-r2 23 | 24 | ldrb r5, [r7], #100 25 | ldrb r5, [r7], #-200 26 | 27 | mov r5, #100 28 | mov r33, #100 29 | mov r33, #0xff 30 | mov r5, #-1 31 | 32 | add r5,r6,#2 33 | add r5,r6,#-4 34 | add r5,r6,#-1024 35 | add r5,r6,#1000 36 | 37 | lsr r5,r6,#10 38 | lsr r30,r40,#10 39 | 40 | jr r5 41 | jr r30 42 | jalr r5 43 | jalr r30 44 | 45 | gie 46 | gid 47 | nop 48 | idle 49 | bkpt 50 | mbkpt 51 | sync 52 | rti 53 | wand 54 | trap 60 55 | 56 | moveq r5, r7 57 | 58 | 59 | -------------------------------------------------------------------------------- /table/pdk16.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_TABLE_PDK16_H 13 | #define NAKEN_ASM_TABLE_PDK16_H 14 | 15 | #include "common/assembler.h" 16 | 17 | enum 18 | { 19 | OP_NONE, 20 | OP_A, 21 | OP_K5, 22 | OP_N4, 23 | OP_IO_A, 24 | OP_A_IO, 25 | OP_M8, 26 | OP_K8, 27 | OP_A_M9, 28 | OP_M9_A, 29 | OP_A_M8, 30 | OP_M8_A, 31 | OP_A_K, 32 | OP_M9, 33 | OP_IO_N, 34 | OP_M_N, 35 | OP_K13, 36 | }; 37 | 38 | struct _table_pdk16 39 | { 40 | const char *instr; 41 | uint16_t opcode; 42 | uint16_t mask; 43 | uint8_t type; 44 | uint8_t cycles_min; 45 | uint8_t cycles_max; 46 | }; 47 | 48 | extern struct _table_pdk16 table_pdk16[]; 49 | 50 | #endif 51 | 52 | -------------------------------------------------------------------------------- /docs/MSP430.md: -------------------------------------------------------------------------------- 1 | 2 | MSP430 3 | ====== 4 | 5 | RPT Instruction 6 | --------------- 7 | 8 | It was difficult to find good documentation on how the RPT instruction 9 | is supposed to work so naken_asm uses the following syntax: 10 | 11 | rpt #5, rrum.a #2, r9 12 | rptz #5, rrum.a #2, r9 13 | rptc #5, rrum.a #2, r9 14 | rpt r4, rrum.a #2, r9 15 | rptz r4, rrum.a #2, r9 16 | rptc r4, rrum.a #2, r9 17 | 18 | Optimizations 19 | ------------- 20 | 21 | If the -optimize command line argument is set, currently the only thing 22 | that will get optimized is a first operand that is using the indexed 23 | mode where the index is 0 will get optimized to register indirect. An 24 | example is: 25 | 26 | mov.w 0(r4), r6 27 | 28 | will be optimized to: 29 | 30 | mov.w @r4, r6 31 | 32 | There are cases where 0(r4) is preferred so the optimization is not turned 33 | on by default. 34 | 35 | -------------------------------------------------------------------------------- /table/sparc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_TABLE_SPARC_H 13 | #define NAKEN_ASM_TABLE_SPARC_H 14 | 15 | #include "common/assembler.h" 16 | 17 | enum 18 | { 19 | OP_NONE, 20 | OP_REG_REG_REG, 21 | OP_REG_SIMM13_REG, 22 | OP_FREG_FREG_FREG_FREG, 23 | OP_FREG_FREG_IMM5_FREG, 24 | OP_FREG_FREG_FREG, 25 | OP_BRANCH, 26 | OP_BRANCH_P, 27 | OP_BRANCH_P_REG, 28 | OP_CALL, 29 | OP_IMM_ASI_REG_REG, 30 | OP_ASI_REG_REG, 31 | }; 32 | 33 | struct _table_sparc 34 | { 35 | const char *instr; 36 | uint32_t opcode; 37 | uint8_t type; 38 | uint8_t flags; 39 | }; 40 | 41 | extern struct _table_sparc table_sparc[]; 42 | extern uint32_t mask_sparc[]; 43 | 44 | #endif 45 | 46 | -------------------------------------------------------------------------------- /common/directives_data.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DIRECTIVES_DATA_H 13 | #define NAKEN_ASM_DIRECTIVES_DATA_H 14 | 15 | #include "common/assembler.h" 16 | 17 | int parse_db(AsmContext *asm_context, int null_term_flag); 18 | int parse_dc16(AsmContext *asm_context); 19 | int parse_dc32(AsmContext *asm_context); 20 | int parse_dc64(AsmContext *asm_context); 21 | //int parse_dc(AsmContext *asm_context); 22 | int parse_data_fill(AsmContext *asm_context); 23 | int parse_varuint(AsmContext *asm_context, int fixed_size); 24 | int parse_resb(AsmContext *asm_context, int size); 25 | int parse_align_bits(AsmContext *asm_context); 26 | int parse_align_bytes(AsmContext *asm_context); 27 | 28 | #endif 29 | 30 | -------------------------------------------------------------------------------- /disasm/ps2_ee_vu.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_DISASM_PS2_EE_VU_H 13 | #define NAKEN_ASM_DISASM_PS2_EE_VU_H 14 | 15 | #include "common/assembler.h" 16 | #include "table/ps2_ee_vu.h" 17 | 18 | #define PS2_EE_VU0 0 19 | #define PS2_EE_VU1 1 20 | 21 | int disasm_ps2_ee_vu( 22 | Memory *memory, 23 | uint32_t address, 24 | char *instruction, 25 | int length, 26 | int flags, 27 | int *cycles_min, 28 | int *cycles_max); 29 | 30 | void list_output_ps2_ee_vu( 31 | AsmContext *asm_context, 32 | uint32_t start, 33 | uint32_t end); 34 | 35 | void disasm_range_ps2_ee_vu( 36 | Memory *memory, 37 | uint32_t flags, 38 | uint32_t start, 39 | uint32_t end); 40 | 41 | #endif 42 | 43 | -------------------------------------------------------------------------------- /include/playstation2/registers_gs_priv.inc: -------------------------------------------------------------------------------- 1 | ;; 2 | ;; Playstation 2 Graphics Synthesizer Priviliged Registers 3 | ;; 4 | ;; A part of the naken_asm assembler 5 | ;; 6 | ;; For more information: 7 | ;; https://www.mikekohn.net/ 8 | ;; 9 | 10 | ;; GS privileged registers 11 | ;; These registers are accessed directly through the EE 12 | 13 | GS_PMODE equ 0x1200_0000 14 | GS_SMODE1 equ 0x1200_0010 15 | GS_SMODE2 equ 0x1200_0020 16 | GS_SRFSH equ 0x1200_0030 17 | GS_SYNCH1 equ 0x1200_0040 18 | GS_SYNCH2 equ 0x1200_0050 19 | GS_SYNCV equ 0x1200_0060 20 | GS_DISPFB1 equ 0x1200_0070 21 | GS_DISPLAY1 equ 0x1200_0080 22 | GS_DISPFB2 equ 0x1200_0090 23 | GS_DISPLAY2 equ 0x1200_00a0 24 | GS_EXTBUF equ 0x1200_00b0 25 | GS_EXTDATA equ 0x1200_00c0 26 | GS_EXTWRITE equ 0x1200_00d0 27 | GS_BGCOLOR equ 0x1200_00e0 28 | GS_CSR equ 0x1200_1000 29 | GS_IMR equ 0x1200_1010 30 | GS_BUSDIR equ 0x1200_1040 31 | GS_SIGLBLID equ 0x1200_1080 32 | 33 | -------------------------------------------------------------------------------- /table/tms9900.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_TABLE_TMS9900_H 13 | #define NAKEN_ASM_TABLE_TMS9900_H 14 | 15 | #include "common/assembler.h" 16 | 17 | enum 18 | { 19 | OP_DUAL, 20 | OP_DUAL_MULTIPLE, 21 | OP_XOP, 22 | OP_SINGLE, 23 | OP_CRU_MULTIBIT, 24 | OP_CRU_SINGLEBIT, 25 | OP_JUMP, 26 | OP_SHIFT, 27 | OP_IMMEDIATE, 28 | OP_INT_REG_LD, 29 | OP_INT_REG_ST, 30 | OP_RTWP, 31 | OP_EXTERNAL, 32 | }; 33 | 34 | struct _table_tms9900 35 | { 36 | const char *instr; 37 | unsigned short int opcode; 38 | unsigned char type; 39 | unsigned char cycles_min; 40 | unsigned char cycles_max; 41 | }; 42 | 43 | extern struct _table_tms9900 table_tms9900[]; 44 | 45 | #endif 46 | 47 | -------------------------------------------------------------------------------- /include/amiga/mathffp.inc: -------------------------------------------------------------------------------- 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2 | ;; 3 | ;; Amiga mathffp.library include file 4 | ;; Part of the naken_asm assembler 5 | ;; 6 | ;; Generated by: Michael Kohn (mike@mikekohn.net) 7 | ;; Date: 2019-Jan-01 8 | ;; 9 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 10 | 11 | ;; mathffp.library 12 | 13 | SPFix equ -30 ; SPFix (float)(DO) 14 | SPFlt equ -36 ; SPFlt (integer)(DO) 15 | SPCmp equ -42 ; SPCmp (leftFloat.rightFloat)(D1,DO) 16 | SPTst equ -48 ; SPTst (float)(Dl) 17 | SPAbs equ -54 ; SPAbs (float)(DO) 18 | SPNeg equ -60 ; SPNeg (float)(DO) 19 | SPAdd equ -66 ; SPAdd (leftFloat,rightFloat) (D1,DO) 20 | SPSub equ -72 ; SPSub (leftFloat,rightFloat) (D1,DO) 21 | SPMul equ -78 ; SPMul (leftFloat,rightFloat) (D1,DO) 22 | SPDiv equ -84 ; SPDiv (leftFloat,rightFloat) (D1,DO) 23 | 24 | -------------------------------------------------------------------------------- /tests/comparison/scripts/gen_8051.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import os, sys 4 | 5 | def create_asm(instruction): 6 | out = open("temp.asm", "w") 7 | out.write(" " + instruction + "\n") 8 | out.write("END\n") 9 | out.close() 10 | 11 | # --------------------------------- fold here ------------------------------- 12 | 13 | fp = open("template/8051.txt", "r") 14 | out = open("8051.txt", "w") 15 | 16 | for instruction in fp: 17 | instruction = instruction.strip() 18 | print(instruction) 19 | create_asm(instruction) 20 | 21 | a = os.system("c51asm temp.asm") 22 | 23 | if a != 0: 24 | print("Error! Quitting.. on " + instruction) 25 | sys.exit(-1) 26 | 27 | fp1 = open("temp.hex", "r") 28 | hex = fp1.readline().strip() 29 | out.write(instruction + "|" + hex + "\n") 30 | fp1.close 31 | 32 | 33 | os.remove("temp.hex") 34 | 35 | fp.close() 36 | out.close() 37 | 38 | os.remove("temp.asm") 39 | 40 | -------------------------------------------------------------------------------- /asm/common.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_ASM_COMMON_H 13 | #define NAKEN_ASM_ASM_COMMON_H 14 | 15 | #include 16 | 17 | #include "common/add_bin.h" 18 | #include "common/assembler.h" 19 | #include "common/tokens.h" 20 | 21 | int ignore_operand(AsmContext *asm_context); 22 | int ignore_paren_expression(AsmContext *asm_context); 23 | int ignore_line(AsmContext *asm_context); 24 | void lower_copy(char *d, const char *s); 25 | int expect_token(AsmContext *asm_context, char ch); 26 | int expect_token_s(AsmContext *asm_context, const char *s); 27 | int check_range(AsmContext *asm_context, const char *type, int num, int min, int max); 28 | int get_reg_number(const char *token, int max); 29 | 30 | #endif 31 | 32 | -------------------------------------------------------------------------------- /scripts/graveyard/lsfr.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | address_to_lsfr = { } 4 | lsfr_to_address = { } 5 | 6 | lsfr = 0 7 | 8 | for address in range(0, 64): 9 | address_to_lsfr[address] = lsfr 10 | lsfr_to_address[lsfr] = address 11 | 12 | b5 = (lsfr >> 5) & 1 13 | b4 = (lsfr >> 4) & 1 14 | b0 = (b5 ^ b4) ^ 1 15 | 16 | if lsfr == 0x1f: b0 = 1 17 | elif lsfr == 0x3f: b0 = 0 18 | 19 | #print "%02x %d %d -> %d" % (lsfr, b5, b4, b0) 20 | 21 | lsfr = (lsfr << 1) & 0x3f 22 | lsfr |= b0 23 | 24 | #lsfr_to_address[lsfr] = address 25 | 26 | print "uint8_t address_to_lsfr[] =" 27 | print "{" 28 | 29 | for i in range(0, 64): 30 | if (i % 8) == 0: print 31 | print "0x%02x," % address_to_lsfr[i], 32 | 33 | print "};" 34 | 35 | print "uint8_t lsfr_to_address[] =" 36 | print "{" 37 | 38 | for i in range(0, 64): 39 | if (i % 8) == 0: print 40 | print "0x%02x," % lsfr_to_address[i], 41 | 42 | print "};" 43 | 44 | 45 | -------------------------------------------------------------------------------- /table/m8c.h: -------------------------------------------------------------------------------- 1 | /** 2 | * naken_asm assembler. 3 | * Author: Michael Kohn 4 | * Email: mike@mikekohn.net 5 | * Web: https://www.mikekohn.net/ 6 | * License: GPLv3 7 | * 8 | * Copyright 2010-2023 by Michael Kohn 9 | * 10 | */ 11 | 12 | #ifndef NAKEN_ASM_TABLE_M8C_H 13 | #define NAKEN_ASM_TABLE_M8C_H 14 | 15 | #include "common/assembler.h" 16 | 17 | enum 18 | { 19 | OP_NONE, 20 | OP_A, 21 | OP_X, 22 | OP_F, 23 | OP_SP, 24 | OP_EXPR, 25 | OP_INDEX_EXPR, 26 | OP_INDEX_X_EXPR, 27 | //OP_INDEX_EXPR_INC, 28 | OP_REG_INDEX_EXPR, 29 | OP_REG_INDEX_X_EXPR, 30 | OP_EXPR_S12, 31 | OP_EXPR_S12_JUMP, 32 | OP_EXPR_U16, 33 | }; 34 | 35 | struct _table_m8c 36 | { 37 | const char *instr; 38 | uint8_t opcode; 39 | uint8_t mask; 40 | uint8_t operand_0; 41 | uint8_t operand_1; 42 | uint8_t byte_count; 43 | uint8_t cycles; 44 | }; 45 | 46 | extern struct _table_m8c table_m8c[]; 47 | 48 | #endif 49 | 50 | --------------------------------------------------------------------------------