SourcePoint AMD Help

Table of Contents

asm

Display memory as disassembled instructions or assemble instructions in-line.

Syntax

Disassembler:

[[px]] asm addr-spec

Assembler:

[[px]] asm addr-spec = "statement" [, "statement"]

ย 

[[px]] asm addr =

Where:

[px]

is the viewpoint override, including punctuation ([]), specifying that the viewpoint is temporarily set to processor x of the boundary scan chain. ย The processor can be specified as px (where x is the processor ID), or an alias you have defined for a given processor ID. ย ALL cannot be used as a viewpoint override.

addr-spec

{ addr l addr to addr l addr length expr }

statement

{ instruction l directive }

addr

specifies an address for display or assembly.

length

specifies the number of instructions to be displayed.

expr

specifies a number or an expression that indicates the number of instructions to be displayed.

instruction

is the Intel assembly language instruction.

directive

is an assembly language directive or comment.

Discussion

Use the asm command to display memory as disassembled instructions or to in-line assemble instructions into memory. The output from the asm command is a fixed format. For more control of disassembler output, the Code window should be used. The in-line assembler is provided to enable quick patches in active memory. The assembler uses a single pass, and therefore cannot use labels that have not yet been defined; however, the command language offers the ability to define labels, and the assembler offers the org directive for out-of-order assembly.

Disassembler

Displays memory as disassembled instructions. When disassembling, the displayed instructions will be look something like this:

addr codebytes mnemonic [[operand,] operand]

Where:

addr

specifies the address of the start of the instruction.

codebytes

is the byte encoding of the instruction. ย ย 

mnemonic

is the instruction mnemonic.

operand

is an instruction operand. The number of operands is instruction specific. There may be zero or more.

Example 1

To display a single instruction at offset 0ah in the current code segment:

Command input:

asm 0ah

Result:

00000000AH 0000 ADD [BX+SI] ,AL

Example 2

To display three instructions beginning at the current execution point:

Command input:

asm cs:ip length 3

Result:

00C3:00000000H 55 PUSH EBP
00C3:00000001H 8BEC MOVE EBP,ESP
00C3:00000003H 81EC04000000 SUB ESP,4H

Example 3

To display two instructions beginning at offset 0 in the code segment with selector 25 referenced through the LDT with selector 98:

Command input:

asm 098:025:0000H length 2

Result:

0098:0025:00000000H 9A00000000D100 CALL 0D1:0H
0098:0025:00000007H 66CF IRET

Example 4

To display instructions from linear address 11426 to 11430:

Command input:

asm 11426L to 11430L

Result:

00011426L 0000 ADD [BX+SI] ,AL
00011428L 0000 ADD [BX+SI] ,AL
0001142AL 0000 ADD [BX+SI] ,AL
0001142CL 0000 ADD [BX+SI] ,AL
0001142EL 0000 ADD [BX+SI] ,AL

Assembler

The assembler assembles instructions in-line using the current processor modes and settings and places the instruction code in memory. The current focus processor settings are used by default, but may be overridden by the command language or assembler directives. The assembler has been designed to accept all of the assembler forms output by the SourcePoint disassembler as well as the common forms found in Intel assemblers.

mov

ax, table[bx][di]

mov

ax, table[di][bx]

mov

ax,table[bx+di]

mov

ax,[table+bx+di]

mov

ax,[bx][di]+table

Operand size can be explicitly represented with the PTR operator. The PTR keyword should be preceded immediately by one of the size keywords.

byte ptr

unsigned byte (8-bit)

sbyte ptr

signed byte (8-bit)

word ptr

unsigned word (16-bit)

sword ptr

signed word (16-bit)

dword ptr

doubleword (32-bit)

sdword ptr

signed doubleword (32-bit)

dfword ptr

farword (48-bit)

dqword ptr

quadword (64-bit)

tbyte ptr

ten-byte (80-bits)

For instance:

mov

eax, byte ptr foo

mov

eax, word ptr bar

Jump size can be explicitly represented with one of the distance operators.

short

jump short, relative

near

jump near, relative

near16

jump near 16-bit, relative

near32

jump near 32-bit, relative

far

jump far, absolute

far16

jump far 16-bit, absolute

far32

jump far 32-bit, absolute

For instance:

jmp

near ptr target

jmp

far32 ptr thing+0x122

Numbers entered into the assembler have the default radix specified by the command language. The default can be changed via the base command.

Radix overrides are allowed as either prefix or suffix operators. See constants.

The $ symbol may be used as a shorthand key for the current assembly address. The $ can be used alone or inside an expression (e.g., $+10). This makes it easy to enter loops.

Example

To generate an infinite loop at the current execution point:

Command input:

asm $ = "jmp $"

Numeric expressions can be formed wherever a number or address is required. The following expression operators are recognized.

/

n / m

integer divide

*

n * m

integer multiply

+

+n

unary plus

+

n + m

integer addition

-

-n

unary minus

-

n - m

integer subtraction

( )

(n * m) - p

precedence grouping

When assembling, the instructions can be entered in one of two forms: batch and interactive.

