title "aaa" .model small .stack 100h .data num1 db '9' num2 db '5' result db 0 ; Initialize result variable .code mov ax, @data mov ds, ax ; Convert ASCII characters to numerical values sub num1, '0' ; Convert character '9' to numerical value 9 sub num2, '0' ; Convert character '5' to numerical value 5 ; Add numerical values mov al, num1 ; Move num1 into AL add al, num2 ; Add num2 to AL ; Store the result mov result, al ; Store the result in result variable mov ah, 4ch ; Exit program int 21h end ********************* title "aaa" .model small .stack 100h .data num1 db '9' num2 db '5' result db ? .code mov ax, @data mov ds, ax ; Convert ASCII characters to binary mov al, num1 sub al, '0' ; Convert ASCII character to binary mov bl, num2 sub bl, '0' ; Convert ASCII character to binary ; Perform addition add al, bl ; Adjust the result using aaa aaa ; Convert result back to ASCII character add al, '0' ; Convert binary to ASCII character ; Store the result mov result, al ; Display result (if needed) mov ah, 02h ; DOS function to display character mov dl, al ; Move the result to DL register int 21h ; Call DOS interrupt ; Terminate program mov ah, 4Ch ; DOS function to exit program int 21h ; Call DOS interrupt end
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter