flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Arrays in FASM?

Author
Thread Post new topic Reply to topic
rhyno_dagreat



Joined: 31 Jul 2006
Posts: 487
Location: Maryland, Unol Daleithiau
rhyno_dagreat 29 Sep 2006, 17:25
Is it possible to make like an array in FASM? The reason why I have this question in the OS construction is I want to put the keyboard layout in an array in FB, and then have my input interrupt store the scancode in AL, and then go to AL place in the array, where the actual character would be, if that makes any sense whatsoever.

C pseudo-code:

char myarray[KBD_SIZE] = {0, 27, "1", "2", "3"...};

printf(myarray[scancode]);
Post 29 Sep 2006, 17:25
View user's profile Send private message Reply with quote
okasvi



Joined: 18 Aug 2005
Posts: 382
Location: Finland
okasvi 29 Sep 2006, 18:25
...

myarray db 0, 27, "1", "2", "3"

Wink
Post 29 Sep 2006, 18:25
View user's profile Send private message MSN Messenger Reply with quote
rhyno_dagreat



Joined: 31 Jul 2006
Posts: 487
Location: Maryland, Unol Daleithiau
rhyno_dagreat 29 Sep 2006, 21:19
Umm... and I'd access each individual byte by doing "myarray + n", right?
Post 29 Sep 2006, 21:19
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 29 Sep 2006, 23:38
Since it's a byte array yes, (symbol+elementNumber) is enough but for general accessing is (symbol+elementNumber*sizeOfElement).
Post 29 Sep 2006, 23:38
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 30 Sep 2006, 00:41
You could do something like this pseudo code
Code:
xor   eax,eaxin    al,0x60; do some test here for ctrl etcmov   [ScanCode],al ;al = scan codemov   edi,eax;Convert to ASCIImov   al,[edi+normal_keymap] ; normal_keymap = address of array    
Post 30 Sep 2006, 00:41
View user's profile Send private message Reply with quote
rhyno_dagreat



Joined: 31 Jul 2006
Posts: 487
Location: Maryland, Unol Daleithiau
rhyno_dagreat 30 Sep 2006, 03:08
I think I get it, thanks... but why copy al to scan code?
Post 30 Sep 2006, 03:08
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 30 Sep 2006, 03:37
rhyno_dagreat wrote:
I think I get it, thanks... but why copy al to scan code?

So you can put it in ah at the end of the function, like this
Code:
        mov   al,[keybuffer]   ; this has the ASCII        mov   ah,[ScanCode] ;this has the scan code    
Post 30 Sep 2006, 03:37
View user's profile Send private message Reply with quote
rhyno_dagreat



Joined: 31 Jul 2006
Posts: 487
Location: Maryland, Unol Daleithiau
rhyno_dagreat 30 Sep 2006, 03:49
Oh, I see now... thanks!
Post 30 Sep 2006, 03:49
View user's profile Send private message Reply with quote
Niels



Joined: 17 Sep 2006
Posts: 255
Niels 30 Sep 2006, 13:39
Hello rhyno_dagreat,

This downloadable booklet has [one] or [two] things on arrays:

http://www.drpaulcarter.com/pcasm/index.php
Post 30 Sep 2006, 13:39
View user's profile Send private message Reply with quote
rhyno_dagreat



Joined: 31 Jul 2006
Posts: 487
Location: Maryland, Unol Daleithiau
rhyno_dagreat 30 Sep 2006, 18:03
Hey, thanks Niels! I believe I've read some of that book before, and it helped me a little while ago. I knew arrays were groups of variables one after another in memory, but I didn't know you could access 'em the way they are said to be able to be accessed in these other languages (if what I said makes any sense Razz) but thank you again for the link! I had to reformat my HD and install Windows again, so I'm gonna download that again.
Post 30 Sep 2006, 18:03
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.