📄 复件 ram_inst.psm
字号:
;NAMEREG sX, <name> ; Rename register sX with <name>
CONSTANT VGA_ADDR_R, 10 ; Define constant <name>, assign value
CONSTANT VGA_ADDR_G, 11 ;
CONSTANT VGA_ADDR_B, 12 ;
CONSTANT PUSHBUTTON_ADDR,20;
CONSTANT SEGLED_ADDR_LED,00;
CONSTANT SEGLED_ADDR_SEGUP,01;
CONSTANT SEGLED_ADDR_SEGLOW,02;
CONSTANT SEGLED_ADDR_SEGDOT,03;
; ROM output file is always called
; <filename>.vhd
ADDRESS 000 ; Programs always start at reset vector 0
ENABLE INTERRUPT ; If using interrupts, be sure to enable
; the INTERRUPT input
BEGIN:
; <<< your code here >>>
LOAD S0, FF;
LOAD S1, FF;
LOAD S2, FF;
LOAD S3, FF;
OUTPUT S0,SEGLED_ADDR_LED;
OUTPUT S1,SEGLED_ADDR_SEGUP;
OUTPUT S2,SEGLED_ADDR_SEGLOW;
OUTPUT S3,SEGLED_ADDR_SEGDOT;
loop:
JUMP loop;
JUMP BEGIN ; Embedded applications never end
ISR: ; An Interrupt Service Routine (ISR) is
; required if using interrupts
; Interrupts are automatically disabled
; when an interrupt is recognized
; Never re-enable interrupts during the ISR
INPUT S0, PUSHBUTTON_ADDR ; Read the ISR register from Push Button module
LOAD S1, S0 ;
AND S1,07 ; mask out the 3 bit of LSB ( B,G,R )
R:
RR S1 ; The LSB is in the carry => R field
JUMP NC, G ;
INPUT S2, VGA_ADDR_R;
ADD S2 , 01 ;
OUTPUT S2,VGA_ADDR_R;
G:
RR S1 ; The Less LSB is in the carry => G field
JUMP NC, B ;
INPUT S2, VGA_ADDR_G;
ADD S2 , 01 ;
OUTPUT S2,VGA_ADDR_G;
B:
RR S1 ; The 3rd LSB is in the carry => B field
JUMP NC, INTEND ;
INPUT S2, VGA_ADDR_B;
ADD S2 , 01 ;
OUTPUT S2,VGA_ADDR_B;
INTEND:
LOAD S3, 00
OUTPUT S3, PUSHBUTTON_ADDR;
RETURNI ENABLE ; Return from interrupt service routine
; Use RETURNI DISABLE to leave interrupts
; disabled
ADDRESS 3FF ; Interrupt vector is located at highest
; instruction address
JUMP ISR ; Jump to interrupt service routine, ISR
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -