MASM

Accessing Segment Registers MASM

a 夏天 提交于 2019-12-01 23:42:06
问题 I'm trying to query the value located in the Process Enviornment Block, pointed to by the FS segment register. Attempting to compile code with the fs:[0] segment included results in an error (error A2108: use of register assumed to ERROR). How do you query the segment registers?! Thanks 回答1: MASM by default assumes that any access to the segment registers is an error (which usually it is). You need to redefine the assumptions for the FS register using ASSUME FS:NOTHING . You can place this

error A2070: invalid instruction operands while using nested while loop in assembly language

我与影子孤独终老i 提交于 2019-12-01 23:00:36
I am trying nested while loop in assembly using masm. I am getting the "error A2070: invalid instruction operands" at line 15 i.e at the endw directive of internal while loop while running the following code. INCLUDE Irvine32.inc .data i byte 1 j byte 2 .code main PROC xor eax,eax .while i<5 mov j, 2 .while j<i mov al, j call writeDec call crlf inc j .endw inc i .endw exit main ENDP END main I cant find the reason for this. Can anyone help me? The error is here: .while j<i You cannot compare two memory contents directly. It is possible to compare a memory content with a register, e.g.: mov dl,

Cannot access label through segment registers, error in assembly

大兔子大兔子 提交于 2019-12-01 22:49:58
INCLUDE Irvine16.inc .data byteArray BYTE 6 DUP(?) listSize = ($ - byteArray) aSum WORD 0 soffset = 0 .code main PROC mov ax, @data mov ds, ax mov cx, listSize Loop1: mov ax, 0 movzx ax, [byteArray + soffset] add aSum, ax soffset = soffset + 1 loop Loop1 exit main ENDP END main The error I'm getting is error "A2074:cannot access label through segment registers" I'm trying to use the soffset to loop through the byteArray. I'm not sure what's in Irvine16.inc, but I bet it is saying .model small,... at some point. If you add ASSUME DS:_DATA then your error messages will go away, although I doubt

Accessing Segment Registers MASM

五迷三道 提交于 2019-12-01 21:35:59
I'm trying to query the value located in the Process Enviornment Block, pointed to by the FS segment register. Attempting to compile code with the fs:[0] segment included results in an error (error A2108: use of register assumed to ERROR). How do you query the segment registers?! Thanks MASM by default assumes that any access to the segment registers is an error (which usually it is). You need to redefine the assumptions for the FS register using ASSUME FS:NOTHING . You can place this directive at the top of your file, OR you could "reassume" the FS register temporarily. Example: ASSUME FS

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

空扰寡人 提交于 2019-12-01 21:33:51
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, on the other hand, produces a compiled program 20,000 bytes larger: .data smallArray DWORD 10 DUP(0) ;

How can I make a batch file that automatically builds, links and executes a .asm file?

﹥>﹥吖頭↗ 提交于 2019-12-01 21:23:05
I am working with DosBox emulator in my university. We build .asm files with MASM. I am extremely tired of having to build my .asm file every time with masm, then pressing enter 4 times, then entering link .obj, then enter 4 times. Then running the actual .exe. I wanted to automate this, and after searching for a while, I understand I need to make a batch file. It currently looks like this @echo off set arg1=%1 masm %arg1%.asm %SendKeys% ("echo off{ENTER}") %SendKeys% "echo off{ENTER}" %SendKeys% "echo off{ENTER}" %SendKeys% "echo off{ENTER}" link %arg1%.obj %SendKeys% "echo off{ENTER}"

Strange output with Irvine's WriteString

狂风中的少年 提交于 2019-12-01 20:28:35
the point of the following program is to print out the letter "c" with the combination of every background and foreground color. In the library I'm using the colors are defined 0-15 and with the following code: mov eax,FOREGROUND + (BACKGROUND * 16) call SetTextColor Here is my code: INCLUDE Irvine32.inc .data character BYTE "c" count DWORD ? background DWORD 0 .code main PROC call Clrscr mov ecx, 15 ; our main counter 0-15 colors L1: mov count, ecx ; store our outer loop counter mov ecx, 15 ; set out inner loop counter L2: ; since our color is defined like so... mov eax,FOREGROUND +

Inline Assembly Jump Error

懵懂的女人 提交于 2019-12-01 14:47:50
Why does this fail, once Masm reaches jmp? struct gdt_entry { unsigned short limit_low; unsigned short base_low; unsigned char base_middle; unsigned char access; unsigned char granularity; unsigned char base_high; }; struct gdt_ptr { unsigned short limit; unsigned int base; }; struct gdt_entry gdt[3]; struct gdt_ptr gp; void gdt_flush() { __asm{ lgdt [gp] mov ax, 0x10 mov ds, ax mov es, ax mov fs, ax mov gs, ax mov ss, ax ; push the address on the stack push 0x08 mov eax, offset flush2 push eax ; ret use the previous pushed address _emit 0xCB ; far return flush2: ;ret } } void gdt_set_gate(int

Assembly language - masm32 - multiplying

和自甴很熟 提交于 2019-12-01 14:42:33
I am multiplying 3 numbers which works good even with a carry. I want to add a 4th number to multiply just for learning purposes. After i multiply 3 numbers i shift into EDX and print. Works great. After i add a 4th number i think i am multiplying 32bit x 32bit? So it stores into EDX:EAX? Would i then need to shift EAX into EDX so they are together to print? Im not sure if i am doing it right for the 4th number? .data? num1 dd ? num2 dd ? num3 dd ? num4 dd ? .data sum dd 0 prod dd 0 prod2 dd 0 here are the prompts mov EAX, sval(input("Enter first number: ")) mov num1, EAX mov EAX, sval(input(

probleme with error A2206: missing operator in expression

你说的曾经没有我的故事 提交于 2019-12-01 14:23:05
Hi guys I have this code here in assembly it should create a message box but when I try to compile it with Masm I get this error: C:..\test.asm(26) : error A2206: missing operator in expression .386 .model flat, stdcall option casemap:none includelib C:\masm32\lib\kernel32.lib includelib C:\masm32\lib\user32.lib include C:\masm32\include\kernel32.inc include C:\masm32\include\user32.inc include C:\masm32\include\windows.inc .data MsgText db "Hello World!",0 MsgTitle db "My First MessageBox",0 .code Main: xor ebx,ebx xor ecx,ecx push offset MsgTitle ;title mov ebx,esp push offset MsgText ;text