MASM

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

Les instruction purpose?

天大地大妈咪最大 提交于 2019-12-22 05:42:17
问题 What is purpose of les instruction in assembly? Why do we need to load es segment and a register? Book gives following example: les bx, p ; Load p into ES:BX mov es:[bx], al ; Store away AL Why do we need to load es and bx in this case? Also why do we use es:[bx] ? If p points to 100h in memory, isn't both es and bx 100h = 200h ( bx+es )? 回答1: Its too bad you are learning assembler for a microprocessor with a messy architecture. You get confusing concepts such as the LES instruction.

masm division overflow

馋奶兔 提交于 2019-12-22 04:02:29
问题 I'm trying divide two numbers in assembly. I'm working out of the Irvine assembly for intel computers book and I can't make division work for the life of me. Here's my code .code main PROC call division exit main ENDP division PROC mov eax, 4 mov ebx, 2 div ebx call WriteDec ret divison ENDP END main Where WriteDec should write whatever number is in the eax register (should be set to the quotient after the division call). Instead everytime I run it visual studio crashes (the program does

[MASM]Another 'cannot use 16-bit register with a 32-bit address' error

六月ゝ 毕业季﹏ 提交于 2019-12-21 17:57:28
问题 I'm learning assembly language with MASM assembler and I get stuck when I tried to assemble a simple file using this command : ml /c test.asm and the test.asm file looks like : .386 .model flat .code MOV BP,WORD PTR[BP+4] END then the problem comes: Microsoft (R) Macro Assembler Version 6.14.8444 Copyright (C) Microsoft Corp 1981-1997. All rights reserved. Assembling: test.asm test.asm(4) : error A2155: cannot use 16-bit register with a 32-bit address the question is , 32-bit address?I didn't

Simple Assembly program on visual studio 2017

余生颓废 提交于 2019-12-21 05:39:07
问题 .386 .model flat, c .stack 100h printf PROTO arg1:Ptr Byte .data msg1 byte "Hello World!", 0Ah, 0 .code main proc INVOKE printf, ADDR msg1 ret main endp end main Hi, I am getting the below errors: I searched around and found someone said that it can be fixed by linking the microsoft runtime library Can anyone teach me how can I exactly fix it? Thanks Severity Code Description Project File Line Suppression State Error LNK2019 unresolved external symbol _printf referenced in function _main

WIN10下运行汇编语言编写的Hello World

对着背影说爱祢 提交于 2019-12-20 13:48:03
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 我们在这里需要DOSBox软件,这里提供MASM和DOSBox下载链接: MASM:https://pan.baidu.com/s/1T-UAPk57iNL-NtvSj-IShA 提取码g3y1 DOSBox:https://pan.baidu.com/s/1wxr9HN51jFqEtYaUcZFIdA 提取码g2fx 下载好了第一个文件会看到里面有debug.exe,LINK.EXE,MASM.EXE三个程序,我们需要把它们和我们写好的hello.asm(用txt创建后改名为hello.asm)文件放在一个文件夹下面,假设这里放在了D盘的MASM文件夹下。 assume cs:code,ds:datas datas segment str db 'helloWorld!','$' datas ends code segment mov ax,datas mov ds,ax lea dx,str ; 获取str的偏移地址 mov ah,9 ; 调用9号功能输出字符串 int 21h mov ah,4ch int 21h code ends end 下载好第二个文件发现里面有DOSBox…的程序,点击正常安装完就好。安装完成后打开桌面上的DOSBox0.74 我们来到红色圈圈包起来的路径下C:\Users\hp

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: "

How do i check whether characters are within certain ascii value ranges?

守給你的承諾、 提交于 2019-12-20 05:48:35
问题 How do i check whether a character is between 0-9, A-Z, and a-z? I understand that you can use cmp char, 'A' or cmp char, '0', etc. However if i have to check three different ranges, how do i do that? If i need to check whether 'A'<= C <= 'Z', then i would have to check whether the character value is below A first, and then whether it's less than or equal to Z. But since 0-9 are below A, how do i account for that without messing up logic? The same goes for Z, since a-z are above Z. Posting

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: