zukushikimimemo 0 Newbie Poster
    mov eax, 4
    mov ebx, 1
    mov ecx, msg1
    mov edx, len1
    int 80h

    mov eax, 3
    mov ebx, 0
    mov ecx, num1
    mov edx, 2
    int 80h

    mov eax, 4
    mov ebx, 1
    mov ecx, msg2
    mov edx, len2
    int 80h

    mov eax, 3
    mov ebx, 0
    mov ecx, num2
    mov edx, 2
    int 80h

    sub byte[num1], 30h
    sub byte[num2], 30h

    mov al, [num1]
    cmp al, [num2]
    jnl continue

    mov al, [num1]
    mov ah, [num2]
    mov [num2], al
    mov [num1], ah

continue:

    add byte[num1], 30h
    add byte[num2], 30h

loop1:

    push choice
    call menu
    cmp byte[choice], 6
    je exit

    mov eax, 4
    mov ebx, 1
    mov ecx, num1
    mov edx, 1
    int 80h

    sub byte[num1], 30h
    sub byte[num2], 30h

    push answer
    push word[num2]
    push word[num1]

    cmp byte[choice], 1
    je plussign

    cmp byte[choice], 2
    je subsign

    cmp byte[choice], 3
    je mulsign

    cmp byte[choice], 4
    je divsign

    cmp byte[choice], 5
    je modsign

plussign:
    mov eax, 4
    mov ebx, 1
    mov ecx, plus
    mov edx, pluslen
    int 80h
    call adds
    jmp number2

subsign:
    mov eax, 4
    mov ebx, 1
    mov ecx, subtract
    mov edx, subtractlen
    int 80h
    call subs
    jmp number2

mulsign:
    mov eax, 4
    mov ebx, 1
    mov ecx, multiply
    mov edx, multiplylen
    int 80h
    call muls
    jmp number2

divsign:
    mov eax, 4
    mov ebx, 1
    mov ecx, divide
    mov edx, dividelen
    int 80h
    call divs
    jmp number2

modsign:
    mov eax, 4
    mov ebx, 1
    mov ecx, modulo
    mov edx, modulolen
    int 80h
    call mods

number2:

    add byte[num1], 30h
    add byte[num2], 30h

    mov eax, 4
    mov ebx, 1
    mov ecx, num2
    mov edx, 1
    int 80h

    mov eax, 4
    mov ebx, 1
    mov ecx, equal
    mov edx, equallen
    int 80h

    mov ax, [answer]
    div byte [consten]
    mov [tens], al
    mov [ones], ah 

    add byte[tens], 30h
    add byte[ones], 30h 

    mov eax, 4
    mov ebx, 1
    mov ecx, tens
    mov edx, 1
    int 80h

    mov eax, 4
    mov ebx, 1
    mov ecx, ones
    mov edx, 1
    int 80h

    jmp loop1

exit: 
    mov eax, 4
    mov ebx, 1
    mov ecx, newline
    mov edx, len
    int 80h

    mov eax, 1   
    mov ebx, 0 
    int 80h

menu: 
    mov ebp, esp
    sub esp, 2

    mov eax, 4
    mov ebx, 1
    mov ecx, msg3
    mov edx, len3
    int 80h

    mov eax, 3
    mov ebx, 0
    lea ecx, [ebp-2]
    mov edx, 2
    int 80h

    sub word[ebp-2], 30h
    mov ax, [ebp-2]
    mov ebx, [ebp+4]
    mov [ebx], ax
    add esp, 2
    ret 4

adds: 
    mov ebp, esp
    mov al, [ebp+4]
    add al, [ebp+6]
    mov ebx, [ebp+8]
    mov [ebx], al
    ret 8

subs: 
    mov ebp, esp
    mov al, [ebp+4]
    sub al, [ebp+6]
    mov ebx, [ebp+8]
    mov [ebx], al
    ret 8

muls:
    mov ebp, esp
    mov al, [ebp+4]
    mul byte [ebp+6]
    mov ebx, [ebp+8]
    mov [ebx], ax
    ret 8

divs: 
    mov ebp, esp
    mov ax, [ebp+4]
    div byte[ebp+6]
    mov ebx, [ebp+8]
    mov [ebx], al
    ret 8

mods: 
    mov ebp, esp
    mov ax, [ebp+4]
    div byte [ebp+6]
    mov ebx, [ebp+8]
    mov [ebx], ah
    ret 8

tell me whats wrong? div and mod part

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.