Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- section .text
- global _start
- _start:
- mov ax, 1234 ;ax = 1234
- mov bx, 10 ;bx = 10
- mov cx, 0 ;cx = 0
- _loop:
- cmp ax, bx ;compare ax == bx
- jl _end ;jump if less _end -> end condition
- push dx ;push dx to the stack
- call _div_and_save ;function call to _div_and_save
- pop dx ;pop dx from the stack
- jmp _loop ;jump to _loop
- _div_and_save:
- mov dx, 0 ;dx = 0
- div bx ;ax = ax / bx (10) and dx = ax % bx
- add cx, dx ;cx = cx + dx
- ret ;return from function
- _end:
- add cx, ax ;cx = cx + ax
- printReg cx
- return0 ;return 0;
- section .data
- HexDig db '0', '1', '2', '3'
- db '4', '5', '6', '7'
- db '8', '9', 'A', 'B'
- db 'C', 'D', 'E', 'F'
- msg db '12 = 0000', 0xa
- len equ $ - msg
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement