Write an 8086 assembly language program Which count the numbers of characters in the string s1 where s1 equals i know assembly programming?

1 answer

Answer

1061995

2026-03-05 01:20

+ Follow

Here’s a simple 8086 assembly language program to count the characters in the string "i know assembly programming":

<code class="language-assembly">section .data

s1 db 'i know assembly programming', 0 ; String with null terminator count db 0 ; To store the character count

section .text global _start

_start: mov si, s1 ; Load address of the string into SI xor cx, cx ; Clear CX for counting characters

count_loop: cmp byte [si], 0 ; Check for null terminator je done ; If found, jump to done inc cx ; Increment character count inc si ; Move to the next character jmp count_loop ; Repeat the loop

done: mov count, cl ; Store the count in 'count' ; Further code to exit or display the count can go here

</code>

This program initializes a string and counts the characters until it encounters the null terminator, storing the final count in a variable.

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.