; Define memory locations for user input buffer and opcode output
INPUT_BUFFER .WORD x2000 ; Memory location to store user input
OPCODE_OUTPUT .WORD x2004 ; Memory location to store opcode output
I tried = . and =. they didn't work unfortunately
; Define memory locations for user input buffer and opcode output
INPUT_BUFFER .WORD x2000 ; Memory location to store user input
OPCODE_OUTPUT .WORD x2004 ; Memory location to store opcode output
I tried = . and =. they didn't work unfortunately
Copyright © 2021 Jogjafile Inc.
You're looking for
.FILL ...to provide a value for an initialized data word as.word ...would work in other assembly languages.Use
.BLKW ...to provide a count of a number of zero initialized data words.There is no
equorequateor#defineor=to declare numeric constants as far as I know.But
.worddoesn't declare a constant either, it declares an initialized data word, which is exactly what.filldoes. (There is a difference in that that.word ...usually accepts multiple comma separated values, whereas LC-3's.fill ...requires one argument per line.)You can use these labels with LC-3's indirect loads and stores,
LDIandSTI. For example,will use the data memory location at
INPUT_BUFFERto get the address of where to go to get the value to put intoR0. So, the instruction itself refers toINPUT_BUFFER, andINPUT_BUFFERstores x2000, which is the effective address used to fetch from memory forR0.You can also load the pointer value directly:
And further, you can increment/modify the memory location at
INPUT_BUFFER, soThat will change the memory location at
INPUT_BUFFERto x2001 (assuming it was x2000 to start with), so for example, a nextLDIorSTIto that memory location will ultimately address memory location x2001.Personally for small algorithms I would prefer to load pointers into registers and use them there including incrementing in registers in loops for example. LC-3, with 8 usable registers, is register rich compared to MARIE, HACK, LMC and some others.