如何打印出給定尺寸的方格
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
如何打印出給定尺寸的方格