如何打印出给定尺寸的方格
Problem statement:
问题陈述:
Write an assembly language program in 8085 to print the table of input integer.
在8085中编写汇编语言程序以打印输入整数表。
Assumptions: Suppose the inputted number is at memory location 2050 and the table will be printed from starting location 3050.
假设:假设输入的数字位于内存位置2050,并且将从起始位置3050开始打印表格。
Algorithm:
算法:
Load the value of input in accumulator from memory location 2050 and then copy it to another register say D. Also store 0A in register B.
从存储器位置2050将输入的值加载到累加器中,然后将其复制到另一个寄存器D中。还将0A存储在寄存器B中。
Store memory location 3050 in M using LXI instruction and take another register say C with its value 00.
使用LXI指令将存储单元3050存储在M中,并取另一个值为C的寄存器C。
Now copy the content of D register to A and add the contents of A and C and store it in A then copy it to M.
现在将D寄存器的内容复制到A,并将A和C的内容相加并存储在A中,然后将其复制到M。
Increment value of M by 1.
M的值增加1。
Copy content of A to C and decrements the content of B by 1 and if its value is 0 then halt otherwise again go to step number 3.
将A的内容复制到C,并将B的内容减1,如果B的值为0,则暂停,否则再次转到步骤3。
Program:
程序:
ADDRESS | MNEMONICS | COMMENTS |
---|---|---|
2000 | LDA 2050 | A |
2003 | MOV D, A | D |
2004 | MVI B 0A | B |
2006 | LXI H 3050 | H |
2009 | MVI C 00 | C |
200B | MOV A, D | A |
200C | ADD C | A |
200D | MOV M, A | M |
200E | INX H | HL |
200F | MOV C, A | C |
2010 | DCR B | B |
2011 | JNZ 200B | Jump to address 200B if ZF=0 |
2014 | HLT | Terminates the program |
地址 | 记忆 | 注释 |
---|---|---|
2000 | LDA 2050 | 一个 |
2003年 | MOV D,A | d |
2004年 | MVI B 0A | 乙 |
2006年 | LXI H 3050 | H |
2009年 | MVI C 00 | C |
200B | MOV A,D | 一个 |
200度 | 加C | 一个 |
200D | MOV M,A | 中号 |
200E | INX H | HL |
200楼 | MOV C,A | C |
2010 | DCR B | 乙 |
2011年 | JNZ 200B | 如果ZF = 0,则跳转到地址200B |
2014年 | HLT | 终止程序 |
Explanation:
说明:
LDA 2050: load the contents from 2050 memory location to accumulator (register A).
LDA 2050:将内容从2050存储器位置加载到累加器(寄存器A)。
MOV D, A: move the contents of accumulator to register D.
MOV D,A:将累加器的内容移至寄存器D。
MVI B 0A: store 0A data into register B.
MVI B 0A:将0A数据存储到寄存器B中。
LXI H 3050: store 30 in H register and 50 in L register; hence M will contain 3050 inside it.
LXI H 3050:在H寄存器中存储30,在L寄存器中存储50; 因此M内含3050。
MVI C 00: store 00 data in register C.
MVI C 00:将00数据存储在寄存器C中。
MOV A, D: move the contents of D register into A.
MOV A,D:将D寄存器的内容移至A。
ADD C: add the contents of A and C register and store in A.
添加C:将A和C寄存器的内容相加并存储在A中。
MOV M, A: move the contents of A register into M.
MOV M,A:将A寄存器的内容移到M。
INX H: increments content of M by 1.
INX H:将M的内容增加1。
MOV C, A: move the contents of A register into C.
MOV C,A:将A寄存器的内容移至C。
DCR B: decrements the content of B register by 1.
DCR B:将B寄存器的内容减1。
JNZ 200B: jump to address 200B if Carry flag is not zero.
JNZ 200B:如果进位标志不为零,则跳转到地址200B。
HLT: terminate the program.
HLT:终止程序。
翻译自: https://www.includehelp.com/embedded-system/print-the-table-of-a-given-number-using-8085-microprocessor.aspx
如何打印出给定尺寸的方格