提交 90bf1b79 创建 作者: 赵鹏翀's avatar 赵鹏翀

Merge branch 'DM' into 'master'

没有这种文件类型的预览
...@@ -811,10 +811,6 @@ ...@@ -811,10 +811,6 @@
<text alignment-baseline="after-edge" fill="#000080" font-family="宋体" font-size="25" font-weight="400" text-anchor="start" x="409" y="1894">复位uPC,执行第一条(地址为0)微指令,完成取指令功能</text> <text alignment-baseline="after-edge" fill="#000080" font-family="宋体" font-size="25" font-weight="400" text-anchor="start" x="409" y="1894">复位uPC,执行第一条(地址为0)微指令,完成取指令功能</text>
<polygon fill="#ffff80" points="19 2894, 19 2869, 144 2869, 169 2894, 144 2919, 19 2919, 19 2894" stroke="#800000" stroke-width="1"/>
<text alignment-baseline="central" fill="#800000" font-family="Times New Roman" font-size="25" font-weight="400" text-anchor="start" x="19" y="2894">RESET</text>
<polyline fill="none" points="1549 1904, 1449 1904, 1389 1904, 1349 1904, 1329 1904, 1229 1904, 1229 2054" stroke="#0000ff" stroke-linecap="round" stroke-linejoin="round" stroke-width="5"/> <polyline fill="none" points="1549 1904, 1449 1904, 1389 1904, 1349 1904, 1329 1904, 1229 1904, 1229 2054" stroke="#0000ff" stroke-linecap="round" stroke-linejoin="round" stroke-width="5"/>
<text alignment-baseline="after-edge" fill="#800000" font-family="Times New Roman" font-size="25" font-weight="400" text-anchor="start" x="1329" y="1904">UPC_RESET_EN</text> <text alignment-baseline="after-edge" fill="#800000" font-family="Times New Roman" font-size="25" font-weight="400" text-anchor="start" x="1329" y="1904">UPC_RESET_EN</text>
...@@ -823,7 +819,7 @@ ...@@ -823,7 +819,7 @@
<rect fill="#80ff80" height="450" stroke="#800000" stroke-width="1" width="500" x="539" y="2304"/> <rect fill="#80ff80" height="450" stroke="#800000" stroke-width="1" width="500" x="539" y="2304"/>
<text alignment-baseline="after-edge" fill="#000000" font-family="Times New Roman" font-size="65" font-weight="700" text-anchor="start" x="499" y="2244">uPC_NEXT</text> <text alignment-baseline="after-edge" fill="#000000" font-family="微软雅黑" font-size="65" font-weight="700" text-anchor="start" x="499" y="2244">uPC_NEXT</text>
<text alignment-baseline="after-edge" fill="#000080" font-family="Times New Roman" font-size="25" font-weight="400" text-anchor="start" x="549" y="2294">uPC_NEXT.dlsche</text> <text alignment-baseline="after-edge" fill="#000080" font-family="Times New Roman" font-size="25" font-weight="400" text-anchor="start" x="549" y="2294">uPC_NEXT.dlsche</text>
...@@ -991,7 +987,7 @@ ...@@ -991,7 +987,7 @@
<circle cx="1594" cy="2704" fill="none" r="5" stroke="#000000" stroke-width="5"/> <circle cx="1594" cy="2704" fill="none" r="5" stroke="#000000" stroke-width="5"/>
<text alignment-baseline="after-edge" fill="#000000" font-family="Arial" font-size="40" font-weight="700" text-anchor="start" x="1419" y="2304">UPC_NEXT_GATE</text> <text alignment-baseline="after-edge" fill="#000000" font-family="Arial" font-size="40" font-weight="700" text-anchor="start" x="1569" y="2294">uPC_gate</text>
<text alignment-baseline="after-edge" fill="#000000" font-family="Arial" font-size="25" font-weight="700" text-anchor="start" x="1559" y="2794">BUS_TRANS16</text> <text alignment-baseline="after-edge" fill="#000000" font-family="Arial" font-size="25" font-weight="700" text-anchor="start" x="1559" y="2794">BUS_TRANS16</text>
...@@ -1209,7 +1205,7 @@ ...@@ -1209,7 +1205,7 @@
<circle cx="1594" cy="1324" fill="none" r="5" stroke="#000000" stroke-width="5"/> <circle cx="1594" cy="1324" fill="none" r="5" stroke="#000000" stroke-width="5"/>
<text alignment-baseline="after-edge" fill="#000000" font-family="Arial" font-size="40" font-weight="700" text-anchor="start" x="1589" y="934">IR_gate</text> <text alignment-baseline="after-edge" fill="#000000" font-family="Arial" font-size="40" font-weight="700" text-anchor="start" x="1499" y="934">IR_uAddress_gate</text>
<text alignment-baseline="after-edge" fill="#000000" font-family="Arial" font-size="25" font-weight="700" text-anchor="start" x="1559" y="1414">BUS_TRANS16</text> <text alignment-baseline="after-edge" fill="#000000" font-family="Arial" font-size="25" font-weight="700" text-anchor="start" x="1559" y="1414">BUS_TRANS16</text>
...@@ -1349,7 +1345,7 @@ ...@@ -1349,7 +1345,7 @@
<circle cx="1594" cy="1904" fill="none" r="5" stroke="#000000" stroke-width="5"/> <circle cx="1594" cy="1904" fill="none" r="5" stroke="#000000" stroke-width="5"/>
<text alignment-baseline="after-edge" fill="#000000" font-family="Arial" font-size="40" font-weight="700" text-anchor="start" x="1379" y="1514">UPC_RESET_GATE</text> <text alignment-baseline="after-edge" fill="#000000" font-family="Arial" font-size="40" font-weight="700" text-anchor="start" x="1499" y="1504">IR_Fetch_gate</text>
<text alignment-baseline="after-edge" fill="#000000" font-family="Arial" font-size="25" font-weight="700" text-anchor="start" x="1559" y="1994">BUS_TRANS16</text> <text alignment-baseline="after-edge" fill="#000000" font-family="Arial" font-size="25" font-weight="700" text-anchor="start" x="1559" y="1994">BUS_TRANS16</text>
...@@ -1791,6 +1787,10 @@ ...@@ -1791,6 +1787,10 @@
<text alignment-baseline="after-edge" fill="#000000" font-family="Arial" font-size="25" font-weight="700" text-anchor="start" x="2829" y="1674">REG_EN8</text> <text alignment-baseline="after-edge" fill="#000000" font-family="Arial" font-size="25" font-weight="700" text-anchor="start" x="2829" y="1674">REG_EN8</text>
<polygon fill="#ffff80" points="19 2894, 19 2869, 144 2869, 169 2894, 144 2919, 19 2919, 19 2894" stroke="#800000" stroke-width="1"/>
<text alignment-baseline="central" fill="#800000" font-family="Times New Roman" font-size="25" font-weight="400" text-anchor="start" x="19" y="2894">RESET</text>
<circle cx="3169" cy="3434" fill="#0000ff" r="8" stroke="#0000ff" stroke-width="5"/> <circle cx="3169" cy="3434" fill="#0000ff" r="8" stroke="#0000ff" stroke-width="5"/>
<circle cx="1229" cy="1904" fill="#0000ff" r="8" stroke="#0000ff" stroke-width="5"/> <circle cx="1229" cy="1904" fill="#0000ff" r="8" stroke="#0000ff" stroke-width="5"/>
......
没有这种文件类型的预览
差异被折叠。
没有这种文件类型的预览
差异被折叠。
没有这种文件类型的预览
...@@ -965,7 +965,7 @@ ...@@ -965,7 +965,7 @@
<circle cx="1126" cy="4284" fill="#ffffff" r="5" stroke="#000000" stroke-width="5"/> <circle cx="1126" cy="4284" fill="#ffffff" r="5" stroke="#000000" stroke-width="5"/>
<text alignment-baseline="after-edge" fill="#000000" font-family="Arial" font-size="45" font-weight="700" text-anchor="start" x="1201" y="3954">ST</text> <text alignment-baseline="after-edge" fill="#000000" font-family="Arial" font-size="45" font-weight="700" text-anchor="start" x="1201" y="3954">SP</text>
<text alignment-baseline="after-edge" fill="#000000" font-family="Arial" font-size="25" font-weight="700" text-anchor="start" x="1181" y="4404">REG_EN8</text> <text alignment-baseline="after-edge" fill="#000000" font-family="Arial" font-size="25" font-weight="700" text-anchor="start" x="1181" y="4404">REG_EN8</text>
...@@ -1887,7 +1887,7 @@ ...@@ -1887,7 +1887,7 @@
<circle cx="1806" cy="4284" fill="none" r="5" stroke="#000000" stroke-width="5"/> <circle cx="1806" cy="4284" fill="none" r="5" stroke="#000000" stroke-width="5"/>
<text alignment-baseline="after-edge" fill="#000000" font-family="Arial" font-size="25" font-weight="700" text-anchor="start" x="1841" y="3964">ST_gate</text> <text alignment-baseline="after-edge" fill="#000000" font-family="Arial" font-size="25" font-weight="700" text-anchor="start" x="1841" y="3964">SP_gate</text>
<text alignment-baseline="after-edge" fill="#000000" font-family="Arial" font-size="25" font-weight="700" text-anchor="start" x="1811" y="4374">BUS_TRANS8</text> <text alignment-baseline="after-edge" fill="#000000" font-family="Arial" font-size="25" font-weight="700" text-anchor="start" x="1811" y="4374">BUS_TRANS8</text>
......
...@@ -124,7 +124,7 @@ const char* r1_register_indirect_keyword = "[r1]"; ...@@ -124,7 +124,7 @@ const char* r1_register_indirect_keyword = "[r1]";
const char* r2_register_indirect_keyword = "[r2]"; const char* r2_register_indirect_keyword = "[r2]";
const char* r3_register_indirect_keyword = "[r3]"; const char* r3_register_indirect_keyword = "[r3]";
const char* a_register_keyword = "a"; const char* a_register_keyword = "a";
const char* st_register_keyword = "st"; const char* sp_register_keyword = "sp";
const char* delimit_char = "\n\t\r "; // 需要忽略的空白字符 const char* delimit_char = "\n\t\r "; // 需要忽略的空白字符
const char* delimit_char_comma = "\n\t\r, "; // 需要忽略的空白字符,包括英文逗号 const char* delimit_char_comma = "\n\t\r, "; // 需要忽略的空白字符,包括英文逗号
...@@ -241,7 +241,7 @@ enum ...@@ -241,7 +241,7 @@ enum
,OT_REGISTER_R3_INDIRECT // [r3] ,OT_REGISTER_R3_INDIRECT // [r3]
,OT_IMMEDIATE // 立即数 ,OT_IMMEDIATE // 立即数
,OT_SYMBOL // 符号 ,OT_SYMBOL // 符号
,OT_REGISTER_ST // 堆栈寄存器 ,OT_REGISTER_SP // 堆栈指针寄存器
}; };
// 得到指令操作数的类型 // 得到指令操作数的类型
...@@ -285,9 +285,9 @@ unsigned long get_operand_type(const char* op) ...@@ -285,9 +285,9 @@ unsigned long get_operand_type(const char* op)
{ {
op_type = OT_REGISTER_R3_INDIRECT; op_type = OT_REGISTER_R3_INDIRECT;
} }
else if (stricmp(op, st_register_keyword) == 0) else if (stricmp(op, sp_register_keyword) == 0)
{ {
op_type = OT_REGISTER_ST; op_type = OT_REGISTER_SP;
} }
else if(is_immediate(op)) else if(is_immediate(op))
{ {
...@@ -422,9 +422,9 @@ void parse_mov(int line_num) ...@@ -422,9 +422,9 @@ void parse_mov(int line_num)
machine_code[machine_code_address] = get_machine_code_from_immediate(op2); machine_code[machine_code_address] = get_machine_code_from_immediate(op2);
machine_code_address++; machine_code_address++;
} }
else if (OT_REGISTER_ST == op1_type && OT_IMMEDIATE == op2_type) else if (OT_REGISTER_SP == op1_type && OT_IMMEDIATE == op2_type)
{ {
// mov st, immediate // mov sp, immediate
machine_code[machine_code_address] = 0x9c; machine_code[machine_code_address] = 0x9c;
machine_code_address++; machine_code_address++;
...@@ -1581,7 +1581,7 @@ struct KEYWORD_FUNCTION_ENTRY keyword_function_table[] = ...@@ -1581,7 +1581,7 @@ struct KEYWORD_FUNCTION_ENTRY keyword_function_table[] =
,{ &r2_register_indirect_keyword, NULL } ,{ &r2_register_indirect_keyword, NULL }
,{ &r3_register_indirect_keyword, NULL } ,{ &r3_register_indirect_keyword, NULL }
,{ &a_register_keyword, NULL } ,{ &a_register_keyword, NULL }
,{ &st_register_keyword, NULL } ,{ &sp_register_keyword, NULL }
}; };
// 判断是否是一个关键字。返回0,不是关键字;返回非0,是关键字,并且返回值就是关键字在表中的下标。 // 判断是否是一个关键字。返回0,不是关键字;返回非0,是关键字,并且返回值就是关键字在表中的下标。
......
没有这种文件类型的预览
...@@ -52,7 +52,7 @@ const char* rx_register_keyword = "rx"; ...@@ -52,7 +52,7 @@ const char* rx_register_keyword = "rx";
const char* mar_register_keyword = "mar"; const char* mar_register_keyword = "mar";
const char* rin_register_keyword = "rin"; const char* rin_register_keyword = "rin";
const char* rout_register_keyword = "rout"; const char* rout_register_keyword = "rout";
const char* st_register_keyword = "st"; const char* sp_register_keyword = "sp";
const char* ia_register_keyword = "ia"; const char* ia_register_keyword = "ia";
const char* ir_register_keyword = "ir"; const char* ir_register_keyword = "ir";
const char* flag_register_keyword = "flag"; const char* flag_register_keyword = "flag";
...@@ -82,12 +82,12 @@ const char* alu_rcl_keyword = "alu_rcl"; ...@@ -82,12 +82,12 @@ const char* alu_rcl_keyword = "alu_rcl";
const char* alu_not_keyword = "alu_not"; const char* alu_not_keyword = "alu_not";
const char* st_add_keyword = "st_add"; const char* sp_inc_keyword = "sp_inc";
const char* st_minus_keyword = "st_minus"; const char* sp_dec_keyword = "sp_dec";
const char* int_number_keyword = "int_number"; // 中断号 const char* int_number_keyword = "int_number"; // 中断号
const char* int_ia_keyword = "int_ia"; const char* int_ia_keyword = "int_ia";
const char* int_pc_keyword = "int_pc"; const char* int_pc_keyword = "[int_pc]";
// 访问主存或外设的操作数 // 访问主存或外设的操作数
const char* pc_main_memory_keyword = "[pc]"; const char* pc_main_memory_keyword = "[pc]";
...@@ -177,29 +177,29 @@ struct PATH_INSTRUCTION_OPERAND_ENTRY path_operand_table[] = ...@@ -177,29 +177,29 @@ struct PATH_INSTRUCTION_OPERAND_ENTRY path_operand_table[] =
,{ &alu_aout_keyword, &mar_main_memory_keyword, 0xd0f4fbec } // path alu_aout, [mar] ,{ &alu_aout_keyword, &mar_main_memory_keyword, 0xd0f4fbec } // path alu_aout, [mar]
,{ &pc_main_memory_keyword, &pc_register_keyword, 0xfff96fef } // path [pc], pc ,{ &pc_main_memory_keyword, &pc_register_keyword, 0xfff96fef } // path [pc], pc
,{ &pc_inc_main_memory_keyword, &pc_register_keyword, 0xfff96fff } // path [+pc], pc 读出PC指向主存单元的内容,同时允许PC加1,主要用在jz和jc指令中 ,{ &pc_inc_main_memory_keyword, &pc_register_keyword, 0xfff96fff } // path [+pc], pc 读出PC指向主存单元的内容,同时允许PC加1,主要用在jz和jc指令中
,{ &pc_register_keyword, &st_register_keyword, 0xfff3feef } // path pc, st ,{ &pc_register_keyword, &sp_register_keyword, 0xfff3feef } // path pc, sp
,{ &ia_register_keyword, &mar_register_keyword, 0xfff1f7ef } // path ia, mar ,{ &ia_register_keyword, &mar_register_keyword, 0xfff1f7ef } // path ia, mar
,{ &pc_register_keyword, &mar_register_keyword, 0xfff3f7ef } // path pc, mar ,{ &pc_register_keyword, &mar_register_keyword, 0xfff3f7ef } // path pc, mar
,{ &rin_register_keyword, &a_register_keyword, 0xbff0ffef } // path rin, a ,{ &rin_register_keyword, &a_register_keyword, 0xbff0ffef } // path rin, a
,{ &a_register_keyword, &rout_register_keyword, 0xd0f4ffee } // path a, rout ,{ &a_register_keyword, &rout_register_keyword, 0xd0f4ffee } // path a, rout
,{ &mar_main_memory_keyword, &pc_register_keyword, 0xfff9ebef } // 从地址寄存器指定的内存单元读数据到程序计数器pc ,{ &mar_main_memory_keyword, &pc_register_keyword, 0xfff9ebef } // 从地址寄存器指定的内存单元读数据到程序计数器pc
,{ &pc_main_memory_keyword, &st_register_keyword, 0xfff97eef } // path [pc], st 执行后pc应加1指向下一条指令 ,{ &pc_main_memory_keyword, &sp_register_keyword, 0xfff97eef } // path [pc], sp 执行后pc应加1指向下一条指令
,{ &st_register_keyword, &mar_register_keyword, 0xfff2f7ef } // path st, mar ,{ &sp_register_keyword, &mar_register_keyword, 0xfff2f7ef } // path sp, mar
,{ &st_register_keyword, &cst_counter_keyword, 0xff72ffef } // path st, cst ,{ &sp_register_keyword, &cst_counter_keyword, 0xff72ffef } // path sp, cst
,{ &pc_main_memory_keyword, &ia_register_keyword, 0xfff97feb } // path [pc], ia 执行后pc应加1指向下一条指令 ,{ &pc_main_memory_keyword, &ia_register_keyword, 0xfff97feb } // path [pc], ia 执行后pc应加1指向下一条指令
,{ &pc_main_memory_keyword, &asr_register_keyword, 0xfff97def } // path [pc], asr ,{ &pc_main_memory_keyword, &asr_register_keyword, 0xfff97def } // path [pc], asr
,{ &cst_counter_keyword, &mar_register_keyword, 0xfff8f7ef } // path cst, mar ,{ &cst_counter_keyword, &mar_register_keyword, 0xfff8f7ef } // path cst, mar
,{ &cst_counter_keyword, &st_register_keyword, 0xfff8feef } // path cst, st ,{ &cst_counter_keyword, &sp_register_keyword, 0xfff8feef } // path cst, sp
,{ &st_add_keyword, &cst_counter_keyword, 0xffffffe7 } // path st_add, cst ,{ &sp_inc_keyword, &cst_counter_keyword, 0xffffffe7 } // path st_inc, cst
,{ &st_minus_keyword, &cst_counter_keyword, 0xffffffef } // path st_minus, cst ,{ &sp_dec_keyword, &cst_counter_keyword, 0xffffffef } // path st_dec, cst
,{ &pc_register_keyword, &mar_main_memory_keyword, 0xfff3fbed } // path pc, [mar] 将pc值写入mar指向的内存 ,{ &pc_register_keyword, &mar_main_memory_keyword, 0xfff3fbed } // path pc, [mar] 将pc值写入mar指向的内存
,{ &asr_register_keyword, &pc_register_keyword, 0xfff7efef } // path asr, pc ,{ &asr_register_keyword, &pc_register_keyword, 0xfff7efef } // path asr, pc
,{ &st_register_keyword, &asr_register_keyword, 0xfff2fdef } // path st, asr ,{ &sp_register_keyword, &asr_register_keyword, 0xfff2fdef } // path sp, asr
,{ &int_number_keyword, &ia_register_keyword, 0xfffbffeb } // path int_number, ia 将中断号给ia寄存器 ,{ &int_number_keyword, &ia_register_keyword, 0xfffbffeb } // path int_number, ia 将中断号给ia寄存器
,{ &int_ia_keyword, &pc_register_keyword, 0xfff1dfef } // path int_ia, pc ,{ &int_ia_keyword, &pc_register_keyword, 0xfff1dfef } // path int_ia, pc
......
没有这种文件类型的预览
; 示例程序 ; 示例程序
.text .text
mov sp, 0xf8 ;初始化堆栈指针寄存器
mov r0, 16 mov r0, 16 ;将立即数16存入寄存器r0
mov a, num mov a, num ;将标号num指定的存储单元内容复制到累加器a中
add a, r0 add a, r0 ;将累加器a与寄存器r0相加,结果写回a中
Endless_Loop: Endless_Loop:
jmp Endless_Loop jmp Endless_Loop ;死循环
.data .data
......
没有这种文件类型的预览
0001 ; 示例程序 0001 ; 示例程序
0002 0002
0003 .text 0003 .text
0004 0004 00 9C F8 mov sp, 0xf8 ;初始化堆栈指针寄存器
0005 00 8C 10 mov r0, 16 0005 02 8C 10 mov r0, 16 ;将立即数16存入寄存器r0
0006 02 78 07 mov a, num 0006 04 78 09 mov a, num ;将标号num指定的存储单元内容复制到累加器a中
0007 04 10 add a, r0 0007 06 10 add a, r0 ;将累加器a与寄存器r0相加,结果写回a中
0008 0008
0009 Endless_Loop: 0009 Endless_Loop:
0010 05 AC 05 jmp Endless_Loop 0010 07 AC 07 jmp Endless_Loop ;死循环
0011 0011
0012 .data 0012 .data
0013 0013
0014 07 FF num: -1 0014 09 FF num: -1
没有这种文件类型的预览
没有这种文件类型的预览
差异被折叠。
...@@ -8,17 +8,17 @@ path [pc], ir ...@@ -8,17 +8,17 @@ path [pc], ir
dup 31, null dup 31, null
; add a, rx ; add a, rx
path rx, w path rx, w ;将寄存器 R 的内容传送到工作寄存器 W 中,R 的内容不变
path alu_add, a path alu_add, a ;累加器 A 与工作寄存器 W 进行无进位加运算,结果写回 A 中,即A=A+W
inc pc inc pc ;PC 加1,指向下一个字节单元
reset upc reset upc ;uPC 寄存器复位为0,指向第一条微指令,该微指令完成取指令功能
dup 4, null dup 4, null
; add a, [rx] ; add a, [rx]
path rx, mar path rx, mar ;将寄存器 R 的内容传送到地址寄存器 MAR,R 的内容不变
path [mar], w path [mar], w ;读出地址寄存器 MAR 指定存储单元的内容并写入工作寄存器 W 中
path alu_add, a path alu_add, a
inc pc inc pc
reset upc reset upc
...@@ -26,8 +26,8 @@ dup 3, null ...@@ -26,8 +26,8 @@ dup 3, null
; add a, symbol ; add a, symbol
inc pc inc pc
path [pc], mar path [pc], mar ;读出 PC 指定存储单元的内容并写入地址寄存器 MAR
path [mar], w path [mar], w
path alu_add, a path alu_add, a
inc pc inc pc
reset upc reset upc
...@@ -36,7 +36,7 @@ dup 2, null ...@@ -36,7 +36,7 @@ dup 2, null
; add a, immediate ; add a, immediate
inc pc inc pc
path [pc], w path [pc], w ;读出 PC 指定存储单元的内容并写入工作寄存器 W
path alu_add, a path alu_add, a
inc pc inc pc
reset upc reset upc
...@@ -45,7 +45,7 @@ dup 3, null ...@@ -45,7 +45,7 @@ dup 3, null
; adc a, rx ; adc a, rx
path rx, w path rx, w
path alu_adc, a path alu_adc, a ;累加器 A 与工作寄存器 W 进行带进位的加法运算,结果写回 A 中,即A=A+W+1
inc pc inc pc
reset upc reset upc
...@@ -81,7 +81,7 @@ dup 3, null ...@@ -81,7 +81,7 @@ dup 3, null
; sub a, rx ; sub a, rx
path rx, w path rx, w
path alu_sub, a path alu_sub, a ;累加器 A 减 W 进行减法运算,结果写回 A 中,即A=A-W
inc pc inc pc
reset upc reset upc
...@@ -117,7 +117,7 @@ dup 3, null ...@@ -117,7 +117,7 @@ dup 3, null
; sbb a, rx ; sbb a, rx
path rx, w path rx, w
path alu_sbb, a path alu_sbb, a ;累加器 A 与工作寄存器 W 进行带进位的减法运算,结果写回 A 中,即A=A-W-1
inc pc inc pc
reset upc reset upc
...@@ -153,7 +153,7 @@ dup 3, null ...@@ -153,7 +153,7 @@ dup 3, null
; and a, rx ; and a, rx
path rx, w path rx, w
path alu_and a path alu_and a ;A = A & W,A与W进行按位与运算
inc pc inc pc
reset upc reset upc
...@@ -189,7 +189,7 @@ dup 3, null ...@@ -189,7 +189,7 @@ dup 3, null
; or a, rx ; or a, rx
path rx, w path rx, w
path alu_or a path alu_or a ;A = A | W,A与W进行按位或运算
inc pc inc pc
reset upc reset upc
...@@ -224,15 +224,15 @@ reset upc ...@@ -224,15 +224,15 @@ reset upc
dup 3, null dup 3, null
; mov a, rx ; mov a, rx
path rx, a path rx, a ;将寄存器 R 的内容传送到累加器 A 中
inc pc inc pc
reset upc reset upc
dup 5, null dup 5, null
; mov a, [rx] ; mov a, [rx]
path rx, mar path rx, mar ;将寄存器 R 的内容传送到地址寄存器 MAR 中
path [mar], a path [mar], a ;将地址寄存器MAR指定存储单元的内容传送到累加器 A 中
inc pc inc pc
reset upc reset upc
...@@ -240,7 +240,7 @@ dup 4, null ...@@ -240,7 +240,7 @@ dup 4, null
; mov a, symbol ; mov a, symbol
inc pc inc pc
path [pc], mar path [pc], mar ;将程序计数器 PC 指定存储单元的内容传送到 MAR 中
path [mar], a path [mar], a
inc pc inc pc
reset upc reset upc
...@@ -249,22 +249,22 @@ dup 3, null ...@@ -249,22 +249,22 @@ dup 3, null
; mov a, immediate ; mov a, immediate
inc pc inc pc
path [pc], a path [pc], a ;将程序计数器 PC 指定存储单元的内容传送到 A 中
inc pc inc pc
reset upc reset upc
dup 4, null dup 4, null
; mov rx, a ; mov rx, a
path a, rx path a, rx ;将累加器 A 的内容传送到寄存器 R 中
inc pc inc pc
reset upc reset upc
dup 5, null dup 5, null
; mov [rx], a ; mov [rx], a
path rx, mar path rx, mar ;将寄存器 R 的内容传送到地址寄存器 MAR 中
path a, [mar] path a, [mar] ;将累加器 A 的内容写入地址寄存器 MAR 指定存储单元中
inc pc inc pc
reset upc reset upc
...@@ -272,7 +272,7 @@ dup 4, null ...@@ -272,7 +272,7 @@ dup 4, null
; mov symbol, a ; mov symbol, a
inc pc inc pc
path [pc], mar path [pc], mar ;将 PC 指定存储单元的内容传送到地址寄存器 MAR 中
path a, [mar] path a, [mar]
inc pc inc pc
reset upc reset upc
...@@ -281,29 +281,17 @@ dup 3, null ...@@ -281,29 +281,17 @@ dup 3, null
; mov rx, immediate ; mov rx, immediate
inc pc inc pc
path [pc], rx path [pc], rx ;将 PC 指定存储单元的内容传送到寄存器 R 中
inc pc inc pc
reset upc reset upc
dup 4, null dup 4, null
; read a, symbol ; 填充空白指令
inc pc dup 8, null
path [pc], mar
path <mar>, a
inc pc
reset upc
dup 3, null
; write symbol, a
inc pc
path [pc], mar
path alu_aout, [mar]
inc pc
reset upc
dup 3, null ; 填充空白指令
dup 8, null
; lea a, symbol ; lea a, symbol
inc pc inc pc
...@@ -313,9 +301,9 @@ reset upc ...@@ -313,9 +301,9 @@ reset upc
dup 4, null dup 4, null
;mov st, immediate ;mov sp, immediate
inc pc inc pc
path [pc], st path [pc], sp ;将 PC 指定存储单元的内容传送到堆栈指针寄存器 SP 中
inc pc inc pc
reset upc reset upc
...@@ -323,7 +311,7 @@ dup 4, null ...@@ -323,7 +311,7 @@ dup 4, null
; jc symbol ; jc symbol
inc pc inc pc
path [pc], pc path [pc], pc ;将 PC 指定存储单元的内容作为指令地址加载到 PC 中,实现程序跳转
reset upc reset upc
dup 5, null dup 5, null
...@@ -346,73 +334,80 @@ reset upc ...@@ -346,73 +334,80 @@ reset upc
dup 5, null dup 5, null
; in ; in
path rin, a path rin, a ;将输入寄存器 RIN 的内容传送到累加器 A 中
inc pc inc pc
reset upc reset upc
dup 5, null dup 5, null
; out ; out
path a, rout path a, rout ;将累加器 A 中的内容传送到输出寄存器 ROUT 中
inc pc inc pc
reset upc reset upc
dup 5, null dup 5, null
;=======================================================================
;软中断,通过执行软中断指令,调用指定的中断服务程序
;软中断指令是双字节指令,第二个字节是立即数操作数,指调用中断的标号
; int immediate ; int immediate
inc pc inc pc ;PC+1,指向指令中的立即数操作数,即中断号,准备读出
path [pc], ia path [pc], ia ;将读出的中断号写入寄存器 IA 中,将来自于立即数的低3位中断号与IA寄存器的高5位中断向量起始地址组合,得到调用中断的中断向量
path st, cst path sp, cst ;堆栈指针寄存器的值传送到计数器CST中
path st_minus, cst path sp_dec, cst ;CST计数器减1
path cst, st path cst, sp ;将CST减1后的结果写入SP中,完成SP-1,入栈,更新栈顶
path st, mar path sp, mar ;将SP指针暂存到MAR
inc pc inc pc ;PC+1,中断返回地址,指向下一条指令
path pc, [mar] path pc, [mar] ;将PC值写入MAR指定存储单元,在这里实现的功能是将中断返回地址(PC)写入堆栈指针(SP)指定的存储单元中
path ia, mar path ia, mar ;将寄存器IA 的内容作为地址写入 MAR,在这里实现的功能是将调用中断的中断向量写入地址寄存器MAR中,准备读出中断向量指定单元的中断服务程序入口地址
path [mar], pc path [mar], pc ;将地址寄存器MAR指定单元的内容加载到PC中,在这里实现的功能是将调用中断的服务程序首地址加载到PC,使处理器转去执行中断服务程序
reset upc reset upc
dup 5, null dup 5, null
;=======================================================================
; ;
dup 16, null dup 16, null
;=======================================================================
;子程序调用返回指令
; ret ; ret
path st, mar path sp, mar ;将堆栈指针(栈顶地址)传送到 MAR
path st, cst path sp, cst ;
path st_add, cst path sp_inc, cst ;
path cst, st path cst, sp ;SP = SP + 1,出栈,更新栈顶
path [mar], pc path [mar], pc ;将调用返回地址加载到PC,转移到调用处的下一条指令继续执行
reset upc reset upc
dup 2, null dup 2, null
;=======================================================================
; 填充空白指令 ; 填充空白指令
dup 8, null dup 8, null
; shr a ; shr a
path alu_shr, a path alu_shr, a ;累加器A 进行逻辑右移,结果写回A中
inc pc inc pc
reset upc reset upc
dup 5, null dup 5, null
; shl a ; shl a
path alu_shl, a path alu_shl, a ;累加器A 进行逻辑左移,结果写回A中
inc pc inc pc
reset upc reset upc
dup 5, null dup 5, null
; rcr a ; rcr a
path alu_rcr, a path alu_rcr, a ;累加器A 进行循环右移,结果写回A中
inc pc inc pc
reset upc reset upc
dup 5, null dup 5, null
; rcl a ; rcl a
path alu_rcl, a path alu_rcl, a ;累加器A 进行循环左移,结果写回A中
inc pc inc pc
reset upc reset upc
dup 5, null dup 5, null
...@@ -424,22 +419,24 @@ reset upc ...@@ -424,22 +419,24 @@ reset upc
dup 6, null dup 6, null
; not a ; not a
path alu_not, a path alu_not, a ;累加器A 取反运算,结果写回A中
inc pc inc pc
reset upc reset upc
dup 5, null dup 5, null
;=============================================================
;子程序调用指令,双字节指令,第二个字节是调用子程序标号,该标号实质为一个地址,所指存储单元中就是被调用子程序的入口地址(起始地址)
; call symbol ; call symbol
inc pc inc pc ;PC+1
path [pc], asr path [pc], asr ;将PC指向存储单元内容写入辅助寄存器ASR中,也就是将被调用子程序的入口地址暂存到ASR中
path st, cst path sp, cst
path st_minus, cst path sp_dec, cst
path cst, st path cst, sp ;返回地址入栈前,先将SP-1,指向新的栈顶
path st, mar path sp, mar
inc pc inc pc ;PC+1,指向下一条指令,即返回地址
path pc, [mar] path pc, [mar] ;将PC(返回地址)入栈
path asr, pc path asr, pc ;将ASR寄存器的值加载到PC,也就是将调用子程序的入口地址加载到PC,转移到子程序处执行
reset upc reset upc
dup 6, null dup 6, null
...@@ -447,11 +444,13 @@ dup 6, null ...@@ -447,11 +444,13 @@ dup 6, null
; 填充空白指令 ; 填充空白指令
dup 16, null dup 16, null
;===============================================================
;中断返回指令,可参照子程序调用返回指令,出栈
; iret ; iret
path st, mar path sp, mar
path st, cst path sp, cst
path st_add, cst path sp_inc, cst
path cst, st path cst, sp
path [mar], pc path [mar], pc
reset upc reset upc
......
没有这种文件类型的预览
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论