这个旧程序用什么语言编写?

时间:2018-07-15 14:53:58

标签: programming-languages dos forth

“嗨,您能帮我重写一下吗”,老板说,“一些旧代码”。是的,遗留代码是在中生代早期编写的。

我还有30个小时了,但我仍然不知道,这是什么样的语法! VHLD? VBA?该程序专门用于处理音频文件,并在DOS下运行。

您能给我个提示吗?怎么编译呢?

代码段:

enter \ Load - main screen
empty  forth definitions  decimal
application  warning on

: TITLE ." KCS version 0.8  28-Jan-06" cr ;

cr .( Compiling: )  title  2 load

 cr .( Save to disk? )  y/n
[if]
\  pad reserve @ + 256 + limit s0 @ - + set-limit
  turnkey program  KCS
[then]



\ Load - defaults
 variable RESERVE  0 reserve !       \ reserved memory tally
 defer ?BREAK  ' noop is ?break      \ break check off
 defer SET-IO  ' bios-io is set-io   \ default console mode
 defer ERRFIX  ' noop is errfix      \ reset on-error handler

 blk @ 1+ #screens 1- thru       \ load electives & application

 ' (?break) is ?break           \ enable user break
\ ' dos-io is set-io             \ enable console redirection
\ ' deloutfile +is errfix        \ delete outfile on error
\ wrtchk off                     \ disable overwrite check




\ Load - electives
  1 fload DOSLIB     \ load DOSLIB library

 _Errors            \ error handler
 _Inout1            \ number output
 _Inout2            \ string & number input
 _String1           \ basic strings
\ _String2           \ extra strings
 _Parsing           \ command-line parsing
 _Fileprims         \ file primitives
 _Files             \ default files
 _Bufinfile         \ buffered input file
 _Bufoutfile        \ buffered output file


\ DECODE
\ Convert wave file to program
: DECODE  ( -- )
  0. decodecount 2!  0. paritycount 2!  0 errors !
  skipheader
  begin
    ['] decodebyte  1 ?catch 0=
   while ( not EOF )


 conout @ if  emit  else  writechar  then
    1 decodecount m+!
  repeat
  .decoded ;




\ SETMODE
\ Select Kansas City Standard or Processor Tech. CUTS mode
: SETMODE  ( -- )
  mode @ if ( CUTS )
    8 to databits  2 sbits !  4 speed !  parity off  pace off
    nullcnt off
    ['] 0bit-sqr-cuts is 0bit-sqr  ['] 1bit-sqr-cuts is 1bit-sqr
    ['] 0bit-sin-cuts is 0bit-sin  ['] 1bit-sin-cuts is 1bit-sin
    ['] seekstart-cuts is seekstart  ['] getbit-cuts is getbit
  else ( KCS )
    ['] 0bit-sqr-kcs is 0bit-sqr  ['] 1bit-sqr-kcs is 1bit-sqr
    ['] 0bit-sin-kcs is 0bit-sin  ['] 1bit-sin-kcs is 1bit-sin
    ['] seekstart-kcs is seekstart  ['] getbit-kcs is getbit
  then ;


\ (RUN)
\ Run application
: (RUN)  ( -- )
  setmode
  r/o openinfile
  decoding @ if
    conout @ 0= if  r/w makeoutfile  then
    cr decode
  else
    r/w makeoutfile
    cr encode
  then
  closefiles
  ;


\ DEFAULTS
\ Set application defaults
: DEFAULTS  ( -- )
  mode off  decoding on  strict off  ignore off  conout off
  1 speed !  2 sbits !  parity off  5 leadtime !  10 nullchar !
  pace off  nullcnt off  wave off  tone off  inverted off ;

defaults








\ RUN PROGRAM
\ Run application with error handling
: RUN  ( -- )
  ['] (run) catch ?dup if  >r errfix r> throw  then ;

\ Main
: PROGRAM  ( -- )
  set-io                \ set console mode
  defaults              \ set defaults
  cr title              \ show application name
  parsecmd              \ get options/filenames
  run                   \ run application
  cr ." done"           \ show success
  ;

1 个答案:

答案 0 :(得分:11)

它用Forth(可能是DX-Forth方言)编写。该程序对WAVE files中包含数据的Kansas City standard format进行解码和编码。此格式用于在早期S-100 CP / M机器上的盒式磁带上记录数据。在网上搜索发现有一个program written in DX-Forth可以解码和编码这种格式的WAVE文件,所以我猜这是您要重写的程序。

但是,与其重写这段代码,不如做一个简单的事情,那就是使用已经完成任务的现有免费软件。例如,有一个用Python编写的名为py-kcs的程序应该是功能替代品,而有一个用Haxe编写的名为hx-kcs的程序可以解码。