Re: Anvil-6502 : A Modern Multimedia Computer using a Real 6
Posted: Thu Jun 22, 2017 11:11 pm
Oneironaut wrote:
What I meant by Pseudo-Ops are fake instructions that some assemblers allow as legal instructions.
Like Garth, I tend to use a lot of macros, especially in code that sets up stack frames, in which a simple mistake can send the machine into the swamp. For example, I've been working on a display driver package that allows a program to do all sorts of stuff on the console screen, from changing attributes in a character string using embedded macros to drawing shapes such as graphic lines and rectangles. The underlying code tends to be complicated and the setup required to call some functions can be easily botched with a typo. Here's an example of where a macro saves the day, so to speak, in drawing a rectangle. The subroutine call requires a stack frame containing five parameters, which have to be in a certain order:
Code: Select all
; ————————————————————————————————————————————————————————————————————————
; termrect: Draw Rectangle (macro)
;
; termrect width,height,col,row,attr
;
; col,row set the coordinates for the rectangle's top left corner.
; Attributes (attr) are defined as follows:
;
; 00000000xxxx0xxx
; ||||||||||||||||
; |||||||||||||+++———> color
; ||||||||||||+——————> reserved
; |||||||||||+———————> 1: underline
; ||||||||||+————————> 1: blink
; |||||||||+—————————> 0: normal
; ||||||||| 1: reverse
; ||||||||+——————————> 0: foreground
; |||||||| 1: background
; ++++++++———————————> reserved
;
; Color bits are ignored in current version of the terminal manager.
; The reserved bit should be set to 0.
; ————————————————————————————————————————————————————————————————————————
;
termrect .macro .w,.h,.c,.r,.a
pea .a
pea .r
pea .c
pea .h
pea .w
jsr termrect
.endm