ASCII Codes in LMC

462 views
Skip to first unread message

Sweety

unread,
Jan 24, 2012, 4:23:51 PM1/24/12
to Little Man Computer

How can I write a program to read a series of character inputs? I know
I have to use the ASCII codes for that but I tried and it didn't
accept it.
I tried:
STO '65' 365
to store A but it didn't work.
Please help me.

Sharmeen Ibrahim

unread,
Jan 24, 2012, 4:22:44 PM1/24/12
to l...@cs.kookmin.ac.kr

Daeyoung Heo

unread,
Jan 25, 2012, 10:31:49 PM1/25/12
to Little Man Computer, Sharmeen Ibrahim
If you want to write a string, you have to use branch instructions.
Our LMC support 5 registers and various addressing modes.

For example in Our LMC:

Input String: 'example'
7 characters

Program: Using register and addressing modes
LD X #0 ; Load 0 to X register.
LD C #7 ; Load 7 to C register.
LOOP: IN {device} ; keyboard input. a character's ASCII code
into A register.
ST A @65 ; Store A register's value to (65+X)
address in memory.
SUB C #1 ; C = C - 1
JP LOOP ; If last expression's results is
positive, it jump to LOOP: section

Instruction:
LD: Load
ST: Store
IN: Input from device
SUB: Subtract
JP: Conditional Jump, 'P' is positive condition.

Daeyoung Heo.

On 1월25일, 오전6시22분, Sharmeen Ibrahim <sharmeen...@gmail.com>
wrote:
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages