(Updated February 18, 2025)
Table of Contents
What is an IDE?
An Integrated Development Environment, or IDE, is typically a graphical user interface with an editor, compiler, debugger, and much more at your fingertips.
One possible IDE combination is
Visual Studio Code with x86 and x86 Assembly by 13xforever
Another is to try out myCompiler.io.
Still, another way is to have a Linux desktop system like Ubuntu where you can load NASM and use Gedit or another GUI editor.
Hello World
Now that we’ve defined some IDEs and capabilities let’s examine some examples of x86_64 assembly language development.
The idea behind assembly language is to provide the programmer with instructions (opcodes) and various addressing models to move data and perform various operations. However, as mentioned earlier, it is primitive.
Assembly language source lines are generally made up of the following:
label: instruction operand(s) ; comment
You may also see them as
label: instruction operand(s) ; comment
Consider this simple assembly language program that prints the obligatory "Hello, World!"
. By selecting the Load Workspace
button, another window will launch, and the project code will be loaded.
section .data
hello: db "Hello, World!",0xa
len: equ $ - hello
section .text
global _start
_start:
mov rax, 1 ; write syscall
mov rdi, 1 ; stdout
mov rsi, hello ; text
mov rdx, len ; length
syscall
exit:
mov rax, 60 ; exit
mov rdi, 0 ; return code
syscall
Once the example code is loaded into the IDE, you select the Assemble
button to turn the source code into a program in the simulated memory. Selecting the Run
button will cause the program to be executed in the simulated computer.
All of this happens within your browser. Later chapters will discuss the other buttons in the IDE. Now, we’re ready to dive deep into the 6502!
Let’s quickly discuss what’s happening in this code. The table below helps to break down the details of the program’s text. Thankfully, it is also colorized, so identifying certain pieces is more effortless.
Name | Example | Purpose |
---|---|---|
Labels | print: , done: , words: |
A named location in the program. These are used instead of explicit addresses to represent positions in the code or data. This allows the programmer to not worry too much about memory locations. Note that labels alone on a line need a colon. |
Instructions | ldx , jsr , inx , brk |
Assembly language instructions. These are the named actions the CPU is to perform with any provided operands. |
Operands | words, x and CHROUT |
Provides the instruction with the information to work with, where appropriate. (Not all instructions have operands, while some have 1 or 2.) |
Directives | define , txt , dcb |
Help to inform the assembler about some of the labels, data types, and external entities. |
A Bigger Example
The example provided below demonstrates the majority of the features we will use.
define bmaplo $10
define bmaphi $11
define scolor $13
define temp $14
lda #$00 ; set bitmap address to $0200
sta bmaplo
sta scolor ; starting color (black)
lda #$02
sta bmaphi
ldx #$06 ; max value for bmaphi
ldy #$00 ; index - this value is added to the pointer
lda #$00 ; colour code to be used to fill the display
loop: sta (bmaplo),y ; store color at bmaplo + y
clc
adc #$01 ; add one to the color
sta temp ; safely store
tya ; test y
and #31 ; cheap mod 32
cmp #31 ; 32 blocks filled?
bne no ; nope
inc scolor ; yup, increment start color
lda scolor ; get new color
sta temp ; ready for next row
no:
lda temp ; restore or new
iny ; increment index
bne loop ; branch until page done - stops when Y==0
inc bmaphi ; increment high byte of pointer
cpx bmaphi ; compare with max value
bne loop ; continue if not done
brk ; done - return to debugger