Re: Uniform spacing of labels in MASM32



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.

.



Relevant Pages

  • Re: Is this right?
    ... On 6 Oct 2006 Martin Wuerthner wrote: ... Rob suggested, the instruction LDR PC,xxx is used, which does not have ... alternative to SWI calls. ... the case when the called routine does some non-trivial amount of work. ...
    (comp.sys.acorn.programmer)
  • Re: HLA v1.86 is now available
    ... generally don't have the algorithmic background to write such a routine ... And you're *still* way ahead of where the students are at when they ... I didn't chose this four instruction for a start (I would have selected ... when they could be using a canned puti routine to get their ...
    (alt.lang.asm)
  • Re: Need to get to function names using an assembly instruction address
    ... This will fail for any routine that doesn't have debug info, ... > instruction of the last source code line in each routine, ... In order to understand recursion you must first understand recursion. ...
    (comp.unix.aix)
  • Re: processor compatibility map ?
    ... You can simply check support through the CPUID instruction. ... What I do is write two routines, one with HADDPD and one without. ... HADDPD routine, if not, then I do a pointer to the other routine. ...
    (comp.lang.asm.x86)
  • Re: Indirect indexed confusion
    ... BIT-operation ($2C = opcode of the BIT instruction). ... providing that many different entry points to a common routine (in that case ... instruction is usually CLC or SEC, which flags something to the common ...
    (comp.sys.apple2.programmer)