What will be in CH and AH after these commands?

MOV AX, 1234
MOV DX, 999
MOV CH, 222 [bp+di]

Do you have DEBUG?
You can run this through DEBUG just like in your last post.

Build trace tables!

MOV AX, 1234             AX:1234  CH:-- DI:---- DX:---- BP:----
MOV BP, AX               AX:1234  CH:-- DI:---- DX:---- BP:1234
MOV DX, 999              AX:1234  CH:-- DI:---- DX:999  BP:1234
MOV DI, DX               AX:1234  CH:-- DI:999  DX:999  BP:1234
MOV CH, 222 [bp+di]      ? <--  [2455] <-- [1234 + 999 + 222]

Okay, so ah will have 12(because ax has 1234)
but in the last line the values are given hexadecimal, so 222+1234+999 is 1DEF, not 2455. ch will have 1def.
Is this correct?

You used decimal not HEX so no!

You used a decimal 1234 which is hex 04d2, so AH=04, AL=D2.
If you meant hex, you should have had 1234h 999h 222h etc.

And no to your second question!
MOV CH, 222 [bp+di] ? <-- [2455] <-- [1234 + 999 + 222]

[ ] <-- memory reference by. The 222 appears outside the braces but in reality are part of the memory reference!

But the teacher told us that when you write 222 is hex by default.

Okay, let's say it's:
MOV AX, 1234h
MOV DX, 999h
MOV CH, 222h [bp+di]

Now, does ah has 12, and does ch has 1DEF?

If your instructor has been programming for years then you heard them wrong. in Assembly language it's in decimal unless it has a (h) (H) as a suffice. If the first ASCII character in the hex is A,B,C,D,E,F then it needs to be preceeded with a 0 so as not to be confused with a label!

1234h is okay
0FACEh is okay
FACEh is NOT okay! It's a label!

We have no idea what is in ch because it is loaded from a byte in memory at location


and we have no idea what is in memory at that location as there is no provided block of memory to observe!

BUT, ch can not have 1DEF as ch is an 8-bit register therefore 00h - FFh

OMG you totally cleared this up for me. Thx a lot!! You really helped me :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.