MASM

TYPEDEF PTR - size doesn't matter?

走远了吗. 提交于 2019-12-08 12:30:50
问题 I noticed using TYPEDEF to define PTR's with various data types doesn't seem to make any difference. For example, these three types seem to behave exactly the same when used to store and mov 32-bit addresses: PTYPE TYPEDEF PTR PBYTE TYPEDEF PTR BYTE PWORD TYPEDEF PTR WORD .data arrayByte BYTE 10h,20h,30h ptr_1 PTYPE arrayByte ptr_2 PBYTE arrayByte ptr_3 PWORD arrayByte .code main PROC mov eax, ptr_1 mov eax, ptr_2 mov eax, ptr_3 exit main ENDP Is there any practical reason to specify a size

Convert Character to binary assembly language

半腔热情 提交于 2019-12-08 12:21:12
问题 Hi i m using dosbox and masm compilor. I want to prompts the user to enter a character, and prints the ASCII code of the character in hex and in binary on the next line. Repeat this process untill the user types a carriage return. The following code work fine to display the charcters in hexadecimal until a carriage return how can i modify this code to display the binary of charcter as well.? .MODEL SMALL .STACK 100H .DATA PROMPT_1 DB 0DH,0AH,'Enter the character : $' PROMPT_2 DB 0DH,0AH,'The

MASM : How do you declare a string with carriage return?

天涯浪子 提交于 2019-12-08 11:26:37
问题 I would like to know if it is possible in MASM to write special character in string. HelloWorld db "Hello World!\r\n", 0 Would be an intuitive way but it does not work. Thanks. 回答1: The ASCII codes for CR and LF are 13 and 10, so: HelloWorld db "Hello World!",13,10,0 来源: https://stackoverflow.com/questions/22090605/masm-how-do-you-declare-a-string-with-carriage-return

Need help understanding conditional directives with MASM

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-08 09:39:37
问题 I am trying to implement the following c code in MASM using MASM directives: if ( a > b ) a = a - 1; else if ( b >= c ) b = b − 2; else if ( c > d) c = c + d; else d = d / 2; This is my attempt: .if (a > b) sub a, 1 .elseif b >= c1 sub b, 2 .elseif c1 > d add c1, d .else mov eax, d cdq mov ebx, 2 idiv ebx mov d, eax .endif .endif I feel like my logic is sound yet no matter what I change around to keep it intact I am getting errors. I am sure I have misunderstood something, but don't unsure

How to run a MS-DOS .asm file using VS2013 or MASM32?

北城余情 提交于 2019-12-08 09:18:05
问题 Here is my test.asm code. Basically 'nothing' inside because just want to get it to build and run without errors first. .model small .stack 64 .data .code main proc mov ax,@data mov ds,ax mov ax,4c00h int 21h main endp end main I have tried using visual studio 2013 include the lib, add the linkers and all those guides from websites but no luck. Always getting this error message "error A2006: undefined symbol : DGROUP" for both MASM32 and visual studio 2013. Please guide me step by step on the

How do you do a selection sort in MASM Assembly?

随声附和 提交于 2019-12-08 08:14:31
问题 So I'm trying to sort an array in ascending order, and it just doesn't seem to work for me. I know my swap procedure is wrong, and my minIndex procedure only works half the time, but the randomly filled array generates just fine. Working Code Thanks to vitsoft: include Irvine32.inc ; Constants NUM_INTEGERS = 20 NUM_RANGE = 99d TO_ENSURE_NOT_ZERO = 1d .data ; Declare Arrays ; Declare Array of 20 Integers array byte NUM_INTEGERS dup(?) ; Displayed Annotation for Unsorted Array unsortedArrayText

Anyone knows anything that can encode an asm string in bytes using c++?

岁酱吖の 提交于 2019-12-08 02:13:47
问题 Anyone knows anything that can encode a string in bytes using c++? asmpure do it on x86. I need something similar on x64 I need to convert strings into hexadecimal bytes i.e. "mov rdx, rax" => 48 8B D0 "add ax, 17h" => 66 83 C0 17 "sub cl, 5Bh" => 80 E9 5B 回答1: Problem solved. For anyone looking for solution here it is: http://www.keystone-engine.org/ 来源: https://stackoverflow.com/questions/50465724/anyone-knows-anything-that-can-encode-an-asm-string-in-bytes-using-c

“Function-level linking” (i.e. COMDAT generation) in MASM assembly?

佐手、 提交于 2019-12-07 12:56:05
问题 Is there any way to make MASM generate COMDATs for functions, so that unused functions are removed by the linker? (i.e. I'm looking for the equivalents of /Gy for MASM.) 回答1: Not straightforward, but doable; discussed here and here. The first step involves putting each function into a separate segment with names like .text$a, .text$b, etc. This way, the assembler won't unite them into a single .text section, but the linker eventually will; there's a special rule in Microsoft linkers regarding

What is the minimum file size of a PE file (exe) on Windows? And the minimal memory allocation? [duplicate]

时光毁灭记忆、已成空白 提交于 2019-12-07 11:44:02
问题 This question already has answers here : What is the smallest possible Windows (PE) executable? (2 answers) Closed 3 years ago . What is the minimum file size of a PE file (exe) on Windows? And the minimum memory allocation? I assembled (using MASM (ml.exe) and link.exe that come with VS 10) the following code: I can not leave out kernel32.lib and ExitProcess, if I do, the program crashes. ; Assmebly options .386 .MODEL FLAT, STDCALL option casemap:none ; Include Libs includelib kernel32.lib

MASM: Using Current Location Counter ($) in .data declaration

人走茶凉 提交于 2019-12-07 08:08:33
问题 I met a problem about the Current Location Counter in MASM. Here is my assembly code, and I used Visual Studio 2013 Express for assembling .386 .model flat,stdcall .stack 8192 ExitProcess proto,dwExitCode:dword .data ptr1 DWORD $ ptr2 DWORD $ ptr5 DWORD $ .code main proc mov eax, $ mov eax, $ invoke ExitProcess,0 main endp end main In my opinion, I think that ptr1, ptr2, and ptr5 should have their own location value. But it's not correct in fact. When in debugging mode, the variables show the