-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path16bits_division.asm
49 lines (39 loc) · 896 Bytes
/
16bits_division.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
org 0x7c00
bits 16
mov ax, 0
mov ds, ax
cli
mov dx, 0
mov ax, 4567 ; number that will be divided
mov bx, ax
mov cl, 4 ; counter with the character qty of the number
mov ch, cl
call showInt
hlt
showInt:
loop:
or cl, cl
jz printInt
mov ax, bx ; divide and put the quotient into bx
mov bx, 10
cwd
div bx
push dx ; mod
mov bx, ax
dec cl
jmp loop
printInt: mov cl, ch
loop2:
or cl, cl
jz halt
pop dx
mov ax, dx ; print mod
add al, 48
mov ah, 0x0e
int 10h
dec cl
jmp loop2
halt: ret
times 510 - ($ - $$) db 0
db 0x55
db 0xaa