{{htmlmetatags>metatag-robots=()
metatag-title=(ASM | ugBASIC User Manual)
metatag-keywords=(ugBASIC,Commodore 64,Commodore PLUS/4,ZX Spectrum)
metatag-description=(Manual page for ASM)
metatag-media-og:image=(:ugbasic:logo-ugbasic-fb.png)
metatag-og:title=(ASM | ugBASIC User Manual)
metatag-og:description=(Manual page for ASM)
}}
====== ugBASIC User Manual ======
===== ASM =====
===== SYNTAX =====
ASM line
BEGIN ASM
...
END ASM
==== PURPOSE ====
The ''ASM'' command is a bridge between ugBASIC and the assembly language.
It allows you to directly insert instructions in machine language or
assembly language into the source code.
In some sections of the code, especially those that require maximum
performance or very precise control over the hardware, writing directly
in assembly can bring significant speed improvements. Assembly allows you
to interact directly with the registers and instructions of the CPU,
offering granular control over the hardware.
When dealing with code that must run on different architectures,
assembly can be used to write portions of code that are highly
optimized for a specific platform. In some cases, you may need to
interface with code written in assembly or with pre-existing libraries.
The first syntax allow to introduce a single machine code
for each line, while the second one allows to introduce multiple
lines, at once.
Note that assembly code is tightly coupled to the processor
architecture. A block of assembly code written for a Zilog Z80
will not run on an MOS 6502. Moreover, it is less readable than
ugBASIC language, making it more difficult to maintain. Finally,
a single error in assembly can cause the program to crash,
and indiscriminate use of assembly can interact with compiler
optimizations.
Inline assembly should be used sparingly and only when
absolutely necessary. It is best used for small sections of
performance-critical code, for direct access to processor-specific
registers or instructions and to Interface with legacy code or
specific hardware.
==== EXAMPLE ====
BEGIN ASM
LDA #02
STA $D020
END ASM ON CPU6502
==== ABBREVIATION ====
Asm
==== AVAILABLE ON ====
==== ANY PROBLEM? ====
If you have encountered a problem using this command, if you think there is a bug or the explanation is unclear, please [[https://github.com/spotlessmind1975/ugbasic/issues/new?title=ISSUE ON ASM|open an issue]] for this keyword on GitHub. Thank you!===== POWERED BY =====
[[:ugbasic:user:index|{{ :ugbasic:user:logo-ugbasic.png?nolink&600 |}}]]