Hi, have a look at https://sourceforge.net/p/sdcc/code/HEAD/tree/trunk/sdcc/sim/ucsim/example/simif.c
They use #define SIF_ADDRESS_SPACE_NAME "xram" #define SIF_ADDRESS_SPACE __xdata #define SIF_ADDRESS 0xffff unsigned char SIF_ADDRESS_SPACE * volatile sif; and read multi-byte values by repeatedly reading *sif: void get_commands(void) { int i; *sif= SIFCM_COMMANDS; nuof_commands= *sif; for (i= 0; i < nuof_commands; i++) commands[i]= *sif; } Hope that helps Raphael Am Fr., 22. Mai 2020 um 00:37 Uhr schrieb Basil Hussain <ba...@stasisleak.uk >: > Hi all, > > I'm trying to understand how to use the μCsim simulator interface - the > interface between the program running within the simulator, and the > simulator itself. My aim is to have the program that's running in the > sim measure the execution time (i.e. no. of cycles) of some of it's own > code. > > As far as I understand, you configure it by specifying a certain memory > location (not one which is used by the chip being simulated!) which > provides a single-byte 'register' of sorts through which your running > program can communicate with the simulator. I have that working, by > specifying command-line args of "-I if=rom[0x5800]" (I chose an address > just after the peripheral registers, in what is otherwise 'reserved' > address space). Then if I attempt, from within my running program, to > use the 'detect' command by writing the value 0x5F to that address, and > then read back, I successfully get the '!' response character. Similarly > I can read the interface version successfully (returns 0x01). > > One thing I do not understand how to do, and the documentation does not > reveal, is how to read the simulator's configuration information. When > you (in the simulator console) issue the command "info hw simif", in > addition to the simif command summary, it shows: > > Configuration memory of simif > 0x00 00000001 . Turn simif on/off (bool, RW) > 0x01 00000000 . WR: sets running state, RD: check if simulation is running > 0x02 00000000 . WR: start simulation, RD: true if running > 0x03 00000001 . WR: stop simulation, RD: true if stopped > 0x04 00000000 . Quit simulator (any, WO) > 0x05 0000006e n Reason of last stop (int, RO) > 0x06 007a1200 . Xtal frequency in Hz (int, RW) > 0x07 000a7db0 . Nuof ticks simulated so far (int, RO) > 0x08 00000000 . Ticks spent in ISR (int, RO) > 0x09 00000000 . Ticks spent in idle state (int, RO) > 0x0a 00000055 U Real time since reset in msec (int, RO) > 0x0b 00151ae2 . Nuof simulated virtual clocks (int, RO) > 0x0c 000098e2 . PC register (int, RW) > 0x0d 00000000 . Print char on stdout (int, WO) > 0x0e 00000000 . Write char to simif output (int, WO) > 0x0f 00000000 . Not used > > How is one meant to read/write this data? I thought perhaps you write > the first byte to the simif memory location, then read 4 bytes back with > the value? But when I tried this to get, for example, the PC, I don't > read anything that looks like the correct data. I tried it two ways: > > #define UCSIM_IF (*(volatile uint8_t *)(0x5800)) > > /* doesn't work, pc = 0xF3000000 */ > UCSIM_IF = 0x0C; > uint32_t pc = (*(volatile uint32_t *)(&UCSIM_IF)); > > /* also doesn't work, pc = 0xF3F3F3F3 */ > union { > uint32_t val; > uint8_t raw[4]; > } pc; > UCSIM_IF = 0x0C; > pc.raw[0] = UCSIM_IF; > pc.raw[1] = UCSIM_IF; > pc.raw[2] = UCSIM_IF; > pc.raw[3] = UCSIM_IF; > > Can anyone tell me how I am supposed to read the simif configuration > values? > > Regards, > Basil Hussain > > > _______________________________________________ > Sdcc-user mailing list > Sdcc-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/sdcc-user >
_______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user