Problem 1
An example procedure
//Code .MODEL small .STACK 256 .data .code main proc mov ax, @data mov ds, ax mov ax, 3 mov bx, 4 call addd Exit: mov ah, 4Ch mov al, 0 int 21h main endp addd proc ;ax+bx+bx add ax, bx add ax, bx ret addd endp END MAIN
Problem 2
Multiplication procedure
//Code .MODEL small .STACK 256 .data .code main proc mov ax, @data mov ds, ax mov ax, 3 mov bx, 4 call multiply Exit: mov ah, 4Ch mov al, 0 int 21h main endp multiply proc push ax push bx mov dx, 0 repeat: test bx, 1 jz end_if add dx, ax end_if: shl ax, 1 shr bx, 1 jnz repeat pop bx pop ax ret multiply endp END MAIN
Problem 3
Multiply and Division instructions
//Code mov ax, 2 mov bx, 010ffh mul bx ; Unsigned operation mov ax, 2 mov bx, 010ffh imul bx ; Signed operation mov ax, 2 mov bx, 010ffh div bx ; Unsigned operation mov ax, 2 mov bx, 010ffh idiv bx ; Signed operation
Problem 4
Decimal input output procedure
//Code .MODEL small .STACK 256 .data .code main proc mov ax, @data mov ds, ax mov ax, 50 mov bx, 60 add ax, bx call indec inc ax push ax mov ah, 2 mov dl, 0dh int 21h mov dl, 0ah int 21h pop ax call outdec Exit: mov ah, 4Ch mov al, 0 int 21h main endp outdec proc push ax push bx push cx push dx or ax, ax jge end_if1 push ax mov dl, '-' mov ah, 2 int 21h pop ax neg ax end_if1: xor cx, cx mov bx, 10D repeat1: xor dx, dx div bx push dx inc cx or ax, ax jne repeat1 mov ah, 2 printloop: pop dx or dl, 30h int 21h loop printloop pop dx pop cx pop bx pop ax ret outdec endp indec proc push bx push cx push dx begin: mov ah, 2 mov dl, '?' int 21h xor bx, bx xor cx, cx mov ah, 1 int 21h cmp al, '-' je minus cmp al, '+' je plus jmp repeat2 minus: MOV CX, 1 plus: INT 21H REPEAT2: CMP AL, '0' JNGE notdigit cmp al, '9' jnle notdigit and ax, 000Fh push ax mov ax, 10 mul bx pop bx add bx, ax mov ah,1 int 21h cmp al, 0dh jne repeat2 mov ax, bx or cx, cx je exit2 neg ax exit2: pop dx pop cx pop bx ret notdigit: mov ah, 2 mov dl, 0dh int 21h mov dl, 0ah int 21h jmp begin indec endp END MAIN
Problem 5 (Group a)
Take 2 decimal numbers greater than 10 as inputs and print their sum and difference afterwards
Sample execution
?120
?15
Sum is 135
Difference is 105
//Code To be done by students
Problem 5 (Group b)
Take 2 decimal numbers greater than 10 as inputs and print their sum, difference, and product afterwards
Sample execution
?120
?5
Sum is 125
Difference is 115
product is 600
//Code To be done by students