Hey guys, I'm working on an assignment and have been given this really difficult question to solve. Basically, I'm using the MARIE language, and have been asked to create a subroutine which simulates a binary shift left operation of data stored in the accumulator.
To an extent I understand that a binary shift operation can be exampled as:
001010 (shift left) 010100
001010 (shift right) 000101
I just have no idea how to implement this as a MARIE program. I've been theorising that considering MARIE coding runs on a hexadecimal/decimal system then I could possibly multiply the AC number by 10/16 to move the digits along... but I'm not sure.
If any of you guys could explain this to me ill be very appreciative.
This is what I was given as information on subroutines. As well as a hexadecimal multiplication program I developed.
To an extent I understand that a binary shift operation can be exampled as:
001010 (shift left) 010100
001010 (shift right) 000101
I just have no idea how to implement this as a MARIE program. I've been theorising that considering MARIE coding runs on a hexadecimal/decimal system then I could possibly multiply the AC number by 10/16 to move the digits along... but I'm not sure.
If any of you guys could explain this to me ill be very appreciative.
This is what I was given as information on subroutines. As well as a hexadecimal multiplication program I developed.
SUBROUTINE
LOAD X
JNS PROC
STORE X
JNS PROC
JNS PROC
STORE X
HALT
PROC, DEC 0
ADD FIVE
JUMPI PROC
X, DEC 3
FIVE, DEC 5
MULTIPLICATION
LOAD X
STORE Z
JUMP counter
Loop, LOAD Z
ADD X
STORE Z
JUMP counter
counter, LOAD Y
SUBT M
STORE Y
Skipcond 400
Jump Loop
LOAD X
output
Halt
X, hex 20A
Y, hex F
M, hex 1
Z, hex 0
Last edited: