Giter Club home page Giter Club logo

simavr-sap's Introduction

simavr_sap_emulator - Atmel AVR atmega328p simulator for FIT SAP LCD 1602 keypad board

Precompiled simulator & tools for macOS arm64 and Linux x86_64 here

image

Compiling ASM code using avra (avrasm2 is also supported)

avra program.asm

Example program

Please only define .org 0 and always include pritnlib.inc after

.include "asm/m328Pdef.inc"

; Zacatek programu - po resetu
.org 0
    jmp start

; podprogramy pro praci s displejem
.include "asm/printlib.inc"

; Zacatek programu - hlavni program
start:
    ; Inicializace displeje
    call init_disp
    
    ; *** ZDE muzeme psat nase instrukce
    ldi r16, '0'    ; znak
    ldi r17, 0      ; pozice (0x00-0x0f - prvni radek; 0x40-0x4f - druhy radek)
    call show_char  ; zobraz znak z R16 na pozici z R17

end: jmp end        ; Zastavime program - nekonecna smycka

Running the simulator

simavr_sap_emulator program.hex

VSCode bindings

.vscode/tasks.json

CMD + SHIFT + B now builds active .asm file

{
    "version": "2.0.0",
    "tasks": [
      {
        "label": "Assembler",
        "type": "shell",
        "command": "avra ${file}",
        "problemMatcher": {
          "base": "$gcc",
          "fileLocation": [
            "relative",
          ]
        },
        "group": {
          "kind": "build",
          "isDefault": true
        }
      },
      {
        "label": "Emulate",
        "type": "shell",
        "command": "simavr_sap_emulator ${fileDirname}/${fileBasenameNoExtension}.hex",
        "problemMatcher": [],
        "group": {
          "kind": "test",
          "isDefault": true
        }
      }
    ]
  }

GDB

simavr_sap_emulator program.hex -d
avr-gdb -q -n -ex 'target remote 127.0.0.1:1234'

GDB Dashboard

gdb Dashboard

Setup

wget -P ~ https://github.com/cyrus-and/gdb-dashboard/raw/master/.gdbinit
# without -n and .gdbinit in $home or (gdb) source .gdbinit at runtime
avr-gdb -q -ex 'target remote 127.0.0.1:1234'

Run dashboard

(gdb) dashboard

Print next 200 instructions -> print assembly

(gdb) x/200i $pc

Breakpoint

(gdb) break *0x1b8

Finding your code instruction

you can set an additional jump to code part you want to breakpoint. After initializing the screen and using the previous code to dump asm, find the instruction where brk starts. There won't be much jmp instructions in the code.

diff --git a/sap/program.asm b/sap/program.asm
index 2e1070f..9b591f1 100644
--- a/sap/program.asm
+++ b/sap/program.asm
@@ -11,7 +11,8 @@
 start:
     ; Inicializace displeje
     call init_disp
-    
+    jmp brk
+brk:
     ; *** ZDE muzeme psat nase instrukce
     ldi r16, '0'    ; znak
     ldi r17, 0      ; pozice (0x00-0x0f - prvni radek; 0x40-0x4f - druhy radek)

Continue until breakpoint

(gdb) c

Next instruction

(gdb) ni

macOS

Building

brew tap osx-cross/avr
brew install avr-gcc@12
make

Testing

cd sap
make
make run

macOS arm64 avr-gdb build

https://mirrors.ocf.berkeley.edu/gnu/gdb/ (latest is 14.2 atm)

./configure --target=avr --prefix=/Users/xxx/bin/avr-gdb/ --disable-debug  --disable-dependency-tracking --disable-binutils --disable-nls  --disable-libssp --disable-install-libbfd --disable-install-libiberty --with-python=/opt/homebrew/opt/[email protected]/bin/python3.12 --with-gmp=/opt/homebrew/opt/gmp/ --with-mpfr=/opt/homebrew/opt/mpfr/

Tools

you can use the included static programs in the zip

brew install avrdude avra

Linux

Building

sudo apt-get install gcc-avr avr-libc
make

Testing

cd sap
make
make run

Tools

sudo apt-get install avrdude avra

More Info

Check README.simavr.md for more info on the simulator

simavr-sap's People

Contributors

buserror avatar schuay avatar bsekisser avatar eetagent avatar cardoe avatar dougszumski avatar the-real-orca avatar akosthekiss avatar dxxb avatar maxgerhardt avatar dgeelen avatar kostic2000 avatar hovercraft-github avatar vintagepc avatar gin66 avatar messani avatar xqms avatar endofexclusive avatar cskarai avatar msquirogac avatar nnayo avatar rouseabout avatar mikeplayle avatar ppd avatar jcreekmore avatar taylorconor avatar lotharyx avatar thecrazyt avatar andreasschultes avatar adbancroft avatar

Stargazers

The Potato Chronicler avatar Daniel Bulant avatar Lukáš avatar

Watchers

 avatar

simavr-sap's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.