预处理阶乘和阶乘逆元_计算数字的阶乘| 8086微处理器
預處理階乘和階乘逆元
Problem statement:
問題陳述:
Write an assembly language program for calculating the factorial of a number using 8086 microprocessor.
編寫一個匯編語言程序,以使用8086微處理器來計算數字的階乘。
Assumptions:
假設:
Starting address of program: 0400
程序起始地址:0400
Input memory location: 0500
輸入存儲器位置:0500
Output memory location: 0600 and 0601
輸出存儲器位置:0600和0601
Point to be noted:
需要注意的地方:
If the Given Number is a 16-bit number, the AX register is automatically used as the second parameter and the product is stored in the DX:AX register pair. This means that the DX register holds the high part and the AX register holds the low part of a 32-bit number.
如果給定數字是16位數字,則AX寄存器將自動用作第二個參數,并且乘積存儲在DX:AX寄存器對中。 這意味著DX寄存器保持32位數字的高位,而AX寄存器保持32位數字的低位。
Algorithm:
算法:
Input the Number whose factorial is to be find and Store that Number in CX Register (Condition for LOOP Instruction)
輸入要查找其階乘的編號,并將該編號存儲在CX寄存器中(LOOP指令的條件)
Insert 0001 in AX(Condition for MUL Instruction) and 0000 in DX
在AX(MUL指令的條件)中插入0001,在DX中插入0000
Multiply CX with AX until CX become Zero(0) using LOOP Instruction
使用LOOP指令將CX與AX相乘,直到CX變為零(0)
Copy the content of AX to memory location 0600
將AX的內容復制到內存位置0600
Copy the content of DX to memory location 0601
將DX的內容復制到內存位置0601
Stop Execution
停止執行
Program:
程序:
table {border-collapse: collapse;}table, th, td {border: 1px solid black;} table {border-collapse: collapse;}table, th, td {border: 1px solid black;}| 0400 | MOV CX, [0500] | CX ← [0500] |
| 0404 | MOV AX, 0001 | AX ← 0001 |
| 0407 | MOV DX, 0000 | DX ← 0000 |
| 040A | MUL CX | DX:AX ← AX * CX |
| 040C | LOOP 040A | Go To [040A] till CX->00 |
| 0410 | MOV [0600], AX | [0600]←AX |
| 0414 | MOV [0601], DX | [0601]←DX |
| 0418 | HLT | Stop Execution |
| 0400 | MOV CX,[0500] | CX←[0500] |
| 0404 | MOV斧,0001 | 斧←0001 |
| 0407 | MOV DX,0000 | DX←0000 |
| 040A | MUL CX | DX:AX←AX * CX |
| 040C | 環040A | 轉到[040A]直到CX-> 00 |
| 0410 | MOV [0600],AX | [0600]←AX |
| 0414 | MOV [0601],DX | [0601]←DX |
| 0418 | HLT | 停止執行 |
Explanation:
說明:
MOV CX, [0500] loads 0500 Memory location content to CX Register
MOV CX ,[0500]將0500內存位置內容加載到CX寄存器
MOV AX, 0001 loads AX register with 0001
MOV AX ,0001將0001裝入AX寄存器
MOV DX, 0000 loads DX register with 0000
MOV DX ,0000將0000裝入DX寄存器
MUL CX multiply AX with CX and store result in DX:AX pair
MUL CX將AX與CX相乘并將結果存儲在DX:AX對中
LOOP 040A runs loop till CX not equal to Zero
LOOP 040A循環運行,直到CX不等于零
MOV [0600], AX store AX register content to memory location 0600
MOV [0600] ,AX將AX寄存器內容存儲到內存位置0600
MOV [0601], DX store DX register content to memory location 0601
MOV [0601] ,DX將DX寄存器內容存儲到存儲器位置0601
HLT stops the execution of program
HLT停止執行程序
翻譯自: https://www.includehelp.com/embedded-system/calculate-the-factorial-of-a-number.aspx
預處理階乘和階乘逆元
總結
以上是生活随笔為你收集整理的预处理阶乘和阶乘逆元_计算数字的阶乘| 8086微处理器的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: repeating 路由_CSS中带有示
- 下一篇: 对称密码和非对称密码体系_密码学类型:对