Online Compiler Nasm

section .data msg1 db 'Vvedite simvol: $' msg2 db 13,10,'ASCII kod (dec): $' section .text global _start _start: mov ah, 09h mov dx, msg1 int 21h mov ah, 01h int 21h mov bl, al mov ah, 02h mov dl, bl int 21h mov ah, 09h mov dx, msg2 int 21h mov al, bl call print_decimal mov ah, 4Ch int 21h print_decimal: push ax push bx push cx push dx xor cx, cx mov bl, 10 test al, al jnz convert mov dl, '0' mov ah, 02h int 21h jmp done convert: xor ah, ah div bl push ax inc cx test al, al jnz convert print_digits: pop dx mov dl, dh add dl, '0' mov ah, 02h int 21h loop print_digits done: pop dx pop cx pop bx pop ax ret
This program reads a character from the keyboard, prints it back, then prints its ASCII code in decimal. It uses DOS interrupt 21h for input/output. The `print_decimal` function converts a byte value to decimal digits and prints them.

- In the `print_decimal` function, after dividing by 10, you push the remainder onto the stack, but you push the whole word `ax` instead of just the remainder. This will cause the stack to contain extra data that will be popped incorrectly later.
- When popping digits for printing, you pop a word into `dx`, but then you use `dh` as the digit. However, the remainder from division is stored in `ah`, not `dh`. Check which register actually holds the remainder after `div bl`.