1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Galina-37 [17]
2 years ago
5

Create a macro named mReadInt that reads a 16- or 32-bit signed integer from standard input and returns the value in an argument

. Use conditional operators to allow the macro to adapt to the size of the desired result. Write a program that tests the macro, passing it operands of various sizes.
Computers and Technology
1 answer:
timofeeve [1]2 years ago
7 0

Answer:

;Macro mReadInt definition, which take two parameters

;one is the variable to save the number and other is the length

;of the number to read (2 for 16 bit and 4 for 32 bit) .

%macro mReadInt 2

mov eax,%2

cmp eax, "4"

je read2

cmp eax, "2"

je read1

read1:

mReadInt16 %1

cmp eax, "2"

je exitm

read2:

mReadInt32 %1

exitm:

xor eax, eax

%endmacro

;macro to read the 16 bit number, parameter is number variable

%macro mReadInt16 1

mov eax, 3

mov ebx, 2

mov ecx, %1

mov edx, 5

int 80h

%endmacro

;macro to read the 32 bit number, parameter is number variable

%macro mReadInt32 1

mov eax, 3

mov ebx, 2

mov ecx, %1

mov edx, 5

int 80h

%endmacro

;program to test the macro.

;data section, defining the user messages and lenths

section .data

userMsg db 'Please enter the 32 bit number: '

lenUserMsg equ $-userMsg

userMsg1 db 'Please enter the 16 bit number: '

lenUserMsg1 equ $-userMsg1

dispMsg db 'You have entered: '

lenDispMsg equ $-dispMsg

;.bss section to declare variables

section .bss

;num to read 32 bit number and num1 to rad 16-bit number

num resb 5

num1 resb 3

;.text section

section .text

;program start instruction

global _start

_start:

;Displaying the message to enter 32bit number

mov eax, 4

mov ebx, 1

mov ecx, userMsg

mov edx, lenUserMsg

int 80h

;calling the micro to read the number

mReadInt num, 4

;Printing the display message

mov eax, 4

mov ebx, 1

mov ecx, dispMsg

mov edx, lenDispMsg

int 80h

;Printing the 32-bit number

mov eax, 4

mov ebx, 1

mov ecx, num

mov edx, 4

int 80h

;displaying message to enter the 16 bit number

mov eax, 4

mov ebx, 1

mov ecx, userMsg1

mov edx, lenUserMsg1

int 80h

;macro call to read 16 bit number and to assign that number to num1

;mReadInt num1,2

;calling the display mesage function

mov eax, 4

mov ebx, 1

mov ecx, dispMsg

mov edx, lenDispMsg

int 80h

;Displaying the 16-bit number

mov eax, 4

mov ebx, 1

mov ecx, num1

mov edx, 2

int 80h

;exit from the loop

mov eax, 1

mov ebx, 0

int 80h

Explanation:

For an assembly code/language that has the conditions given in the question, the program that tests the macro, passing it operands of various sizes is given below;

;Macro mReadInt definition, which take two parameters

;one is the variable to save the number and other is the length

;of the number to read (2 for 16 bit and 4 for 32 bit) .

%macro mReadInt 2

mov eax,%2

cmp eax, "4"

je read2

cmp eax, "2"

je read1

read1:

mReadInt16 %1

cmp eax, "2"

je exitm

read2:

mReadInt32 %1

exitm:

xor eax, eax

%endmacro

;macro to read the 16 bit number, parameter is number variable

%macro mReadInt16 1

mov eax, 3

mov ebx, 2

mov ecx, %1

mov edx, 5

int 80h

%endmacro

;macro to read the 32 bit number, parameter is number variable

%macro mReadInt32 1

mov eax, 3

mov ebx, 2

mov ecx, %1

mov edx, 5

int 80h

%endmacro

;program to test the macro.

;data section, defining the user messages and lenths

section .data

userMsg db 'Please enter the 32 bit number: '

lenUserMsg equ $-userMsg

userMsg1 db 'Please enter the 16 bit number: '

lenUserMsg1 equ $-userMsg1

dispMsg db 'You have entered: '

lenDispMsg equ $-dispMsg

;.bss section to declare variables

section .bss

;num to read 32 bit number and num1 to rad 16-bit number

num resb 5

num1 resb 3

;.text section

section .text

;program start instruction

global _start

_start:

;Displaying the message to enter 32bit number

mov eax, 4

mov ebx, 1

mov ecx, userMsg

mov edx, lenUserMsg

int 80h

;calling the micro to read the number

mReadInt num, 4

;Printing the display message

mov eax, 4

mov ebx, 1

mov ecx, dispMsg

mov edx, lenDispMsg

int 80h

;Printing the 32-bit number

mov eax, 4

mov ebx, 1

mov ecx, num

mov edx, 4

int 80h

;displaying message to enter the 16 bit number

mov eax, 4

mov ebx, 1

mov ecx, userMsg1

mov edx, lenUserMsg1

int 80h

;macro call to read 16 bit number and to assign that number to num1

;mReadInt num1,2

;calling the display mesage function

mov eax, 4

mov ebx, 1

mov ecx, dispMsg

mov edx, lenDispMsg

int 80h

;Displaying the 16-bit number

mov eax, 4

mov ebx, 1

mov ecx, num1

mov edx, 2

int 80h

;exit from the loop

mov eax, 1

mov ebx, 0

int 80h

You might be interested in
In modern computer systems, a byte consists of
Cerrena [4.2K]
8 smaller units, called bits :)
8 0
3 years ago
What kind of output device would not be used to output images
saveliy_v [14]

Answer:

Speakers.

Explanation: Cause they only output sound, and are devices, further more they are not used to output images, like how could speakers output images using sound? They can't.

3 0
3 years ago
Software, also called a(n) ____________________, consists of a series of related instructions, organized for a common purpose, t
Naddika [18.5K]
Software is also called a program or an application.
8 0
3 years ago
HOW CAN YOU GET THE COOLEST FONTS ON GOGGLE SLIDES???
Viefleur [7K]
I would love to help. but if you could text my number i could help more. i have a chromebook
8 0
2 years ago
Read 2 more answers
Which of the threats discussed in this chapter should receive Charlie’s attention early in his planning process?Ethical Decision
ratelena [41]

Answer:

Explanation:

1. Before the discussion at the start of this chapter, how do Fred, Gladys, and Charlie each perceive the scope and scale of the new information security effort? Did Fred’s perception change after that?

Answer:

Before the discussion, Fred, Gladys, and Charlie focused on other ends in regards to information security. Fred was more concerned with adding additional software to fix the malware issues when clearly there were easier steps that need to be taken

2. How should Fred measure success when he evaluates Gladys’ performance for this project? How should he evaluate Charlie’s performance?

Answer:

Gladys’s performance should be based on the new security measures and protocol that she has in place for the organization. This of course, is putting a lot of trust into Charlie’s performance as she was the one to introduce Charlie with his new plan on the organization’s new security. She practically had him nominated for CIO.

3. Which of the threats discussed in this chapter should receive Charlie’s attention early in his planning process?

Answer:

Before considering outside threats, internal threats should be looked into early in the planning process. Internal threats does not necessarily mean that the employees have malicious intent, but the case of human error and failure can also be a negative contribution to cyber security. Creating a security program and education end users by creating a security policy guidance is one of the the best ways to prevent simple cyber security issues from starting

Instead of Charlie being named CISO, suppose instead that Fred hired his son-in-law, an unemployed accountant, to fill the role. Assuming the person had no prior experience or preparation for a job in information security, did Fred make an ethical choice? Explain your answer.

Answer:

Absolutely not! By hiring an unexperienced family member over a trained professional, Fred is letting his emotions get the better of him. Fred should consult with Gladys on whether his son-in-law is good candidate for the position or not. Rather than sacrifice company security, Fred could possibly find his son-in-law a position in the companies’ financial or human resources departments.

8 0
3 years ago
Other questions:
  • .exe, .msi, .msp, .inf - together, what do these filetypes indicate
    12·2 answers
  • Compare GBN, SR, and TCP (no delayed ACK). Assume that the timeout values for all three protocols are sufficiently long such tha
    7·1 answer
  • William found out that someone used his report on American culture without his permission. What is William a victim of?
    13·2 answers
  • How has technology fragmented the audience for sports and entertainment<br> commodities?
    10·1 answer
  • Describe the positive and negative effects of Internet​
    6·2 answers
  • __________ are hosted on dedicated computers known as 'web servers'.​
    8·2 answers
  • 2. ¿Cuáles de los siguientes Software son lenguajes de Programación?
    10·1 answer
  • Please help im not good at computer class ​
    10·2 answers
  • What distinguishes Accenture as a holistic provider of Extended Reality (XR) services?.
    9·1 answer
  • THIS IS TIMED PLS HURRY UP
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!