Use literal loads in calculator.asm

This commit is contained in:
Juhani Krekelä 2022-08-27 19:34:57 +03:00
parent 677f31ea91
commit 2b2cdac605
1 changed files with 93 additions and 177 deletions

View File

@ -46,35 +46,35 @@ debug:
debugRegs: debugRegs:
load r0, debugr0 load r0, debugr0
cleq r0, r0, writehexByte cleq r0, r0, writehexByte
load r0, litcharSpace load r0, #20
store ffff, r0 store ffff, r0
load r0, debugr1 load r0, debugr1
cleq r0, r0, writehexByte cleq r0, r0, writehexByte
load r0, litcharSpace load r0, #20
store ffff, r0 store ffff, r0
load r0, debugr2 load r0, debugr2
cleq r0, r0, writehexByte cleq r0, r0, writehexByte
load r0, litcharSpace load r0, #20
store ffff, r0 store ffff, r0
load r0, debugr3 load r0, debugr3
cleq r0, r0, writehexByte cleq r0, r0, writehexByte
load r0, litcharSpace load r0, #20
store ffff, r0 store ffff, r0
debugTmpWords: debugTmpWords:
load r0, tmpWordHigh load r0, tmpWordHigh
load r1, tmpWordLow load r1, tmpWordLow
cleq r0, r0, writeHexWord cleq r0, r0, writeHexWord
load r0, litcharSpace load r0, #20
store ffff, r0 store ffff, r0
load r0, tmpWord2High load r0, tmpWord2High
load r1, tmpWord2Low load r1, tmpWord2Low
cleq r0, r0, writeHexWord cleq r0, r0, writeHexWord
load r0, litcharPipe load r0, #7c
store ffff, r0 store ffff, r0
load r0, SPStart+0 load r0, SPStart+0
@ -118,7 +118,7 @@ debug:
store debugPtr+0, r0 store debugPtr+0, r0
store debugPtr+1, r1 store debugPtr+1, r1
load r0, litcharSpace load r0, #20
store ffff, r0 store ffff, r0
breq r0, r0, debugLoop breq r0, r0, debugLoop
@ -151,11 +151,11 @@ readline:
; Is it enter? ; Is it enter?
cleq r0, r0, peekWord cleq r0, r0, peekWord
load r0, litcharCR load r0, #0d
breq r0, r1, readlineEnter breq r0, r1, readlineEnter
; Is it backspace? ; Is it backspace?
load r0, litcharBS load r0, #08
breq r0, r1, readlineBackspace breq r0, r1, readlineBackspace
; Is the buffer full? ; Is the buffer full?
@ -207,9 +207,9 @@ readline:
; Decrease the index and erase the echoed character ; Decrease the index and erase the echoed character
; TODO: utf-8 ; TODO: utf-8
cleq r0, r0, stDec cleq r0, r0, stDec
load r3, litcharSpace load r3, #20
store ffff, r3 store ffff, r3
load r3, litcharBS load r3, #08
store ffff, r3 store ffff, r3
breq r0, r0, readlineLoop breq r0, r0, readlineLoop
@ -218,11 +218,11 @@ readline:
; Drop the input byte and erase the echoed character ; Drop the input byte and erase the echoed character
; TODO: utf-8 ; TODO: utf-8
cleq r0, r0, popWord cleq r0, r0, popWord
load r3, litcharBS load r3, #08
store ffff, r3 store ffff, r3
load r3, litcharSpace load r3, #20
store ffff, r3 store ffff, r3
load r3, litcharBS load r3, #08
store ffff, r3 store ffff, r3
breq r0, r0, readlineLoop breq r0, r0, readlineLoop
@ -453,7 +453,7 @@ peekWord:
load r0, SP+0 load r0, SP+0
load r1, SP+1 load r1, SP+1
xor r2, r2 xor r2, r2
load r3, lit02 load r3, #02
cleq r0, r0, addWord cleq r0, r0, addWord
store SP+0, r0 store SP+0, r0
store SP+1, r1 store SP+1, r1
@ -609,7 +609,7 @@ subWord:
xor r0, r0 xor r0, r0
or r0, r3 or r0, r3
nand r0, r0 nand r0, r0
load r2, lit01 load r2, #01
cleq r0, r0, addByte3 cleq r0, r0, addByte3
store subWordResultLow, r0 store subWordResultLow, r0
@ -639,7 +639,7 @@ incWord:
store incWordHigh, r0 store incWordHigh, r0
; Add 1 to low byte ; Add 1 to low byte
load r0, lit01 load r0, #01
cleq r0, r0, addByte cleq r0, r0, addByte
store incWordLow, r0 store incWordLow, r0
@ -662,12 +662,12 @@ decWord:
store decWordHigh, r0 store decWordHigh, r0
; Add ff to low byte ; Add ff to low byte
load r0, litff load r0, #ff
cleq r0, r0, addByte cleq r0, r0, addByte
store decWordLow, r0 store decWordLow, r0
; Add ff and carry to high byte ; Add ff and carry to high byte
load r0, litff load r0, #ff
load r2, decWordHigh load r2, decWordHigh
cleq r0, r0, addByte3 cleq r0, r0, addByte3
@ -762,86 +762,86 @@ addByte:
nybble2hex: nybble2hex:
xor r3, r3 xor r3, r3
breq r0, r3, nybble2hex0 breq r0, r3, nybble2hex0
load r3, lit01 load r3, #01
breq r0, r3, nybble2hex1 breq r0, r3, nybble2hex1
load r3, lit02 load r3, #02
breq r0, r3, nybble2hex2 breq r0, r3, nybble2hex2
load r3, lit03 load r3, #03
breq r0, r3, nybble2hex3 breq r0, r3, nybble2hex3
load r3, lit04 load r3, #04
breq r0, r3, nybble2hex4 breq r0, r3, nybble2hex4
load r3, lit05 load r3, #05
breq r0, r3, nybble2hex5 breq r0, r3, nybble2hex5
load r3, lit06 load r3, #06
breq r0, r3, nybble2hex6 breq r0, r3, nybble2hex6
load r3, lit07 load r3, #07
breq r0, r3, nybble2hex7 breq r0, r3, nybble2hex7
load r3, lit08 load r3, #08
breq r0, r3, nybble2hex8 breq r0, r3, nybble2hex8
load r3, lit09 load r3, #09
breq r0, r3, nybble2hex9 breq r0, r3, nybble2hex9
load r3, lit0a load r3, #0a
breq r0, r3, nybble2hexa breq r0, r3, nybble2hexa
load r3, lit0b load r3, #0b
breq r0, r3, nybble2hexb breq r0, r3, nybble2hexb
load r3, lit0c load r3, #0c
breq r0, r3, nybble2hexc breq r0, r3, nybble2hexc
load r3, lit0d load r3, #0d
breq r0, r3, nybble2hexd breq r0, r3, nybble2hexd
load r3, lit0e load r3, #0e
breq r0, r3, nybble2hexe breq r0, r3, nybble2hexe
load r3, lit0f load r3, #0f
breq r0, r3, nybble2hexf breq r0, r3, nybble2hexf
breq r0, r0, error breq r0, r0, error
nybble2hex0: nybble2hex0:
load r0, litchar0 load r0, #30
ret ret
nybble2hex1: nybble2hex1:
load r0, litchar1 load r0, #31
ret ret
nybble2hex2: nybble2hex2:
load r0, litchar2 load r0, #32
ret ret
nybble2hex3: nybble2hex3:
load r0, litchar3 load r0, #33
ret ret
nybble2hex4: nybble2hex4:
load r0, litchar4 load r0, #34
ret ret
nybble2hex5: nybble2hex5:
load r0, litchar5 load r0, #35
ret ret
nybble2hex6: nybble2hex6:
load r0, litchar6 load r0, #36
ret ret
nybble2hex7: nybble2hex7:
load r0, litchar7 load r0, #37
ret ret
nybble2hex8: nybble2hex8:
load r0, litchar8 load r0, #38
ret ret
nybble2hex9: nybble2hex9:
load r0, litchar9 load r0, #39
ret ret
nybble2hexa: nybble2hexa:
load r0, litchara load r0, #61
ret ret
nybble2hexb: nybble2hexb:
load r0, litcharb load r0, #62
ret ret
nybble2hexc: nybble2hexc:
load r0, litcharc load r0, #63
ret ret
nybble2hexd: nybble2hexd:
load r0, litchard load r0, #64
ret ret
nybble2hexe: nybble2hexe:
load r0, litchare load r0, #65
ret ret
nybble2hexf: nybble2hexf:
load r0, litcharf load r0, #66
ret ret
; in: ; in:
@ -851,49 +851,49 @@ nybble2hex:
; clobbers: ; clobbers:
; r3 ; r3
hex2nybble: hex2nybble:
load r3, litchar0 load r3, #30
breq r0, r3, hex2nybble0 breq r0, r3, hex2nybble0
load r3, litchar1 load r3, #31
breq r0, r3, hex2nybble1 breq r0, r3, hex2nybble1
load r3, litchar2 load r3, #32
breq r0, r3, hex2nybble2 breq r0, r3, hex2nybble2
load r3, litchar3 load r3, #33
breq r0, r3, hex2nybble3 breq r0, r3, hex2nybble3
load r3, litchar4 load r3, #34
breq r0, r3, hex2nybble4 breq r0, r3, hex2nybble4
load r3, litchar5 load r3, #35
breq r0, r3, hex2nybble5 breq r0, r3, hex2nybble5
load r3, litchar6 load r3, #36
breq r0, r3, hex2nybble6 breq r0, r3, hex2nybble6
load r3, litchar7 load r3, #37
breq r0, r3, hex2nybble7 breq r0, r3, hex2nybble7
load r3, litchar8 load r3, #38
breq r0, r3, hex2nybble8 breq r0, r3, hex2nybble8
load r3, litchar9 load r3, #39
breq r0, r3, hex2nybble9 breq r0, r3, hex2nybble9
load r3, litchara load r3, #61
breq r0, r3, hex2nybblea breq r0, r3, hex2nybblea
load r3, litcharb load r3, #62
breq r0, r3, hex2nybbleb breq r0, r3, hex2nybbleb
load r3, litcharc load r3, #63
breq r0, r3, hex2nybblec breq r0, r3, hex2nybblec
load r3, litchard load r3, #64
breq r0, r3, hex2nybbled breq r0, r3, hex2nybbled
load r3, litchare load r3, #65
breq r0, r3, hex2nybblee breq r0, r3, hex2nybblee
load r3, litcharf load r3, #66
breq r0, r3, hex2nybblef breq r0, r3, hex2nybblef
load r3, litcharUppera load r3, #41
breq r0, r3, hex2nybblea breq r0, r3, hex2nybblea
load r3, litcharUpperb load r3, #42
breq r0, r3, hex2nybbleb breq r0, r3, hex2nybbleb
load r3, litcharUpperC load r3, #43
breq r0, r3, hex2nybblec breq r0, r3, hex2nybblec
load r3, litcharUpperD load r3, #44
breq r0, r3, hex2nybbled breq r0, r3, hex2nybbled
load r3, litcharUpperE load r3, #45
breq r0, r3, hex2nybblee breq r0, r3, hex2nybblee
load r3, litcharUpperF load r3, #46
breq r0, r3, hex2nybblef breq r0, r3, hex2nybblef
breq r0, r0, error breq r0, r0, error
@ -902,49 +902,49 @@ hex2nybble:
xor r0, r0 xor r0, r0
ret ret
hex2nybble1: hex2nybble1:
load r0, lit01 load r0, #01
ret ret
hex2nybble2: hex2nybble2:
load r0, lit02 load r0, #02
ret ret
hex2nybble3: hex2nybble3:
load r0, lit03 load r0, #03
ret ret
hex2nybble4: hex2nybble4:
load r0, lit04 load r0, #04
ret ret
hex2nybble5: hex2nybble5:
load r0, lit05 load r0, #05
ret ret
hex2nybble6: hex2nybble6:
load r0, lit06 load r0, #06
ret ret
hex2nybble7: hex2nybble7:
load r0, lit07 load r0, #07
ret ret
hex2nybble8: hex2nybble8:
load r0, lit08 load r0, #08
ret ret
hex2nybble9: hex2nybble9:
load r0, lit09 load r0, #09
ret ret
hex2nybblea: hex2nybblea:
load r0, lit0a load r0, #0a
ret ret
hex2nybbleb: hex2nybbleb:
load r0, lit0b load r0, #0b
ret ret
hex2nybblec: hex2nybblec:
load r0, lit0c load r0, #0c
ret ret
hex2nybbled: hex2nybbled:
load r0, lit0d load r0, #0d
ret ret
hex2nybblee: hex2nybblee:
load r0, lit0e load r0, #0e
ret ret
hex2nybblef: hex2nybblef:
load r0, lit0f load r0, #0f
ret ret
; ------------------------------------------------------------------ ; ------------------------------------------------------------------
@ -981,7 +981,7 @@ writehexByte:
store ffff, r0 store ffff, r0
; Low nybble ; Low nybble
load r0, lit0f load r0, #0f
and r0, r2 and r0, r2
cleq r0, r0, nybble2hex cleq r0, r0, nybble2hex
store ffff, r0 store ffff, r0
@ -995,109 +995,25 @@ writehexByte:
; clobbers: ; clobbers:
; r3 ; r3
newline: newline:
load r3, litcharCR load r3, #0d
store ffff, r3 store ffff, r3
load r3, litcharLF load r3, #0a
store ffff, r3 store ffff, r3
ret ret
; noreturn ; noreturn
error: error:
load r0, litchare load r0, #65
store ffff, r0 store ffff, r0
load r0, litcharr load r0, #72
store ffff, r0 store ffff, r0
store ffff, r0 store ffff, r0
load r1, litcharo load r1, #6f
store ffff, r1 store ffff, r1
store ffff, r0 store ffff, r0
cleq r0, r0, newline cleq r0, r0, newline
halt halt
; ==================================================================
; Literals pool
; ==================================================================
lit01: data 01
lit02: data 02
lit03: data 03
lit04: data 04
lit05: data 05
lit06: data 06
lit07: data 07
litcharBS:
lit08: data 08
lit09: data 09
litcharLF:
lit0a: data 0a
lit0b: data 0b
lit0c: data 0c
litcharCR:
lit0d: data 0d
lit0e: data 0e
lit0f: data 0f
litcharSpace:
lit20: data 20
litchar0:
lit30: data 30
litchar1:
lit31: data 31
litchar2:
lit32: data 32
litchar3:
lit33: data 33
litchar4:
lit34: data 34
litchar5:
lit35: data 35
litchar6:
lit36: data 36
litchar7:
lit37: data 37
litchar8:
lit38: data 38
litchar9:
lit39: data 39
litcharUppera:
lit41: data 41
litcharUpperb:
lit42: data 42
litcharUpperc:
lit43: data 43
litcharUpperd:
lit44: data 44
litcharUppere:
lit45: data 45
litcharUpperf:
lit46: data 46
litchara:
lit61: data 61
litcharb:
lit62: data 62
litcharc:
lit63: data 63
litchard:
lit64: data 64
litchare:
lit65: data 65
litcharf:
lit66: data 66
litcharo:
lit6f: data 6f
litcharr:
lit72: data 72
litcharPipe:
lit7c: data 7c
litff: data ff
; ================================================================== ; ==================================================================
; Data ; Data
; ================================================================== ; ==================================================================