URL
https://opencores.org/ocsvn/blue/blue/trunk
Subversion Repositories blue
[/] [blue/] [trunk/] [blue8/] [bluemon.asm] - Rev 2
Compare with Previous | Blame | View Log
/* Monitor V0.4 *//* Note: because of the monitors relocationYou can't use the # form of immediate addressing nowsupported by the assembler */#define CODEOFFSET 0xED0#define FIRSTCODE 0xED1#include "blue.inc"ORG 0start: jmp reloadDEFSTACK;; Need to eventually copy all code to top of memorycall print_msgcr+CODEOFFSETds "Blue Monitor 0.4\xFF"prompt: call print_msg+CODEOFFSETds "\r\r\nBLUE> \xFF"prompt0:call waitcharecho+CODEOFFSETJMPIF(lf+CODEOFFSET,prompt0+CODEOFFSET)JMPIF(space+CODEOFFSET,prompt0+CODEOFFSET)ior makelower+CODEOFFSETJMPIF(cmdl+CODEOFFSET,load+CODEOFFSET)JMPIF(cmdd+CODEOFFSET,dump+CODEOFFSET)JMPIF(cmdg+CODEOFFSET,go+CODEOFFSET)JMPIF(cmdi+CODEOFFSET,intel+CODEOFFSET);; unknown commandcall print_msgcr+CODEOFFSETds "?\xFF"jmp prompt+CODEOFFSET;; load command (ESC ends)load: call hexin4+CODEOFFSET ; set X=addressldxaload1:call hexin4+CODEOFFSET ; get next wordlda numin+CODEOFFSET ; get numberstax ; put it awayincx ; next wordlda hexsep+CODEOFFSET ; if escape goto promptJMPIF(escape+CODEOFFSET,prompt+CODEOFFSET)jmp load1+CODEOFFSET ; keep going;; dump commanddump:call hexin4+CODEOFFSET ; get addressldxa;; would like to spin excess 8 wordsdump1:stx ; see if are on xx0 or xx8and bits3+CODEOFFSETszjmp dump2+CODEOFFSET;; do we want out? -- only test at end of lineslda uart+1sposjmp prompt+CODEOFFSET;; new linecall hexaddr+CODEOFFSETdump2:ldax ; get wordcall hexout4+CODEOFFSET ; print itldi ' ' ; spacecall printchar+CODEOFFSETincx ; next wordjmp dump1+CODEOFFSET ; keep going;; show XXXX: (address)hexaddr:call crlf+CODEOFFSETstxcall hexout4+CODEOFFSETldi ':'call printchar+CODEOFFSETldi ' 'jmp printchar+CODEOFFSET;; go command;; escape cancelsgo: call hexin4+CODEOFFSETlda hexsep+CODEOFFSET ; see if we cancelledcmp escape+CODEOFFSETsnzjmp prompt+CODEOFFSETlda numin+CODEOFFSET ; nope. get number and jumpjmpaintel: call waitcharecho+CODEOFFSETcmp escape+CODEOFFSETsnzjmp prompt+CODEOFFSETcmp colon+CODEOFFSETszjmp intel+CODEOFFSETldi 2call hexinct+CODEOFFSET;; count of bytesrar ; divide by 2and hexnib+CODEOFFSET ; max of 16sta icount+CODEOFFSETldi 4call hexinct+CODEOFFSETrar ; divide by 2pushpopxldi 2call hexinct+CODEOFFSETadd hexzero+CODEOFFSETszjmp inteldone+CODEOFFSETintelloop:ldi 4call hexinct+CODEOFFSETstaxincxlda icount+CODEOFFSETdecasta icount+CODEOFFSETszjmp intelloop+CODEOFFSETjmp intel+CODEOFFSET ; ignore checksum crlfinteldone:call waitcharecho+CODEOFFSETcmp lf+CODEOFFSETszjmp inteldone+CODEOFFSETjmp prompt+CODEOFFSET;; commandscmdl: dw 'l'cmdd: dw 'd'cmdg: dw 'g'cmdi: dw 'i'colon: dw ':';; cancel keyescape: dw 0x1b;; bit to OR to make upper case lower casemakelower: dw 0x20;; constantszero: dw '0'hexzero: dw 0nine: dw '9'hexa: dw 'a'hexmask: dw 0xFFF0// The below doesn't work because lf isn't defined in pass1//ten: equ lf#define ten lfhexnib: dw 0xFbits3: dw 0x7;; number in winds up here (and in ACC)numin: dw 0hextmp: dw 0hextmp2: dw 0hexsep: dw 0 ; hexin separatorbs: dw 8hexct: dw 4mask3: dw 0xFFFicount: dw 0space: dw ' ';; read 4 hex characters, result in acc and numin;; also set hexsep to the "ending character" (e.g., space, CR, etc.)hexin4: ldi 0xFFFFhexinct:sta hexct+CODEOFFSETldi 0 ; clear accsta numin+CODEOFFSET ; store acchexinl:call waitcharecho+CODEOFFSET ; get characterJMPIF(space+CODEOFFSET,hexinl+CODEOFFSET)SKIPhexinl2: call waitcharecho+CODEOFFSET ; character after firstcmp bs+CODEOFFSETsnzjmp hexbs+CODEOFFSETcmp zero+CODEOFFSET ; if <'0' then donesnzjmp hexin09+CODEOFFSETscjmp hexin4done+CODEOFFSETcmp nine+CODEOFFSET ; if <='9' then numberscjmp hexin09+CODEOFFSETsnzjmp hexin09+CODEOFFSET;; TODO: need to test that not above 'F';; if here we have a non number (A-F)ior makelower+CODEOFFSET ; make lower casesub hexa+CODEOFFSETscjmp hexin4done+CODEOFFSETadd ten+CODEOFFSETSKIPhexin09:sub zero+CODEOFFSETsta hextmp+CODEOFFSETlda numin+CODEOFFSET ; shift number overralralralraland hexmask+CODEOFFSETior hextmp+CODEOFFSET ; put in our current numbersta numin+CODEOFFSET ; store acclda hexct+CODEOFFSETdecasta hexct+CODEOFFSETszjmp hexinl2+CODEOFFSEThexin4done:sta hexsep+CODEOFFSET ; remember why we quitlda numin+CODEOFFSET ; load the number and returnrethexbs: lda numin+CODEOFFSETrarrarrarrarand mask3+CODEOFFSETsta numin+CODEOFFSET;; assume hextct will equal FFFF if backspaces occurjmp hexinl2+CODEOFFSET;; print out 4 hex digitshexout4: sta hextmp+CODEOFFSETswapcall hexout2+CODEOFFSETlda hextmp+CODEOFFSEThexout2: sta hextmp2+CODEOFFSETrarrarrarrarcall hexout1+CODEOFFSETlda hextmp2+CODEOFFSEThexout1: and hexnib+CODEOFFSETcmp ten+CODEOFFSETsncjmp hexouta+CODEOFFSETadd zero+CODEOFFSETjmp printchar+CODEOFFSEThexouta: sub ten+CODEOFFSETadd hexa+CODEOFFSETjmp printchar+CODEOFFSET ; hidden return#include "syslib.inc"reload: ldx 0reloadx:ldax 0stax CODEOFFSETincxstxsub limitszjmp reloadxjmp FIRSTCODElimit: dw reloadEND
