flat assembler
Message board for the users of flat assembler.
Index
> DOS > memory access with dx |
Author |
|
vid 23 Jun 2007, 11:44
"dx" cannot be used to address memory in 16 bit code.
the error message in this case is very bad, i agree |
|||
23 Jun 2007, 11:44 |
|
realcr 23 Jun 2007, 12:55
thanks vid.
Someone told me to try it in masm and see if it works. I wrote this code: Code: .model small .stack 100 .data CLRF db 13,10,'$' MSG db 'passed the writing test!$' .code MAIN Proc mov AX,@Data mov DS,AX mov AH,9 lea DX,CLRF INT 21H label1: mov si,label1 ; load the label's location mov word ptr [si],1337h ; try to write to memory mov ax,1337h cmp [si],ax ; check the memory write jnz exit2 ; if we get here it means the write to memory ; was successful mov AH,9 lea DX,MSG ; load the message INT 21H ; print the message to screen mov AH,9 ; print the crlf thingy lea DX,CLRF INT 21H exit2: ; if we get here we exit the program mov AH,4CH INT 21H MAIN Endp End MAIN and I got: Code: C:\>test.exe passed the7<riting test! and we all know that 0x37 is the char "7" , which proves it is somehow possible. |
|||
23 Jun 2007, 12:55 |
|
Goplat 23 Jun 2007, 21:27
Nowhere in that MASM example did you actually do a memory access with DX. It worked because you used SI.
|
|||
23 Jun 2007, 21:27 |
|
DOS386 23 Jun 2007, 22:55
Code: mov word ptr [si],1337h Please delete the MA$M code from your post. It's unnecessarily long and not related to the issue at all Code: use16 org $100 mov ax,[bx] ; mov ax,[dx] mov ax,[bp] mov ax,[si] mov ax,[di] ud2 Quote:
Right. Should be: Code: Only BX, BP, SI, and DI can be used for indexing in 16-bit code _________________ Bug Nr.: 12345 Title: Hello World program compiles to 100 KB !!! Status: Closed: NOT a Bug |
|||
23 Jun 2007, 22:55 |
|
realcr 26 Jun 2007, 17:03
I'm sorry for sending the wrong masm32 example,
However it does work with masm if you replaec the si with dx. I tried to see the output in olly , and I fould out that masm actually moves dx into si , and then restores it , just in order to do the memory operation. So you were right about not being able to use dx. Thanks for help, realcr. |
|||
26 Jun 2007, 17:03 |
|
f0dder 26 Jun 2007, 22:30
realcr wrote:
And that is a thing that an assembler shouldn't be doing, imho - ugly. One thing is if things happen "behind your back" when you use macros, but instructions should never be "magicified" like that. Oh, and please call the assembler "MASM" and not "masm32" - the former is the name of the assembler, the latter is the name of that particular Australian's hodgepodge package. _________________ - carpe noctem |
|||
26 Jun 2007, 22:30 |
|
DOS386 28 Jun 2007, 00:59
Quote: that masm actually moves dx into si NOT amused |
|||
28 Jun 2007, 00:59 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.