irvine32

Reversing an array in assembly

南楼画角 提交于 2020-01-02 17:54:18
问题 I'm trying to figure out how to reverse an array in assembly in a way that makes it as flexible as possible. The code I have so far is this: ; This program takes an integer array and reverses it's elements, using a loop, the SIZE, TYPE and LENGTHOF ; operators. TITLE lab4 (lab4.asm) INCLUDE Irvine32.inc .data arr DWORD 1h, 2h, 3h, 4h, 5h, 6h ; Array of integers with 6 elements. len DWORD LENGTHOF arr / 2 ; The length of the array divided by 2. ;rng DWORD LENGTHOF arr ; The complete length of

Sort contents of array in assembly

依然范特西╮ 提交于 2019-12-25 05:03:32
问题 I am working on an assignment where the user enters the number of values they will input in to an array inputs that amount of numbers. After all of this however I need to do a bubble sort that will put the inputted numbers in the array from smallest to biggest. The confusing part is that it says "the inner loop of the bubble sort is to be in a procedure". I'm not even sure where to begin on how to do this let alone creating inner and outer loops. All of the examples that I have found online

Printing star triangle in assembly

元气小坏坏 提交于 2019-12-24 07:28:04
问题 I'm trying to print a triangle like this: in assembly. The formula to find the number of stars in each row is: 2 * x + 1. Here is my code so far. I seem to be looping infinitely. .data prompt BYTE "Please enter the number of rows in the pyramid: ", 0 numRows DWORD ? count DWORD 0 .code main PROC mov edx, OFFSET prompt call WriteString call ReadInt mov numRows,eax mov ecx,numRows + 1 ; Let ecx = numRows + 1 L1: inc count ; Increment count mov eax,ecx L2: sub eax,count ; eax = eax - count mov

Returning pointer to the letter in string

99封情书 提交于 2019-12-23 01:38:11
问题 This is my code to search ih some string consists of one letter: selectedWords BYTE "BICYCLE" inputLetter BYTE 'Y' cld mov ecx, LENGTHOF selectedWords mov edi, offset selectedWords mov al, inputLetter ;Load character to find repne scasb ;Search jne notfound But how to return the pointer to the letter in string? If I want after to change one leter with some other. Its easy to do if you have pointer to the letter in string. 回答1: If repne scasb finds the element, EDI points to the element after

jump destination too far : by 3 byte(s)

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-20 07:41:15
问题 I m having a problem with my loop, the code contained in it is long and it gives me error jump destination too far : by 3 byte(s) . When ı remove: mov edx,offset str1 call writestring this part below the main PROC, it doesnt give an error. But ı need this string user enters a negative number to give a message. How can ı? INCLUDE Irvine32.inc .data money dword 200,100,50,20,10,5,1 str1 byte "Enter the amounts for each value of money : ",0 str2 byte "The sum of your moneys are:",0 total dword 0

subtracting two integers bit by bit in assembly

流过昼夜 提交于 2019-12-20 06:34:21
问题 I'm trying to subtract 2 integers bit-by-bit and was given this algorithm b = 0 difference = 0 for i = 0 to (n-1) x = bit i of X y = bit i of Y bit i of difference = x xor y xor b b = ((not x) and y) or ((not x) and b) or (y and b) end for loop I have implemented up to this line b = ((not x) and y) or ((not x) and b) or (y and b) . How should I implement that last line of the algorithm in my code This is what I have so far: INCLUDE Irvine32.inc .data prompt1 BYTE "Enter the first integer: "

error A2022: instruction operands must be the same size

你说的曾经没有我的故事 提交于 2019-12-20 05:35:15
问题 Hey so I am getting this error when I run this code: 1>------ Build started: Project: Project, Configuration: Debug Win32 ------ 1> Assembling [Inputs]... 1>assign2.asm(32): error A2022: instruction operands must be the same size 1>assign2.asm(33): error A2022: instruction operands must be the same size 1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations\masm.targets(49,5): error MSB3721: The command "ml.exe /c /nologo /Zi /Fo"Debug\assign2.obj" /Fl"Project.lst" /I "c:

Summing an array in assembly x86. On the inputted indexes

笑着哭i 提交于 2019-12-20 04:26:12
问题 Im having some trouble adding an array but on the inputted indexes. For example, the user inputs 4 as starting and 6 as ending array so I will have to loop through array[4] to array[6] and add the numbers inclusively. I'm not sure if i can use my array in .data in the my ArraySum procedure. Do i have to push it into the procedure somehow? I am using Kip Irvine's external library for this. My code is here: TITLE Assignment 7 INCLUDE Irvine32.inc .data str1 BYTE "The array sum is: ",0 start

Assembly bit memory limit in arithmetic

℡╲_俬逩灬. 提交于 2019-12-20 04:05:32
问题 I wanted to add the following numbers: 40, 90, 50 and 155 and I get a total of 355. I wanted to experiment and test out whether the register AL will have a bit limit of (2^8) - 1, and when I compiled the code and execute the code, I get decimal of 1376331855. How did that happen? Also, I thought 355 is greater than 255, and as a result should display an overflow exception. I understand if I use MOVZX I will be able to carry the calculation into the higher register of AX. Also, I am very

How to see the memory occupied by initialised array vs uninitialised array

為{幸葍}努か 提交于 2019-12-20 02:26:16
问题 I'm currently learning assembly programming by following Kip Irvine's "Assembly Language for x86 Processor". In section 3.4.12, the author states: The .DATA? directive declares uninitialized data. When defining a large block of uninitialized data, the .DATA? directive reduces the size of a compiled program. For example, the following code is declared efficiently: .data smallArray DWORD 10 DUP(0) ; 40 bytes .data? bigArray DWORD 5000 DUP(?) ; 20,000 bytes, not initialized The following code,