Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

just starting out with assembly language please help!!

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
START: LD CX,HTU
LD BX,64H
CALL DIGIT
LD BX,0AH
CALL DIGIT
LD BX,01
CALL DIGIT
RET
DIGIT: SUB AX,BX
JP M,NEXT
INC(CX)
JP DIGIT
NEXT: INC CX
ADD AX,BX
RET
HTU: DEFM '000'

(a) If AX is set to 0F5 hex and the subroutine then successfully called and executed. Trace the code above using HTU, HTU+1, HTU+2 and the registers as headings.
(b) What does the code do?
(c) If AX is set to 1A5 hex and the HTU reset to '000' and the subroutine again successfully called executed. Trace again or otherwise to determine the values in HTU, HTU+1 and HTU+2.
(d) (i) What is the largest hexadecimal value AX can have before the subroutine fails to produce the intended result?
(ii) What would be the effect on the subroutine of having too large a value in AX?

thankyou

time and effort much appreciated..



 
I always though that the idea was to design the purpose and function first and then write the code to suit.

This isnt a technical question it sounds like a examination question to me!!!

The only way to learn is to do it your self!!! (the hard way, like everyone else). Write your own truth table, I'm not going to do it for you!

Anyway, you can write you own truth table and see where the error developes. The first collumn is the commands and an additional collumn for each register and memory operand (basically all variables).
write in the first command and then the affect of the command into the other collumns (the new value of variables) and any vars with no value yet assigned just write a dash "-".
this is a linear table of commands that the processor will execute so when you get to a jump command write it in the next row (put a tick or cross in the collumn of the variable that is used for the conidtional jump) but no other information is required. if the jump is made continue with the new command and if the conditional jump fails the continue with the following command.

the table only works if you wite the results of each command exactly correct!! a collumn for the flags usually helps.


The only thing I see unusual about the code is 'JMP M,NEXT'
Jumps only contain a single operand. A conditional jump works by examining the flags, and if the conditions match the jump is made using the operand, in this case as an offset.
The flags are set by what ever method is used in the command(s) executed previous to the jump.

0000:0000:0000:0000h
The people who have nothing to say and say it too loud have little knowledge, It's the quiet ones you need to worry about!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top