uploadToBDOS.sh 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/bin/bash
  2. # script for compiling a C program for BDOS, and upload it to the FPGC over the network, whithout running it
  3. if [ "$1" == "" ]
  4. then
  5. echo "No program to compile given"
  6. exit 1
  7. fi
  8. # Default output filename is filename of first argument
  9. OUTFILE=$(basename $1)
  10. # Remove file extension
  11. OUTFILE=${OUTFILE%.*}
  12. if [ "$2" != "" ]
  13. then
  14. OUTFILE=$2
  15. fi
  16. echo "Processing: $1"
  17. # compile and upload
  18. echo "Compiling C code to B32P ASM"
  19. if (./bcc --bdos $1 ../Assembler/code.asm) # compile c code with BDOS flag and write compiled code to code.asm in Assembler folder
  20. then
  21. echo "C code successfully compiled"
  22. echo "Assembling B32P ASM code"
  23. if (cd ../Assembler && python3 Assembler.py bdos 0x400000 -O > ../Programmer/code.list) # assemble with offset for BDOS and write to code.list in Programmer folder
  24. then
  25. echo "B32P ASM code successfully assembled"
  26. # convert list to binary files and upload to FPGC
  27. (cd ../Programmer && bash compileROM.sh noPadding && cp code.bin $OUTFILE && echo "Uploading $OUTFILE to FPGC over Network" && python3 netUpload.py $OUTFILE && rm $OUTFILE)
  28. else # assemble failed, run again to show error
  29. echo "Failed to assemble B32P ASM code"
  30. cd ../Assembler && python3 Assembler.py bdos 0x400000 -O
  31. fi
  32. else # compile failed
  33. echo "Failed to compile C code"
  34. fi