From 7f1d5020c94012fceb500652c6c41b5e3c7040ee Mon Sep 17 00:00:00 2001 From: Tobias Girstmair Date: Sun, 2 May 2021 16:47:07 +0200 Subject: [PATCH] use sdcc's ucsim to simulate the program warning: ucsim's pdk13 simulation is broken in sdcc-4.1.0. you must apply the following patch before compiling it: https://sourceforge.net/p/sdcc/patches/_discuss/thread/e1d0a5f04c/771d/attachment/0001-v4-fix-ucsim-pdk13-bitops.patch upstream integration of the patch is tracked in . --- bsv.asm | 12 ++++++++++-- run-simulator | 14 ++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100755 run-simulator diff --git a/bsv.asm b/bsv.asm index 5401d64..956b036 100644 --- a/bsv.asm +++ b/bsv.asm @@ -14,6 +14,7 @@ tmp_1: .ds 1 ; 0x15 .even ; make next two bytes word-aligned tmp_lo: .ds 1 ; 0x16 tmp_hi: .ds 1 ; 0x17 +simif: .ds 1 ;0x18 .even ; SP must be aligned stack_start: .ds 1 @@ -295,9 +296,10 @@ init: MOV notes+0x9, a MOV notes+0xC, a - ENGINT +; ENGINT loop: +call interrupt MOV a, i2 CEQSN a, #0x78 ; compare, skip next if equal ; Note: usually, this is the place where the MCU is put into some @@ -350,7 +352,7 @@ halt: interrupt: PUSH af T1SN intrq, #2 ; if intrq.t16 is triggered, skip next - GOTO ivr_end +nop; GOTO ivr_end ;clear t16int: SET0 intrq, #2 @@ -483,6 +485,11 @@ voice4: SWAP a MOV pwm, a ; next sample is now ready. +mov a, #'w' +mov simif, a +mov a, pwm +mov simif, a + INC i0 ADDC i1 @@ -491,4 +498,5 @@ voice4: SET0 pa, #6 ; debug ivr_end: POP af +ret RETI diff --git a/run-simulator b/run-simulator new file mode 100755 index 0000000..2b53de8 --- /dev/null +++ b/run-simulator @@ -0,0 +1,14 @@ +#!/bin/sh + +file=pwm.bin +:> $file # touch or truncate + +tail -f $file|head -c 131072|aplay - & # 65536==1st bar, _*2==2nd bar +pid=$! + +make +echo '!!!!!!!!! press q + return to stop !!!!!!!!!' +spdk -Pt PDK13 -I if='ram[0x18],out='$file -g bsv.ihx + +kill $pid +rm $file -- 2.39.3