數字圖像處理圖像反轉的實現
Problem statement:
問題陳述:
Write an assembly language program in 8086 microprocessor to reverse 16 bit number using 8 bits operation.
在8086微處理器中編寫匯編語言程序,以使用8位操作反轉16位數字。
Example: Assume 16 bit number is stored at memory location 2050 and 2051.
示例:假設16位數字存儲在內存位置2050和2051中。
Algorithm:
算法:
Load contents of memory location 2050 in register AL
將存儲單元2050中的內容加載到寄存器AL中
Load contents of memory location 2051 in register AH
將存儲單元2051的內容加載到寄存器AH中
Assign 0004 to CX Register Pair
將0004分配給CX寄存器對
Rotate the contents of AL by executing ROL instruction using CX
通過使用CX執行ROL指令來旋轉AL的內容
Rotate the contents of AH by executing ROL instruction using CX
通過使用CX執行ROL指令來旋轉AH的內容
Store the content of AH in memory location 2050
將AH的內容存儲在內存位置2050中
Store the content of AL in memory location 2051
將AL的內容存儲在內存位置2051中
Program:
程序:
MEMORY ADDRESS | MNEMONICS | COMMENT |
---|---|---|
400 | MOV AL, [2050] | AL |
404 | MOV AH, [2051] | AH |
408 | MOV CX, 0004 | CX |
40B | ROL AL, CX | Rotate AL content left by 4 bits(value of CX) |
40D | ROL AH, CX | Rotate AH content left by 4 bits(value of CX) |
40F | MOV [2050], AH | [2050] |
413 | MOV [2051], AL | [2051] |
417 | HLT | Stop Execution |
內存地址 | 記憶 | 評論 |
---|---|---|
400 | MOV AL,[2050] | 鋁 |
404 | MOV AH,[2051] | 啊 |
408 | MOV CX,0004 | CX |
40B | ROL AL,CX | 將AL內容左移4位(CX值) |
40D | ROL AH,CX | 將AH內容向左旋轉4位(CX值) |
40樓 | MOV [2050],AH | [2050] |
413 | MOV [2051],AL | [2051] |
417 | HLT | 停止執行 |
Explanation
說明
MOV AL, [2050]: loads contents of memory location 2050 in AL
MOV AL,[2050] :將存儲位置2050中的內容加載到AL中
MOV AH, [2051]: loads contents of memory location 2051 in AH
MOV AH,[2051] :在AH中加載存儲位置2051的內容
MOV CX, 0004: assign 0004 to CX register pair
MOV CX,0004 :將0004分配給CX寄存器對
ROL AL, CX: rotate the content of AL register left by 4 bits i.e. value of CX register pair
ROL AL,CX :將AL寄存器的內容向左旋轉4位,即CX寄存器對的值
ROL AH, CX: rotate the content of AH register left by 4 bits i.e. value of CX register pair
ROL AH,CX :將AH寄存器的內容向左旋轉4位,即CX寄存器對的值
MOV [2050], AH: stores the content of AH in 2050 memory address
MOV [2050],AH :將AH的內容存儲在2050的存儲器地址中
MOV [2051], AL: stores the content of AL in 2051 memory address
MOV [2051],AL :將AL的內容存儲在2051存儲器地址中
HLT: stops executing the program
HLT :停止執行程序
翻譯自: https://www.includehelp.com/embedded-system/reverse-a-16-bits-number-using-8086-microprocessor.aspx
數字圖像處理圖像反轉的實現