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.print The result on the screen Assume string length will not exceed 255 character.

Solutions

Expert Solution

Answer.

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

Please upvote me.

Thank you.


Related Solutions

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?
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 in assembly 8086. Write a program to input nine numbers in 4*4 array and prints...
Write in assembly 8086. Write a program to input nine numbers in 4*4 array and prints the maximum value of each row and then prints the minimum of each column.
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 program that counts the letters in a given string and then display the letter...
Write a program that counts the letters in a given string and then display the letter count in order from high to low. The program should: Display a message stating its goal Prompt the user to enter a string input Count the letters in the string (hint: use dictionaries) Display the letter count in order from high to low (sort your letter count) For example, for the input Google the output should be G - 2 O - 2 E...
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.
Write a program that takes a string from the user, identifies and counts all unique characters...
Write a program that takes a string from the user, identifies and counts all unique characters in that given string. You are bound to use only built-in string functions where necessary. For identification of unique characters and for counting of the characters make separate functions. For character identification Develop a program that takes a string argument, and returns an array containing all unique characters. For character counting Develop a program that takes an array returned from above function as an...
Write a program that takes a string from the user, identifies and counts all unique characters...
Write a program that takes a string from the user, identifies and counts all unique characters in that given string. You are bound to use only built-in string functions where necessary. For identification of unique characters and for counting of the characters make separate functions. For character identification Develop a program that takes a string argument, and returns an array containing all unique characters. For character counting Develop a program that takes an array returned from above function as an...
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:...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT