Contrasting Languages at 3 Levels

 

Assembly language (Intel 80386)

 

_main proc far
mov word ptr [bp-2],1  ;the address of a is bp-2
                       ;the value is 1
 
mov word ptr [bp-4],2  ;the address of b is bp-4
                       ;the value is 2
 
mov word ptr [bp-6],3  ;the address of c is bp-6
                       ;the value is 3
 
mov word ptr [bp-8],4  ;the address of d is bp-8 
                       ;the value is 4 
 
mov ax,word ptr [bp-2] ;put a's value in ax reg
 
imul word ptr [bp-4]   ;multiply ax reg by b, 
                       ;put result back in ax
 
mov dx,word ptr [bp-6] ;put c's value in dx reg 
add dx,word ptr [bp-8] ;add d to the dx reg
                       ;put result back in dx
 
imul dx                ;multiply ax reg by dx
                       ;put result back in ax
 
mov word ptr [bp-10],ax ;the address of e is bp-10
                        ;the value of e is 14
_main endp

 

 

Machine language (Intel 80386)

 

0101001101010010010011001101010010001011010110101101
0010101100010111010010011010100100001001111110010000
1001101010010001011100110000100110101011001110110001
0001001101010010001001000110001101010010000010011010
1001000100110101001000000010011001010001000010001000
010001001101000100010011000110010011111101100100111

 

 Next Slide