flat assembler
Message board for the users of flat assembler.

Index > Main > DB/DW/DD/etc

Author
Thread Post new topic Reply to topic
babyboy10777



Joined: 28 Jun 2006
Posts: 6
Location: IL
babyboy10777
Hi. I've been browsing this forum for a while and I have a question.

Do the DB/DW/DD/etc keywords operate the same in .code/.text as they do
in .data? For some reason, the following code causes an access violation:

dd vga 0
setvga:
mov eax, [esp + 4]
mov dword [vga], eax
ret 4

Why doesn't this work? vga is defined in the .code section directly before this
procedure.

Thanks.
Post 28 Jun 2006, 08:09
View user's profile Send private message Reply with quote
babyboy10777



Joined: 28 Jun 2006
Posts: 6
Location: IL
babyboy10777
Also, here is a procedure I wrote that refers to bytes defined inside code, and it works perfectly, so I don't understand why the previous code doesn't.

; n2th(*t, n) - Convert 32BIT number to unsigned hexadecimal text

db '0123456789ABCDEF'
n2th:
mov eax, [esp + 8]
mov ecx, [esp + 4]
xor edx, edx
@@:
mov dl, al
and dl, 15
mov dl, [(n2th-16) + edx]
mov [ecx], dl
inc ecx
shr eax, 4
jnz @b
mov byte [ecx], 0
push ecx
call trev
ret 8
Post 28 Jun 2006, 08:34
View user's profile Send private message Reply with quote
dead_body



Joined: 21 Sep 2005
Posts: 187
Location: Ukraine,Kharkov
dead_body
.code section maybe has not atrribute "writeable"?
see macro '.code' and macro '.data' and compare it.(and if you need correct ".code" macro(add writeable attribute))
Post 28 Jun 2006, 08:35
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
it's best to use macros only when you understand them. for example, instead of .code you can write section '.text' code readable executable. To make it writable, change this to section '.text' code readable writeable executable
Post 28 Jun 2006, 08:40
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
babyboy10777



Joined: 28 Jun 2006
Posts: 6
Location: IL
babyboy10777
Oh, I forgot the "writeable" attribute Smile It was: section '.code' code readable executable.

Thanks everyone.
Post 28 Jun 2006, 10:45
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.