NewOPL

Use this section to showcase your programming examples. Or to ask members for programming suggestions
amenjet
Posts: 395
Joined: Tue Jan 03, 2023 7:54 pm

Re: NewOPL

Post by amenjet »

Another update. I'm adding runtime support, and quite a few QCodes are implemented. the files starting 'extst' show what is implemented, they are the execution test files.
For the debug of the programs I have been using debug files, which are either information like the intcode.txt file, which shows QCode output like this:

Code: Select all

QCode idx:0002  --++  local pass%, pass2%, num%  --++
N001       Read EXP_BUFF_ID_META                       ty:U qcty:U ' LOCAL' npar:0 nidx:0 trapped:0 %:0  0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0  nb 0:()
N002       Read EXP_BUFF_ID_VARIABLE                   ty:i qcty:U 'PASS%' npar:0 nidx:0 trapped:0 %:0  0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0  nb 0:()
N003       Read EXP_BUFF_ID_VARIABLE                   ty:i qcty:U 'PASS2%' npar:0 nidx:0 trapped:0 %:0  0: 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0  nb 0:()
N004       Read EXP_BUFF_ID_VARIABLE                   ty:i qcty:U 'NUM%' npar:0 nidx:0 trapped:0 %:0  0: 3 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0  nb 0:()
N004       Read EXP_BUFF_ID_FUNCTION                   ty:i qcty:U 'DROP' npar:0 nidx:0 trapped:0 %:0  0: 3 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0  nb 0:()

QCode idx:0002  --++  pass% = 1  --++
N001      Write EXP_BUFF_ID_VARIABLE                   ty:i qcty:U 'PASS%' npar:0 nidx:0 trapped:0 %:0  0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0  nb 0:()
N002       Read EXP_BUFF_ID_INTEGER                    ty:i qcty:U '1' npar:0 nidx:0 trapped:0 %:0  0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0  nb 0:()
N003       Read EXP_BUFF_ID_OPERATOR                   ty:i qcty:U ':=' npar:0 nidx:0 trapped:0 %:0  2: 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0  nb 0:()

QCode idx:0009  --++  pass2% = 0  --++
N001      Write EXP_BUFF_ID_VARIABLE                   ty:i qcty:U 'PASS2%' npar:0 nidx:0 trapped:0 %:0  0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0  nb 0:()
N002       Read EXP_BUFF_ID_INTEGER                    ty:i qcty:U '0' npar:0 nidx:0 trapped:0 %:0  0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0  nb 0:()
N003       Read EXP_BUFF_ID_OPERATOR                   ty:i qcty:U ':=' npar:0 nidx:0 trapped:0 %:0  2: 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0  nb 0:()
It's been updated to show the source OPL lines that lead to the QCode. There's a vars.txt file as well, that has variable information:

Code: Select all

Variables

   0:  VAR: '                 A'      Local Float             DECLARE max_str:  0 max_ary:  0 num_ind:  0 offset:FFF6
   1:  VAR: '                 B'      Local Float             DECLARE max_str:  0 max_ary:  0 num_ind:  0 offset:FFEE
   2:  VAR: '                 E'      Local Float             DECLARE max_str:  0 max_ary:  0 num_ind:  0 offset:FFE6
   3:  VAR: '                E%'      Local Integer           DECLARE max_str:  0 max_ary:  0 num_ind:  0 offset:FFE4
   4:  VAR: '               ANS'      Local Float             DECLARE max_str:  0 max_ary:  0 num_ind:  0 offset:FFDC
   5:  VAR: '              ANS%'      Local Integer           DECLARE max_str:  0 max_ary:  0 num_ind:  0 offset:FFDA
   6:  VAR: '             PASS%'      Local Integer           DECLARE max_str:  0 max_ary:  0 num_ind:  0 offset:FFD8
   7:  VAR: '            PASS2%'      Local Integer           DECLARE max_str:  0 max_ary:  0 num_ind:  0 offset:FFD6
   8:  VAR: '              NUM%'      Local Integer           DECLARE max_str:  0 max_ary:  0 num_ind:  0 offset:FFD4
these files are fine, but I have found that the debug of the runtime code needed a more interactive system, mainly so I can wander around the stack looking at objects. The debug files require the code to be changed and debug added and a rebuild whenever new data needed to be examined. So, i added an interactive TUI. This is a textual User Interface, a character based GUI. The layout is below:

Code: Select all

