x86128: (Default)
x86128 ([personal profile] x86128) wrote2021-10-01 12:01 pm

Компиляция оператора IF

Добавил компиляцию оператора IF.

MODULE Samples;
var t1 : integer;

begin

    t1 := 10;
    if t1 = 10 then
        writeint(10)
    elsif t1 < 0 then
        writeint(-5)
    else
        writeint(44)
    end

END Samples.



MODULE Samples
{'decls': {'consts': {}, 'procs': {}, 'vars': {'t1': (0, 'integer')}},
 'name': 'Samples',
 'text': [('CONST', '10'),
          ('STOR', 't1'),
          ('LOAD', 't1'),
          ('CONST', '10'),
          ('RELOP', '='),
          ('BR_ZERO', 'L0'),
          ('CONST', '10'),
          ('CALL', 'writeint'),
          ('BR', 'L3'),
          ('LABEL', 'L0'),
          ('LOAD', 't1'),
          ('CONST', '0'),
          ('RELOP', '<'),
          ('BR_ZERO', 'L1'),
          ('CONST', '5'),
          ('UNARY', '-'),
          ('CALL', 'writeint'),
          ('BR', 'L3'),
          ('LABEL', 'L1'),
          ('CONST', '44'),
          ('CALL', 'writeint'),
          ('LABEL', 'L3'),
          ('STOP', '')]}
10
STOP at 22

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting