0% found this document useful (0 votes)
65 views6 pages

LAB4-Implementation of I - O Instructions

This document discusses Lab 4 which focuses on implementing input and output operations using the Irvine64 assembly language library in Visual Studio. It describes various procedures in the Irvine64 library for tasks like generating random numbers, reading input from the keyboard, comparing/copying strings, and writing output. Students are instructed to use specific Irvine64 procedures to prompt the user for input, display output, and complete tasks like reading/displaying numbers and strings.

Uploaded by

alihassan009669
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views6 pages

LAB4-Implementation of I - O Instructions

This document discusses Lab 4 which focuses on implementing input and output operations using the Irvine64 assembly language library in Visual Studio. It describes various procedures in the Irvine64 library for tasks like generating random numbers, reading input from the keyboard, comparing/copying strings, and writing output. Students are instructed to use specific Irvine64 procedures to prompt the user for input, display output, and complete tasks like reading/displaying numbers and strings.

Uploaded by

alihassan009669
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

(CS-222) Computer Organization and Assembly Language

Course Instructor: Kainat Ibrar


Lab Instructor: Kainat Ibrar

Lab 4- Implementation of Input and Output Operations

Objective
 Implementation of Irvine64 library functions
s
 Basic Syntax and Semantics
 Linking Irvine64 with the Visual Studio code
 Implementation of Input and output operations

Assembly language Irvine64 link library


In this lab we will learn about a minimal link library that can support 64-bit programming, which
includes the following procedures:
 Crlf: Write a line ending sequence to the console.
 Random64: Generate a 64-bit pseudo-random integer within 0~2⁶⁴-1. The random
value is returned in the RAX register.
 Randomize: Use a value as the seed of the random number generator.
 Readlnt64: Read a 64-bit signed integer from the keyboard and end with a carriage
return. The value is returned using the RAX register.
 ReadString: Read a string from the keyboard and end with a carriage return. The
process uses RDX to transfer the input buffer offset; uses RCX to transfer the maximum
number of characters that the user can enter plus 1 (for unll terminator byte). The return
value (using RAX) is the number of characters actually entered by the user.
 Str_compare: Compare two strings. The process passes the source string pointer to
RSI, and the destination string pointer to RDIO. Set the zero flag and carry flag in the
same way as the CMP (compare) instruction.
 Str_copy: Copy a source string to the location specified by the target pointer. The
source string offset is passed to RSI, and the target offset is passed to RDI.
 Strjength: Use the RAX register to return the length of a null-terminated character
string. The process uses RCX to pass the offset of the string.
 Writelnt64: Display the contents of the RAX register as a 64-bit signed decimal
number, plus a plus or minus sign in front. The procedure did not return a value.
 WriteHex64: Display the contents of the RAX register as a 64-bit hexadecimal
number. The procedure did not return a value.
 WriteHexB: Display the contents of the RAX register as a 1-byte, 2-byte, 4-byte or 8-
byte hexadecimal number. Pass the displayed size (1, 2, 4, or 8) to the RBX register. The
procedure did not return a value.
 WriteString: Display an ASCII string ending with a null byte. Pass the 64-bit offset of
the string to RDX. The procedure did not return a value.

Although this library is much smaller than the 32-bit link library, it still contains many important
tools to make the program more interactive. With the deepening of learning, you can use your
own code to expand this link library. The Irvine64 link library will retain the RBX, RBP, RDI,
RSI, R12, R13, R14, and R15 register values. On the contrary, the RAX, RCX, RDX, R8, R9,
R10 and R11 register values will not be retained.

To use the Irvine64 link library, add the Irvine64.obj file to the user's Visual Studio project. The
operation steps in Visual Studio are as follows

Steps to be performed to setup the Irvine64 library file


 Right-click the project name in the Solution Explorer window
 Select Add
 Select Existing Item, and then select the Irvine64.obj file name.

 Right-click the project name in the Solution Explorer window


 Go to the properties  Linker  System  Enable Large Addresses
 Select “No (/LARGEADDRESSAWARE:NO)” from the drop-down menu

Practice Code:

ExitProcess proto
WriteInt64 proto
WriteHex64 proto
WriteHexB proto
WriteString proto
Practice Code:

;*********************TO READ STRING***************


mov rdx, offset read_string
mov rcx, 8 ;6 characters
**********************************************************************************

Perform the following tasks.


1. Take two numbers from the user and display them on the screen.
2. Prompt user to enter a word and display the total number of characters of the string
on the screen.
Sample Output:

3. Prompt user to Enter an array of numbers and write the total number of digits in that
array on console.

4. Prepare your CV
Sample Output:

You might also like