Memory────────────────────────────────────────────┐ Machine───────────────────────────────────────────┐ Variables─────────────────────────────────────────────────────────────────────────────────────────────┐
│                                                 │ │                                                 │ │                                                                                                     │
│3B06 0D FF D8 22 00 01 7F 0D   ..."....          │ │rta_fp:3EF0                                      │ │(Addr:3EE6) A: - (22) 2 . 22222222222 E34                                                            │
│3B0E FF D6 22 00 00 7F 0D FF   ..".....          │ │rta_sp:3B06                                      │ │(Addr:3EDE) B: - (22) 2 . 22222222222 E34                                                            │
│3B16 D4 22 00 00 7F 0E FF E6   ."......          │ │rta_pc:3B06                                      │ │(Addr:3ED6) E: - (22) 2 . 22222222222 E34                                                            │
│3B1E 23 02 12 03 23 02 78 FC   #...#.x.          │ │                                                 │ │(Addr:3ED4) E%:2222                                                                                  │
│3B26 3F 80 0E FF DC 23 07 46   ?....#.F          │ │                                                 │ │(Addr:3ECC) ANS: - (22) 2 . 22222222222 E34                                                          │
│3B2E 38 15 46 38 15 06 80 00   8.F8....          │ │                                                 │ │(Addr:3ECA) ANS%:2222                                                                                │
│3B36 FF D4 24 01 41 8B 2D B8   ..$.A.-.          │ │                                                 │ │(Addr:3EC8) PASS%:2222                                                                               │
│3B3E 71 24 01 28 71 01 FF DC   q$.(q...          │ │                                                 │ │(Addr:3EC6) PASS2%:2222                                                                              │
│                                                 │ │                                                 │ │(Addr:3EC4) NUM%:2222                                                                                │
└─────────────────────────────────────────────────┘ └─────────────────────────────────────────────────┘ │                                                                                                     │
                                                                                                        │                                                                                                     │
QCode─────────────────────────────────────────────────────────────────────────────────────────────────┐ │                                                                                                     │
│                                                                                                     │ │                                                                                                     │
│QI_LS_INT_SIM_FP                                                                                     │ │                                                                                                     │
│000D: 10                                                                                             │ │                                                                                                     │
│                                                                                                     │ │                                                                                                     │
│float5:                                                                                              │ │                                                                                                     │
│                                                                                                     │ │                                                                                                     │
│3B06: 0D       Push local/global integer variable reference     (bytes code:v)                       │ │                                                                                                     │
│3B07: FFD8       (65496)                                                                             │ │                                                                                                     │
│                                                                                                     │ │                                                                                                     │
│                                                                                                     │ │                                                                                                     │
└─────────────────────────────────────────────────────────────────────────────────────────────────────┘ └─────────────────────────────────────────────────────────────────────────────────────────────────────┘
amenjet
Posts: 395
Joined: Tue Jan 03, 2023 7:54 pm

Re: NewOPL

Post by amenjet »

The TUI uses the curses library and shows the stack memory (a memory address can be entered in hex to move the window around the stack), the Qcode machine FP, SP, and PC, variables and a QCode decode.
This is interactive, the OPL QCode is single stepped with the ENTER key, 'q' exits.

The TUI is currently a compiled-in option, there's two build scripts, one for normal execution, one for single stepped TUI execution.
If you want to try it, run an OPL file xxx.opl using the 'eft' script:

Code: Select all

$ ./eft extst_autocon
If you want to run without the TUI, then the 'ef' script does that:

Code: Select all

$ ./ef extst_time

global size:0000
Externals size:0000
Writing binary...
Length:000D
 28 lines scanned Ok  0 lines scanned failed  7 variables  16 lines blank
Time:6:29:37
Time:6:29:37
Time:6:29:37
Time:6:29:37
Time:6:29:37
Time:6:29:37
Time:6:29:37
Time:6:29:37
Time:6:29:37
Time:6:29:37
PASS
The variable values are updated as the OPL runs. There's no OPL source display at the moment (at least not a working one), but that could probaby be added. No memory editing yet either. there's still bugs in the execution, and missing QCodes, but even so, it can do quite a bit now.

The TUI uses some of the files output by the translator, specifically the vars.txt. It uses that file to display the variables, and because of this it can display locals as well as globals. It also knows the offsets into the frame so you can work out which variable is which. Because of this, some features will fail if an Organiser translated ob3 is run, I haven't tried that yet. the newopl translator can translate a lot of code now, though, and byte for byte identical with the Orgniser, so it. not too much of a problem I think. It could fail and display nothing, or a reduced output if the files it expects aren't there.

Hopefully this is maybe useful to someone...
amenjet
Posts: 395
Joined: Tue Jan 03, 2023 7:54 pm

Re: NewOPL

Post by amenjet »

Current status is that the compiler/translator supports everything, I think. The runtine supports a majority of the language. Major things missing: Externals and parameters to procedures, and anything to do with the display apart from PRINT. The full list is here:

Code: Select all

NOBJ_QCODE_INFO qcode_info[] =
  {
    { QI_INT_SIM_FP,     "QI_INT_SIM_FP",     {qca_fp,           qca_null,        qca_push_int_at_ind}},
    { QI_NUM_SIM_FP,     "QI_NUM_SIM_FP",     {qca_fp,           qca_null,        qca_num_ind_con}},
    { QI_STR_SIM_FP,     "QI_STR_SIM_FP",     {qca_fp,           qca_null,        qca_str_ind_con}},
    { QI_INT_ARR_FP,     "QI_INT_ARR_FP",     {qca_fp,           qca_pop_idx,     qca_push_int_arr_at_ind}},
    { QI_NUM_ARR_FP,     "QI_NUM_ARR_FP",     {qca_fp,           qca_pop_idx,     qca_push_num_arr_at_ind}},
    { QI_STR_ARR_FP,     "QI_STR_ARR_FP",     {qca_fp,           qca_pop_idx,     qca_push_str_arr_at_ind}},
    { QI_NUM_SIM_ABS,    "QI_NUM_SIM_ABS",    {qca_abs,          qca_null,        qca_num_ind_con}},
    { QI_INT_SIM_IND,    "QI_INT_SIM_IND",    {qca_fp,           qca_ind,         qca_push_int_at_ind}},
    { QI_NUM_SIM_IND,    "QI_NUM_SIM_IND",    {qca_fp,           qca_ind,         qca_num_ind_con}},
    { QI_STR_SIM_IND,    "QI_STR_SIM_IND",    {qca_fp,           qca_ind,         qca_str_ind_con}},
    { QI_INT_SIM_IND,    "QI_INT_SIM_IND",    {qca_fp_ind,       qca_pop_idx,     qca_push_int_arr_at_ind}}, // test
    { QI_NUM_SIM_IND,    "QI_NUM_SIM_IND",    {qca_fp_ind,       qca_pop_idx,     qca_push_num_arr_at_ind}}, // test
    { QI_STR_SIM_IND,    "QI_STR_SIM_IND",    {qca_fp_ind,       qca_pop_idx,     qca_push_str_arr_at_ind}}, // test
    { QI_LS_INT_SIM_FP,  "QI_LS_INT_SIM_FP",  {qca_fp,           qca_null,        qca_push_ind_addr }},
    { QI_LS_NUM_SIM_FP,  "QI_LS_NUM_SIM_FP",  {qca_fp,           qca_null,        qca_push_ind_addr}},
    { QI_LS_STR_SIM_FP,  "QI_LS_STR_SIM_FP",  {qca_fp,           qca_null,        qca_str }},
    { QI_LS_INT_ARR_FP,  "QI_LS_INT_ARR_FP",  {qca_fp,           qca_pop_idx,     qca_push_int_arr_addr }},
    { QI_LS_NUM_ARR_FP,  "QI_LS_NUM_ARR_FP",  {qca_fp,           qca_pop_idx,     qca_push_num_arr_addr }},
    { QI_LS_STR_ARR_FP,  "QI_LS_STR_ARR_FP",  {qca_fp,           qca_pop_idx,     qca_push_str_arr_addr }},
    { QI_LS_NUM_ARR_FP,  "QI_LS_NUM_ARR_FP",  {qca_fp,           qca_pop_idx,     qca_push_num_arr_addr }},
    { QI_LS_NUM_SIM_ABS, "QI_LS_NUM_SIM_ABS", {qca_abs,          qca_null,        qca_push_ind_addr }},
    { QI_LS_INT_SIM_IND, "QI_LS_INT_SIM_FP",  {qca_fp,           qca_ind,         qca_push_ind_addr }},
    { QI_LS_NUM_SIM_IND, "QI_LS_NUM_SIM_FP",  {qca_fp,           qca_ind,         qca_push_ind_addr}},
    { QI_LS_STR_SIM_IND, "QI_LS_STR_SIM_IND", {qca_fp,           qca_ind,         qca_str }},
    { QI_LS_INT_ARR_IND, "QI_LS_INT_ARR_IND", {qca_fp_ind,       qca_pop_idx,     qca_push_int_arr_addr }}, // test
    { QI_LS_NUM_ARR_IND, "QI_LS_NUM_ARR_IND", {qca_fp_ind,       qca_pop_idx,     qca_push_num_arr_addr }}, // test
    { QI_LS_STR_ARR_IND, "QI_LS_STR_ARR_IND", {qca_fp_ind,       qca_pop_idx,     qca_push_str_arr_addr }}, // test

    { QI_INT_FLD,        "QI_INT_FLD",        {qca_int_fld,      qca_null,        qca_null }},          // QI_INT_FLD              0x1A
    { QI_NUM_FLD,        "QI_NUM_FLD",        {qca_num_fld,      qca_null,        qca_null }},          // 1B
    { QI_STR_FLD,        "QI_STR_FLD",        {qca_str_fld,      qca_null,        qca_null }},          // QI_STR_FLD              0x1C
    { QI_LS_INT_FLD,     "QI_LS_INT_FLD",     {qca_ls_int_fld,   qca_null,        qca_null }},
    { QI_LS_NUM_FLD,     "QI_LS_NUM_FLD",     {qca_ls_int_fld,   qca_null,        qca_null }},
    { QI_LS_STR_FLD,     "QI_LS_STR_FLD",     {qca_ls_int_fld,   qca_null,        qca_null }},    // QI_LS_STR_FLD           0x1F    
    { QI_STK_LIT_BYTE,   "QI_STK_LIT_BYTE",   {qca_null,         qca_null,        qca_push_qc_byte}},    // QI_STK_LIT_BYTE         0x20
    { QI_STK_LIT_WORD,   "QI_STK_LIT_WORD",   {qca_null,         qca_null,        qca_push_qc_word}},    // QI_STK_LIT_WORD         0x21
    { QI_INT_CON,        "QI_INT_CON",        {qca_null,         qca_null,        qca_int_qc_con}},
    { QI_NUM_CON,        "QI_NUM_CON",        {qca_null,         qca_null,        qca_num_qc_con}},
    { QI_STR_CON,        "QI_STR_CON",        {qca_null,         qca_null,        qca_str_qc_con}},
    // QCO_SPECIAL             0x25    
    // QCO_BREAK               0x26
    { QCO_LT_INT,        "QI_LT_INT",         {qca_pop_2int,     qca_lt_int,      qca_null}},
    { QCO_LTE_INT,       "QI_LTE_INT",        {qca_pop_2int,     qca_lte_int,     qca_null}},
    { QCO_GT_INT,        "QI_GT_INT",         {qca_pop_2int,     qca_gt_int,      qca_null}},
    { QCO_GTE_INT,       "QI_GTE_INT",        {qca_pop_2int,     qca_gte_int,     qca_null}},
    { QCO_NE_INT,        "QI_NE_INT",         {qca_pop_2int,     qca_ne_int,      qca_null}},
    { QCO_EQ_INT,        "QI_EQ_INT",         {qca_pop_2int,     qca_eq_int,      qca_null}},
    { QCO_ADD_INT,       "QCO_ADD_INT",       {qca_pop_2int,     qca_add,         qca_push_result}},
    { QCO_SUB_INT,       "QCO_SUB_INT",       {qca_pop_2int,     qca_sub,         qca_push_result}},
    { QCO_MUL_INT,       "QCO_MUL_INT",       {qca_pop_2int,     qca_mul,         qca_push_result}},
    { QCO_DIV_INT,       "QCO_DIV_INT",       {qca_pop_2int,     qca_div,         qca_push_result}},
    { QCO_POW_INT,       "QCO_POW_INT",       {qca_pop_2int,     qca_powint,      qca_push_result}},   // QCO_POW_INT             0x31    
    { QCO_UMIN_INT,      "QCO_UMIN_INT",      {qca_pop_int,      qca_umin_int,    qca_push_result}},
    { QCO_NOT_INT,       "QCO_NOT_INT",       {qca_pop_int,      qca_not_int,     qca_push_result}},
    { QCO_AND_INT,       "QCO_AND_INT",       {qca_pop_2int,     qca_and_int,     qca_push_result}},
    { QCO_OR_INT,        "QCO_OR_INT",        {qca_pop_2int,     qca_or_int,      qca_push_result}},
    { QCO_LT_NUM,        "QI_LT_NUM",         {qca_pop_2num,     qca_lt_num,      qca_null}},
    { QCO_LTE_NUM,       "QI_LTE_NUM",        {qca_pop_2num,     qca_lte_num,     qca_null}},
    { QCO_GT_NUM,        "QI_GT_NUM",         {qca_pop_2num,     qca_gt_num,      qca_null}},
    { QCO_GTE_NUM,       "QI_GTE_NUM",        {qca_pop_2num,     qca_gte_num,     qca_null}},
    { QCO_NE_NUM,        "QI_NE_NUM",         {qca_pop_2num,     qca_ne_num,      qca_null}},
    { QCO_EQ_NUM,        "QI_EQ_NUM",         {qca_pop_2num,     qca_eq_num,      qca_null}},
    { QCO_ADD_NUM,       "QCO_ADD_NUM",       {qca_pop_2num,     qca_add_num,     qca_push_num_result}},
    { QCO_SUB_NUM,       "QCO_SUB_NUM",       {qca_pop_2num,     qca_sub_num,     qca_push_num_result}},
    { QCO_MUL_NUM,       "QCO_MUL_NUM",       {qca_pop_2num,     qca_mul_num,     qca_push_num_result}},
    { QCO_DIV_NUM,       "QCO_DIV_NUM",       {qca_pop_2num,     qca_div_num,     qca_push_num_result}},
    { QCO_POW_NUM,       "QCO_POW_NUM",       {qca_pop_2num,     qca_pow_num,     qca_push_num_result}},  // QCO_POW_NUM             0x40    
    { QCO_UMIN_NUM,      "QCO_UMIN_NUM",      {qca_pop_num,      qca_umin_num,    qca_push_num}},
    { QCO_NOT_NUM,       "QCO_NOT_NUM",       {qca_pop_num,      qca_not_num,     qca_push_result}},
    { QCO_AND_NUM,       "QCO_AND_NUM",       {qca_pop_2num,     qca_and_num,     qca_push_result}},
    { QCO_OR_NUM,        "QCO_OR_NUM",        {qca_pop_2num,     qca_or_num,      qca_push_result}},
    { QCO_LT_STR,        "QI_LT_STR",         {qca_pop_2str,     qca_lt_str,      qca_push_int_result}},        // QCO_LT_STR              0x45    
    { QCO_LTE_STR,       "QI_LTE_STR",        {qca_pop_2str,     qca_gt_str,      qca_push_not_int_result}},    // QCO_LTE_STR             0x46    
    { QCO_GT_STR,        "QI_GT_STR",         {qca_pop_2str,     qca_gt_str,      qca_push_int_result}},        // QCO_GT_STR              0x47    
    { QCO_GTE_STR,       "QI_GTE_STR",        {qca_pop_2str,     qca_lt_str,      qca_push_not_int_result}},    // QCO_GTE_STR             0x48    
    { QCO_NE_STR,        "QI_NE_STR",         {qca_pop_2str,     qca_eq_str,      qca_push_not_int_result}},    // QCO_NE_STR              0x49    
    { QCO_EQ_STR,        "QI_EQ_STR",         {qca_pop_2str,     qca_eq_str,      qca_push_int_result}},
    { QCO_ADD_STR,       "QI_ADD_STR",        {qca_pop_2str,     qca_add_str,     qca_push_string}},
    { QCO_AT,            "QI_AT",             {qca_pop_2int,     qca_null,        qca_null}},
    { QCO_BEEP,          "QCO_BEEP",          {qca_pop_2int,     qca_null,        qca_null}},
    // QCO_CLS                 0x4E    
    // QCO_CURSOR              0x4F    
    // QCO_ESCAPE              0x50    
    { QCO_GOTO,          "QCO_GOTO",          {qca_goto,         qca_null,        qca_null}},
    // QCO_OFF                 0x52    
    // QCO_ONERR               0x53    
    // QCO_PAUSE               0x54
    { QCO_PAUSE,         "QCO_PAUSE",         {qca_pop_int,      qca_pause,       qca_null}},
    // QCO_POKEB               0x55    
    // QCO_POKEW               0x56    
    { QCO_RAISE,         "QCO_RAISE",         {qca_raise,        qca_null,        qca_null}},    // QCO_RAISE               0x57    
    // QCO_RANDOMIZE           0x58    
    // QCO_STOP                0x59    
    // QCO_TRAP                0x5A    
    { QCO_APPEND,         "QCO_APPEND",         {qca_append,      qca_null,       qca_null}},    // QCO_APPEND              0x5B    
    { QCO_CLOSE,          "QCO_CLOSE",          {qca_close,       qca_null,       qca_null}},     // QCO_CLOSE               0x5C    
    // QCO_COPY                0x5D    
    { QCO_CREATE,         "QCO_CREATE",         {qca_create,      qca_null,       qca_null}},
    // QCO_DELETE              0x5F    
    // QCO_ERASE               0x60
    { QCO_FIRST,          "QCO_FIRST",          {qca_first,       qca_null,       qca_null}},    // QCO_FIRST               0x61    
    { QCO_LAST,           "QCO_LAST",           {qca_last,        qca_null,       qca_null}},    // QCO_LAST                0x62    
    { QCO_NEXT,           "QCO_NEXT",           {qca_next,        qca_null,       qca_null}},    // QCO_NEXT                0x63    
    { QCO_BACK,           "QCO_BACK",           {qca_back,        qca_null,       qca_null}},    // QCO_BACK                0x64
    { QCO_OPEN,           "QCO_OPEN",           {qca_open,        qca_null,       qca_null}},    // QCO_OPEN                0x65    
    { QCO_POSITION,       "QCO_POSITION",       {qca_position,    qca_null,       qca_null}},    // QCO_POSITION            0x66    
    // QCO_RENAME              0x67    
    // QCO_UPDATE              0x68
    { QCO_USE,            "QCO_USE",            {qca_use,        qca_null,       qca_null}},  // QCO_USE                 0x69    
    // QCO_KSTAT               0x6A    
    // QCO_EDIT                0x6B    
    // QCO_INPUT_INT           0x6C    
    // QCO_INPUT_NUM           0x6D    
    // QCO_INPUT_STR           0x6E
    { QCO_PRINT_INT,     "QCO_PRINT_INT",     {qca_pop_int,      qca_print_int,   qca_null}},
    { QCO_PRINT_NUM,     "QCO_PRINT_NUM",     {qca_pop_num,      qca_print_num,   qca_null}},
    { QCO_PRINT_STR,     "QCO_PRINT_STR",     {qca_pop_str,      qca_print_str,   qca_null}},
    { QCO_PRINT_SP,      "QCO_PRINT_SP",      {qca_null,         qca_print_sp,    qca_null}},
    { QCO_PRINT_CR,      "QCO_PRINT_CR",      {qca_null,         qca_print_cr,    qca_null}},
    // QCO_LPRINT_INT          0x74    
    // QCO_LPRINT_NUM          0x75    
    // QCO_LPRINT_STR          0x76    
    // QCO_LPRINT_SP           0x77    
    // QCO_LPRINT_CR           0x78
    { QCO_RETURN,        "QCO_RETURN",        {qca_unwind_proc,  qca_null,        qca_null}},
    { QCO_RETURN_NOUGHT, "QCO_RETURN_NOUGHT", {qca_unwind_proc,  qca_push_nought, qca_null}},
    { QCO_RETURN_ZERO,   "QCO_RETURN_ZERO",   {qca_unwind_proc,  qca_push_zero,   qca_null}},
    { QCO_RETURN_NULL,   "QCO_RETURN_NULL",   {qca_unwind_proc,  qca_push_null,   qca_null}},
    { QCO_PROC,          "QCO_PROC",          {qca_push_proc,    qca_push_null,   qca_null}},
    { QCO_BRA_FALSE,     "QCO_BRA_FALSE",     {qca_bra_false,    qca_null,        qca_null}},
    { QCO_ASS_INT,       "QCO_ASS_INT",       {qca_ass_int,      qca_null,        qca_null}},
    { QCO_ASS_STR,       "QCO_ASS_STR",       {qca_ass_str,      qca_null,        qca_null}},
    { QCO_ASS_NUM,       "QCO_ASS_NUM",       {qca_ass_num,      qca_null,        qca_null}},
    // QCO_DROP_BYTE           0x82    
    { QCO_DROP_WORD,     "QCO_DROP_WORD",     {qca_pop_int,      qca_null,        qca_null}},
    { QCO_DROP_NUM,      "QCO_DROP_NUM",      {qca_pop_num,      qca_null,        qca_null}},
    { QCO_DROP_STR,      "QCO_DROP_STR",      {qca_pop_str,      qca_null,        qca_null}},
    { QCO_INT_TO_NUM,    "QCO_INT_TO_NUM",    {qca_pop_int,      qca_int_to_num,  qca_push_num_result}},
    { QCO_NUM_TO_INT,    "QCO_NUM_TO_INT",    {qca_pop_num,      qca_num_to_int,  qca_push_result}},
    // QCO_END_FIELDS          0x88    
    // QCO_RUN_ASSEM           0x89    
    { RTF_ADDR,          "RTF_ADDR",          {qca_pop_ref,      qca_null,        qca_null}},
    { RTF_ASC,           "RTF_ASC",           {qca_pop_str,      qca_asc,         qca_push_result}},
    { RTF_DAY,           "RTF_DAY",           {qca_clock_day,    qca_null,        qca_null}},
    // RTF_DISP                0x8D    
    // RTF_ERR                 0x8E    
    // RTF_FIND                0x8F    
    // RTF_FREE                0x90    
    // RTF_GET                 0x91    
    { RTF_HOUR,          "RTF_HOUR",          {qca_clock_hour,   qca_null,        qca_null}},
    // RTF_IABS                0x93    
    // RTF_INT                 0x94    
    // RTF_KEY                 0x95
    { RTF_LEN,           "RTF_LEN",           {qca_pop_str,      qca_len,         qca_push_result}},
    { RTF_LOC,           "RTF_LOC",           {qca_pop_2str,     qca_loc,         qca_push_result}},
    // RTF_MENU                0x98
    { RTF_MINUTE,        "RTF_MINUTE",        {qca_clock_minute, qca_null,        qca_null}},
    { RTF_MONTH,         "RTF_MONTH",         {qca_clock_month,  qca_null,        qca_null}},
    // RTF_PEEKB               0x9B    
    // RTF_PEEKW               0x9C    
    // RTF_RECSIZE             0x9D
    { RTF_SECOND,        "RTF_SECOND",        {qca_clock_second, qca_null,        qca_null}},
    // RTF_IUSR                0x9F    
    // RTF_VIEW                0xA0    
    { RTF_YEAR,          "RTF_YEAR",          {qca_clock_year,   qca_null,        qca_null}},
    // RTF_COUNT               0xA2    
    // RTF_EOF                 0xA3    
    // RTF_EXIST               0xA4    
    // RTF_POS                 0xA5
    { RTF_ABS,           "RTF_ABS",           {qca_pop_num,      qca_abs_num,     qca_push_num_result}},
    { RTF_ATAN,          "RTF_ATAN",          {qca_pop_num,      qca_atan_num,    qca_push_num_result}},
    { RTF_COS,           "RTF_COS",           {qca_pop_num,      qca_cos_num,     qca_push_num_result}},
    // RTF_DEG                 0xA9    
    // RTF_EXP                 0xAA    
    // RTF_FLT                 0xAB    
    // RTF_INTF                0xAC
    { RTF_LN,            "RTF_LN",            {qca_pop_num,      qca_log_num,     qca_push_num_result}},    // RTF_LN                  0xAD 
    { RTF_LOG,           "RTF_LOG",           {qca_pop_num,      qca_log10_num,   qca_push_num_result}},    // RTF_LOG                 0xAE
    { RTF_PI,            "RTF_PI",            {qca_null,         qca_pi_num,      qca_push_num_result}},    // RTF_PI                  0xAF    
    // RTF_RAD                 0xB0    
    // RTF_RND                 0xB1    
    { RTF_SIN,           "RTF_SIN",           {qca_pop_num,      qca_sin_num,     qca_push_num_result}},
    { RTF_SQR,           "RTF_SQR",           {qca_pop_num,      qca_sqr_num,     qca_push_num_result}},
    { RTF_TAN,           "RTF_TAN",           {qca_pop_num,      qca_tan_num,     qca_push_num_result}},
    { RTF_VAL,           "RTF_VAL",           {qca_pop_str,      qca_val,         qca_push_num_result}},    // RTF_VAL                 0xB5
    
    // RTF_SPACE               0xB6    
    // RTF_DIR                 0xB7    
    { RTF_CHR,           "RTF_CHR",           {qca_pop_int,      qca_chr,         qca_push_string}},    // RTF_CHR                 0xB8
    // RTF_DATIM               0xB9    
    // RTF_SERR                0xBA    
    // RTF_FIX                 0xBB    
    // RTF_GEN                 0xBC    
    // RTF_SGET                0xBD    
    // RTF_HEX                 0xBE    
    // RTF_SKEY                0xBF    
    // RTF_LEFT                0xC0    
    // RTF_LOWER               0xC1    
    // RTF_MID                 0xC2    
    // RTF_NUM                 0xC3    
    // RTF_RIGHT               0xC4    
    // RTF_REPT                0xC5    
    // RTF_SCI                 0xC6    
    // RTF_UPPER               0xC7    
    // RTF_SUSR                0xC8    
    // RTF_SADDR               0xC9    
    //
    //////////////////////////////// LZ QCode //////////////////////////////
    //
    // RTF_DOW                 0xD7
    // RTF_LTPERCENT           0xCC
    // RTF_GTPERCENT           0xCD
    // RTF_PLUSPERCENT         0xCE
    // RTF_MINUSPERCENT        0xCF
    // RTF_TIMESPERCENT        0xD0
    // RTF_DIVIDEPERCENT       0xD1
    // RTF_OFFX                0xD2
    // RTF_COPYW               0xD3
    // RTF_DELETEW             0xD4
    { RTF_UDG,           "RTF_UDG",           {qca_pop_9int,     qca_null,        qca_null}},    // RTF_UDG                 0xD5

    // RTF_CLOCK               0xD6
    // RTF_DOW                 0xD7
    // RTF_FINDW               0xD8
    // RTF_MENUN               0xD9
    // RTF_WEEK                0xDA
    { RTF_ACOS,          "RTF_ACOS",          {qca_pop_num,      qca_acos_num,    qca_push_num_result}},
    { RTF_ASIN,          "RTF_ASIN",          {qca_pop_num,      qca_asin_num,    qca_push_num_result}},
    // RTF_DAYS                0xDD
    { RTF_MAX,           "RTF_MAX",           {qca_rtf_max,      qca_null,        qca_push_num_result}},    // RTF_MAX                 0xDE
    { RTF_MEAN,          "RTF_MEAN",          {qca_rtf_sum,      qca_mean,        qca_push_num_result}},    // RTF_MEAN                0xDF
    { RTF_MIN,           "RTF_MIN",           {qca_rtf_min,      qca_null,        qca_push_num_result}},    // RTF_MIN                 0xE0
    // RTF_STD                 0xE1
    { RTF_SUM,           "RTF_SUM",           {qca_rtf_sum,      qca_null,        qca_push_num_result}},        // RTF_SUM                 0xE2
    { RTF_VAR,           "RTF_VAR",           {qca_rtf_sum,      qca_rtf_var,     qca_push_num_result}},    // RTF_VAR                 0xE3
    // RTF_DAYNAME             0xE4
    // RTF_DIRW                0xE5
    // RTF_MONTHSTR            0xE6
  };
Any line that is just a comment isn't supported yet. i have built some executables that should run in Windows, I have tried in Wine and they seem to work. The files are in the newopl/pc directory in the github. I can't post them as attachments here. The files are:

Code: Select all

newopl_exec.exe  
newopl_objdump.exe  
newopl_tran.exe
If you have a program like this:

Code: Select all

intarr:

LOCAL X%(10)

X%(1) = 1
X%(2) = 2

X%(3) = x%(1) + x%(2)

print x%(1),x%(2)

if X%(1)=1 and x%(2) = 2 and x%(3)=3
print "PASS"
else
print "FAIL"
endif
then it can be translated with (In Linux using wine):

Code: Select all

menadue@4A-12-87-2A-47-51:~/tree/github/newopl/pc$ wine ./newopl_tran.exe extst_intarr.opl 
002c:fixme:winediag:loader_init wine-staging 10.0-rc4 is a testing version containing experimental patches.
002c:fixme:winediag:loader_init Please mention your exact version when filing bug reports on winehq.org.

global size:0000
Externals size:0000
Writing binary...
Length:0011
Base name:extst_intarr
Output name:extst_intarr.ob3
 18 lines scanned Ok  0 lines scanned failed  1 variables  12 lines blank
menadue@4A-12-87-2A-47-51:~/tree/github/newopl/pc$ 
This generates an 0b3 file which can be dumped with:

Code: Select all

menadue@4A-12-87-2A-47-51:~/tree/github/newopl/pc$ wine ./newopl_objdump.exe extst_intarr.ob3 
002c:fixme:winediag:loader_init wine-staging 10.0-rc4 is a testing version containing experimental patches.
002c:fixme:winediag:loader_init Please mention your exact version when filing bug reports on winehq.org.

Filename:'extst_intarr'
File ext:'ob3
Dropping OB3 header...
Enter:dump_proc
Var Space Size:0018
QCode Space Size:0071
Number of parameters:00
Parameter types:
Global varname Size:0000
Global variables (0)

External varname Size:0000
External variables (0)

String length fixups (0)

Array size fixups (1)
 0: FFE8 000A

QCode

0000: 59       STOP     (bytes code:-)
0001: B2       SIN     (bytes code:-)
0002: 22       Push integer literal     (bytes code:I)
0003: 0001       (1)
0005: 10       Pop integer index and push local/global integer array variable reference     (bytes code:v)
0006: FFE8       (65512)
0008: 22       Push integer literal     (bytes code:I)
0009: 0001       (1)
000B: 7F       Assign integer     (bytes code:-)
000C: 22       Push integer literal     (bytes code:I)
000D: 0002       (2)
000F: 10       Pop integer index and push local/global integer array variable reference     (bytes code:v)
0010: FFE8       (65512)
0012: 22       Push integer literal     (bytes code:I)
0013: 0002       (2)
0015: 7F       Assign integer     (bytes code:-)
0016: 22       Push integer literal     (bytes code:I)
0017: 0003       (3)
0019: 10       Pop integer index and push local/global integer array variable reference     (bytes code:v)
001A: FFE8       (65512)
001C: 22       Push integer literal     (bytes code:I)
001D: 0001       (1)
001F: 03       Pop integer index and push local/global integer array variable value     (bytes code:v)
0020: FFE8       (65512)
0022: 22       Push integer literal     (bytes code:I)
0023: 0002       (2)
0025: 03       Pop integer index and push local/global integer array variable value     (bytes code:v)
0026: FFE8       (65512)
0028: 2D       Plus integer     (bytes code:-)
0029: 7F       Assign integer     (bytes code:-)
002A: 22       Push integer literal     (bytes code:I)
002B: 0001       (1)
002D: 03       Pop integer index and push local/global integer array variable value     (bytes code:v)
002E: FFE8       (65512)
0030: 6F       PRINT integer     (bytes code:-)
0031: 72       PRINT ,     (bytes code:-)
0032: 22       Push integer literal     (bytes code:I)
0033: 0002       (2)
0035: 03       Pop integer index and push local/global integer array variable value     (bytes code:v)
0036: FFE8       (65512)
0038: 6F       PRINT integer     (bytes code:-)
0039: 73       PRINT newline     (bytes code:-)
003A: 22       Push integer literal     (bytes code:I)
003B: 0001       (1)
003D: 03       Pop integer index and push local/global integer array variable value     (bytes code:v)
003E: FFE8       (65512)
0040: 22       Push integer literal     (bytes code:I)
0041: 0001       (1)
0043: 2C       Equal integer     (bytes code:-)
0044: 22       Push integer literal     (bytes code:I)
0045: 0002       (2)
0047: 03       Pop integer index and push local/global integer array variable value     (bytes code:v)
0048: FFE8       (65512)
004A: 22       Push integer literal     (bytes code:I)
004B: 0002       (2)
004D: 2C       Equal integer     (bytes code:-)
004E: 34       AND integer     (bytes code:-)
004F: 22       Push integer literal     (bytes code:I)
0050: 0003       (3)
0052: 03       Pop integer index and push local/global integer array variable value     (bytes code:v)
0053: FFE8       (65512)
0055: 22       Push integer literal     (bytes code:I)
0056: 0003       (3)
0058: 2C       Equal integer     (bytes code:-)
0059: 34       AND integer     (bytes code:-)
005A: 7E       Branch if false     (bytes code:D)
005B: Dest:0068 (Dist:000D)
005D: 24       Push string literal     (bytes code:S)
005E: Len:4
005F: 'PASS'
0063: 71       PRINT string     (bytes code:-)
0064: 73       PRINT newline     (bytes code:-)
0065: 51       GOTO     (bytes code:D)
0066: Dest:0070 (Dist:000A)
0068: 24       Push string literal     (bytes code:S)
0069: Len:4
006A: 'FAIL'
006E: 71       PRINT string     (bytes code:-)
006F: 73       PRINT newline     (bytes code:-)
0070: 7B       RETURN (float 0)     (bytes code:-)

QCode Data

0000:59 B2 22 00 01 10 FF E8 22 00 01 7F 22 00 02 10
0010:FF E8 22 00 02 7F 22 00 03 10 FF E8 22 00 01 03
0020:FF E8 22 00 02 03 FF E8 2D 7F 22 00 01 03 FF E8
0030:6F 72 22 00 02 03 FF E8 6F 73 22 00 01 03 FF E8
0040:22 00 01 2C 22 00 02 03 FF E8 22 00 02 2C 34 22
0050:00 03 03 FF E8 22 00 03 2C 34 7E 00 0D 24 04 50
0060:41 53 53 71 73 51 00 0A 24 04 46 41 49 4C 71 73
0070:7B
menadue@4A-12-87-2A-47-51:~/tree/github/newopl/pc$ 
and run with:

Code: Select all

menadue@4A-12-87-2A-47-51:~/tree/github/newopl/pc$ wine ./newopl_exec.exe extst_intarr.ob3 
002c:fixme:winediag:loader_init wine-staging 10.0-rc4 is a testing version containing experimental patches.
002c:fixme:winediag:loader_init Please mention your exact version when filing bug reports on winehq.org.
1 2
PASS
menadue@4A-12-87-2A-47-51:~/tree/github/newopl/pc$
This program worked for me in wine, but I have had errors when trying to run others. It would be interesting if this could be tried on a real windows to see what happens.
Post Reply