Use call and ret instructions to calculate the cube of data

assume cs:code

data segment
dw 1,2,3,4,5,6,7,8
dd 0,0,0,0,0,0,0,0
data ends

code segment

start:	mov ax, data
		mov ds, ax
		mov si, 0		;ds:si指向第一组word单元
		mov di, 16		;ds:di指向第二组dword单元
		
		mov cx, 8
	  s:mov bx, [si]
		call cube
		mov [di], ax
		mov [di].2, dx	;若发生进位,高位数据在dx中,把dx中的数据给ds:[di+2]
		add si, 2		;ds:si指向下一组word单元
		add di, 4		;ds:di指向下一个dword单元
		loop s
		
		mov ax, 4C00H
		int 21H
   
   cube:mov ax, bx
		mul bx
		mul bx
		ret
		
code ends
end start
78 original articles published · Like 3 · Visits 5596

Guess you like

Origin blog.csdn.net/qq_43071318/article/details/105426114