div divisor
被除数 | 被除数长度 | 商 | 余数 |
AX | 16位 | AL | AH |
DX:AX | 32位 | AX | DX |
EDX:EAX | 64位 | EAX | EDX |
.section .data
dividend:
.quad 8335
divisor:
.int 25
quotient:
.int 0
remainder:
.int 0
output:
.asciz "The quotient is %d, and the remainder is %d\n"
.section .text
.global _start
_start:
nop
movl dividend, %eax
movl dividend+4, %edx
divl divisor
movl %eax, quotient
movl %edx, remainder
pushl remainder
pushl quotient
pushl $output
call printf
add $12, %esp
pushl $0
call exit
$ ld -dynamic-linker /lib/ld-linux.so.2 -lc -o div div.o
$ ./div
The quotient is 333, and the remainder is 10
idiv divisor
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |