Menu

#14 A way to send bytes to the host system?

open
nobody
None
5
2021-05-10
2021-05-06
//gir.st/
No

I'm looking to verify the result of some algorithm against the output of a known-good "truth table". For this, I'd need to write a byte to a file/pipe/stdout/... at the end of each loop iteration. ucSim (from the sdcc project) implements simif (simulator interface), which works like so: you define a memory address to use with simif and an output file on the host, then whenever you send 'w', followed by a byte, the byte is written into the file.

Is there something similar available for gpsim? It feels like FileRecorder might be able to do what I want, but I'm not sure how to set that up. (afaict, it's supposed to write output on each cpu cycle?)

Discussion

  • Roy Rankin

    Roy Rankin - 2021-05-10

    One possible option is to add the .command to your code.

    In gpasm code the following
    .command "porta"
    nop

    will output to stdout the line "porta = 0xval"  when that part of code is executed, where val is the contents of a register or global variable.
    
    To output a debug statement you can use
    
    .command "echo this is a message"
    nop
    
     
  • //gir.st/

    //gir.st/ - 2021-05-10

    thanks! in the meantime, i've figured out something else that kind-of works: I'm writing the bytes I need to debug_var (in SRAM) and invoke gpsim like so:

    printf 'log on test.log\nlog w debug_var\nbreak w <exit condition>\nrun\nq\n'|gpsim -i test.cod

    this is then post-processed to get the raw bytes like this:

    grep -o '^ Wrote: 0x....' test.log|cut -b14-15|xxd -pl -r > /tmp/test.bin

    yours would've been a bit cleaner, but still require some post-processing.

     

Anonymous
Anonymous

Add attachments
Cancel