I try to calculate 4n^2 where n[1..10]. This is my code, but i can't understand why result is not printed in console. I tried with ShowUInt16 and without, but result is just black screen insead of 1540
.model small
.data
.stack 100h
.code
main:
mov ax, @data
mov ds, ax
mov cx, 1
mov bx, 0
l1:
mov ax, cx
mul ax
shl ax, 1
shl ax, 1
add bx, ax
cmp cx, 10
jbe l1
mov ax, bx
call ShowUInt16
mov ax, 4C00h
int 21h
ShowUInt16 proc
push ax
push bx
push cx
push dx
mov bx, 10
mov cx, 0
@@div:
xor dx, dx
div bx
add dl, '0'
push dx
inc cx
test ax, ax
jnz @@div
@@show:
mov ah, 02h
pop dx
int 21h
loop @@show
pop dx
pop cx
pop bx
pop ax
ret
ShowUInt16 endp
end main
C++ analogical code so solve this equation
#include <iostream>
using namespace std;
int main(){
int n;
for(int i = 1; i <= 10; i++){
n += 4*i*i;
}
cout<<n;
}