当前位置:网站首页>Microcomputer principle and interface technology exercise 1
Microcomputer principle and interface technology exercise 1
2022-06-09 23:15:00 【Not coincidentally】
Microcomputer principle and interface technology exercises 1
Reference books :《 Microcomputer principle and interface technology ( The third edition )》 Hongyongqiang
The original title is in the 125 page ,4-12
Only provide personal ideas , Maybe the solution is not very good , Welcome to exchange .
subject
12. Programming , No multiplication Z=10×X+Y/8, Use shift operation .
analysis
① First of all, this is a simple calculation problem , There is addition 、 Multiplication 、 Division operations . Multiplication is not allowed , Use shift instead of multiplication . So we can only use addition 、 division 、 displacement .
② Convert multiplication to shift .
The computer stores binary data , Moving one bit to the left is equivalent to doing X2 Arithmetic . Moving one bit to the right is equivalent to doing ÷2 Arithmetic .
But not exactly the same , It also depends on the instructions used , Involving overflow , Cyclic shift, etc .
③ If 10xX, There are two ways to calculate , One is the X Split into 2 Of n1 Power +2 Of n2 Power +… Another way is to put 10 Split into 2 Of 3 Power +2 Of 1 Power . Solve the existing problems as simple as possible , Here choose the latter method .
④Y/8 You can divide , But right shift is used here 3 position (2^3=8) Faster .
⑤ Finally, add , Come to the conclusion .
flow chart

Instructions needed
Add instruction :
1) Add instruction without carry ADD(add)
Format :ADD DEST, SRC
function :DEST←SRC+DEST
2) Add instruction with carry ADC(add with carry)
Format :ADC DEST, SRC
function :DEST←SRC+DEST+CF
ADC It is mainly used in multi byte addition .
Shift instructions :
Logic shift left :SHL DEST,COUNT
Logical shift right :SHR DEST,COUNT
among , DEST You can use any addressing method other than immediate ; COUNT Indicates the number of shifts , Its value is or equal to 1, Or greater than 1, Greater than 1 The value should be sent to CL register , And then move it .
Program
;4-12 Shift without multiplication Z=10*X+Y/8
DATA SEGMENT; Data segment
X DW 90 ; The assumption is 90
Y DW 80 ; hypothesis 80
Z DW 0 ; The result should be 910
DATA ENDS
STACKS SEGMENT; stack segment
STACKS ENDS
CODE SEGMENT; Code segment
ASSUME CS:CODE,DS:DATA,SS:STACKS
START: MOV AX,DATA
MOV DS,AX
MOV AX,STACKS
MOV SS,AX ; initialization
MOV CL,3 ; The number of shifts is 3
MOV AX,X
SHL AX,1 ;X Move left 1 position
MOV BX,X
SHL BX,CL ;X Move left 3 position
ADD AX,BX ;X*2+X*8
MOV BX,Y
SHR BX,CL ;Y Move right 3 position
ADD AX,BX ;X*10+Y/8
MOV Z,AX
CODE ENDS
END START
debugging
from emu8086 Call up the variable box in , Start running program .








边栏推荐
- At present, I am 28 years old, and I have successfully won the 15K salary since I started to wander to the north in 20 years and started to test the entry software
- im即时通讯开发:移动端协议UDP还是TCP?
- Information leakage and computational complexity of EMD like methods in time series prediction
- Online text string batch replacement tool
- STM32 drive relay stm32f103rct6 drives IO port based on register and library function
- June training (day 09) - two point search
- OpenHarmony RISC-V 轻量系统移植—润和W800移植分享
- CMD command
- 原来树状数组可以这么简单?
- 數據庫優化方面的經驗
猜你喜欢

cadence SPB17.4 - allegro - Move With Dynamic Alignment ON/OFF

Leetcode(力扣)超高频题讲解(一)

2022爱分析· 隐私计算厂商全景报告 | 爱分析报告

emu8086的入门使用

QNX system learning

Microsoft Word tutorial "4", how to apply styles and themes in word?

CMD command

Leetcode(力扣)超高频题讲解(三)
![[reprint] six aspects of async/await that are superior to promise](/img/c0/e09ec7baaf9ba0f74c4de18a5721ea.png)
[reprint] six aspects of async/await that are superior to promise

15 provinces publish the average wage in 2021, and these industries have "money paths"
随机推荐
STM32 drive relay stm32f103rct6 drives IO port based on register and library function
CMD command
Classic interview question: how to quickly solve root 2?
M-arch (yateli M4) [at-start-f425 evaluation] No.04 CRC
『查漏补缺』Android实习面试知识点(二)
uni-app是如何构建小程序的?
浅谈企业自媒体如何才能脱颖而出
qnx系统学习
Sparksql source code series | the most complete logical plan optimization rules (spark2.3)
IPSec的特征与功能
cadence SPB17.4 - allegro - Move With Dynamic Alignment ON/OFF
im即时通讯开发:移动端协议UDP还是TCP?
初识WebSocket
EasyRecovery15手机电脑全功能数据恢复软件
Metauniverse may replace the Internet as the mainstream lifestyle in the next decade or even two
At present, I am 28 years old, and I have successfully won the 15K salary since I started to wander to the north in 20 years and started to test the entry software
CMD命令
鲲鹏DevKit工具基础那些事
[BP prediction] BP neural network based on AdaBoost realizes data regression prediction with matlab code
AI helps release the potential energy of legal affairs -- the itarms contract intelligent review system of Fada was officially released