> For the complete documentation index, see [llms.txt](https://digitalgarden.batamladen.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://digitalgarden.batamladen.com/notes/programming/assembly/assembly-8086/examples-projects/simple-arithmetic.md).

# Simple Arithmetic

{% tabs %}
{% tab title="code.asm" %}
Takes two 8-bit numbers as input from the user\
Adds the numbers and stores the result in the AX register. \
Multiplies the numbers and stores the result in the BX register. \
Displays the results.

```nasm
DATA SEGMENT 
    MSG1 DB "Enter first number (0-9): $"
    MSG2 DB "Enter second number (0-9): $"
    RESULT_SUM DB "Sum is: $"
    Result_MUL DB "Product is: $"
DATA ENDS

CODE SEGMENT
    ASSUME CS:CODE, DS:DATA
    START:
        MOV AX, DATA
        MOV DS, AX

        ; Prompt for the first number
        MOV AH, 09H
        LEA DX, MSG1
        INT 21H

        ; Read the first number
        MOV AH, 01H
        INT 21H
        SUB AL, '0'
        MOV BL,AL

        ; Prompt for the second number
        MOV AH, 09H
        LEA DX, MSG2
        INT 21H

        ; Read the first number
        MOV AH, 01H
        INT 21H
        SUB AL, '0'
        MOV BH,AL

        ; Calculate sum
        MOV AL,BL
        ADD AL, BH
        ADD AL, '0'

        ; Display sum
        MOV AH, 09H
        LEA DX, RESULT_SUM
        INT 21H
        MOV DL, AL
        MOV AH,02H
        INT 21H

        ; Calculate product
        MOV AL, BL
        MUL BH
        ADD AL, '0'

        ; Display product
        MOV AH, 09H
        LEA DX, RESULT_MUL
        INT 21H
        MOV DL, AL
        MOV AH, 02H
        INT 21H

        ; Exit program
        MOV AX, 4C00H
        INT 21H
CODE ENDS
END START
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://digitalgarden.batamladen.com/notes/programming/assembly/assembly-8086/examples-projects/simple-arithmetic.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
