Precompiled simulator & tools for macOS arm64 and Linux x86_64 here
avra program.asm
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
simavr_sap_emulator program.hex
.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
}
}
]
}
simavr_sap_emulator program.hex -d
avr-gdb -q -n -ex 'target remote 127.0.0.1:1234'
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'
(gdb) dashboard
(gdb) x/200i $pc
(gdb) break *0x1b8
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)
(gdb) c
(gdb) ni
brew tap osx-cross/avr
brew install avr-gcc@12
make
cd sap
make
make run
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/
you can use the included static programs in the zip
brew install avrdude avra
sudo apt-get install gcc-avr avr-libc
make
cd sap
make
make run
sudo apt-get install avrdude avra
Check README.simavr.md for more info on the simulator