flat assembler
Message board for the users of flat assembler.

Index > Main > help me with opcodes please

Author
Thread Post new topic Reply to topic
terex



Joined: 31 Dec 2003
Posts: 16
Location: Saint-Petersburg, Russia
terex 05 Jan 2004, 03:20
I'm newbie in this topic. Is this right?
Code:
      ;1)
     ;mov    ebx, scan2ascii {
                      db 0xC7
                     db 0xC3
     ps2a rd 1
   ; }

        ;2)
     ;mov    ebx, [screenpos] {
                     db 0xC7
                     db 0x1D
     ppsp1 rd 1
  ; }

        ;3)
     ;add    [screenpos], 0x2 {
                     db 0x81
                     db 0x5
      ppsp2 rd 1
  ; }

        ;4)
     ;mov    [screenpos], ebx {
                     db 0x89
                     db 0x1D
     ppsp3 rd 1
  ; }
    

ps2a contains offset of scan2ascii label, ppsp[n] contains offset of screenpos one. You may ask me, why do i need code like this. Answer is simple: that piece of code will execute in pagintation pmode, so i don't know real addresses of labels in compile-time.

_________________
sorry for my english
Post 05 Jan 2004, 03:20
View user's profile Send private message Visit poster's website Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 05 Jan 2004, 06:02
Why not:
Code:
ps2a:   mov   ebx, [0]
ppsp1: mov   ebx, [0]
ppsp2: add   [0], 0x2
ppsp3: mov   [0], ebx
    


and then you can use: [ps2a+2], [ppsp1+1], etc. to fill real addresses.

or better use on runtime:

Code:

; compute the address in esi. 

   mov   ebx, [esi]
   mov   ebx, [esi]
   add   [esi], 0x2
   mov   [esi], ebx
    
Post 05 Jan 2004, 06:02
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
terex



Joined: 31 Dec 2003
Posts: 16
Location: Saint-Petersburg, Russia
terex 05 Jan 2004, 08:07
Oh, chets, it is really mutch more better! Thanks. Why i didn't get this solve myself? Sad Btw, i compiled instruction... and sow that my interpretatioon of opcode-building is not very right Smile Opcodes for all of written commands are wrong Confused

_________________
sorry for my english
Post 05 Jan 2004, 08:07
View user's profile Send private message Visit poster's website Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 05 Jan 2004, 08:37
terex wrote:
Smile Opcodes for all of written commands are wrong Confused


Well, I never check them. Smile To programm in hex, you need hex editor, not an assembler. Wink I can't remember who was, but someone wrote: "Real man code in hex." Very Happy Very Happy Very Happy

Regards
Post 05 Jan 2004, 08:37
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
scientica
Retired moderator


Joined: 16 Jun 2003
Posts: 689
Location: Linköping, Sweden
scientica 05 Jan 2004, 11:35
There are an opcode tutotial on the http://board.win32asmcommunty.net by the Svin (very good stuff IMO), if you want to do opciding there are a few macros for modrm,sib (and single byte instruction /reg), which accepts binary (eg bsib 01,100,001).

_________________
... a professor saying: "use this proprietary software to learn computer science" is the same as English professor handing you a copy of Shakespeare and saying: "use this book to learn Shakespeare without opening the book itself.
- Bradley Kuhn
Post 05 Jan 2004, 11:35
View user's profile Send private message Visit poster's website Reply with quote
terex



Joined: 31 Dec 2003
Posts: 16
Location: Saint-Petersburg, Russia
terex 05 Jan 2004, 21:41
Quote:
someone wrote: "Real man code in hex."

My friend told me that one ultraexpirenced professor in his university have said it to students during first lesson of programming Wink

2scientica: i have read good (imho) opcode tutorial in my native language on wasm.ru... and it didn't help me Smile It's not important. Because i'm not going to opcoding. I just want to be able use it when it really need. But thanks in any case.
About macroses. Continueing this idea we can got a set of macroses which translate mnemonic instructions to the opcode Smile But we allready have so many different assembler compilers Laughing

_________________
sorry for my english
Post 05 Jan 2004, 21:41
View user's profile Send private message Visit poster's website Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2139
Location: Estonia
Madis731 05 Jan 2004, 23:25
I guess I must be a "real man" Laughing
I have a PC-E500 pocket computer from Sharp and I could code only in BASIC in it until I found out that I can call memory addresses from BASIC Very Happy
Now I poke to some memory addresses, call it and later peek the values that should have changed by running my code:)
Fun, ain't it?
It has only 26K of RAM, so I can't do any large programs in it:(
...but I'm building a dungeon game (or was it MUD game) I guess it will be about 2KB

P.S. I'm a really lucky man, 'cause the computer allows me to code in hex AND in dec too Cool
Post 05 Jan 2004, 23:25
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 05 Jan 2004, 23:46
Madis731 wrote:
I guess I must be a "real man" Laughing
I have a PC-E500 pocket computer from Sharp and I could code only in BASIC in it until I found out that I can call memory addresses from BASIC Very Happy


Well this is classics. Smile Now you should write not a game, but simple assembler, to make you live easyer. Then write a game - it will be faster.

Or better write some Win32 programm with FASM. Very Happy

Regards.
Post 05 Jan 2004, 23:46
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2139
Location: Estonia
Madis731 07 Jan 2004, 00:18
...some work has been done for me by some fine chinese and japanise people, but I don't understand their language so I'm just testing the assemblers how would they work. And of course, I don't have any cable between my PC and PC(PocketComputer), so every byte must be hand-written to the PC-E500 Evil or Very Mad
But I can manage, I'll keep my code size optimized & everyone will be happy Wink
But thanks for the advice, I'll do that some day inside my PC(pocket). As you said, my life would be MUCH easier Razz
Post 07 Jan 2004, 00:18
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger 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.