Batch Assembly

The first form allows multiple instructions to be entered on a single line. The instructions must be enclosed in quotation marks and separated by commas. Multiple lines can be used; ending a line with a comma indicates line continuation. The instructions are parsed and placed in memory. Any errors encountered are reported at the end. This form is well suited to inclusion in macros or procedures. This is also the form to use to fill a region of memory with an instruction sequence.

If a range of memory is given as the addr-spec using either the addr to addr or addr length expr, then that range of memory is filled with the code bytes generated by the statements given. This is very useful for rapidly filling memory with single or repeated instruction sequences.

Example 1

To patch 16 NOP instructions starting at address 5000:

Command input:

asm 5000 len 16t = "nop"

Example 2

To fill a region of memory starting at physical address 4000 with 20 repetitions of a repeating sequence of instructions:

Command input:

asm 4000 len 20t = "add bx,ax", "add cx,ax"

Interactive Assembly

The second form of in-line assembly provides an interactive interface. The first line gives the asm command, the starting address, and the equals sign. Each successive line gives a single instruction. To end assembly, the special command ENDASM can be used. Alternatively, if the form is being typed interactively by the user, a blank line can be used to terminate assembly. When used in a macro, debug procedure, or include file, the ENDASM command is required.

Note: Interactive assembly is not available within procedures.

Unlike the batch assembly mode, the interactive mode performs memory updates as the statements are entered. The user can follow the progress by noting that the address prompt will advance to the next address. If an error is encountered during interactive assembly, a message is output, the address doesn't advance, and the user is given another chance to enter the statement.

If a range of memory is given as the addr-spec using either the addr to addr or addr length expr form, then that range of memory is filled with the code bytes generated by the statements given. This is useful for rapidly filling memory with single or repeated instruction sequences.

Example

To patch code starting at address 4000:

Command input:

asm 4000 =

@00004000>mov bx,ax
@00004004>mov bx,ax
@00004008>endasm

Assembler Directives

A number of assembly directives are supported. Most of the directives are meant for interactive use, but all are available in batch.

Address Mode Directive { use16 | use32 }

Where:

use16

temporarily overrides the code size indicated by the current processor state. ย This allows you to input 16-bit code while the processor is in 32-bit mode.*

use32

temporarily overrides the code size indicated by the current processor state. ย This allows you to input 32-bit code while the processor is in 16-bit mode.*

* The command language use control variable may have already overridden the current processor setting. ย If so, then the assembler use16 and use32 directives temporarily override the mode set via the command language override and not the current processor default.

Address Directive

org addr-expr

Where:

addr-expr

is the numeric and/or symbolic expression that evaluates to an address.

Data Directive

data-op data-value

ย 

Where:

data-value { data | count dup ( [ data, ] data ) }

data { integer | float | string }

data-op is one the following:

db or byte

Defines unsigned bytes of data (8-bit)
Defines unsigned numbers from 0 to 255
Also used for strings

sbyte

Defines signed bytes of data (8-bit)
Defines signed numbers from -128 to +127

dw or word

Defines unsigned words of data (16-bit)
Defines unsigned numbers from 0 to 65, 535 (64K)

sword

Defines signed words of data (16-bit)
Defines signed numbers from -32,768 to +32,767

dd or dword

Defines doublewords of data (32-bit)
Defines unsigned numbers from 0 to 4,294,967,295 (4M)

sdword

Define signed doublewords of data (32-bit)
Defines signed numbers from -2,147,483,648 to +2,147,483,647

df or dfword

Defines farword data (48-bit)
Defines pointer variables.

dq or dqword

Defines quadwords of data (64-bit)
Defines 8-byte integers used with floating-point instructions

dt or tbyte

Defines ten-byte data (80-bits)
Defines 10-byte integers used with floating-point instructions

ddq or dqword

Defines 16-byte data (128-bit)

real4

Defines short real data (32-bits)
1.18 x 10-38 to 3.40 x 1038

real8

Defines long real data (64-bits)
2.23 x 10-308 to 1.79 x 10308

real10

Defines ten-byte real data (80-bits)
3.37 x 10-4932 to 1.18 x 104932

real16

Defines 16-byte real data (128-bit)

Assembler Directives

Example 1

To enter a string as data at linear address 1000:

Command input:

asm 1000L =
P0@00001000L>byte "This is a test string."
P0@00001016L>

Example 2

To clear 10 bytes to zero starting at linear address 5432:

asm 5432L =
P0@00005432L>db 10 dup ( 0 )
P0@0000543CL>

Example 3

To enter a few floating pointer numbers starting at physical address 4000:

asm 4000p=

P0@00004000P>real4 12.34
P0@00004004P>real8 5.234
P0@0000400CP>real16 543.34
P0@0000401CP>

Example 4

To enter data at one location (linear 1000) and then place instructions to use the data at another location (linear 2000):

asm 1000l=
P0@00001000L>dw 1
P0@00001002L>org 2000l
P0@00002000L>mov eax, word ptr [1000]
P0@00002004L>

Related Topics

ย 

ย