program NewFeaturesDemo {
section module {
io,
std,
string
}
section data {
int rax = 0
int rbx = 0
int rcx = 0
int rdx = 0
int rsi = 0
int rdi = 0
int r8 = 0
int r9 = 0
int r10 = 0
int r11 = 0
ptr _tmpptr0 = null
ptr _tmpptr1 = null
ptr _tmpptr2 = null
string str_0 = "=== MXVM New Features Demo ==="
string str_1 = "--- Part 1: Set Operations ---"
string str_2 = "Vowel positions: "
string str_3 = " "
string str_4 = "Primes or evens (1-20): "
string str_5 = "Odd primes (1-20): "
string str_6 = "Even primes: "
string str_7 = "Modifying sets with include/exclude:"
string str_8 = " Before: 6 in primes? "
string str_9 = "yes"
string str_10 = "no"
string str_11 = " After include(primes, 6): 6 in primes? "
string str_12 = " After exclude(primes, 6): 6 in primes? "
string str_13 = "Fibonacci numbers up to 20: "
string str_14 = "All primes up to 23 (odd primes + 2): "
string str_15 = "--- Part 2: File I/O ---"
string str_16 = "demo_data.txt"
string str_17 = "w"
string str_18 = "Name: MXVM Pascal Compiler"
string str_19 = "\n"
string str_20 = "Version: 2.0"
string str_21 = "Features: sets, files, packed"
string str_22 = "Item "
string str_23 = ": value="
string str_24 = "Wrote demo_data.txt"
string str_25 = "Contents of demo_data.txt:"
string str_26 = "r"
string str_27 = " ["
string str_28 = "] "
string str_29 = "Read "
string str_30 = " lines."
string str_31 = "a"
string str_32 = "Appended: timestamp=2026-04-06"
string str_33 = "Appended one line."
string str_34 = "File now has "
string str_35 = "primes.csv"
string str_36 = "number,is_prime,is_even,is_odd"
string str_37 = ",yes"
string str_38 = ",no"
string str_39 = ""
string str_40 = "Wrote primes.csv with 30 rows."
string str_41 = "--- Part 3: Packed Types ---"
string str_42 = "Packed array: "
string str_43 = "Packed record: x="
string str_44 = " y="
string str_45 = "=== All demos completed successfully ==="
string fmt_int = "%lld "
string fmt_str = "%s "
string newline = "\n"
ptr vowels = null
ptr consonants = null
ptr letters = null
ptr primes = null
ptr evens = null
ptr odds = null
ptr result_set = null
ptr f = null
ptr f_filename = null
ptr line = null
int i = 0
int count = 0
ptr pa = null
ptr pr = null
}
section code {
start:
alloc vowels, 8, 256
mov rbx, 0
SET_INIT_0:
cmp rbx, 256
jge SET_INIT_END_1
store 0, vowels, rbx, 8
add rbx, 1
jmp SET_INIT_0
SET_INIT_END_1:
alloc consonants, 8, 256
mov rbx, 0
SET_INIT_2:
cmp rbx, 256
jge SET_INIT_END_3
store 0, consonants, rbx, 8
add rbx, 1
jmp SET_INIT_2
SET_INIT_END_3:
alloc letters, 8, 256
mov rbx, 0
SET_INIT_4:
cmp rbx, 256
jge SET_INIT_END_5
store 0, letters, rbx, 8
add rbx, 1
jmp SET_INIT_4
SET_INIT_END_5:
alloc primes, 8, 256
mov rbx, 0
SET_INIT_6:
cmp rbx, 256
jge SET_INIT_END_7
store 0, primes, rbx, 8
add rbx, 1
jmp SET_INIT_6
SET_INIT_END_7:
alloc evens, 8, 256
mov rbx, 0
SET_INIT_8:
cmp rbx, 256
jge SET_INIT_END_9
store 0, evens, rbx, 8
add rbx, 1
jmp SET_INIT_8
SET_INIT_END_9:
alloc odds, 8, 256
mov rbx, 0
SET_INIT_10:
cmp rbx, 256
jge SET_INIT_END_11
store 0, odds, rbx, 8
add rbx, 1
jmp SET_INIT_10
SET_INIT_END_11:
alloc result_set, 8, 256
mov rbx, 0
SET_INIT_12:
cmp rbx, 256
jge SET_INIT_END_13
store 0, result_set, rbx, 8
add rbx, 1
jmp SET_INIT_12
SET_INIT_END_13:
alloc pa, 8, 10
alloc pr, 16, 1
print fmt_str, str_0
print newline
print newline
print fmt_str, str_1
print newline
alloc _tmpptr0, 8, 256
mov rbx, 0
SET_LIT_INIT_14:
cmp rbx, 256
jge SET_LIT_INIT_END_15
store 0, _tmpptr0, rbx, 8
add rbx, 1
jmp SET_LIT_INIT_14
SET_LIT_INIT_END_15:
store 1, _tmpptr0, 1, 8
store 1, _tmpptr0, 5, 8
store 1, _tmpptr0, 9, 8
store 1, _tmpptr0, 15, 8
store 1, _tmpptr0, 21, 8
mov rbx, 0
set_copy_16:
cmp rbx, 256
jge set_copy_end_17
load rcx, _tmpptr0, rbx, 8
store rcx, vowels, rbx, 8
add rbx, 1
jmp set_copy_16
set_copy_end_17:
free _tmpptr0
alloc _tmpptr0, 8, 256
mov rbx, 0
SET_LIT_INIT_18:
cmp rbx, 256
jge SET_LIT_INIT_END_19
store 0, _tmpptr0, rbx, 8
add rbx, 1
jmp SET_LIT_INIT_18
SET_LIT_INIT_END_19:
store 1, _tmpptr0, 2, 8
store 1, _tmpptr0, 3, 8
store 1, _tmpptr0, 4, 8
store 1, _tmpptr0, 6, 8
store 1, _tmpptr0, 7, 8
store 1, _tmpptr0, 8, 8
store 1, _tmpptr0, 10, 8
store 1, _tmpptr0, 11, 8
store 1, _tmpptr0, 12, 8
store 1, _tmpptr0, 13, 8
store 1, _tmpptr0, 14, 8
store 1, _tmpptr0, 16, 8
store 1, _tmpptr0, 17, 8
store 1, _tmpptr0, 18, 8
store 1, _tmpptr0, 19, 8
store 1, _tmpptr0, 20, 8
store 1, _tmpptr0, 22, 8
store 1, _tmpptr0, 23, 8
store 1, _tmpptr0, 24, 8
store 1, _tmpptr0, 25, 8
store 1, _tmpptr0, 26, 8
mov rbx, 0
set_copy_20:
cmp rbx, 256
jge set_copy_end_21
load rcx, _tmpptr0, rbx, 8
store rcx, consonants, rbx, 8
add rbx, 1
jmp set_copy_20
set_copy_end_21:
free _tmpptr0
alloc _tmpptr0, 8, 256
mov rbx, 0
SET_LIT_INIT_22:
cmp rbx, 256
jge SET_LIT_INIT_END_23
store 0, _tmpptr0, rbx, 8
add rbx, 1
jmp SET_LIT_INIT_22
SET_LIT_INIT_END_23:
store 1, _tmpptr0, 2, 8
store 1, _tmpptr0, 3, 8
store 1, _tmpptr0, 5, 8
store 1, _tmpptr0, 7, 8
store 1, _tmpptr0, 11, 8
store 1, _tmpptr0, 13, 8
store 1, _tmpptr0, 17, 8
store 1, _tmpptr0, 19, 8
store 1, _tmpptr0, 23, 8
mov rbx, 0
set_copy_24:
cmp rbx, 256
jge set_copy_end_25
load rcx, _tmpptr0, rbx, 8
store rcx, primes, rbx, 8
add rbx, 1
jmp set_copy_24
set_copy_end_25:
free _tmpptr0
alloc _tmpptr0, 8, 256
mov rbx, 0
SET_LIT_INIT_26:
cmp rbx, 256
jge SET_LIT_INIT_END_27
store 0, _tmpptr0, rbx, 8
add rbx, 1
jmp SET_LIT_INIT_26
SET_LIT_INIT_END_27:
store 1, _tmpptr0, 2, 8
store 1, _tmpptr0, 4, 8
store 1, _tmpptr0, 6, 8
store 1, _tmpptr0, 8, 8
store 1, _tmpptr0, 10, 8
store 1, _tmpptr0, 12, 8
store 1, _tmpptr0, 14, 8
store 1, _tmpptr0, 16, 8
store 1, _tmpptr0, 18, 8
store 1, _tmpptr0, 20, 8
mov rbx, 0
set_copy_28:
cmp rbx, 256
jge set_copy_end_29
load rcx, _tmpptr0, rbx, 8
store rcx, evens, rbx, 8
add rbx, 1
jmp set_copy_28
set_copy_end_29:
free _tmpptr0
alloc _tmpptr0, 8, 256
mov rbx, 0
SET_LIT_INIT_30:
cmp rbx, 256
jge SET_LIT_INIT_END_31
store 0, _tmpptr0, rbx, 8
add rbx, 1
jmp SET_LIT_INIT_30
SET_LIT_INIT_END_31:
store 1, _tmpptr0, 1, 8
store 1, _tmpptr0, 3, 8
store 1, _tmpptr0, 5, 8
store 1, _tmpptr0, 7, 8
store 1, _tmpptr0, 9, 8
store 1, _tmpptr0, 11, 8
store 1, _tmpptr0, 13, 8
store 1, _tmpptr0, 15, 8
store 1, _tmpptr0, 17, 8
store 1, _tmpptr0, 19, 8
mov rbx, 0
set_copy_32:
cmp rbx, 256
jge set_copy_end_33
load rcx, _tmpptr0, rbx, 8
store rcx, odds, rbx, 8
add rbx, 1
jmp set_copy_32
set_copy_end_33:
free _tmpptr0
print fmt_str, str_2
mov i, 1
FOR_34:
cmp i, 26
jg ENDFOR_35
load rbx, vowels, i, 8
cmp rbx, 0
je IN_NOT_FOUND_39
mov rcx, 1
jmp IN_END_40
IN_NOT_FOUND_39:
mov rcx, 0
IN_END_40:
cmp rcx, 0
je ELSE_37
print fmt_int, i
print fmt_str, str_3
ELSE_37:
FOR_CONTINUE_36:
add i, 1
jmp FOR_34
ENDFOR_35:
print newline
alloc _tmpptr0, 8, 256
mov rbx, 0
SET_OP_41:
cmp rbx, 256
jge SET_OP_END_42
load rdx, primes, rbx, 8
load rsi, evens, rbx, 8
cmp rdx, 0
jne SET_OP_STORE_43
cmp rsi, 0
jne SET_OP_STORE_43
jmp SET_OP_ZERO_44
SET_OP_STORE_43:
store 1, _tmpptr0, rbx, 8
jmp SET_OP_NEXT_45
SET_OP_ZERO_44:
store 0, _tmpptr0, rbx, 8
SET_OP_NEXT_45:
add rbx, 1
jmp SET_OP_41
SET_OP_END_42:
mov rbx, 0
set_copy_46:
cmp rbx, 256
jge set_copy_end_47
load rdx, _tmpptr0, rbx, 8
store rdx, result_set, rbx, 8
add rbx, 1
jmp set_copy_46
set_copy_end_47:
free _tmpptr0
print fmt_str, str_4
mov i, 1
FOR_48:
cmp i, 20
jg ENDFOR_49
load rbx, result_set, i, 8
cmp rbx, 0
je IN_NOT_FOUND_53
mov rdx, 1
jmp IN_END_54
IN_NOT_FOUND_53:
mov rdx, 0
IN_END_54:
cmp rdx, 0
je ELSE_51
print fmt_int, i
print fmt_str, str_3
ELSE_51:
FOR_CONTINUE_50:
add i, 1
jmp FOR_48
ENDFOR_49:
print newline
alloc _tmpptr0, 8, 256
mov rbx, 0
SET_OP_55:
cmp rbx, 256
jge SET_OP_END_56
load rsi, primes, rbx, 8
load rdi, odds, rbx, 8
cmp rsi, 0
je SET_OP_ZERO_58
cmp rdi, 0
je SET_OP_ZERO_58
jmp SET_OP_STORE_57
SET_OP_STORE_57:
store 1, _tmpptr0, rbx, 8
jmp SET_OP_NEXT_59
SET_OP_ZERO_58:
store 0, _tmpptr0, rbx, 8
SET_OP_NEXT_59:
add rbx, 1
jmp SET_OP_55
SET_OP_END_56:
mov rbx, 0
set_copy_60:
cmp rbx, 256
jge set_copy_end_61
load rsi, _tmpptr0, rbx, 8
store rsi, result_set, rbx, 8
add rbx, 1
jmp set_copy_60
set_copy_end_61:
free _tmpptr0
print fmt_str, str_5
mov i, 1
FOR_62:
cmp i, 20
jg ENDFOR_63
load rbx, result_set, i, 8
cmp rbx, 0
je IN_NOT_FOUND_67
mov rsi, 1
jmp IN_END_68
IN_NOT_FOUND_67:
mov rsi, 0
IN_END_68:
cmp rsi, 0
je ELSE_65
print fmt_int, i
print fmt_str, str_3
ELSE_65:
FOR_CONTINUE_64:
add i, 1
jmp FOR_62
ENDFOR_63:
print newline
alloc _tmpptr0, 8, 256
mov rbx, 0
SET_OP_69:
cmp rbx, 256
jge SET_OP_END_70
load rdi, primes, rbx, 8
load r8, odds, rbx, 8
cmp rdi, 0
je SET_OP_ZERO_72
cmp r8, 0
jne SET_OP_ZERO_72
jmp SET_OP_STORE_71
SET_OP_STORE_71:
store 1, _tmpptr0, rbx, 8
jmp SET_OP_NEXT_73
SET_OP_ZERO_72:
store 0, _tmpptr0, rbx, 8
SET_OP_NEXT_73:
add rbx, 1
jmp SET_OP_69
SET_OP_END_70:
mov rbx, 0
set_copy_74:
cmp rbx, 256
jge set_copy_end_75
load rdi, _tmpptr0, rbx, 8
store rdi, result_set, rbx, 8
add rbx, 1
jmp set_copy_74
set_copy_end_75:
free _tmpptr0
print fmt_str, str_6
mov i, 1
FOR_76:
cmp i, 20
jg ENDFOR_77
load rbx, result_set, i, 8
cmp rbx, 0
je IN_NOT_FOUND_81
mov rdi, 1
jmp IN_END_82
IN_NOT_FOUND_81:
mov rdi, 0
IN_END_82:
cmp rdi, 0
je ELSE_79
print fmt_int, i
print fmt_str, str_3
ELSE_79:
FOR_CONTINUE_78:
add i, 1
jmp FOR_76
ENDFOR_77:
print newline
print newline
print fmt_str, str_7
print newline
print fmt_str, str_8
load rbx, primes, 6, 8
cmp rbx, 0
je IN_NOT_FOUND_85
mov r8, 1
jmp IN_END_86
IN_NOT_FOUND_85:
mov r8, 0
IN_END_86:
cmp r8, 0
je ELSE_83
print fmt_str, str_9
print newline
jmp ENDIF_84
ELSE_83:
print fmt_str, str_10
print newline
ENDIF_84:
mov rbx, 1
store rbx, primes, 6, 8
print fmt_str, str_11
load rbx, primes, 6, 8
cmp rbx, 0
je IN_NOT_FOUND_89
mov r9, 1
jmp IN_END_90
IN_NOT_FOUND_89:
mov r9, 0
IN_END_90:
cmp r9, 0
je ELSE_87
print fmt_str, str_9
print newline
jmp ENDIF_88
ELSE_87:
print fmt_str, str_10
print newline
ENDIF_88:
mov rbx, 0
store rbx, primes, 6, 8
print fmt_str, str_12
load rbx, primes, 6, 8
cmp rbx, 0
je IN_NOT_FOUND_93
mov r9, 1
jmp IN_END_94
IN_NOT_FOUND_93:
mov r9, 0
IN_END_94:
cmp r9, 0
je ELSE_91
print fmt_str, str_9
print newline
jmp ENDIF_92
ELSE_91:
print fmt_str, str_10
print newline
ENDIF_92:
print newline
print fmt_str, str_13
mov i, 1
FOR_95:
cmp i, 20
jg ENDFOR_96
cmp i, 1
je IN_FOUND_100
cmp i, 2
je IN_FOUND_100
cmp i, 3
je IN_FOUND_100
cmp i, 5
je IN_FOUND_100
cmp i, 8
je IN_FOUND_100
cmp i, 13
je IN_FOUND_100
mov rbx, 0
jmp IN_END_101
IN_FOUND_100:
mov rbx, 1
IN_END_101:
cmp rbx, 0
je ELSE_98
print fmt_int, i
print fmt_str, str_3
ELSE_98:
FOR_CONTINUE_97:
add i, 1
jmp FOR_95
ENDFOR_96:
print newline
alloc _tmpptr0, 8, 256
mov r9, 0
SET_OP_102:
cmp r9, 256
jge SET_OP_END_103
load r10, primes, r9, 8
load r11, odds, r9, 8
cmp r10, 0
je SET_OP_ZERO_105
cmp r11, 0
je SET_OP_ZERO_105
jmp SET_OP_STORE_104
SET_OP_STORE_104:
store 1, _tmpptr0, r9, 8
jmp SET_OP_NEXT_106
SET_OP_ZERO_105:
store 0, _tmpptr0, r9, 8
SET_OP_NEXT_106:
add r9, 1
jmp SET_OP_102
SET_OP_END_103:
alloc _tmpptr1, 8, 256
mov r9, 0
SET_LIT_INIT_107:
cmp r9, 256
jge SET_LIT_INIT_END_108
store 0, _tmpptr1, r9, 8
add r9, 1
jmp SET_LIT_INIT_107
SET_LIT_INIT_END_108:
store 1, _tmpptr1, 2, 8
alloc _tmpptr2, 8, 256
mov r9, 0
SET_OP_109:
cmp r9, 256
jge SET_OP_END_110
load r10, _tmpptr0, r9, 8
load r11, _tmpptr1, r9, 8
cmp r10, 0
jne SET_OP_STORE_111
cmp r11, 0
jne SET_OP_STORE_111
jmp SET_OP_ZERO_112
SET_OP_STORE_111:
store 1, _tmpptr2, r9, 8
jmp SET_OP_NEXT_113
SET_OP_ZERO_112:
store 0, _tmpptr2, r9, 8
SET_OP_NEXT_113:
add r9, 1
jmp SET_OP_109
SET_OP_END_110:
mov r9, 0
set_copy_114:
cmp r9, 256
jge set_copy_end_115
load r10, _tmpptr2, r9, 8
store r10, result_set, r9, 8
add r9, 1
jmp set_copy_114
set_copy_end_115:
free _tmpptr2
free _tmpptr0
free _tmpptr1
print fmt_str, str_14
mov i, 1
FOR_116:
cmp i, 23
jg ENDFOR_117
load r9, result_set, i, 8
cmp r9, 0
je IN_NOT_FOUND_121
mov r10, 1
jmp IN_END_122
IN_NOT_FOUND_121:
mov r10, 0
IN_END_122:
cmp r10, 0
je ELSE_119
print fmt_int, i
print fmt_str, str_3
ELSE_119:
FOR_CONTINUE_118:
add i, 1
jmp FOR_116
ENDFOR_117:
print newline
print newline
print fmt_str, str_15
print newline
mov f_filename, str_16
invoke fopen, f_filename, str_17
return r9
mov f, r9
invoke fprintf, f, fmt_str, str_18
invoke fputs, str_19, f
invoke fprintf, f, fmt_str, str_20
invoke fputs, str_19, f
invoke fprintf, f, fmt_str, str_21
invoke fputs, str_19, f
mov i, 1
FOR_123:
cmp i, 5
jg ENDFOR_124
invoke fprintf, f, fmt_str, str_22
invoke fprintf, f, fmt_int, i
invoke fprintf, f, fmt_str, str_23
mov r9, i
mul r9, i
invoke fprintf, f, fmt_int, r9
invoke fputs, str_19, f
FOR_CONTINUE_125:
add i, 1
jmp FOR_123
ENDFOR_124:
invoke fclose, f
print fmt_str, str_24
print newline
print fmt_str, str_25
print newline
mov f_filename, str_16
invoke fopen, f_filename, str_26
return r9
mov f, r9
mov count, 0
WHILE_126:
invoke feof, f
return r9
not r9
cmp r9, 0
je ENDWHILE_127
invoke mxvm_fgets, f
return r9
mov line, r9
invoke strlen, line
return r9
cmp r9, 0
jle ELSE_128
mov r9, count
add r9, 1
mov count, r9
print fmt_str, str_27
print fmt_int, count
print fmt_str, str_28
print fmt_str, line
print newline
ELSE_128:
jmp WHILE_126
ENDWHILE_127:
invoke fclose, f
print fmt_str, str_29
print fmt_int, count
print fmt_str, str_30
print newline
mov f_filename, str_16
invoke fopen, f_filename, str_31
return r9
mov f, r9
invoke fprintf, f, fmt_str, str_32
invoke fputs, str_19, f
invoke fclose, f
print fmt_str, str_33
print newline
mov f_filename, str_16
invoke fopen, f_filename, str_26
return r9
mov f, r9
mov count, 0
WHILE_132:
invoke feof, f
return r9
not r9
cmp r9, 0
je ENDWHILE_133
invoke mxvm_fgets, f
return r9
mov line, r9
invoke strlen, line
return r9
cmp r9, 0
jle ELSE_134
mov r9, count
add r9, 1
mov count, r9
ELSE_134:
jmp WHILE_132
ENDWHILE_133:
invoke fclose, f
print fmt_str, str_34
print fmt_int, count
print fmt_str, str_30
print newline
mov f_filename, str_35
invoke fopen, f_filename, str_17
return r9
mov f, r9
invoke fprintf, f, fmt_str, str_36
invoke fputs, str_19, f
mov i, 1
FOR_138:
cmp i, 30
jg ENDFOR_139
invoke fprintf, f, fmt_int, i
load r9, primes, i, 8
cmp r9, 0
je IN_NOT_FOUND_143
mov r10, 1
jmp IN_END_144
IN_NOT_FOUND_143:
mov r10, 0
IN_END_144:
cmp r10, 0
je ELSE_141
invoke fprintf, f, fmt_str, str_37
jmp ENDIF_142
ELSE_141:
invoke fprintf, f, fmt_str, str_38
ENDIF_142:
load r9, evens, i, 8
cmp r9, 0
je IN_NOT_FOUND_147
mov r10, 1
jmp IN_END_148
IN_NOT_FOUND_147:
mov r10, 0
IN_END_148:
cmp r10, 0
je ELSE_145
invoke fprintf, f, fmt_str, str_37
jmp ENDIF_146
ELSE_145:
invoke fprintf, f, fmt_str, str_38
ENDIF_146:
load r9, odds, i, 8
cmp r9, 0
je IN_NOT_FOUND_151
mov r10, 1
jmp IN_END_152
IN_NOT_FOUND_151:
mov r10, 0
IN_END_152:
cmp r10, 0
je ELSE_149
invoke fprintf, f, fmt_str, str_37
jmp ENDIF_150
ELSE_149:
invoke fprintf, f, fmt_str, str_38
ENDIF_150:
invoke fprintf, f, fmt_str, str_39
invoke fputs, str_19, f
FOR_CONTINUE_140:
add i, 1
jmp FOR_138
ENDFOR_139:
invoke fclose, f
print fmt_str, str_40
print newline
print newline
print fmt_str, str_41
print newline
mov i, 1
FOR_153:
cmp i, 10
jg ENDFOR_154
mov r9, i
mul r9, 10
cmp i, 1
jl IDX_OOB_157
cmp i, 10
jg IDX_OOB_157
jmp IDX_OK_156
IDX_OOB_157:
exit 1
IDX_OK_156:
mov r10, i
sub r10, 1
store r9, pa, r10, 8
FOR_CONTINUE_155:
add i, 1
jmp FOR_153
ENDFOR_154:
print fmt_str, str_42
mov i, 1
FOR_158:
cmp i, 10
jg ENDFOR_159
mov r9, i
sub r9, 1
load r10, pa, r9, 8
print fmt_int, r10
print fmt_str, str_3
FOR_CONTINUE_160:
add i, 1
jmp FOR_158
ENDFOR_159:
print newline
store 42, pr, 0, 1
store 99, pr, 8, 1
print fmt_str, str_43
load r9, pr, 0, 1
print fmt_int, r9
print fmt_str, str_44
load r9, pr, 8, 1
print fmt_int, r9
print newline
print newline
print fmt_str, str_45
print newline
free vowels
free consonants
free letters
free primes
free evens
free odds
free result_set
free pa
free pr
done
}
}