Question

In: Computer Science

Write an 8088/8086 assembly program that counts the length of a null terminated string that starts...

Write an 8088/8086 assembly program that counts the length of a null terminated string that starts at location STR.Assume string length will not exceed 255 character.Print the result on the screen?

Solutions

Expert Solution

Step 1

Microprocessor Programming :

The "jargon" of directions which a specific microchip chip has is explicit to that model of chip. An Intel 80386, for instance, utilizes a totally extraordinary arrangement of paired codes than a Motorola 68020, for assigning comparable capacities.

Sadly, there are no principles set up for microchip directions. This makes programming at the most minimal level confounding and concentrated.

At the point when a human developer builds up a lot of guidelines to straightforwardly advise a microprocessor how to accomplish something (like naturally control the fuel infusion rate to a motor), they're customizing in the CPU's own "language." This language, which comprises of exactly the same paired codes which the Control Unit inside the CPU chip disentangles to perform errands, is regularly alluded to as machine language.

While machine language programming can be "phrased" in double documentation, it is regularly written in hexadecimal structure, since it is simpler for people to work with.

Step 2

Code :

PString macro String
local StringLength, StringStart
byte StringLength
StringStart byte String
StringLength = $-StringStart
endm
.
.
.
PString “This string has a length prefix”
; Presumably, ES and DS are set up already
lea si, String1
lea di, String2
mov ch, 0 ;Extend len to 16 bits.
mov cl, String1 ;Get string length.
inc cx ;Include length byte.
rep movsb
include stdlib.a
includelib stdlib.lib
cseg segment para public ‘code’
assume cs:cseg, ds:dseg, es:dseg, ss:sseg
; String assignment procedure
MainPgm proc far
mov ax, seg dseg
mov ds, ax
mov es, ax
lea di, ToString
call StrAssign
byte “This is an example of how the “
byte “StrAssign routine is used”,0
nop
ExitPgm
MainPgm endp
StrAssign proc near
push bp
mov bp, sp
pushf
push ds
push si
push di
push cx
push ax
push di ;Save again for use later.
push es
cld
; Get the address of the source string
mov ax, cs
mov es, ax
mov di, 2[bp] ;Get return address.
mov cx, 0ffffh ;Scan for as long as it takes.
mov al, 0 ;Scan for a zero.
repne scasb ;Compute the length of string.
neg cx ;Convert length to a positive #.
dec cx ;Because we started with -1, not 0.
dec cx ;skip zero terminating byte.
; Now copy the strings
pop es ;Get destination segment.
pop di ;Get destination address.
mov al, cl ;Store length byte.
stosb
; Now copy the source string.
mov ax, cs
mov ds, ax
mov si, 2[bp]
rep movsb
; Update the return address and leave:
inc si ;Skip over zero byte.
mov 2[bp], si
pop ax
pop cx
pop di
pop si
pop ds
popf
pop bp
ret
StrAssign endp
cseg ends
dseg segment para public ‘data’
ToString byte 255 dup (0)
dseg ends
sseg segment para stack ‘stack’
word 256 dup (?)
sseg ends
end MainPgm

Thank you.please vote


Related Solutions

PLEASE PROVIDE COMMENTS ON STEPS Write a C++ program that modifies a string (null terminated) as...
PLEASE PROVIDE COMMENTS ON STEPS Write a C++ program that modifies a string (null terminated) as follows: Consonants are positioned at the beginning of the string and vowels are moved to the end of the string. Example : Original string : washer New string : wshrae Note: The library string functions cannot be used. You must use pointers and the switch statement to execute this program. Assume that the vowels are a, e, i, o, and u. The modification has...
Write a program that accepts a string and character as input, then counts and displays the...
Write a program that accepts a string and character as input, then counts and displays the number of times that character appears (in upper- or lowercase) in the string. Use C++ Enter a string: mallet Enter a character: a "A" appears 1 time(s) Enter a string: Racecar Enter a character: R "R" appears 2 time(s)
Write a MIPS assembly program that prompts the user first for a string, then for a...
Write a MIPS assembly program that prompts the user first for a string, then for a character. The program should then search the string for the character and print out the number of times the character appears in the string. You can use as many restrictions as you want, just be sure to list them. You must allocate space in the .data segment of your program for the user string.
How to write an assembly program that simply counts how many A’s, C’s, T’s, and G’s...
How to write an assembly program that simply counts how many A’s, C’s, T’s, and G’s the input string contain.
Write an assembly language program to input a string from the user. Your program should do...
Write an assembly language program to input a string from the user. Your program should do these two things: ***** I AM POSTING THIS QUESTION FOR THE THIRD TIME NOW,I WANT IT DONE USING INCLUDE IRVINE32.INC***** 1. count and display the number of words in the user input string. 2. Flip the case of each character from upper to lower or lower to upper. For example if the user types in:   "Hello thEre. How aRe yOu?" Your output should be:...
Write a function that counts the colors in a string using JavaScript. String "The quick brown...
Write a function that counts the colors in a string using JavaScript. String "The quick brown fox jumped the blue fence and landed on red paint." This should return the number of colors. The colors you are looking for are "blue, green, brown, gray, black, brown, red, purple".
Write a program in "RISC-V" assembly to convert an ASCII string containing a positive or negative...
Write a program in "RISC-V" assembly to convert an ASCII string containing a positive or negative integer decimal string to an integer. ‘+’ and ‘-’ will appear optionally. And once they appear, they will only appear once in the first byte. If a non-digit character appears in the string, your program should stop and return -1.
Write a program in MIPS assembly language to convert an ASCII number string containing positive and...
Write a program in MIPS assembly language to convert an ASCII number string containing positive and negative integer decimal strings, to an integer. Your program should expect register $a0 to hold the address of a nullterminated string containing some combination of the digits 0 through 9. Your program should compute the integer value equivalent to this string of digits, then place the number in register $v0. If a non-digit character appears anywhere in the string, your program should stop with...
Write an X86-series assembly language program that checks whether input string is palindrome or not. A...
Write an X86-series assembly language program that checks whether input string is palindrome or not. A palindrome is a word, number, phrase or any other sequence which reads the same backward as forward e.g. madam, racecar. Sample Execution: Please enter a String: redivider The string is a palindrome Another Sample Execution: Please enter a String: abracadabra The string is not a palindrome
Write an assembly code the counts the number of accuracies of the byte AAh in memory...
Write an assembly code the counts the number of accuracies of the byte AAh in memory from address 120Ah to address 130Ah. You need to use a subroutine and call it 'COUNT' to do so. You also need to provide the count in BCD if it was less than 64h so that you need to include another subroutine called 'ToBCD' to do so. assembly 8086
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT