MASM

Unable to reverse string in 8086 MASM

大憨熊 提交于 2020-01-06 02:54:10
问题 I've written some 8086 assembly code to reverse a string. I'm relatively new to assembly so please bear with me. The logic is that I define a string called 'str1'. I move this into the SI Register. Suppose string 'str1' is "Hello$" , then I load the address of 'str1'+5 into SI . Now, I load an address, say 5000 into DI . And I load each character from SI into DI and everytime I increment SI and decrement SI till 5 times. Here is the code assume cs:code,ds:data data segment str db "Hello$"

How to access two dimmensional arrays in MASM

有些话、适合烂在心里 提交于 2020-01-05 10:32:05
问题 Can you show me how I can access two dimmensional arrays in MASM? C++ code: int k = 0 for (i = 0; i<5; ++i) { if (k == text.length())break; for (j = 0; j<2; ++j) { for (t = 0; t<26; ++t) { if (text[k] == letters[t]){ tab[i][j] = t; k++; break; } } } } MASM mov al, [ebx] ;ebx - begin of text array xor esi, esi for1: cmp al, 00 je break_for1 mov j, 0 for2: mov t, 0 mov ecx, adrAlphabet ;ecx - begin of letters array for3: ;if (text[k] == letters[t]){ tab[i][j] = t; k++; break; } mov ah, [ecx]

Where can the code be more efficient for checking if an input character is a vowel?

南笙酒味 提交于 2020-01-04 04:20:25
问题 This Assembly project reads the key presses and output them in a specific color. When a vowel is pressed it changes the color of the text until another vowel is pressed and does so until the ESC key is pressed. The colors are in a certain pattern which is why I SUB 8 when it reaches the end of the cycle. I am just looking to make it more efficient. I tried making all the compare statements into one line but wasn't successful. INCLUDE Macros.inc INCLUDE Irvine32.inc INCLUDELIB Irvine32.lib

If-else macro in MASM

℡╲_俬逩灬. 提交于 2020-01-03 06:30:08
问题 In MASM, is it possible to create an if...ekse macro (similar to those found in high-level programming languages)? I haven't yet found any kind of if-else statement macro for MASM, but I think a macro for this purpose would be very useful. It would be useful if I could find a macro to make it easier to write a complicated series of if-statements in masm, as shown here: ;jump to each case here checkCase1: cmp theVariable, 5; jne case1; checkCase2: cmp theVariable, var2; jne case2; jmp

How to reverse and print a string in assembly language

懵懂的女人 提交于 2020-01-03 04:47:05
问题 So my assignment was to write a program in assembly code that could make a statement, recieve a user inputted string. Print that string then reverse it using the cpu stack and print it again. this is what I have thus far. INCLUDE Irvine32.inc .data buffer byte 20 DUP(0) byteCount DWORD ? Question byte "Please enter your name." ,0 Greeting byte "Hello " ,0 Statement byte " Here is your name backwards" .code main proc mov edx , OFFSET Question call WriteString call CRLF Call CRLF mov edx,

MASM: integer to string using std and stosb

我怕爱的太早我们不能终老 提交于 2020-01-03 03:28:33
问题 I have the following procedure for converting a user supplied integer to a string. I'm pretty sure my algorithm is working fine for converting each digit of the integer to it's correct decimal ASCII value. However, I'm having difficulty then storing that digit into its correct place in the outString. I've set the direction flag using 'std', and I then use stosb to load the current, converted digit into the last byte in outString (read from back to front). However, this does not seem to work.

How do I remove everything after a certain character in a string?

烂漫一生 提交于 2020-01-03 03:28:14
问题 How do I remove everything in the string after the '?' ? The code I have so far searches for the '?'. How do I proceed from there? This is my code. INCLUDE Irvine32.inc .data source BYTE "Is this a string? Enter y for yes, and n for no",0 .code main PROC mov edi, OFFSET source mov al, '?' ; search for ? mov ecx, LENGTHOF source cld repne scasb ; repeat while not equal jnz quit dec edi ; edi points to ? end main 回答1: You can replace everything after the "?" by zeroes, so all the characters

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

Carry flag in substraction

纵然是瞬间 提交于 2020-01-01 11:33:51
问题 I am using MASM32. With this code: mov eax,5 sub eax,10 CF status flag will be set. But using my pencil and paper, I actually see that there is no any carry from MSB. Yes, I know that from subtraction from less number great number set CF. But I want to know why? Because using this code: mov eax,5 mov ebx,10 not ebx add ebx,1 add eax,ebx CF flag won't be ever set. 回答1: 5 - 10 = 5 + (-10) = 0x05 + (0xF5 + 1) = 0x05 + 0xF6 = 0xFB 00000101 -- 0x05 11110101 -- 0xF5 + 00000001 -- 0x01 ==========

Moving from DX:AX register to single 32 bit register

南笙酒味 提交于 2019-12-31 06:04:07
问题 I'm having a problem adding to a product of a 16 bit multiplication. I want to multiply a year such as 2015, by 365 to do so I mov dx, 0 ; to clear the register mov ax, cx ; cx holds the year such as 2015 mov dx, 365 ; to use as multiplier mul dx ; multiply dx by ax into dx:ax After checking the registers, I am getting the correct solution but is there a way so that I can store this product into a single register. I want to add separate values to the product and so I would like to move this