can't understand this assembly code
this code is supposed to calculate : p/4+v/8 using shift operations
Data Segment
Db p
Db v
Db q
Data 开发者_开发知识库ends
Code Segment
Assume cs:code,ds:data
Start: mov ax,p
Shr ax,01
Mov cl,02
Shr ax,cl
Mov bx,ax
Mov ax,v
Shr ax,01
Mov cl,03
Shr ax,cl
Mov dx,q
add bx
Mov q,ax
Code ends
end
my main question is : for me it seems like we're calculating p/8+v/16?!!!1 because i think there are 2 shift operations that are not needed
That snippet of code calculates p/8 + v/16 as you said.
Every time you shift 1 bit to the right is like you were doing the integer division by 2.
So, you should remove the SHR ax,01 from both locations to get p/8 + v/16
精彩评论