如何打印出給定尺寸的方格
Problem statement:
問題陳述:
Write an assembly language program in 8086 to print the table of a given integer.
在8086中編寫匯編語言程序以打印給定整數的表。
Assumptions: Suppose the inputted number is at memory location 500 and the table will be printed from starting location 600 till 609 in hexadecimal.
假設:假設輸入的數字位于存儲位置500,并且表格將從起始位置600到609以十六進制打印。
Algorithm:
算法:
Load input number address in SI and also load the address where we want output in DI .
在SI中加載輸入數字地址,并在DI中加載我們要輸出的地址。
Store 00 in CH register.
將00存儲在CH寄存器中。
Increment value of CH by 1 and move the content of [SI] into AH register.
將CH的值遞增1,然后將[SI]的內容移到AH寄存器中。
Multiply content of AL and CH and store it in AX and then move content of AL into [DI], then increment value of DI by 1.
將AL和CH的內容相乘并將其存儲在AX中,然后將AL的內容移至[DI],然后將DI的值加1。
Compare the value of CH and 0A, if not equal then go to step number 3 otherwise halt the program.
比較CH和0A的值,如果不相等,則轉到第3步,否則暫停程序。
Program:
程序:
ADDRESS | MNEMONICS | COMMENTS |
400 | MOV SI, 500 | SI |
403 | MOV DI, 600 | DI |
406 | MOV CH, 00 | CH |
408 | INC CH | CH |
409 | MOV AL, [SI] | AL |
40B | MUL CH | AX |
40D | MOV [DI], AL | [DI] |
40F | INC DI | DI |
410 | CMP CH, 0A | CH-0A |
413 | JNZ 408 | jump to address 408 if zero flag is 0 |
415 | HLT | Terminates the program |
地址 | 記憶 | 注釋 |
400 | MOV SI,500 | SI |
403 | MOV DI,600 | DI |
406 | MOV CH,00 | CH |
408 | INC CH | CH |
409 | MOV AL,[SI] | 鋁 |
40B | UL | 斧頭 |
40D | MOV [DI],AL | [DI] |
40樓 | INC DI | DI |
410 | CMP CH,0A | CH-0A |
413 | JNZ 408 | 如果零標志為0,則跳轉到地址408 |
415 | HLT | 終止程序 |
Explanation:
說明:
MOV SI, 500: load 500 in SI.
MOV SI,500:在SI中加載500。
MOV DI, 600: load 600 in DI.
MOV DI,600:在DI中加載600。
MOV CH, 00: load 00 data in CH register.
MOV CH,00:將00數據加載到CH寄存器中。
INC CH: increment the value inside CH register by 1.
INC CH:將CH寄存器中的值加1。
MOV AL, SI: move the content of SI into AL register.
MOV AL,SI:將SI的內容移到AL寄存器中。
MUL CH: multiply the contents of AL and CH register and store in AX register.
MUL CH:將AL和CH寄存器的內容相乘并存儲在AX寄存器中。
MOV [DI], AL: move the contents of AL register into [DI].
MOV [DI],AL:將AL寄存器的內容移至[DI]。
INC DI: increment the value of DI by 1.
INC DI:將DI的值增加1。
CMP CH, 0A: subtract data inside CH register and 0A.
CMP CH,0A:將CH寄存器和0A內的數據相減。
JNZ 408: jump to address 408 if zero flag is 0.
JNZ 408:如果零標志為0,則跳轉到地址408。
HLT: terminate the program.
HLT:終止程序。
翻譯自: https://www.includehelp.com/embedded-system/print-the-table-of-a-given-number-using-8086-microprocessor.aspx
如何打印出給定尺寸的方格