-
-
Save mediocregopher/3971589 to your computer and use it in GitHub Desktop.
Fuck yea assembly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.global _c_int00 ;This assembler directive allows _c_int00 to be a | |
;global variable. This tells the linker where your | |
;program (.text code) begins and where to boot from. | |
;***************************** Program Constants **************************************** | |
; Creating constants using the .set assembler directive. This should be at the top of your | |
; program. This is like a define statement in C. | |
data_sect .set 0xa000 ;constant that is actually the starting addr of .data section | |
bss_sect .set 0xb000 ;constant that is actually the starting addr of .bss section | |
gpamux .set 0x6f86 | |
gpadir .set 0x6f8a | |
gpadat .set 0x6fc0 | |
gpbmux .set 0x6F96 | |
gpcmux .set 0x6FA6 | |
lospcp .set 0x701B | |
pclkcr0 .set 0x701C | |
pclkcr3 .set 0x7020 | |
sciccr .set 0x7750 | |
scictl1 .set 0x7751 | |
scictl2 .set 0x7754 | |
scihbaud .set 0x7752 | |
scilbaud .set 0x7753 | |
scitxbuf .set 0x7759 | |
scirxbuf .set 0x7757 | |
;**************************************************************************************** | |
;******************* DATA ALLOCATION SECTION - Variables/Data *************************** | |
; Data can go before or after your program code but should not be placed in the middle | |
; nof a program for clarity reasons. | |
.data ;data section, see the command linker file, this puts the | |
;following data defined below in a block of internal SRAM | |
;starting at 0xA000 | |
;**************************************************************************************** | |
.text ;Program section, see the command linker file, program code | |
;should be placed in the text section which starts at 0x9000 | |
_c_int00: ;This label tells the linker where the entry (starting) point for | |
;the first instruction in your program. | |
EALLOW | |
PUSH DP | |
SETC OBJMODE ;allow 32 bit mov instructions | |
MOVZ DP,#0x7029>>6 ;turn off that pesky watchdog timer | |
MOV @7029h,#0x68 | |
POP DP | |
MOV AR0,#lospcp ;Set Low Speed Peripheral Clock to SYSCLOCK/2 | |
MOV *AR0,#1 | |
MOV AR0,#pclkcr0 ;Enable SCIB clock | |
MOV AH,*AR0 | |
OR AH,#0x800 | |
MOV *AR0,AH | |
MOV AR0,#gpamux+2 ;Enable SCITXDB and SCIRXDB | |
MOV *AR0,#0xF000 | |
MOV AR0,#sciccr | |
MOV *AR0,#0x7 ;8-bit, idle-line mode, no loop back, no parity, and one stop bit | |
MOV AR0,#scilbaud ;Set baud rate to 9600 (maybe?) | |
MOV *AR0,#0x32 | |
MOV AR0,#scictl1 ;Enabled TXD and RXD and enable SCI | |
MOV *AR0,#0x23 | |
MOV AL,#0x7F | |
LOOPOUT | |
MOV AH,#0x21 | |
LOOP | |
LC WRITEUSB | |
INC AH | |
CMP AH,AL | |
B LOOPOUT,EQ | |
B LOOP,UNC | |
WRITEUSB | |
PUSH AR0 | |
PUSH AR1 | |
PUSH AL | |
PUSH AH | |
MOV AR1,#scitxbuf | |
MOV AR0,#scictl2 | |
WRITETRY | |
MOV AH,*AR0 | |
MOV AL,#0x80 | |
AND AH,AL | |
CMP AH,AL | |
B WRITETRY,NEQ | |
POP AH | |
MOV *AR1,AH | |
POP AL | |
POP AR1 | |
POP AR0 | |
LRET |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment