Re: Uniform spacing of labels in MASM32
- From: Steve <spamtrap@xxxxxxxxxx>
- Date: Wed, 21 Dec 2005 08:19:45
Chris Martens wrote:
<...>
> The way I thought of doing this was allocating each binary instruction
> (16 bits wide) a 64 byte chunk of code to implement what it had to do.
> I've done this before writing text blitters for DirectX (yes, I'm a bit
> of an oddball), but I thought that using masm32 to compile the function
> in assembly would give me greater control than inline assembly in MS
> VC++ 6.0 like the way I used to do things.
<...>
> Other syntax errors and elegance issues aside, is there some other way
> to space these code blocks apart easily without having to dump NOP's in
> between each?
Hello Chris,
In a similar vein, I decode keystrokes to commands in
a game. Main difference to you is 8 bit instructions
rather than your 16 bit ones. And it is for a DOS 5.0
environment.
Process is (loosely) convert keystroke (instruction)
into a offset into a command table. Use this to indirectly
call the routine.
Example:
; Data segment.
; - - - Command Procedure Call Table - - -
CallTab DW Null, Function, MovePL, Help_Scr, RotateP, Paws, DropIt
DW PPreview, MovePR, Quit, IQuit, IPlay, PRight, PLeft
DW IUp, ILeft, IRight, IDown, DispScr, DumpScrn, IP_1
; Code segment example routines
; The Function routine is similar to the main decode logic.
; CommExFn is the function key to offset conversion table.
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Process a function key/Non-ASCII
Function:
MOV BX,OFFSET CommExFn
MOV AL,AH ; check scan code
XLAT ; translate scan code to command number
XOR AH,AH
SHL AX,1 ; creates an index into table of words
MOV BX,OFFSET CallTab
ADD BX,AX
CALL [BX]
RET
; - - - - - - - - - - - - - - - - - - - - - - - - - - -
Null: ; Undefined commands / keystrokes
RET
; - - - - - - - - - - - - - - - - - - - - - - - - - - -
Paws:
MOV [Pause],1
MOV AH,10H ; Read Extended Keyboard Input.
INT 16H ; AL = ASCII, AH = Scan code
MOV [Pause],0
RET
; - - - - - - - - - - - - - - - - - - - - - - - - - - -
HTH
Steve N.
.
- Prev by Date: Re: Page flipping on LFB in protected mode...how??!?!
- Next by Date: Re: varargs in C (AMD64 architecture)
- Previous by thread: Page flipping on LFB in protected mode...how??!?!
- Next by thread: Uniform spacing of labels in MASM32
- Index(es):
Relevant Pages
|